conflicts

This commit is contained in:
cxt 2016-04-25 11:15:44 +08:00
commit 3382355086
48 changed files with 30575 additions and 161 deletions

View File

@ -1 +1 @@
{"access_token":"03kBJXYaoncSoMkMC_GyNNhKmx6rzK3DbzN0_VxgOJO9_Xtp2F5pSYw0X2HdTWg5sUf0zw3oY1O8ZPVF3TbLGwYP5-kj9AlpS4F2fqEY03BE95y5hPRlVv3g_VegHP25VINhAJAIVA","expires_in":7200,"got_token_at":1461306222} {"access_token":"GrEg56Sg5QRM7IXghWlaDzNd-7iaQsqX2acszXkSTFwOh_OxtN_UNIJsj9rlSZeSkZSofQwd0KvFGv_StzARHeLw81JllcI3a3VuXgZ_cjbQnM3m00g0HiLtTniQFsEIUVIdABAPQD","expires_in":7200,"got_token_at":1461314104}

View File

@ -610,15 +610,33 @@ class AdminController < ApplicationController
tStart = @page*30 tStart = @page*30
@code_work_tests = CodeTests.find_by_sql("select * from code_tests order by id desc limit #{tStart},30 ") @code_work_tests = CodeTests.find_by_sql("select * from code_tests order by id desc limit #{tStart},30 ")
#取出各个作是否是模拟答题的 #取出各个作是否是模拟答题的
is_test = {} is_test = {}
#作品是否存在
link_swork = {}
#作业是否存在
link_hwork = {}
@code_work_tests.each do |test| @code_work_tests.each do |test|
#作品是否存在
if is_test[test['student_work_id']] != nil if is_test[test['student_work_id']] != nil
test['link_swork'] = link_swork[test['student_work_id']]
test['is_test'] = is_test[test['student_work_id']] test['is_test'] = is_test[test['student_work_id']]
else else
test['is_test'] = StudentWork.find(test['student_work_id']).is_test work = StudentWork.where("id=?",test['student_work_id']).first
test['link_swork'] = !work.nil?
test['is_test'] = work.nil? ? false : work.is_test
#test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test'] #test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test']
is_test[test['student_work_id']] = test['is_test'] is_test[test['student_work_id']] = test['is_test']
link_swork[test['student_work_id']] = test['link_swork']
end
#作业是否存在
if link_hwork[test['homework_id']] != nil
test['link_hwork'] = link_hwork[test['homework_id']]
else
hwork = HomeworkCommon.where("id=?",test['homework_id']).first
test['link_hwork'] = !hwork.nil?
link_hwork[test['homework_id']] = test['link_hwork']
end end
end end

View File

@ -73,11 +73,18 @@ class HomeworkCommonController < ApplicationController
else else
@homework.publish_time = params[:homework_common][:publish_time] @homework.publish_time = params[:homework_common][:publish_time]
end end
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
@homework.end_time = params[:homework_common][:end_time] || Time.now @homework.end_time = params[:homework_common][:end_time] || Time.now
@homework.course_id = params[:course_id] @homework.course_id = params[:course_id]
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0 anonymous = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 0
if anonymous != @homework.anonymous_comment
if anonymous == 1
homework_detail_manual.ta_proportion = @homework.homework_type == 1 ? 1.0 : 0.4
else
homework_detail_manual.ta_proportion = @homework.homework_type == 1 ? 0.6 : 0.3
end
end
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
homework_detail_manual.comment_status = 1 homework_detail_manual.comment_status = 1
end end
@ -94,6 +101,13 @@ class HomeworkCommonController < ApplicationController
@homework.homework_detail_programing ||= HomeworkDetailPrograming.new @homework.homework_detail_programing ||= HomeworkDetailPrograming.new
@homework_detail_programing = @homework.homework_detail_programing @homework_detail_programing = @homework.homework_detail_programing
@homework_detail_programing.language = params[:language_type].to_i @homework_detail_programing.language = params[:language_type].to_i
if anonymous != @homework.anonymous_comment
if anonymous == 1
@homework_detail_programing.ta_proportion = 0.6
else
@homework_detail_programing.ta_proportion = 0.5
end
end
@homework.homework_tests.delete_all @homework.homework_tests.delete_all
inputs = params[:program][:input] inputs = params[:program][:input]
@ -116,8 +130,9 @@ class HomeworkCommonController < ApplicationController
@homework_detail_group.base_on_project = params[:base_on_project].to_i @homework_detail_group.base_on_project = params[:base_on_project].to_i
end end
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 0
if @homework.save if @homework.save
@homework_detail_manual.save if @homework_detail_manual homework_detail_manual.save if homework_detail_manual
@homework_detail_programing.save if @homework_detail_programing @homework_detail_programing.save if @homework_detail_programing
@homework_detail_group.save if @homework_detail_group @homework_detail_group.save if @homework_detail_group

View File

@ -84,9 +84,6 @@ class OrganizationsController < ApplicationController
@subfield_content = @organization.org_subfields.order("priority") @subfield_content = @organization.org_subfields.order("priority")
@organization = Organization.find(params[:id]) @organization = Organization.find(params[:id])
# 统计访问量
@organization.update_column(:visits, @organization.visits.to_i + 1)
# @org_subfield = OrgSubfield.find(params[:org_subfield_id]) # @org_subfield = OrgSubfield.find(params[:org_subfield_id])
# @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 # @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
# @org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) # @org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
@ -123,8 +120,6 @@ class OrganizationsController < ApplicationController
else else
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id]) @organization = Organization.find(params[:id])
# 统计访问量
@organization.update_column(:visits, @organization.visits.to_i + 1)
if params[:org_subfield_id] if params[:org_subfield_id]
@org_subfield = OrgSubfield.find(params[:org_subfield_id]) @org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0

View File

@ -325,27 +325,11 @@ update
end end
end end
# unless @repository.gitlab?
# # redirect_to to_gitlab_project_repository_path(@project, @repository)
# render :to_gitlab
# return
# end
#if( !User.current.member_of?(@project) || @project.hidden_repo)
# @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
# :name, :path, :kind, :size, :lastrev, :changeset
@entries = @repository.entries(@path, @rev) @entries = @repository.entries(@path, @rev)
# @trees = g.trees(project, @path)
@changeset = @repository.find_changeset_by_name(@rev) @changeset = @repository.find_changeset_by_name(@rev)
#@project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
#@ip = RepositoriesHelper::REPO_IP_ADDRESS
if request.xhr? if request.xhr?
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true) @entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
else else
#Modified by young
# (show_error_not_found; return) unless @entries
g = Gitlab.client g = Gitlab.client
@changesets = g.commits(@project.gpid, :ref_name => @rev) @changesets = g.commits(@project.gpid, :ref_name => @rev)
g_project = g.project(@project.gpid) g_project = g.project(@project.gpid)
@ -360,17 +344,16 @@ update
if @changesets_all_count != @project.project_score.changeset_num && @changesets_all_count != 0 if @changesets_all_count != @project.project_score.changeset_num && @changesets_all_count != 0
update_commits_count(@project, @changesets_all_count) update_commits_count(@project, @changesets_all_count)
end end
# end
# 最近一次提交 # 最近一次提交
@changesets_latest_coimmit = @changesets[0] @changesets_latest_coimmit = @changesets[0]
unless @changesets[0].blank? unless @changesets[0].blank?
update_commits_date(@project, @changesets_latest_coimmit) update_commits_date(@project, @changesets_latest_coimmit)
end end
@creator = User.where("id =?", @project.user_id).first.try(:login) @creator = User.where("id =?", @project.user_id).first.try(:login)
@properties = @repository.properties(@path, @rev) # @properties = @repository.properties(@path, @rev)
@repositories = @project.repositories # @repositories = @project.repositories
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT # project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
ip = RepositoriesHelper::REPO_IP_ADDRESS # ip = RepositoriesHelper::REPO_IP_ADDRESS
gitlab_address = Redmine::Configuration['gitlab_address'] gitlab_address = Redmine::Configuration['gitlab_address']
if @repository.type.to_s == "Repository::Gitlab" if @repository.type.to_s == "Repository::Gitlab"
@repos_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git" @repos_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git"
@ -586,8 +569,6 @@ update
end end
end end
end end
# @static_month__per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 2)
# @static_week_per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 3)
rescue rescue
render_404 render_404
return return

View File

@ -504,6 +504,7 @@ class StudentWorkController < ApplicationController
end end
@score = @b_sort == "desc" ? "asc" : "desc" @score = @b_sort == "desc" ? "asc" : "desc"
@is_focus = params[:is_focus] ? params[:is_focus].to_i : 0
# 消息传过来的ID # 消息传过来的ID
@message_student_work_id = params[:student_work_id] @message_student_work_id = params[:student_work_id]
respond_to do |format| respond_to do |format|
@ -920,8 +921,6 @@ class StudentWorkController < ApplicationController
student_work.late_penalty = @homework.late_penalty student_work.late_penalty = @homework.late_penalty
student_work.save student_work.save
end end
@homework.save
end end
if params[:absence_penalty] && homework_detail_manual.absence_penalty.to_s != params[:absence_penalty].to_s if params[:absence_penalty] && homework_detail_manual.absence_penalty.to_s != params[:absence_penalty].to_s
@ -944,7 +943,6 @@ class StudentWorkController < ApplicationController
homework_detail_programing.ta_proportion = params[:sy_proportion] if homework_detail_programing homework_detail_programing.ta_proportion = params[:sy_proportion] if homework_detail_programing
@homework.teacher_priority = teacher_priority @homework.teacher_priority = teacher_priority
@homework.save
homework_detail_manual.save if homework_detail_manual homework_detail_manual.save if homework_detail_manual
homework_detail_programing.save if homework_detail_programing homework_detail_programing.save if homework_detail_programing
@ -953,6 +951,8 @@ class StudentWorkController < ApplicationController
student_work.save student_work.save
end end
end end
@homework.save
if params[:student_path] if params[:student_path]
redirect_to student_work_index_url(:homework => @homework.id) redirect_to student_work_index_url(:homework => @homework.id)
else else

View File

@ -750,7 +750,11 @@ class UsersController < ApplicationController
render_attachment_warning_if_needed(homework) render_attachment_warning_if_needed(homework)
homework_detail_manual = HomeworkDetailManual.new homework_detail_manual = HomeworkDetailManual.new
if homework.anonymous_comment == 1
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 1.0 : 0.4
else
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3
end
if homework.publish_time > Date.today if homework.publish_time > Date.today
homework_detail_manual.comment_status = 0 homework_detail_manual.comment_status = 0
else else
@ -766,7 +770,11 @@ class UsersController < ApplicationController
if homework.homework_type == 2 if homework.homework_type == 2
homework_detail_programing = HomeworkDetailPrograming.new homework_detail_programing = HomeworkDetailPrograming.new
homework.homework_detail_programing = homework_detail_programing homework.homework_detail_programing = homework_detail_programing
if homework.anonymous_comment == 1
homework_detail_programing.ta_proportion = 0.6
else
homework_detail_programing.ta_proportion = 0.5 homework_detail_programing.ta_proportion = 0.5
end
homework_detail_programing.language = params[:language_type].to_i homework_detail_programing.language = params[:language_type].to_i
inputs = params[:program][:input] inputs = params[:program][:input]

View File

@ -123,7 +123,7 @@ module ApplicationHelper
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :homework_journal_num => 1) CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :homework_journal_num => 1)
else else
score = course_contributor_score.homework_journal_num.to_i + 1 score = course_contributor_score.homework_journal_num.to_i + 1
course_contributor_score.update_attributes(:homework_journal_num => score) course_contributor_score.update_column(:homework_journal_num, score)
end end
# 课程留言 # 课程留言
when "Course" when "Course"
@ -131,42 +131,42 @@ module ApplicationHelper
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :journal_num => 1) CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :journal_num => 1)
else else
score = course_contributor_score.journal_num.to_i + 1 score = course_contributor_score.journal_num.to_i + 1
course_contributor_score.update_attributes(:journal_num => score) course_contributor_score.update_column(:journal_num, score)
end end
when "Message" when "Message"
if course_contributor_score.nil? if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 1) CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 1)
else else
score = course_contributor_score.message_num.to_i + 1 score = course_contributor_score.message_num.to_i + 1
course_contributor_score.update_attributes(:message_num => score) course_contributor_score.update_column(:message_num, score)
end end
when "MessageReply" when "MessageReply"
if course_contributor_score.nil? if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_reply_num => 1) CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_reply_num => 1)
else else
score = course_contributor_score.message_reply_num.to_i + 1 score = course_contributor_score.message_reply_num.to_i + 1
course_contributor_score.update_attributes(:message_reply_num => score) course_contributor_score.update_column(:message_reply_num, score)
end end
when "NewReply" when "NewReply"
if course_contributor_score.nil? if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_reply_num => 1) CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_reply_num => 1)
else else
score = course_contributor_score.news_reply_num.to_i + 1 score = course_contributor_score.news_reply_num.to_i + 1
course_contributor_score.update_attributes(:news_reply_num => score) course_contributor_score.update_column(:news_reply_num, score)
end end
when "News" when "News"
if course_contributor_score.nil? if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_num => 1) CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_num => 1)
else else
score = course_contributor_score.news_num.to_i + 1 score = course_contributor_score.news_num.to_i + 1
course_contributor_score.update_attributes(:news_num => score) course_contributor_score.update_column(:news_num, score)
end end
when "Attachment" when "Attachment"
if course_contributor_score.nil? if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :resource_num => 1) CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :resource_num => 1)
else else
score = course_contributor_score.resource_num.to_i + 1 score = course_contributor_score.resource_num.to_i + 1
course_contributor_score.update_attributes(:resource_num => score) course_contributor_score.update_column(:resource_num, score)
end end
end end
end end
@ -178,38 +178,38 @@ module ApplicationHelper
when "HomeworkCommon" when "HomeworkCommon"
unless course_contributor_score.nil? unless course_contributor_score.nil?
score = course_contributor_score.homework_journal_num.to_i - 1 score = course_contributor_score.homework_journal_num.to_i - 1
course_contributor_score.update_attribute(:homework_journal_num, score < 0 ? 0 : score) course_contributor_score.update_column(:homework_journal_num, score < 0 ? 0 : score)
end end
# 课程留言 # 课程留言
when "Course" when "Course"
unless course_contributor_score.nil? unless course_contributor_score.nil?
score = course_contributor_score.journal_num.to_i - 1 score = course_contributor_score.journal_num.to_i - 1
course_contributor_score.update_attribute(:journal_num, score < 0 ? 0 : score) course_contributor_score.update_column(:journal_num, score < 0 ? 0 : score)
end end
when "Message" when "Message"
unless course_contributor_score.nil? unless course_contributor_score.nil?
score = course_contributor_score.message_num.to_i - 1 score = course_contributor_score.message_num.to_i - 1
course_contributor_score.update_attribute(:message_num, score < 0 ? 0 : score) course_contributor_score.update_column(:message_num, score < 0 ? 0 : score)
end end
when "MessageReply" when "MessageReply"
unless course_contributor_score.nil? unless course_contributor_score.nil?
score = course_contributor_score.message_reply_num.to_i - 1 score = course_contributor_score.message_reply_num.to_i - 1
course_contributor_score.update_attribute(:message_reply_num, score < 0 ? 0 : score) course_contributor_score.update_column(:message_reply_num, score < 0 ? 0 : score)
end end
when "NewReply" when "NewReply"
unless course_contributor_score.nil? unless course_contributor_score.nil?
score = course_contributor_score.news_reply_num.to_i - 1 score = course_contributor_score.news_reply_num.to_i - 1
course_contributor_score.update_attribute(:news_reply_num, score < 0 ? 0 : score) course_contributor_score.update_column(:news_reply_num, score < 0 ? 0 : score)
end end
when "News" when "News"
unless course_contributor_score.nil? unless course_contributor_score.nil?
score = course_contributor_score.news_num.to_i - 1 score = course_contributor_score.news_num.to_i - 1
course_contributor_score.update_attribute(:news_num, score < 0 ? 0 : score) course_contributor_score.update_column(:news_num, score < 0 ? 0 : score)
end end
when "Attachment" when "Attachment"
unless course_contributor_score.nil? unless course_contributor_score.nil?
score = course_contributor_score.resource_num.to_i - 1 score = course_contributor_score.resource_num.to_i - 1
course_contributor_score.update_attribute(:resource_num, score < 0 ? 0 : score) course_contributor_score.update_column(:resource_num, score < 0 ? 0 : score)
end end
end end
end end
@ -2983,9 +2983,13 @@ def homework_common_index_url_in_org(course_id)
Setting.protocol + "://" + Setting.host_name + "/homework_common?course=" + course_id.to_s Setting.protocol + "://" + Setting.host_name + "/homework_common?course=" + course_id.to_s
end end
def student_work_index_url_in_org(homework_id) def student_work_index_url_in_org(homework_id, is_focus = '')
if is_focus != ''
Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&is_focus=" + is_focus.to_s
else
Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s
end end
end
def course_url_in_org(course_id) def course_url_in_org(course_id)
Setting.protocol + "://" + Setting.host_name + "/courses/" + course_id.to_s Setting.protocol + "://" + Setting.host_name + "/courses/" + course_id.to_s

View File

@ -41,6 +41,23 @@ module RepositoriesHelper
identifiers.include?(iden) ? false :true identifiers.include?(iden) ? false :true
end end
# 获取文件目录的最新动态
def get_trees_last_changes(project_id, rev, ent_name)
g = Gitlab.client
begin
tree_changes = g.rep_last_changes(project_id, :rev => rev, :path => ent_name)
tree_changes
rescue
logger.error("faile to get tress activities!")
end
end
def translate_time time
case time
when time.include("")
end
end
# 获取diff内容行号 # 获取diff内容行号
def diff_line_num content def diff_line_num content
content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i

View File

@ -261,7 +261,7 @@ class Message < ActiveRecord::Base
ws = WechatService.new ws = WechatService.new
if self.course if self.course
if self.parent_id.nil? # 主贴 if self.parent_id.nil? # 主贴
self.course.members.each do |m| self.course.members.includes(:user).each do |m|
if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
content = strip_html self.subject, 200 content = strip_html self.subject, 200
@ -269,7 +269,7 @@ class Message < ActiveRecord::Base
end end
end end
else # 回帖 else # 回帖
self.course.members.each do |m| self.course.members.includes(:user).each do |m|
if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
content = strip_html self.content.html_safe, 200 content = strip_html self.content.html_safe, 200
@ -279,7 +279,7 @@ class Message < ActiveRecord::Base
end end
elsif self.project # 项目相关 elsif self.project # 项目相关
if self.parent_id.nil? # 主贴 if self.parent_id.nil? # 主贴
self.project.members.each do |m| self.project.members.includes(:user).each do |m|
if m.user_id != self.author_id if m.user_id != self.author_id
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false)
content = strip_html self.subject, 200 content = strip_html self.subject, 200
@ -287,7 +287,7 @@ class Message < ActiveRecord::Base
end end
end end
else # 回帖 else # 回帖
self.project.members.each do |m| self.project.members.includes(:user).each do |m|
if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false)
content = strip_html self.content.html_safe, 200 content = strip_html self.content.html_safe, 200

View File

@ -44,7 +44,7 @@ class Repository < ActiveRecord::Base
# validates_uniqueness_of :identifier, :allow_blank => true # validates_uniqueness_of :identifier, :allow_blank => true
validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph) validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
# donwcase letters, digits, dashes, underscores but not digits only # donwcase letters, digits, dashes, underscores but not digits only
validates_format_of :identifier, :with => /^[a-z0-9_\-]+$/, :allow_blank => true validates_format_of :identifier, :with => /^[a-zA-Z0-9_\-]*[a-zA-Z_\-]+[a-zA-Z0-9_\-]*$/, :allow_blank => true
# Checks if the SCM is enabled when creating a repository # Checks if the SCM is enabled when creating a repository
validate :repo_create_validation, :on => :create validate :repo_create_validation, :on => :create

View File

@ -37,14 +37,22 @@
<% if test['homework_id'] != nil %> <% if test['homework_id'] != nil %>
<tr class="<%= cycle("odd", "even") %>"> <tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center; " title='<%=test['homework_id']%>'> <td style="text-align: center; " title='<%=test['homework_id']%>'>
<% if test['link_hwork'] %>
<%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%> <%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%>
<% else %>
<%= test['homework_id'] %>
<% end %>
</td> </td>
<td style="text-align: center; " title='<%=test['student_work_id']%>'> <td style="text-align: center; " title='<%=test['student_work_id']%>'>
<% if test['link_swork'] && test['link_hwork'] %>
<% if !test['is_test'] %> <% if !test['is_test'] %>
<%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%> <%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%>
<% else %> <% else %>
<%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%> <%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%>
<% end %> <% end %>
<% else %>
<%= test['student_work_id'] %>
<% end %>
</td> </td>
<td style="text-align: center;"> <td style="text-align: center;">
<% if test.wait_time != 0 %> <% if test.wait_time != 0 %>

View File

@ -113,6 +113,9 @@
<!--<span class="img_private"><%#= l(:label_private)%></span>--> <!--<span class="img_private"><%#= l(:label_private)%></span>-->
<!--<%# end %>--> <!--<%# end %>-->
<!--</div>--> <!--</div>-->
<%# 更新访问数,刷新的时候更新访问次数 %>
<% update_visiti_count @organization %>
<%# over %>
<div class="cl"></div> <div class="cl"></div>
<div class="f12 fontGrey3"> <div class="f12 fontGrey3">

View File

@ -397,6 +397,9 @@
<% end %> <% end %>
<% end %> <% end %>
<%# 更新访问数,刷新的时候更新访问次数 %>
<% update_visiti_count @organization %>
<%# over %>
<div class="footer"> <div class="footer">
<div class="footer-con"> <div class="footer-con">

View File

@ -66,11 +66,16 @@
</div> </div>
<% end %> <% end %>
<% end %> <% end %>
<div class="homepagePostSubmit">
<% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %> <% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %>
<div class="homepagePostSubmit">
<%= user_for_homework_common activity,is_teacher %> <%= user_for_homework_common activity,is_teacher %>
</div> </div>
<% work = cur_user_works_for_homework activity %>
<% if activity.end_time < Date.today && !is_teacher && !work.nil? %>
<div class="homepagePostSubmit">
<%=link_to "追加附件", student_work_index_url_in_org(activity.id, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
</div>
<% end %>
<% if activity.homework_type == 2 && is_teacher%> <% if activity.homework_type == 2 && is_teacher%>
<div class="homepagePostSubmit"> <div class="homepagePostSubmit">
<%= link_to "模拟答题", Setting.protocol + "://" + Setting.host_name + "/users/new_user_commit_homework?homework_id="+activity.id.to_s + "&is_test=true", class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> <%= link_to "模拟答题", Setting.protocol + "://" + Setting.host_name + "/users/new_user_commit_homework?homework_id="+activity.id.to_s + "&is_test=true", class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>

View File

@ -29,7 +29,7 @@
<!--CONTENT LIST--> <!--CONTENT LIST-->
</div> </div>
<% unless @project.gpid.nil? || @project.project_score.changeset_num == 0 %> <% unless @project.gpid.nil? || @project.project_score.changeset_num == 0 || @project.rep_statics.blank? %>
<div class="resources mt10"> <div class="resources mt10">
<div class="homepagePostBrief"> <div class="homepagePostBrief">
<%= render :partial => "rep_static" %> <%= render :partial => "rep_static" %>

View File

@ -1,5 +1,5 @@
<div class="autoscroll"> <div class="autoscroll">
<table class="list entries" id="browser"> <table class="list entries" id="browser" style="table-layout: fixed;">
<tbody> <tbody>
<%= render :partial => 'dir_list_content' %> <%= render :partial => 'dir_list_content' %>

View File

@ -1,11 +1,13 @@
<% @entries.each do |entry| %> <% @entries.each do |entry| %>
<% tr_id = Digest::MD5.hexdigest(entry.path) <% tr_id = Digest::MD5.hexdigest(entry.path)
depth = params[:depth].to_i %> depth = params[:depth].to_i %>
<% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(entry.path) %> <% sub_path = entry.path[0] == "/" ? entry.path.sub("/", "") : entry.path %>
<% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(sub_path) %>
<% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %> <% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %>
<% latest_changes = get_trees_last_changes(@project.gpid, @rev, ent_path) %>
<tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>"> <tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>">
<td style="padding-left: <%=18 * depth%>px;" class="<%= <td style="padding-left: <%=18 * depth%>px;" class="filename_no_report hidden">
@repository.report_last_commit ? "filename" : "filename_no_report" %>">
<% if entry.is_dir? %> <% if entry.is_dir? %>
<%# 展开文件目录 %> <%# 展开文件目录 %>
<span class="expander" onclick="scmEntryClick('<%= tr_id %>', '<%= escape_javascript(url_for( <span class="expander" onclick="scmEntryClick('<%= tr_id %>', '<%= escape_javascript(url_for(
@ -14,20 +16,40 @@
:repository_id => @repository.identifier_param, :repository_id => @repository.identifier_param,
:path => to_path_param(ent_path), :path => to_path_param(ent_path),
:rev => @rev, :rev => @rev,
:latest_changes => latest_changes,
:depth => (depth + 1), :depth => (depth + 1),
:parent_id => tr_id)) %>');">&nbsp;</span> :parent_id => tr_id)) %>');">&nbsp;</span>
<% end %> <% end %>
<!--<a class="<%#= (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}") %>">-->
<!--<%#= h(ent_name) %>-->
<!--</a>-->
<%#= h(ent_name), :class => "(entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%>
<%= link_to h(ent_name), <%= link_to h(ent_name),
{:action => (entry.is_dir? ? 'show' : 'entry'), :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev}, {:action => (entry.is_dir? ? 'show' : 'entry'), :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev},
:class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%> :class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%>
</td> </td>
<!--<td class="size"><%#= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>--> <!--<td class="size"><%#= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>-->
<!--<td class="size"><%#= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>--> <!--<td class="size"><%#= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>-->
<% if @repository.report_last_commit %> <%# if @repository.report_last_commit %>
<td class="revision"><%= link_to_revision(entry.changeset, @repository) if entry.changeset %></td> <div id="children_tree">
<td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td> <td class="tree-comments c_grey hidden">
<td class="author"><%= entry.author %></td> <div class="hidden" title="<%= (latest_changes.message) if latest_changes && latest_changes.message %>">
<td class="comments"><%=h truncate(entry.changeset.comments, :length => 50) if entry.changeset %></td> <%= (latest_changes.message) if latest_changes && latest_changes.message %>
<% end %> </div>
</td>
<td class="tree-author c_grey">
<div class="hidden" title="<%= (latest_changes.author) if latest_changes && latest_changes.author %>">
<%= (latest_changes.author) if latest_changes && latest_changes.author %>
</div>
</td>
<td class="tree-age c_grey">
<div class="hidden" title="<%= distance_of_time_in_words(latest_changes.time, Time.now + 8.hours) if latest_changes && latest_changes.time %>">
<%# 为了转换UTC时间时差8小时 %>
<%= distance_of_time_in_words(latest_changes.time, Time.now + 8.hours) if latest_changes && latest_changes.time %>
<%#= latest_changes.time if latest_changes && latest_changes.time %>
</div>
</td>
</div>
<%# end %>
</tr> </tr>
<% end %> <% end %>

View File

@ -25,7 +25,7 @@
<textarea id="copy_rep_content" class="cloneUrl mt5 fl" type="input" ><%= @repository.type.to_s=="Repository::Gitlab" ? @repos_url.to_s.lstrip : @repository.url %></textarea> <textarea id="copy_rep_content" class="cloneUrl mt5 fl" type="input" ><%= @repository.type.to_s=="Repository::Gitlab" ? @repos_url.to_s.lstrip : @repository.url %></textarea>
<a href="javascript:void(0);" class="clone_btn mt5" onclick="jsCopy()"><span class="vl_copy" title="点击复制版本库地址"></span></a> <a href="javascript:void(0);" class="clone_btn mt5" onclick="jsCopy()"><span class="vl_copy" title="点击复制版本库地址"></span></a>
<div class="fl mt5 ml15"> <div class="fl mt5 ml15">
<%=link_to "统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator, :default_branch => @g_default_branch ), :class => "fl vl_zip" %> <%=link_to "代码统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator, :default_branch => @g_default_branch ), :class => "fl vl_zip" %>
</div> </div>
<%# 针对公开项目:用户必须创建了项目,否则用户无法同步 %> <%# 针对公开项目:用户必须创建了项目,否则用户无法同步 %>
<% if User.current.id != @project.user_id %> <% if User.current.id != @project.user_id %>

View File

@ -119,6 +119,11 @@
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(function(){
<% if defined?(is_focus) && is_focus.to_i == 1 %>
$("#upload_revise_attachment").click();
<% end %>
});
function show_upload(){ function show_upload(){
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>'); $("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>');
showModal('ajax-modal', '452px'); showModal('ajax-modal', '452px');

View File

@ -30,7 +30,7 @@
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
<div class="mb10 mt5"> <div class="mb10 mt5">
<a href="javascript:void(0);" onclick="show_upload();" class="blueCir ml5" title="请选择文件上传">上传附件</a> <a href="javascript:void(0);" id="upload_revise_attachment" onclick="show_upload();" class="blueCir ml5" title="请选择文件上传">上传附件</a>
</div> </div>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -19,21 +19,21 @@
<script> <script>
$("#sy_proportion").change(function(){ $("#sy_proportion").change(function(){
var ta_proportion = 100 - parseInt($("#sy_proportion").val() * 100); var ta_proportion = 100 - parseInt(parseFloat($("#sy_proportion").val()) * 100);
$("#ta_proportion").replaceWith(build_selector(ta_proportion)); $("#ta_proportion").replaceWith(build_selector(ta_proportion));
$("#student_proportion").val("0%"); $("#student_proportion").val("0%");
}); });
$("#ta_proportion").live("change",function(){ $("#ta_proportion").live("change",function(){
var ta_proportion = 100 - parseInt($("#sy_proportion").val() * 100) - parseInt($("#ta_proportion").val() * 100); var ta_proportion = 100 - parseInt(parseFloat($("#sy_proportion").val()) * 100) - parseInt(parseFloat($("#ta_proportion").val()) * 100);
$("#student_proportion").val(ta_proportion + "%"); $("#student_proportion").val(ta_proportion + "%");
}); });
</script> </script>
<% else%> <% else%>
<script> <script>
$("#ta_proportion").change(function(){ $("#ta_proportion").change(function(){
var ta_proportion = $("#ta_proportion").val(); var ta_proportion = parseFloat($("#ta_proportion").val());
$("#student_proportion").val((100 - parseInt(ta_proportion * 100)) + "%"); $("#student_proportion").val((100 - parseFloat(parseInt(ta_proportion * 100))) + "%");
}); });
</script> </script>
<% end%> <% end%>

View File

@ -107,6 +107,9 @@
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
showNormalImage('student_work_img_<%=work.id %>'); showNormalImage('student_work_img_<%=work.id %>');
<% if defined?(is_focus) && is_focus.to_i == 1 %>
$("#upload_revise_attachment").click();
<% end %>
}); });
function show_upload(){ function show_upload(){
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>'); $("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>');

View File

@ -7,6 +7,7 @@
<% my_work = @homework.student_works.where("user_id = #{User.current.id}").first %> <% my_work = @homework.student_works.where("user_id = #{User.current.id}").first %>
<% if !@is_teacher && my_work.nil? && User.current.member_of_course?(@course) %> <% if !@is_teacher && my_work.nil? && User.current.member_of_course?(@course) %>
<span class="f12 c_red">您尚未提交作品</span> <span class="f12 c_red">您尚未提交作品</span>
<%=link_to "提交作品", new_student_work_url_without_domain(@homework.id),:class => 'blueCir ml5 f12' %>
<% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> <% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
<span class="f12 c_red">您已提交且不可再修改,因为截止日期已过</span> <span class="f12 c_red">您已提交且不可再修改,因为截止日期已过</span>
<% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> <% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
@ -58,7 +59,7 @@
<% end %> <% end %>
<% unless work.nil? %> <% unless work.nil? %>
<% if @homework.homework_type == 2 %> <% if @homework.homework_type == 2 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>"); $("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>");
var program_name = "text/x-csrc"; var program_name = "text/x-csrc";
var language = <%= @homework.language %>; var language = <%= @homework.language %>;
@ -82,11 +83,11 @@
value: $("#work-src_<%= work.id%>").text() value: $("#work-src_<%= work.id%>").text()
}); });
<% elsif @homework.homework_type == 1 %> <% elsif @homework.homework_type == 1 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>"); $("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>");
<% elsif @homework.homework_type == 3 %> <% elsif @homework.homework_type == 3 %>
<% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %>
<% if pro && pro.student_work_id == work.id %> <% if pro && pro.student_work_id == work.id %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>"); $("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>");
<% end %> <% end %>
<% end %> <% end %>
$('#score_<%= work.id%>').peSlider({range: 'min'}); $('#score_<%= work.id%>').peSlider({range: 'min'});

View File

@ -71,7 +71,12 @@
<% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %> <% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %>
<%= user_for_homework_common activity,is_teacher %> <%= user_for_homework_common activity,is_teacher %>
</div> </div>
<% work = cur_user_works_for_homework activity %>
<% if activity.end_time < Date.today && !is_teacher && !work.nil? %>
<div class="homepagePostSubmit">
<%=link_to "追加附件", student_work_index_url_in_org(activity.id, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
</div>
<% end %>
<% if activity.homework_type == 2 && is_teacher%> <% if activity.homework_type == 2 && is_teacher%>
<div class="homepagePostSubmit"> <div class="homepagePostSubmit">
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>

View File

@ -70,6 +70,12 @@
<div class="homepagePostSubmit"> <div class="homepagePostSubmit">
<%= user_for_homework_common homework_common,is_teacher %> <%= user_for_homework_common homework_common,is_teacher %>
</div> </div>
<% work = cur_user_works_for_homework homework_common %>
<% if homework_common.end_time < Date.today && !is_teacher && !work.nil? %>
<div class="homepagePostSubmit">
<%=link_to "追加附件", student_work_index_url_in_org(homework_common.id, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
</div>
<% end %>
<% if homework_common.homework_type == 2 && is_teacher%> <% if homework_common.homework_type == 2 && is_teacher%>
<div class="homepagePostSubmit"> <div class="homepagePostSubmit">
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>

View File

@ -15,6 +15,11 @@
<% if edit_mode && homework.is_group_homework? %> <% if edit_mode && homework.is_group_homework? %>
$("#GroupPopupBox a.group_save_btn").click(); $("#GroupPopupBox a.group_save_btn").click();
<% end %> <% end %>
<% if edit_mode %>
$("#anonymous_comment").on('click',function(){
$("#anonymous_hint").show();
});
<% end %>
}); });
function checked_val() { function checked_val() {
if ($("#anonymous_comment").is(":checked")) { if ($("#anonymous_comment").is(":checked")) {
@ -174,7 +179,8 @@
<% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %> <% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %>
<div class="fl f14 ml10" style="margin-top: 4px;"> <div class="fl f14 ml10" style="margin-top: 4px;">
<input type="checkbox" name="homework_common[anonymous_comment]" value="<%=edit_mode ? homework.anonymous_comment : 1 %>" id="anonymous_comment"/> <input type="checkbox" name="homework_common[anonymous_comment]" value="<%=edit_mode ? homework.anonymous_comment : 1 %>" id="anonymous_comment"/>
<span class="f14 c_grey mr10">禁用匿评</span> <span class="f14 c_grey">禁用匿评</span>
<span id="anonymous_hint" style="display: none; font-size: 12px;" class="c_red">更改后评分比例将恢复默认值</span>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@ -107,7 +107,7 @@
<div class="mt10"> <div class="mt10">
<a href="javascript:void(0);" class="BlueCirBtn fl" data-homework-id="<%=@homework.id%>" data-student-work-id="<%=@student_work.id%>" id="test-program-btn">测试代码</a> <a href="javascript:void(0);" class="BlueCirBtn fl" data-homework-id="<%=@homework.id%>" data-student-work-id="<%=@student_work.id%>" id="test-program-btn">测试代码</a>
<% if @is_test %> <% if @is_test %>
<%=link_to '返 回',homework_common_index_path(:course => @course.id),:class=>'fr mt6' %> <%=link_to '返 回',homework_common_index_path(:course => @course.id),:class=>'fr mt6',:style =>'line-height:30px;' %>
<% else @is_test %> <% else @is_test %>
<a href="javascript:void(0);" class="BlueCirBtn fr" id="commit-program-work-btn">提交代码</a> <a href="javascript:void(0);" class="BlueCirBtn fr" id="commit-program-work-btn">提交代码</a>
<% end %> <% end %>

View File

@ -89,11 +89,10 @@ zh:
project_module_repository: 版本库 project_module_repository: 版本库
project_module_create_repository: 创建版本库 project_module_create_repository: 创建版本库
project_gitlab_create_repository: 新版本库 project_gitlab_create_repository: 新版本库
project_gitlab_create_double_message: 亲,您已经创建了一个同名的版本库,换个特别点的名字同名的概率就会变小哦~ project_gitlab_create_double_message: 温馨提示:您已经创建了一个同名的版本库!
project_gitlab_fork_double_message: 您已经有了一个相同名字的版本库所以不能fork改版本库~ project_gitlab_fork_double_message: 您已经有了一个相同名字的版本库所以不能fork改版本库~
project_gitlab_fork_own: 您好您当前所fork的项目为您自己创建的项目平台暂时不提供fork自己项目的功能敬请谅解 project_gitlab_fork_own: 您好您当前所fork的项目为您自己创建的项目平台暂时不提供fork自己项目的功能敬请谅解
label_project_more: 更多 label_project_more: 更多
project_module_news: 新闻 project_module_news: 新闻
project_module_wiki: Wiki project_module_wiki: Wiki

View File

@ -1,5 +1,6 @@
class UpdateOneStudentScore < ActiveRecord::Migration class UpdateOneStudentScore < ActiveRecord::Migration
def up def up
begin
student_work_score = StudentWorksScore.where("user_id = 11688 AND student_work_id = 34414").first student_work_score = StudentWorksScore.where("user_id = 11688 AND student_work_id = 34414").first
student_work_score.score = 100 student_work_score.score = 100
student_work_score.save student_work_score.save
@ -31,6 +32,9 @@ class UpdateOneStudentScore < ActiveRecord::Migration
end end
work.save work.save
end end
rescue => e
logger.error "[Errno::ENOENT] ===> #{e}"
end
end end
def down def down

View File

@ -1,5 +1,6 @@
class UpdateOneStudentTeacherScore < ActiveRecord::Migration class UpdateOneStudentTeacherScore < ActiveRecord::Migration
def up def up
begin
work = StudentWork.find 49774 work = StudentWork.find 49774
score = StudentWorksScore.new score = StudentWorksScore.new
score.score = 100 score.score = 100
@ -10,6 +11,9 @@ class UpdateOneStudentTeacherScore < ActiveRecord::Migration
work.teacher_score = score.score work.teacher_score = score.score
end end
work.save work.save
rescue => e
logger.error "[Errno::ENOENT] ===> #{e}"
end
end end
def down def down

View File

@ -1,5 +1,6 @@
class DeleteAnonymousWork < ActiveRecord::Migration class DeleteAnonymousWork < ActiveRecord::Migration
def up def up
begin
student_works = StudentWork.where("homework_common_id = 2882").map{|work| work.id} unless StudentWork.where("homework_common_id = 2882").empty? student_works = StudentWork.where("homework_common_id = 2882").map{|work| work.id} unless StudentWork.where("homework_common_id = 2882").empty?
student_work_ids = "(" + student_works.join(",") + ")" student_work_ids = "(" + student_works.join(",") + ")"
student_work_scores = StudentWorksScore.where("student_work_id in #{student_work_ids}") student_work_scores = StudentWorksScore.where("student_work_id in #{student_work_ids}")
@ -12,6 +13,9 @@ class DeleteAnonymousWork < ActiveRecord::Migration
student_work.save student_work.save
end end
end end
rescue => e
logger.error "[Errno::ENOENT] ===> #{e}"
end
end end
def down def down

View File

@ -0,0 +1,21 @@
class AlterHomeworkEndTime < ActiveRecord::Migration
def up
homeworks = HomeworkCommon.where("id in (3229, 3234, 3235, 3236)");
unless homeworks.empty? || homeworks.nil?
homeworks.each do |hw|
hw.end_time = hw.end_time + 4
hm = hw.homework_detail_manual
hm.comment_status = 1
hw.student_works.each do |stu|
stu.late_penalty = 0
stu.save
end
hm.save
hw.save
end
end
end
def down
end
end

View File

@ -11,6 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160421011543) do

View File

@ -106,6 +106,23 @@ class Gitlab::Client
end end
alias_method :repo_rep_stats, :rep_stats alias_method :repo_rep_stats, :rep_stats
# Gets a tree activities of project repository.
#
# @example
# Gitlab.commits('viking')
# Gitlab.repo_commits('gitlab', :ref_name => 'api')
#
# @param [Integer] project The ID of a project.
# @param [Hash] options A customizable set of options.
# @option options [String] :ref_name The branch or tag name of a project repository.
# @option options [String] :creator The user name of a project repository.
# @option options [Integer] :period Statistics over time. 1:total 2one month 3one week
# @return [Array<Gitlab::ObjectifiedHash>]
def rep_last_changes(project, options={})
get("/projects/#{project}/repository/rep_last_changes", :query => options)
end
alias_method :repo_rep_stats, :rep_stats
# Get the diff of a commit in a project. # Get the diff of a commit in a project.
# #
# @example # @example

View File

@ -11,6 +11,21 @@ namespace :gitlab do
end end
end end
task :members => :environment do
projects = Project.where("gpid is not null")
s = Trustie::Gitlab::Sync.new
g = Gitlab.client
projects.each do |project|
begin
if project.members.count != g.team_members(project.gpid).count
s.only_members(project)
end
rescue => e
puts e
end
end
end
desc "update user password" desc "update user password"
task :password => :environment do task :password => :environment do
s = Trustie::Gitlab::Sync.new s = Trustie::Gitlab::Sync.new

View File

@ -122,7 +122,7 @@ module Trustie
project.members.each do |m| project.members.each do |m|
begin begin
gid = m.user.gid gid = m.user.gid
unless gid if gid.nil?
gid = sync_user(m.user).id gid = sync_user(m.user).id
end end
self.g.add_team_member(project.gpid, gid, get_gitlab_role(m)) self.g.add_team_member(project.gpid, gid, get_gitlab_role(m))

View File

@ -14,6 +14,57 @@
<script src="/javascripts/wechat/react.js"></script> <script src="/javascripts/wechat/react.js"></script>
<script src="/javascripts/wechat/JSXTransformer.js"></script> <script src="/javascripts/wechat/JSXTransformer.js"></script>
<script src="/javascripts/wechat/ReactRouter.js"></script> <script src="/javascripts/wechat/ReactRouter.js"></script>
<script> //
var _PageHeight = document.documentElement.clientHeight,
_PageWidth = document.documentElement.clientWidth;
//计算loading框距离顶部和左部的距离loading框的宽度为215px高度为61px
var _LoadingTop = _PageHeight > 61 ? (_PageHeight - 61) / 2 : 0,
_LoadingLeft = _PageWidth > 215 ? (_PageWidth - 215) / 2 : 0;
//在页面未加载完毕之前显示的loading Html自定义内容
var _LoadingHtml = '<div id="loadingDiv" style="position:absolute;left:0;width:100%;height:' + _PageHeight + 'px;top:0;background:#f3f8ff;opacity:0.8;filter:alpha(opacity=80);z-index:10000;"><div style="position: absolute; cursor1: wait; left: ' + _LoadingLeft + 'px; top:' + _LoadingTop + 'px; width: auto; height: 57px; line-height: 57px; padding-left: 50px; padding-right: 5px; background: #fff url(/Content/loading.gif) no-repeat scroll 5px 10px; border: 2px solid #95B8E7; color: #696969; font-family:\'Microsoft YaHei\';">页面加载中,请等待...</div></div>';
//呈现loading效果
document.write(_LoadingHtml);
//window.onload = function () {
// var loadingMask = document.getElementById('loadingDiv');
// loadingMask.parentNode.removeChild(loadingMask);
//};
//监听加载状态改变
document.onreadystatechange = completeLoading;
//加载状态为complete时移除loading效果
function completeLoading() {
if (document.readyState == "complete") {
var loadingMask = document.getElementById('loadingDiv');
loadingMask.parentNode.removeChild(loadingMask);
}
}</script>
</head> </head>
<body> <body>
<div id="container"></div> <div id="container"></div>

View File

@ -13,13 +13,19 @@
</head> </head>
<body> <body>
<div ng-view></div> <div ng-view>
<div class="loading-modal loading-bg" ng-if="loading">
<div class="loading-box">
<img src="/images/wechat/loading.gif" alt=""/><span>加载中...</span>
</div>
</div>
</div>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.js"></script> <script src="/javascripts/wechat/angular.js"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular-route.js"></script> <script src="/javascripts/wechat/angular-route.js"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular-sanitize.min.js"></script> <script src="/javascripts/wechat/angular-sanitize.min.js"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular-cookies.js"></script> <script src="/javascripts/wechat/angular-cookies.js"></script>
<script src="/javascripts/jquery-1.3.2.js"></script> <script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/wechat/app.js"></script> <script src="/javascripts/wechat/app.js"></script>
</body> </body>

BIN
public/images/wechat/loading.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -22,6 +22,7 @@ $(function(){
}; };
var test_program = function(cb){ var test_program = function(cb){
$('#test-program-btn').hide();
var homework_id = $('#test-program-btn').attr('data-homework-id'); var homework_id = $('#test-program-btn').attr('data-homework-id');
var student_work_id = $('#test-program-btn').attr('data-student-work-id'); var student_work_id = $('#test-program-btn').attr('data-student-work-id');
var src = $('#program-src').val(); var src = $('#program-src').val();
@ -29,6 +30,7 @@ $(function(){
var is_test = $('input[name=is_test]').val(); var is_test = $('input[name=is_test]').val();
if(!valid_form()){ if(!valid_form()){
$('#test-program-btn').show();
return; return;
} }
/* /*
@ -78,17 +80,19 @@ $(function(){
$('.ProResult').prepend(html); $('.ProResult').prepend(html);
if (data.status==0 && is_test != 'true') { if (data.status==0 && is_test != 'true') {
if (typeof cb == 'function') {cb(data); return;} if (typeof cb == 'function') {cb(data);$('#test-program-btn').show(); return;}
var r=confirm("答题正确,是否立刻提交?"); var r=confirm("答题正确,是否立刻提交?");
if (r) { if (r) {
$(".HomeWorkCon form").submit(); $(".HomeWorkCon form").submit();
} }
$('#test-program-btn').show();
return; return;
} }
//2 超时 -2 编译错误 测试结束 //2 超时 -2 编译错误 测试结束
if (data.status == 2 || data.status == -2 || tSeq >= tCount ){ if (data.status == 2 || data.status == -2 || tSeq >= tCount ){
if (typeof cb == 'function') {cb(data); return;} if (typeof cb == 'function') {cb(data);$('#test-program-btn').show(); return;}
$('#test-program-btn').show();
return; return;
} }
@ -100,6 +104,7 @@ $(function(){
} else { } else {
alert("对不起,服务器繁忙请稍后再试!"); alert("对不起,服务器繁忙请稍后再试!");
} }
$('#test-program-btn').show();
return; return;
}); });
}; };

View File

@ -0,0 +1,321 @@
/**
* @license AngularJS v1.4.6
* (c) 2010-2015 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, angular, undefined) {'use strict';
/**
* @ngdoc module
* @name ngCookies
* @description
*
* # ngCookies
*
* The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.
*
*
* <div doc-module-components="ngCookies"></div>
*
* See {@link ngCookies.$cookies `$cookies`} for usage.
*/
angular.module('ngCookies', ['ng']).
/**
* @ngdoc provider
* @name $cookiesProvider
* @description
* Use `$cookiesProvider` to change the default behavior of the {@link ngCookies.$cookies $cookies} service.
* */
provider('$cookies', [function $CookiesProvider() {
/**
* @ngdoc property
* @name $cookiesProvider#defaults
* @description
*
* Object containing default options to pass when setting cookies.
*
* The object may have following properties:
*
* - **path** - `{string}` - The cookie will be available only for this path and its
* sub-paths. By default, this would be the URL that appears in your base tag.
* - **domain** - `{string}` - The cookie will be available only for this domain and
* its sub-domains. For obvious security reasons the user agent will not accept the
* cookie if the current domain is not a sub domain or equals to the requested domain.
* - **expires** - `{string|Date}` - String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT"
* or a Date object indicating the exact date/time this cookie will expire.
* - **secure** - `{boolean}` - The cookie will be available only in secured connection.
*
* Note: by default the address that appears in your `<base>` tag will be used as path.
* This is important so that cookies will be visible for all routes in case html5mode is enabled
*
**/
var defaults = this.defaults = {};
function calcOptions(options) {
return options ? angular.extend({}, defaults, options) : defaults;
}
/**
* @ngdoc service
* @name $cookies
*
* @description
* Provides read/write access to browser's cookies.
*
* <div class="alert alert-info">
* Up until Angular 1.3, `$cookies` exposed properties that represented the
* current browser cookie values. In version 1.4, this behavior has changed, and
* `$cookies` now provides a standard api of getters, setters etc.
* </div>
*
* Requires the {@link ngCookies `ngCookies`} module to be installed.
*
* @example
*
* ```js
* angular.module('cookiesExample', ['ngCookies'])
* .controller('ExampleController', ['$cookies', function($cookies) {
* // Retrieving a cookie
* var favoriteCookie = $cookies.get('myFavorite');
* // Setting a cookie
* $cookies.put('myFavorite', 'oatmeal');
* }]);
* ```
*/
this.$get = ['$$cookieReader', '$$cookieWriter', function($$cookieReader, $$cookieWriter) {
return {
/**
* @ngdoc method
* @name $cookies#get
*
* @description
* Returns the value of given cookie key
*
* @param {string} key Id to use for lookup.
* @returns {string} Raw cookie value.
*/
get: function(key) {
return $$cookieReader()[key];
},
/**
* @ngdoc method
* @name $cookies#getObject
*
* @description
* Returns the deserialized value of given cookie key
*
* @param {string} key Id to use for lookup.
* @returns {Object} Deserialized cookie value.
*/
getObject: function(key) {
var value = this.get(key);
return value ? angular.fromJson(value) : value;
},
/**
* @ngdoc method
* @name $cookies#getAll
*
* @description
* Returns a key value object with all the cookies
*
* @returns {Object} All cookies
*/
getAll: function() {
return $$cookieReader();
},
/**
* @ngdoc method
* @name $cookies#put
*
* @description
* Sets a value for given cookie key
*
* @param {string} key Id for the `value`.
* @param {string} value Raw value to be stored.
* @param {Object=} options Options object.
* See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults}
*/
put: function(key, value, options) {
$$cookieWriter(key, value, calcOptions(options));
},
/**
* @ngdoc method
* @name $cookies#putObject
*
* @description
* Serializes and sets a value for given cookie key
*
* @param {string} key Id for the `value`.
* @param {Object} value Value to be stored.
* @param {Object=} options Options object.
* See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults}
*/
putObject: function(key, value, options) {
this.put(key, angular.toJson(value), options);
},
/**
* @ngdoc method
* @name $cookies#remove
*
* @description
* Remove given cookie
*
* @param {string} key Id of the key-value pair to delete.
* @param {Object=} options Options object.
* See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults}
*/
remove: function(key, options) {
$$cookieWriter(key, undefined, calcOptions(options));
}
};
}];
}]);
angular.module('ngCookies').
/**
* @ngdoc service
* @name $cookieStore
* @deprecated
* @requires $cookies
*
* @description
* Provides a key-value (string-object) storage, that is backed by session cookies.
* Objects put or retrieved from this storage are automatically serialized or
* deserialized by angular's toJson/fromJson.
*
* Requires the {@link ngCookies `ngCookies`} module to be installed.
*
* <div class="alert alert-danger">
* **Note:** The $cookieStore service is **deprecated**.
* Please use the {@link ngCookies.$cookies `$cookies`} service instead.
* </div>
*
* @example
*
* ```js
* angular.module('cookieStoreExample', ['ngCookies'])
* .controller('ExampleController', ['$cookieStore', function($cookieStore) {
* // Put cookie
* $cookieStore.put('myFavorite','oatmeal');
* // Get cookie
* var favoriteCookie = $cookieStore.get('myFavorite');
* // Removing a cookie
* $cookieStore.remove('myFavorite');
* }]);
* ```
*/
factory('$cookieStore', ['$cookies', function($cookies) {
return {
/**
* @ngdoc method
* @name $cookieStore#get
*
* @description
* Returns the value of given cookie key
*
* @param {string} key Id to use for lookup.
* @returns {Object} Deserialized cookie value, undefined if the cookie does not exist.
*/
get: function(key) {
return $cookies.getObject(key);
},
/**
* @ngdoc method
* @name $cookieStore#put
*
* @description
* Sets a value for given cookie key
*
* @param {string} key Id for the `value`.
* @param {Object} value Value to be stored.
*/
put: function(key, value) {
$cookies.putObject(key, value);
},
/**
* @ngdoc method
* @name $cookieStore#remove
*
* @description
* Remove given cookie
*
* @param {string} key Id of the key-value pair to delete.
*/
remove: function(key) {
$cookies.remove(key);
}
};
}]);
/**
* @name $$cookieWriter
* @requires $document
*
* @description
* This is a private service for writing cookies
*
* @param {string} name Cookie name
* @param {string=} value Cookie value (if undefined, cookie will be deleted)
* @param {Object=} options Object with options that need to be stored for the cookie.
*/
function $$CookieWriter($document, $log, $browser) {
var cookiePath = $browser.baseHref();
var rawDocument = $document[0];
function buildCookieString(name, value, options) {
var path, expires;
options = options || {};
expires = options.expires;
path = angular.isDefined(options.path) ? options.path : cookiePath;
if (angular.isUndefined(value)) {
expires = 'Thu, 01 Jan 1970 00:00:00 GMT';
value = '';
}
if (angular.isString(expires)) {
expires = new Date(expires);
}
var str = encodeURIComponent(name) + '=' + encodeURIComponent(value);
str += path ? ';path=' + path : '';
str += options.domain ? ';domain=' + options.domain : '';
str += expires ? ';expires=' + expires.toUTCString() : '';
str += options.secure ? ';secure' : '';
// per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum:
// - 300 cookies
// - 20 cookies per unique domain
// - 4096 bytes per cookie
var cookieLength = str.length + 1;
if (cookieLength > 4096) {
$log.warn("Cookie '" + name +
"' possibly not set or overflowed because it was too large (" +
cookieLength + " > 4096 bytes)!");
}
return str;
}
return function(name, value, options) {
rawDocument.cookie = buildCookieString(name, value, options);
};
}
$$CookieWriter.$inject = ['$document', '$log', '$browser'];
angular.module('ngCookies').provider('$$cookieWriter', function $$CookieWriterProvider() {
this.$get = $$CookieWriter;
});
})(window, window.angular);

View File

@ -0,0 +1,991 @@
/**
* @license AngularJS v1.4.6
* (c) 2010-2015 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, angular, undefined) {'use strict';
/**
* @ngdoc module
* @name ngRoute
* @description
*
* # ngRoute
*
* The `ngRoute` module provides routing and deeplinking services and directives for angular apps.
*
* ## Example
* See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`.
*
*
* <div doc-module-components="ngRoute"></div>
*/
/* global -ngRouteModule */
var ngRouteModule = angular.module('ngRoute', ['ng']).
provider('$route', $RouteProvider),
$routeMinErr = angular.$$minErr('ngRoute');
/**
* @ngdoc provider
* @name $routeProvider
*
* @description
*
* Used for configuring routes.
*
* ## Example
* See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`.
*
* ## Dependencies
* Requires the {@link ngRoute `ngRoute`} module to be installed.
*/
function $RouteProvider() {
function inherit(parent, extra) {
return angular.extend(Object.create(parent), extra);
}
var routes = {};
/**
* @ngdoc method
* @name $routeProvider#when
*
* @param {string} path Route path (matched against `$location.path`). If `$location.path`
* contains redundant trailing slash or is missing one, the route will still match and the
* `$location.path` will be updated to add or drop the trailing slash to exactly match the
* route definition.
*
* * `path` can contain named groups starting with a colon: e.g. `:name`. All characters up
* to the next slash are matched and stored in `$routeParams` under the given `name`
* when the route matches.
* * `path` can contain named groups starting with a colon and ending with a star:
* e.g.`:name*`. All characters are eagerly stored in `$routeParams` under the given `name`
* when the route matches.
* * `path` can contain optional named groups with a question mark: e.g.`:name?`.
*
* For example, routes like `/color/:color/largecode/:largecode*\/edit` will match
* `/color/brown/largecode/code/with/slashes/edit` and extract:
*
* * `color: brown`
* * `largecode: code/with/slashes`.
*
*
* @param {Object} route Mapping information to be assigned to `$route.current` on route
* match.
*
* Object properties:
*
* - `controller` `{(string|function()=}` Controller fn that should be associated with
* newly created scope or the name of a {@link angular.Module#controller registered
* controller} if passed as a string.
* - `controllerAs` `{string=}` An identifier name for a reference to the controller.
* If present, the controller will be published to scope under the `controllerAs` name.
* - `template` `{string=|function()=}` html template as a string or a function that
* returns an html template as a string which should be used by {@link
* ngRoute.directive:ngView ngView} or {@link ng.directive:ngInclude ngInclude} directives.
* This property takes precedence over `templateUrl`.
*
* If `template` is a function, it will be called with the following parameters:
*
* - `{Array.<Object>}` - route parameters extracted from the current
* `$location.path()` by applying the current route
*
* - `templateUrl` `{string=|function()=}` path or function that returns a path to an html
* template that should be used by {@link ngRoute.directive:ngView ngView}.
*
* If `templateUrl` is a function, it will be called with the following parameters:
*
* - `{Array.<Object>}` - route parameters extracted from the current
* `$location.path()` by applying the current route
*
* - `resolve` - `{Object.<string, function>=}` - An optional map of dependencies which should
* be injected into the controller. If any of these dependencies are promises, the router
* will wait for them all to be resolved or one to be rejected before the controller is
* instantiated.
* If all the promises are resolved successfully, the values of the resolved promises are
* injected and {@link ngRoute.$route#$routeChangeSuccess $routeChangeSuccess} event is
* fired. If any of the promises are rejected the
* {@link ngRoute.$route#$routeChangeError $routeChangeError} event is fired. The map object
* is:
*
* - `key` `{string}`: a name of a dependency to be injected into the controller.
* - `factory` - `{string|function}`: If `string` then it is an alias for a service.
* Otherwise if function, then it is {@link auto.$injector#invoke injected}
* and the return value is treated as the dependency. If the result is a promise, it is
* resolved before its value is injected into the controller. Be aware that
* `ngRoute.$routeParams` will still refer to the previous route within these resolve
* functions. Use `$route.current.params` to access the new route parameters, instead.
*
* - `redirectTo` {(string|function())=} value to update
* {@link ng.$location $location} path with and trigger route redirection.
*
* If `redirectTo` is a function, it will be called with the following parameters:
*
* - `{Object.<string>}` - route parameters extracted from the current
* `$location.path()` by applying the current route templateUrl.
* - `{string}` - current `$location.path()`
* - `{Object}` - current `$location.search()`
*
* The custom `redirectTo` function is expected to return a string which will be used
* to update `$location.path()` and `$location.search()`.
*
* - `[reloadOnSearch=true]` - {boolean=} - reload route when only `$location.search()`
* or `$location.hash()` changes.
*
* If the option is set to `false` and url in the browser changes, then
* `$routeUpdate` event is broadcasted on the root scope.
*
* - `[caseInsensitiveMatch=false]` - {boolean=} - match routes without being case sensitive
*
* If the option is set to `true`, then the particular route can be matched without being
* case sensitive
*
* @returns {Object} self
*
* @description
* Adds a new route definition to the `$route` service.
*/
this.when = function(path, route) {
//copy original route object to preserve params inherited from proto chain
var routeCopy = angular.copy(route);
if (angular.isUndefined(routeCopy.reloadOnSearch)) {
routeCopy.reloadOnSearch = true;
}
if (angular.isUndefined(routeCopy.caseInsensitiveMatch)) {
routeCopy.caseInsensitiveMatch = this.caseInsensitiveMatch;
}
routes[path] = angular.extend(
routeCopy,
path && pathRegExp(path, routeCopy)
);
// create redirection for trailing slashes
if (path) {
var redirectPath = (path[path.length - 1] == '/')
? path.substr(0, path.length - 1)
: path + '/';
routes[redirectPath] = angular.extend(
{redirectTo: path},
pathRegExp(redirectPath, routeCopy)
);
}
return this;
};
/**
* @ngdoc property
* @name $routeProvider#caseInsensitiveMatch
* @description
*
* A boolean property indicating if routes defined
* using this provider should be matched using a case insensitive
* algorithm. Defaults to `false`.
*/
this.caseInsensitiveMatch = false;
/**
* @param path {string} path
* @param opts {Object} options
* @return {?Object}
*
* @description
* Normalizes the given path, returning a regular expression
* and the original path.
*
* Inspired by pathRexp in visionmedia/express/lib/utils.js.
*/
function pathRegExp(path, opts) {
var insensitive = opts.caseInsensitiveMatch,
ret = {
originalPath: path,
regexp: path
},
keys = ret.keys = [];
path = path
.replace(/([().])/g, '\\$1')
.replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option) {
var optional = option === '?' ? option : null;
var star = option === '*' ? option : null;
keys.push({ name: key, optional: !!optional });
slash = slash || '';
return ''
+ (optional ? '' : slash)
+ '(?:'
+ (optional ? slash : '')
+ (star && '(.+?)' || '([^/]+)')
+ (optional || '')
+ ')'
+ (optional || '');
})
.replace(/([\/$\*])/g, '\\$1');
ret.regexp = new RegExp('^' + path + '$', insensitive ? 'i' : '');
return ret;
}
/**
* @ngdoc method
* @name $routeProvider#otherwise
*
* @description
* Sets route definition that will be used on route change when no other route definition
* is matched.
*
* @param {Object|string} params Mapping information to be assigned to `$route.current`.
* If called with a string, the value maps to `redirectTo`.
* @returns {Object} self
*/
this.otherwise = function(params) {
if (typeof params === 'string') {
params = {redirectTo: params};
}
this.when(null, params);
return this;
};
this.$get = ['$rootScope',
'$location',
'$routeParams',
'$q',
'$injector',
'$templateRequest',
'$sce',
function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce) {
/**
* @ngdoc service
* @name $route
* @requires $location
* @requires $routeParams
*
* @property {Object} current Reference to the current route definition.
* The route definition contains:
*
* - `controller`: The controller constructor as define in route definition.
* - `locals`: A map of locals which is used by {@link ng.$controller $controller} service for
* controller instantiation. The `locals` contain
* the resolved values of the `resolve` map. Additionally the `locals` also contain:
*
* - `$scope` - The current route scope.
* - `$template` - The current route template HTML.
*
* @property {Object} routes Object with all route configuration Objects as its properties.
*
* @description
* `$route` is used for deep-linking URLs to controllers and views (HTML partials).
* It watches `$location.url()` and tries to map the path to an existing route definition.
*
* Requires the {@link ngRoute `ngRoute`} module to be installed.
*
* You can define routes through {@link ngRoute.$routeProvider $routeProvider}'s API.
*
* The `$route` service is typically used in conjunction with the
* {@link ngRoute.directive:ngView `ngView`} directive and the
* {@link ngRoute.$routeParams `$routeParams`} service.
*
* @example
* This example shows how changing the URL hash causes the `$route` to match a route against the
* URL, and the `ngView` pulls in the partial.
*
* <example name="$route-service" module="ngRouteExample"
* deps="angular-route.js" fixBase="true">
* <file name="index.html">
* <div ng-controller="MainController">
* Choose:
* <a href="Book/Moby">Moby</a> |
* <a href="Book/Moby/ch/1">Moby: Ch1</a> |
* <a href="Book/Gatsby">Gatsby</a> |
* <a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> |
* <a href="Book/Scarlet">Scarlet Letter</a><br/>
*
* <div ng-view></div>
*
* <hr />
*
* <pre>$location.path() = {{$location.path()}}</pre>
* <pre>$route.current.templateUrl = {{$route.current.templateUrl}}</pre>
* <pre>$route.current.params = {{$route.current.params}}</pre>
* <pre>$route.current.scope.name = {{$route.current.scope.name}}</pre>
* <pre>$routeParams = {{$routeParams}}</pre>
* </div>
* </file>
*
* <file name="book.html">
* controller: {{name}}<br />
* Book Id: {{params.bookId}}<br />
* </file>
*
* <file name="chapter.html">
* controller: {{name}}<br />
* Book Id: {{params.bookId}}<br />
* Chapter Id: {{params.chapterId}}
* </file>
*
* <file name="script.js">
* angular.module('ngRouteExample', ['ngRoute'])
*
* .controller('MainController', function($scope, $route, $routeParams, $location) {
* $scope.$route = $route;
* $scope.$location = $location;
* $scope.$routeParams = $routeParams;
* })
*
* .controller('BookController', function($scope, $routeParams) {
* $scope.name = "BookController";
* $scope.params = $routeParams;
* })
*
* .controller('ChapterController', function($scope, $routeParams) {
* $scope.name = "ChapterController";
* $scope.params = $routeParams;
* })
*
* .config(function($routeProvider, $locationProvider) {
* $routeProvider
* .when('/Book/:bookId', {
* templateUrl: 'book.html',
* controller: 'BookController',
* resolve: {
* // I will cause a 1 second delay
* delay: function($q, $timeout) {
* var delay = $q.defer();
* $timeout(delay.resolve, 1000);
* return delay.promise;
* }
* }
* })
* .when('/Book/:bookId/ch/:chapterId', {
* templateUrl: 'chapter.html',
* controller: 'ChapterController'
* });
*
* // configure html5 to get links working on jsfiddle
* $locationProvider.html5Mode(true);
* });
*
* </file>
*
* <file name="protractor.js" type="protractor">
* it('should load and compile correct template', function() {
* element(by.linkText('Moby: Ch1')).click();
* var content = element(by.css('[ng-view]')).getText();
* expect(content).toMatch(/controller\: ChapterController/);
* expect(content).toMatch(/Book Id\: Moby/);
* expect(content).toMatch(/Chapter Id\: 1/);
*
* element(by.partialLinkText('Scarlet')).click();
*
* content = element(by.css('[ng-view]')).getText();
* expect(content).toMatch(/controller\: BookController/);
* expect(content).toMatch(/Book Id\: Scarlet/);
* });
* </file>
* </example>
*/
/**
* @ngdoc event
* @name $route#$routeChangeStart
* @eventType broadcast on root scope
* @description
* Broadcasted before a route change. At this point the route services starts
* resolving all of the dependencies needed for the route change to occur.
* Typically this involves fetching the view template as well as any dependencies
* defined in `resolve` route property. Once all of the dependencies are resolved
* `$routeChangeSuccess` is fired.
*
* The route change (and the `$location` change that triggered it) can be prevented
* by calling `preventDefault` method of the event. See {@link ng.$rootScope.Scope#$on}
* for more details about event object.
*
* @param {Object} angularEvent Synthetic event object.
* @param {Route} next Future route information.
* @param {Route} current Current route information.
*/
/**
* @ngdoc event
* @name $route#$routeChangeSuccess
* @eventType broadcast on root scope
* @description
* Broadcasted after a route change has happened successfully.
* The `resolve` dependencies are now available in the `current.locals` property.
*
* {@link ngRoute.directive:ngView ngView} listens for the directive
* to instantiate the controller and render the view.
*
* @param {Object} angularEvent Synthetic event object.
* @param {Route} current Current route information.
* @param {Route|Undefined} previous Previous route information, or undefined if current is
* first route entered.
*/
/**
* @ngdoc event
* @name $route#$routeChangeError
* @eventType broadcast on root scope
* @description
* Broadcasted if any of the resolve promises are rejected.
*
* @param {Object} angularEvent Synthetic event object
* @param {Route} current Current route information.
* @param {Route} previous Previous route information.
* @param {Route} rejection Rejection of the promise. Usually the error of the failed promise.
*/
/**
* @ngdoc event
* @name $route#$routeUpdate
* @eventType broadcast on root scope
* @description
* The `reloadOnSearch` property has been set to false, and we are reusing the same
* instance of the Controller.
*
* @param {Object} angularEvent Synthetic event object
* @param {Route} current Current/previous route information.
*/
var forceReload = false,
preparedRoute,
preparedRouteIsUpdateOnly,
$route = {
routes: routes,
/**
* @ngdoc method
* @name $route#reload
*
* @description
* Causes `$route` service to reload the current route even if
* {@link ng.$location $location} hasn't changed.
*
* As a result of that, {@link ngRoute.directive:ngView ngView}
* creates new scope and reinstantiates the controller.
*/
reload: function() {
forceReload = true;
$rootScope.$evalAsync(function() {
// Don't support cancellation of a reload for now...
prepareRoute();
commitRoute();
});
},
/**
* @ngdoc method
* @name $route#updateParams
*
* @description
* Causes `$route` service to update the current URL, replacing
* current route parameters with those specified in `newParams`.
* Provided property names that match the route's path segment
* definitions will be interpolated into the location's path, while
* remaining properties will be treated as query params.
*
* @param {!Object<string, string>} newParams mapping of URL parameter names to values
*/
updateParams: function(newParams) {
if (this.current && this.current.$$route) {
newParams = angular.extend({}, this.current.params, newParams);
$location.path(interpolate(this.current.$$route.originalPath, newParams));
// interpolate modifies newParams, only query params are left
$location.search(newParams);
} else {
throw $routeMinErr('norout', 'Tried updating route when with no current route');
}
}
};
$rootScope.$on('$locationChangeStart', prepareRoute);
$rootScope.$on('$locationChangeSuccess', commitRoute);
return $route;
/////////////////////////////////////////////////////
/**
* @param on {string} current url
* @param route {Object} route regexp to match the url against
* @return {?Object}
*
* @description
* Check if the route matches the current url.
*
* Inspired by match in
* visionmedia/express/lib/router/router.js.
*/
function switchRouteMatcher(on, route) {
var keys = route.keys,
params = {};
if (!route.regexp) return null;
var m = route.regexp.exec(on);
if (!m) return null;
for (var i = 1, len = m.length; i < len; ++i) {
var key = keys[i - 1];
var val = m[i];
if (key && val) {
params[key.name] = val;
}
}
return params;
}
function prepareRoute($locationEvent) {
var lastRoute = $route.current;
preparedRoute = parseRoute();
preparedRouteIsUpdateOnly = preparedRoute && lastRoute && preparedRoute.$$route === lastRoute.$$route
&& angular.equals(preparedRoute.pathParams, lastRoute.pathParams)
&& !preparedRoute.reloadOnSearch && !forceReload;
if (!preparedRouteIsUpdateOnly && (lastRoute || preparedRoute)) {
if ($rootScope.$broadcast('$routeChangeStart', preparedRoute, lastRoute).defaultPrevented) {
if ($locationEvent) {
$locationEvent.preventDefault();
}
}
}
}
function commitRoute() {
var lastRoute = $route.current;
var nextRoute = preparedRoute;
if (preparedRouteIsUpdateOnly) {
lastRoute.params = nextRoute.params;
angular.copy(lastRoute.params, $routeParams);
$rootScope.$broadcast('$routeUpdate', lastRoute);
} else if (nextRoute || lastRoute) {
forceReload = false;
$route.current = nextRoute;
if (nextRoute) {
if (nextRoute.redirectTo) {
if (angular.isString(nextRoute.redirectTo)) {
$location.path(interpolate(nextRoute.redirectTo, nextRoute.params)).search(nextRoute.params)
.replace();
} else {
$location.url(nextRoute.redirectTo(nextRoute.pathParams, $location.path(), $location.search()))
.replace();
}
}
}
$q.when(nextRoute).
then(function() {
if (nextRoute) {
var locals = angular.extend({}, nextRoute.resolve),
template, templateUrl;
angular.forEach(locals, function(value, key) {
locals[key] = angular.isString(value) ?
$injector.get(value) : $injector.invoke(value, null, null, key);
});
if (angular.isDefined(template = nextRoute.template)) {
if (angular.isFunction(template)) {
template = template(nextRoute.params);
}
} else if (angular.isDefined(templateUrl = nextRoute.templateUrl)) {
if (angular.isFunction(templateUrl)) {
templateUrl = templateUrl(nextRoute.params);
}
if (angular.isDefined(templateUrl)) {
nextRoute.loadedTemplateUrl = $sce.valueOf(templateUrl);
template = $templateRequest(templateUrl);
}
}
if (angular.isDefined(template)) {
locals['$template'] = template;
}
return $q.all(locals);
}
}).
then(function(locals) {
// after route change
if (nextRoute == $route.current) {
if (nextRoute) {
nextRoute.locals = locals;
angular.copy(nextRoute.params, $routeParams);
}
$rootScope.$broadcast('$routeChangeSuccess', nextRoute, lastRoute);
}
}, function(error) {
if (nextRoute == $route.current) {
$rootScope.$broadcast('$routeChangeError', nextRoute, lastRoute, error);
}
});
}
}
/**
* @returns {Object} the current active route, by matching it against the URL
*/
function parseRoute() {
// Match a route
var params, match;
angular.forEach(routes, function(route, path) {
if (!match && (params = switchRouteMatcher($location.path(), route))) {
match = inherit(route, {
params: angular.extend({}, $location.search(), params),
pathParams: params});
match.$$route = route;
}
});
// No route matched; fallback to "otherwise" route
return match || routes[null] && inherit(routes[null], {params: {}, pathParams:{}});
}
/**
* @returns {string} interpolation of the redirect path with the parameters
*/
function interpolate(string, params) {
var result = [];
angular.forEach((string || '').split(':'), function(segment, i) {
if (i === 0) {
result.push(segment);
} else {
var segmentMatch = segment.match(/(\w+)(?:[?*])?(.*)/);
var key = segmentMatch[1];
result.push(params[key]);
result.push(segmentMatch[2] || '');
delete params[key];
}
});
return result.join('');
}
}];
}
ngRouteModule.provider('$routeParams', $RouteParamsProvider);
/**
* @ngdoc service
* @name $routeParams
* @requires $route
*
* @description
* The `$routeParams` service allows you to retrieve the current set of route parameters.
*
* Requires the {@link ngRoute `ngRoute`} module to be installed.
*
* The route parameters are a combination of {@link ng.$location `$location`}'s
* {@link ng.$location#search `search()`} and {@link ng.$location#path `path()`}.
* The `path` parameters are extracted when the {@link ngRoute.$route `$route`} path is matched.
*
* In case of parameter name collision, `path` params take precedence over `search` params.
*
* The service guarantees that the identity of the `$routeParams` object will remain unchanged
* (but its properties will likely change) even when a route change occurs.
*
* Note that the `$routeParams` are only updated *after* a route change completes successfully.
* This means that you cannot rely on `$routeParams` being correct in route resolve functions.
* Instead you can use `$route.current.params` to access the new route's parameters.
*
* @example
* ```js
* // Given:
* // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby
* // Route: /Chapter/:chapterId/Section/:sectionId
* //
* // Then
* $routeParams ==> {chapterId:'1', sectionId:'2', search:'moby'}
* ```
*/
function $RouteParamsProvider() {
this.$get = function() { return {}; };
}
ngRouteModule.directive('ngView', ngViewFactory);
ngRouteModule.directive('ngView', ngViewFillContentFactory);
/**
* @ngdoc directive
* @name ngView
* @restrict ECA
*
* @description
* # Overview
* `ngView` is a directive that complements the {@link ngRoute.$route $route} service by
* including the rendered template of the current route into the main layout (`index.html`) file.
* Every time the current route changes, the included view changes with it according to the
* configuration of the `$route` service.
*
* Requires the {@link ngRoute `ngRoute`} module to be installed.
*
* @animations
* enter - animation is used to bring new content into the browser.
* leave - animation is used to animate existing content away.
*
* The enter and leave animation occur concurrently.
*
* @scope
* @priority 400
* @param {string=} onload Expression to evaluate whenever the view updates.
*
* @param {string=} autoscroll Whether `ngView` should call {@link ng.$anchorScroll
* $anchorScroll} to scroll the viewport after the view is updated.
*
* - If the attribute is not set, disable scrolling.
* - If the attribute is set without value, enable scrolling.
* - Otherwise enable scrolling only if the `autoscroll` attribute value evaluated
* as an expression yields a truthy value.
* @example
<example name="ngView-directive" module="ngViewExample"
deps="angular-route.js;angular-animate.js"
animations="true" fixBase="true">
<file name="index.html">
<div ng-controller="MainCtrl as main">
Choose:
<a href="Book/Moby">Moby</a> |
<a href="Book/Moby/ch/1">Moby: Ch1</a> |
<a href="Book/Gatsby">Gatsby</a> |
<a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> |
<a href="Book/Scarlet">Scarlet Letter</a><br/>
<div class="view-animate-container">
<div ng-view class="view-animate"></div>
</div>
<hr />
<pre>$location.path() = {{main.$location.path()}}</pre>
<pre>$route.current.templateUrl = {{main.$route.current.templateUrl}}</pre>
<pre>$route.current.params = {{main.$route.current.params}}</pre>
<pre>$routeParams = {{main.$routeParams}}</pre>
</div>
</file>
<file name="book.html">
<div>
controller: {{book.name}}<br />
Book Id: {{book.params.bookId}}<br />
</div>
</file>
<file name="chapter.html">
<div>
controller: {{chapter.name}}<br />
Book Id: {{chapter.params.bookId}}<br />
Chapter Id: {{chapter.params.chapterId}}
</div>
</file>
<file name="animations.css">
.view-animate-container {
position:relative;
height:100px!important;
background:white;
border:1px solid black;
height:40px;
overflow:hidden;
}
.view-animate {
padding:10px;
}
.view-animate.ng-enter, .view-animate.ng-leave {
transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s;
display:block;
width:100%;
border-left:1px solid black;
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
padding:10px;
}
.view-animate.ng-enter {
left:100%;
}
.view-animate.ng-enter.ng-enter-active {
left:0;
}
.view-animate.ng-leave.ng-leave-active {
left:-100%;
}
</file>
<file name="script.js">
angular.module('ngViewExample', ['ngRoute', 'ngAnimate'])
.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider
.when('/Book/:bookId', {
templateUrl: 'book.html',
controller: 'BookCtrl',
controllerAs: 'book'
})
.when('/Book/:bookId/ch/:chapterId', {
templateUrl: 'chapter.html',
controller: 'ChapterCtrl',
controllerAs: 'chapter'
});
$locationProvider.html5Mode(true);
}])
.controller('MainCtrl', ['$route', '$routeParams', '$location',
function($route, $routeParams, $location) {
this.$route = $route;
this.$location = $location;
this.$routeParams = $routeParams;
}])
.controller('BookCtrl', ['$routeParams', function($routeParams) {
this.name = "BookCtrl";
this.params = $routeParams;
}])
.controller('ChapterCtrl', ['$routeParams', function($routeParams) {
this.name = "ChapterCtrl";
this.params = $routeParams;
}]);
</file>
<file name="protractor.js" type="protractor">
it('should load and compile correct template', function() {
element(by.linkText('Moby: Ch1')).click();
var content = element(by.css('[ng-view]')).getText();
expect(content).toMatch(/controller\: ChapterCtrl/);
expect(content).toMatch(/Book Id\: Moby/);
expect(content).toMatch(/Chapter Id\: 1/);
element(by.partialLinkText('Scarlet')).click();
content = element(by.css('[ng-view]')).getText();
expect(content).toMatch(/controller\: BookCtrl/);
expect(content).toMatch(/Book Id\: Scarlet/);
});
</file>
</example>
*/
/**
* @ngdoc event
* @name ngView#$viewContentLoaded
* @eventType emit on the current ngView scope
* @description
* Emitted every time the ngView content is reloaded.
*/
ngViewFactory.$inject = ['$route', '$anchorScroll', '$animate'];
function ngViewFactory($route, $anchorScroll, $animate) {
return {
restrict: 'ECA',
terminal: true,
priority: 400,
transclude: 'element',
link: function(scope, $element, attr, ctrl, $transclude) {
var currentScope,
currentElement,
previousLeaveAnimation,
autoScrollExp = attr.autoscroll,
onloadExp = attr.onload || '';
scope.$on('$routeChangeSuccess', update);
update();
function cleanupLastView() {
if (previousLeaveAnimation) {
$animate.cancel(previousLeaveAnimation);
previousLeaveAnimation = null;
}
if (currentScope) {
currentScope.$destroy();
currentScope = null;
}
if (currentElement) {
previousLeaveAnimation = $animate.leave(currentElement);
previousLeaveAnimation.then(function() {
previousLeaveAnimation = null;
});
currentElement = null;
}
}
function update() {
var locals = $route.current && $route.current.locals,
template = locals && locals.$template;
if (angular.isDefined(template)) {
var newScope = scope.$new();
var current = $route.current;
// Note: This will also link all children of ng-view that were contained in the original
// html. If that content contains controllers, ... they could pollute/change the scope.
// However, using ng-view on an element with additional content does not make sense...
// Note: We can't remove them in the cloneAttchFn of $transclude as that
// function is called before linking the content, which would apply child
// directives to non existing elements.
var clone = $transclude(newScope, function(clone) {
$animate.enter(clone, null, currentElement || $element).then(function onNgViewEnter() {
if (angular.isDefined(autoScrollExp)
&& (!autoScrollExp || scope.$eval(autoScrollExp))) {
$anchorScroll();
}
});
cleanupLastView();
});
currentElement = clone;
currentScope = current.scope = newScope;
currentScope.$emit('$viewContentLoaded');
currentScope.$eval(onloadExp);
} else {
cleanupLastView();
}
}
}
};
}
// This directive is called during the $transclude call of the first `ngView` directive.
// It will replace and compile the content of the element with the loaded template.
// We need this directive so that the element content is already filled when
// the link function of another directive on the same element as ngView
// is called.
ngViewFillContentFactory.$inject = ['$compile', '$controller', '$route'];
function ngViewFillContentFactory($compile, $controller, $route) {
return {
restrict: 'ECA',
priority: -400,
link: function(scope, $element) {
var current = $route.current,
locals = current.locals;
$element.html(locals.$template);
var link = $compile($element.contents());
if (current.controller) {
locals.$scope = scope;
var controller = $controller(current.controller, locals);
if (current.controllerAs) {
scope[current.controllerAs] = controller;
}
$element.data('$ngControllerController', controller);
$element.children().data('$ngControllerController', controller);
}
link(scope);
}
};
}
})(window, window.angular);

View File

@ -0,0 +1,16 @@
/*
AngularJS v1.4.6
(c) 2010-2015 Google, Inc. http://angularjs.org
License: MIT
*/
(function(n,h,p){'use strict';function E(a){var f=[];r(f,h.noop).chars(a);return f.join("")}function g(a,f){var d={},c=a.split(","),b;for(b=0;b<c.length;b++)d[f?h.lowercase(c[b]):c[b]]=!0;return d}function F(a,f){function d(a,b,d,l){b=h.lowercase(b);if(s[b])for(;e.last()&&t[e.last()];)c("",e.last());u[b]&&e.last()==b&&c("",b);(l=v[b]||!!l)||e.push(b);var m={};d.replace(G,function(b,a,f,c,d){m[a]=q(f||c||d||"")});f.start&&f.start(b,m,l)}function c(b,a){var c=0,d;if(a=h.lowercase(a))for(c=e.length-
1;0<=c&&e[c]!=a;c--);if(0<=c){for(d=e.length-1;d>=c;d--)f.end&&f.end(e[d]);e.length=c}}"string"!==typeof a&&(a=null===a||"undefined"===typeof a?"":""+a);var b,k,e=[],m=a,l;for(e.last=function(){return e[e.length-1]};a;){l="";k=!0;if(e.last()&&w[e.last()])a=a.replace(new RegExp("([\\W\\w]*)<\\s*\\/\\s*"+e.last()+"[^>]*>","i"),function(a,b){b=b.replace(H,"$1").replace(I,"$1");f.chars&&f.chars(q(b));return""}),c("",e.last());else{if(0===a.indexOf("\x3c!--"))b=a.indexOf("--",4),0<=b&&a.lastIndexOf("--\x3e",
b)===b&&(f.comment&&f.comment(a.substring(4,b)),a=a.substring(b+3),k=!1);else if(x.test(a)){if(b=a.match(x))a=a.replace(b[0],""),k=!1}else if(J.test(a)){if(b=a.match(y))a=a.substring(b[0].length),b[0].replace(y,c),k=!1}else K.test(a)&&((b=a.match(z))?(b[4]&&(a=a.substring(b[0].length),b[0].replace(z,d)),k=!1):(l+="<",a=a.substring(1)));k&&(b=a.indexOf("<"),l+=0>b?a:a.substring(0,b),a=0>b?"":a.substring(b),f.chars&&f.chars(q(l)))}if(a==m)throw L("badparse",a);m=a}c()}function q(a){if(!a)return"";A.innerHTML=
a.replace(/</g,"&lt;");return A.textContent}function B(a){return a.replace(/&/g,"&amp;").replace(M,function(a){var d=a.charCodeAt(0);a=a.charCodeAt(1);return"&#"+(1024*(d-55296)+(a-56320)+65536)+";"}).replace(N,function(a){return"&#"+a.charCodeAt(0)+";"}).replace(/</g,"&lt;").replace(/>/g,"&gt;")}function r(a,f){var d=!1,c=h.bind(a,a.push);return{start:function(a,k,e){a=h.lowercase(a);!d&&w[a]&&(d=a);d||!0!==C[a]||(c("<"),c(a),h.forEach(k,function(d,e){var k=h.lowercase(e),g="img"===a&&"src"===k||
"background"===k;!0!==O[k]||!0===D[k]&&!f(d,g)||(c(" "),c(e),c('="'),c(B(d)),c('"'))}),c(e?"/>":">"))},end:function(a){a=h.lowercase(a);d||!0!==C[a]||(c("</"),c(a),c(">"));a==d&&(d=!1)},chars:function(a){d||c(B(a))}}}var L=h.$$minErr("$sanitize"),z=/^<((?:[a-zA-Z])[\w:-]*)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*(>?)/,y=/^<\/\s*([\w:-]+)[^>]*>/,G=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,K=/^</,J=/^<\//,H=/\x3c!--(.*?)--\x3e/g,x=/<!DOCTYPE([^>]*?)>/i,
I=/<!\[CDATA\[(.*?)]]\x3e/g,M=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,N=/([^\#-~| |!])/g,v=g("area,br,col,hr,img,wbr");n=g("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr");p=g("rp,rt");var u=h.extend({},p,n),s=h.extend({},n,g("address,article,aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,script,section,table,ul")),t=h.extend({},p,g("a,abbr,acronym,b,bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s,samp,small,span,strike,strong,sub,sup,time,tt,u,var"));
n=g("circle,defs,desc,ellipse,font-face,font-face-name,font-face-src,g,glyph,hkern,image,linearGradient,line,marker,metadata,missing-glyph,mpath,path,polygon,polyline,radialGradient,rect,stop,svg,switch,text,title,tspan,use");var w=g("script,style"),C=h.extend({},v,s,t,u,n),D=g("background,cite,href,longdesc,src,usemap,xlink:href");n=g("abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules,scope,scrolling,shape,size,span,start,summary,tabindex,target,title,type,valign,value,vspace,width");
p=g("accent-height,accumulate,additive,alphabetic,arabic-form,ascent,baseProfile,bbox,begin,by,calcMode,cap-height,class,color,color-rendering,content,cx,cy,d,dx,dy,descent,display,dur,end,fill,fill-rule,font-family,font-size,font-stretch,font-style,font-variant,font-weight,from,fx,fy,g1,g2,glyph-name,gradientUnits,hanging,height,horiz-adv-x,horiz-origin-x,ideographic,k,keyPoints,keySplines,keyTimes,lang,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mathematical,max,min,offset,opacity,orient,origin,overline-position,overline-thickness,panose-1,path,pathLength,points,preserveAspectRatio,r,refX,refY,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,rotate,rx,ry,slope,stemh,stemv,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,systemLanguage,target,text-anchor,to,transform,type,u1,u2,underline-position,underline-thickness,unicode,unicode-range,units-per-em,values,version,viewBox,visibility,width,widths,x,x-height,x1,x2,xlink:actuate,xlink:arcrole,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,xml:space,xmlns,xmlns:xlink,y,y1,y2,zoomAndPan",
!0);var O=h.extend({},D,p,n),A=document.createElement("pre");h.module("ngSanitize",[]).provider("$sanitize",function(){this.$get=["$$sanitizeUri",function(a){return function(f){var d=[];F(f,r(d,function(c,b){return!/^unsafe/.test(a(c,b))}));return d.join("")}}]});h.module("ngSanitize").filter("linky",["$sanitize",function(a){var f=/((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"\u201d\u2019]/i,d=/^mailto:/i;return function(c,b){function k(a){a&&g.push(E(a))}function e(a,
c){g.push("<a ");h.isDefined(b)&&g.push('target="',b,'" ');g.push('href="',a.replace(/"/g,"&quot;"),'">');k(c);g.push("</a>")}if(!c)return c;for(var m,l=c,g=[],n,p;m=l.match(f);)n=m[0],m[2]||m[4]||(n=(m[3]?"http://":"mailto:")+n),p=m.index,k(l.substr(0,p)),e(n,m[0].replace(d,"")),l=l.substring(p+m[0].length);k(l);return a(g.join(""))}}])})(window,window.angular);
//# sourceMappingURL=angular-sanitize.min.js.map

28826
public/javascripts/wechat/angular.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ var apiUrl = '/api/v1/';
var debug = false; //调试标志,如果在本地请置为true var debug = false; //调试标志,如果在本地请置为true
if(debug===true){ if(debug===true){
apiUrl = 'http://localhost:3000/api/v1/'; apiUrl = 'https://www.trustie.net/api/v1/';
} }
app.factory('auth', function($http,$routeParams, $cookies, $q){ app.factory('auth', function($http,$routeParams, $cookies, $q){
@ -394,11 +394,12 @@ app.directive('textAutoHeight', function($timeout){
}); });
} }
}, false); }, false);
} }
} }
}); });
app.config(['$routeProvider',function ($routeProvider) { app.config(['$routeProvider',"$httpProvider",function ($routeProvider, $httpProvider) {
$routeProvider $routeProvider
.when('/activities', { .when('/activities', {
templateUrl: 'activities.html', templateUrl: 'activities.html',
@ -435,4 +436,22 @@ app.config(['$routeProvider',function ($routeProvider) {
.otherwise({ .otherwise({
redirectTo: '/activities' redirectTo: '/activities'
}); });
$httpProvider.interceptors.push('timestampMarker');
}]);
//loading
app.factory('timestampMarker', ["$rootScope", function ($rootScope) {
var timestampMarker = {
request: function (config) {
$rootScope.loading = true;
config.requestTimestamp = new Date().getTime();
return config;
},
response: function (response) {
// $rootScope.loading = false;
response.config.responseTimestamp = new Date().getTime();
return response;
}
};
return timestampMarker;
}]); }]);

View File

@ -593,6 +593,9 @@ img.ui-datepicker-trigger {
.repos_files ul:hover{ background:#ffffdd;} .repos_files ul:hover{ background:#ffffdd;}
.repos_t_c li{ text-align:center;} .repos_t_c li{ text-align:center;}
.pic_stats{display:block; background:url(../images/public_icon.png) 0px -548px no-repeat; width:20px; height:15px;} .pic_stats{display:block; background:url(../images/public_icon.png) 0px -548px no-repeat; width:20px; height:15px;}
.tree-age{width:10%; text-align:right;}
.tree-author{width:10%; text-align:left;}
.tree-comments{width:40%; text-align:left;}
/* 里程碑 */ /* 里程碑 */
@ -816,7 +819,7 @@ div.changeset { border-bottom: 1px solid #ddd; }
tr.entry { border: 1px solid #DDD; } tr.entry { border: 1px solid #DDD; }
tr.entry td { white-space: nowrap; } tr.entry td { white-space: nowrap; }
tr.entry td.filename { width: 30%; } tr.entry td.filename { width: 30%; }
tr.entry td.filename_no_report { width: 70%; } tr.entry td.filename_no_report { width: 40%; }
tr.entry td.size { text-align: right; font-size: 90%; } tr.entry td.size { text-align: right; font-size: 90%; }
tr.entry td.revision, tr.entry td.author { text-align: center; } tr.entry td.revision, tr.entry td.author { text-align: center; }
tr.entry td.age { text-align: right; } tr.entry td.age { text-align: right; }

View File

@ -71,3 +71,9 @@ a.underline {text-decoration:underline;}
.reply-icon {background:url(/images/wechat/wechat_icon.png) -100px 1px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;} .reply-icon {background:url(/images/wechat/wechat_icon.png) -100px 1px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;}
.praise-icon {background:url(/images/wechat/wechat_icon.png) -100px -38px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;} .praise-icon {background:url(/images/wechat/wechat_icon.png) -100px -38px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;}
.praised-icon {background:url(/images/wechat/wechat_icon.png) -100px -76px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;} .praised-icon {background:url(/images/wechat/wechat_icon.png) -100px -76px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;}
/* loading 弹框*/
.loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(206, 206, 206, 0.3); overflow:hidden;}
.loading-box {position:absolute; top:50%; background:white; width:160px; height:72px; left:50%; margin-top:-36px; margin-left:-80px; text-align:center;}
.loading-box img {margin-top: 3px; text-align: center;}
.loading-box span {display: block; font-size:13px;}