diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 2a3ce15d8..d87644e43 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -234,4 +234,96 @@ class AdminController < ApplicationController format.api end end + + #首页定制 + def first_page_made + if request.get? + @first_page = FirstPage.where("page_type = 'project'").first + elsif request.post? + @first_page = FirstPage.where("page_type = 'project'").first + @first_page.web_title = params[:web_title] + @first_page.description = params[:description] + @first_page.title = params[:title] + if @first_page.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to admin_first_page_made_path + } + format.api { render_api_ok } + end + else + respond_to do |format| + format.html { + first_page_made + render :action => 'first_page_made' + } + format.api { render_validation_errors(@first_page) } + end + end + end + end + + def course_page_made + if request.get? + @course_page = FirstPage.where("page_type = 'course'").first + @first_page = FirstPage.where("page_type = 'project'").first + elsif request.post? + @first_page = FirstPage.where("page_type = 'project'").first + @course_page = FirstPage.where("page_type = 'course'").first + @first_page.web_title = params[:web_title] + @course_page.title = params[:course_title] + @course_page.description = params[:course_description] + if @first_page.save && @course_page.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to admin_course_page_made_path + } + format.api { render_api_ok } + end + else + respond_to do |format| + format.html { + course_page_made + render :action => 'course_page_made' + } + format.api { render_validation_errors(@first_page) } + format.api { render_validation_errors(@course_page) } + end + end + end + end + + def contest_page_made + if request.get? + @contest_page = FirstPage.where("page_type = 'contest'").first + @first_page = FirstPage.where("page_type = 'project'").first + elsif request.post? + @first_page = FirstPage.where("page_type = 'project'").first + @contest_page = FirstPage.where("page_type = 'contest'").first + @first_page.web_title = params[:web_title] + @contest_page.title = params[:contest_title] + @contest_page.description = params[:contest_description] + if @first_page.save && @contest_page.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to admin_contest_page_made_path + } + format.api { render_api_ok } + end + else + respond_to do |format| + format.html { + contest_page_made + render :action => 'contest_page_made' + } + format.api { render_validation_errors(@first_page) } + format.api { render_validation_errors(@contest_page) } + end + end + end + end + end diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index a728ee6e2..b9f9245c8 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -449,7 +449,7 @@ class BidsController < ApplicationController # 显示作业课程 # add by nwb def show_courseEx - if (User.current.logged? && User.current.member_of_course?(@bid.courses.first)) + if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?)) # flash[:notice] = "" @membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current)) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index bf18332df..03bca6162 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -16,12 +16,13 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class WelcomeController < ApplicationController + include ApplicationHelper caches_action :robots # before_filter :fake, :only => [:index, :course] before_filter :entry_select, :only => [:index] def index - + @first_page = FirstPage.where("page_type = 'project'").first end def robots @@ -30,6 +31,7 @@ class WelcomeController < ApplicationController end def course + @course_page = FirstPage.where("page_type = 'course'").first if params[:school_id] @school_id = params[:school_id] elsif User.current.logged? && User.current.user_extensions.school @@ -41,13 +43,24 @@ class WelcomeController < ApplicationController def logolink() + @course_page = FirstPage.where("page_type = 'course'").first + logo = get_avatar?(@course_page) id = params[:school_id] logo_link = "" - if id.nil? and User.current.user_extensions.school.nil? - logo_link = '/images/transparent.png' + if id.nil? && User.current.user_extensions.school.nil? + if logo + logo_link = url_to_avatar(@course_page) + else + logo_link = '/images/transparent.png' + end + else if id == "0" - logo_link = '/images/transparent.png' + if logo + logo_link = url_to_avatar(@course_page) + else + logo_link = '/images/transparent.png' + end else if id.nil? if School.find(User.current.user_extensions.school.id).logo_link.nil? @@ -66,7 +79,7 @@ class WelcomeController < ApplicationController def contest - + @contest_page = FirstPage.where("page_type = 'contest'").first end def search diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6bbf6ed6..4f6cb3e95 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -256,8 +256,8 @@ module ApplicationHelper end def format_activity_description(text) - h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...') - ).gsub(/[\r\n]+/, "
").html_safe + h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "
").html_safe + #h(truncate(text.to_s, :length => 120).gsub(/<\/?.*?>/,"")).html_safe end def format_version_name(version) @@ -625,10 +625,15 @@ module ApplicationHelper end def html_title(*args) + first_page = FirstPage.where("page_type = 'project'").first if args.empty? title = @html_title || [] title << @project.name if @project - title << Setting.app_title unless Setting.app_title == title.last + if first_page.nil? || first_page.web_title.nil? + title << Setting.app_title unless Setting.app_title == title.last + else + title << first_page.web_title unless first_page.web_title == title.last + end title.select {|t| !t.blank? }.join(' - ') else @html_title ||= [] diff --git a/app/models/course.rb b/app/models/course.rb index b6974eed0..248f80e0b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -104,7 +104,19 @@ class Course < ActiveRecord::Base # 课程的短描述信息 def short_description(length = 255) - description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description + description.gsub(/<\/?.*?>/,"").html_safe if description + #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description + end + + def strip_html(html) + return html if html.empty? || !html.include?('<') + output = "" + tokenizer = HTML::Tokenizer.new(html) + while token = tokenizer.next + node = HTML::Node.parse(nil, 0, 0, token, false) + output += token unless (node.kind_of? HTML::Tag) or (token =~ /^/,"").html_safe if description + #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description + end + private :workflow_rule_by_attribute def done_ratio @@ -1513,4 +1519,6 @@ class Issue < ActiveRecord::Base def be_user_score_new_issue UserScore.project(:post_issue, User.current,self, { issue_id: self.id }) end + + end diff --git a/app/models/news.rb b/app/models/news.rb index 9a0f8b75c..66e339291 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -74,6 +74,12 @@ class News < ActiveRecord::Base visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all end + # 新闻的短描述信息 + def short_description(length = 255) + description.gsub(/<\/?.*?>/,"").html_safe if description + #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description + end + private def add_author_as_watcher diff --git a/app/models/open_source_project.rb b/app/models/open_source_project.rb index e3556ce55..2de5966bb 100644 --- a/app/models/open_source_project.rb +++ b/app/models/open_source_project.rb @@ -84,7 +84,8 @@ class OpenSourceProject < ActiveRecord::Base # end def short_description(length = 255) - description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description + #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description + description.gsub(/<\/?.*?>/,"").html_safe if description end def applied_by?(user) diff --git a/app/models/project.rb b/app/models/project.rb index 37ca8f20b..698b1f26a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -629,7 +629,8 @@ class Project < ActiveRecord::Base # Returns a short description of the projects (first lines) def short_description(length = 255) - description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description + #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description + description.gsub(/<\/?.*?>/,"").html_safe if description end def css_classes diff --git a/app/views/admin/contest_page_made.html.erb b/app/views/admin/contest_page_made.html.erb new file mode 100644 index 000000000..b8a86fa4d --- /dev/null +++ b/app/views/admin/contest_page_made.html.erb @@ -0,0 +1,39 @@ +

<%=l(:label_first_page_made)%>

+ +<%= form_tag(:controller => 'admin', :action => 'contest_page_made') do %> +

+ + <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+
+ +
+ +

<%=l(:label_contest_first_page)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %> +
+

+ + <%= text_field_tag 'contest_title', params[:label_site_title], :value => @contest_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ +

+ + <%= text_area_tag 'contest_description',@contest_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ + <%= submit_tag l(:button_save), :class => "small", :name => nil %> +<% end %> +
+ + + +
\ No newline at end of file diff --git a/app/views/admin/course_page_made.html.erb b/app/views/admin/course_page_made.html.erb new file mode 100644 index 000000000..4554fb8e0 --- /dev/null +++ b/app/views/admin/course_page_made.html.erb @@ -0,0 +1,37 @@ +

<%=l(:label_first_page_made)%>

+ +<%= form_tag(:controller => 'admin', :action => 'course_page_made') do %> +

+ + <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+
+ +
+

<%=l(:label_course_first_page)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %> +
+

+ + <%= text_field_tag 'course_title', params[:label_site_title], :value => @course_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

+ + <%= text_area_tag 'course_description',@course_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ + <%= submit_tag l(:button_save), :class => "small", :name => nil %> +<% end %> +
+ + + +
\ No newline at end of file diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb new file mode 100644 index 000000000..a64bbb443 --- /dev/null +++ b/app/views/admin/first_page_made.html.erb @@ -0,0 +1,38 @@ +

<%=l(:label_first_page_made)%>

+ +<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %> +

+ + <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+
+ +
+

<%=l(:label_project_first_page)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %> +
+ +

+ + <%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

+ + <%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ + <%= submit_tag l(:button_save), :class => "small", :name => nil %> +<% end %> +
+ + + +
\ No newline at end of file diff --git a/app/views/admin/project_page_made.html.erb b/app/views/admin/project_page_made.html.erb new file mode 100644 index 000000000..e338c21a9 --- /dev/null +++ b/app/views/admin/project_page_made.html.erb @@ -0,0 +1,31 @@ +

<%=l(:label_first_page_made)%>

+ +<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %> +

+ + <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

<%=l(:label_project_first_page)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %> +
+ +

+ + <%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

+ + <%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ + <%= submit_tag l(:button_save), :class => "small", :name => nil %> +<% end %> +
+ + + +
\ No newline at end of file diff --git a/app/views/avatar/_avatar_form.html.erb b/app/views/avatar/_avatar_form.html.erb index 272397c62..a880f32aa 100644 --- a/app/views/avatar/_avatar_form.html.erb +++ b/app/views/avatar/_avatar_form.html.erb @@ -45,6 +45,7 @@ <%= l(:button_upload_photo) %> + <%= file_field_tag 'avatar[image]', :id => nil, @@ -57,6 +58,8 @@ :max_file_size => Setting.attachment_max_size.to_i.kilobytes, :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :file_type => Redmine::Configuration['pic_types'].to_s, + :type_support_message => l(:error_pic_type), :upload_path => upload_avatar_path(:format => 'js'), :description_placeholder => nil ,# l(:label_optional_description) :source_type => source.class.to_s, diff --git a/app/views/contests/_contest_list.html.erb b/app/views/contests/_contest_list.html.erb index 8b5e34975..61dd6192c 100644 --- a/app/views/contests/_contest_list.html.erb +++ b/app/views/contests/_contest_list.html.erb @@ -2,11 +2,19 @@ <% contests.each do |contest|%> - + @@ -51,31 +51,31 @@ <% case e.act_type %> <% when 'JournalsForMessage' %> <% if User.current.login == e.user.try(:login) %> - <%# if e.user_id == act.jour.id %> - + <%# if e.user_id == act.jour.id %> + <%# else %> <%# end %> <% else %> - + <% end %> - - - + + + - - - + + + <% when 'Bid' %> <% if act.reward_type ==3 %> @@ -92,7 +92,7 @@ <% end %> <% end %> - + <% end %> - + <% end %> - + - <% when 'Principal' %> @@ -161,8 +161,8 @@ <% end %> - - + <% end %> - + <% end %> - +
<%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'), user_path(contest.author), :class => "avatar") %> + <% unless contest.author.nil? %> + <%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'), user_path(contest.author), :class => "avatar") %> + <% end %> + - + diff --git a/app/views/users/_score_new_index.html.erb b/app/views/users/_score_new_index.html.erb index 43687aa78..0f5d96a45 100644 --- a/app/views/users/_score_new_index.html.erb +++ b/app/views/users/_score_new_index.html.erb @@ -28,7 +28,7 @@
= <%= l(:label_user_score_of_collaboration) %> + <%= l(:label_user_score_of_influence) %> + <%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %>
-
= <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_f %> - + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %>
-
= <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_f %>
+
= <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_i %> + + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
+
= <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_i %>
diff --git a/app/views/users/_show_new_score.html.erb b/app/views/users/_show_new_score.html.erb index c5f15694e..fddca46ac 100644 --- a/app/views/users/_show_new_score.html.erb +++ b/app/views/users/_show_new_score.html.erb @@ -38,7 +38,7 @@ @@ -49,23 +49,23 @@
<%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>:  <%= link_to(contest.name, show_contest_contest_path(contest), :class => 'bid_path', :target => "_blank") %> + <% unless contest.author.nil? %> + <%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>: + <% end %> +  <%= link_to(contest.name, show_contest_contest_path(contest), :class => 'bid_path', :target => "_blank") %>
diff --git a/app/views/courses/_course.html.erb b/app/views/courses/_course.html.erb index ef8f37566..6b720229a 100644 --- a/app/views/courses/_course.html.erb +++ b/app/views/courses/_course.html.erb @@ -16,7 +16,7 @@ <%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%> <% @admin = @course.course_infos%> <%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%> - + <% unless @course.teacher.user_extensions.school.nil? %> <%= link_to @course.teacher.user_extensions.school.try(:name), school_course_list_path(@course.teacher.user_extensions.school) %> <% end %> @@ -28,7 +28,7 @@ <%= content_tag('a', @admin.collect{|u| link_to(u.user.lastname+u.user.firstname, user_path(u.user_id))}.join(", ").html_safe) %> <% end %>

- +
@@ -76,6 +76,10 @@
<%= content_tag "span", "#{l(:label_course_brief_introduction)}:", :class => "course-font" %> + <%# desc = course.short_description.nil? ? "" : course.short_description%> + <%= content_tag "div", course.short_description, :class => "brief_introduction", :title => course.short_description %>
diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index db94cf6c5..0586262e9 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -35,6 +35,8 @@
<%if @courses%> <%= render_course_hierarchy(@courses)%> + <%#= render :partial => 'course', :locals => {:course => @courses.first}%> + <%#= "hello".html_safe %> <%end%>
diff --git a/app/views/forums/_forum_list.html.erb b/app/views/forums/_forum_list.html.erb index 0bbb0ddd4..2b8f98494 100644 --- a/app/views/forums/_forum_list.html.erb +++ b/app/views/forums/_forum_list.html.erb @@ -3,7 +3,11 @@ <% if forums.any? %> <% forums.each do |forum| %>
-
<%= link_to image_tag(url_to_avatar(forum.creator), :class => "avatar"), user_path(forum.creator) %>
+
+ <% unless forum.creator.nil? %> + <%= link_to image_tag(url_to_avatar(forum.creator), :class => "avatar"), user_path(forum.creator) %> + <% end %> +

<%= link_to h(forum.name), forum_path(forum) %>

<%= forum.description%>

diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index b36c4b57d..57d8a60cb 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -38,7 +38,7 @@ <% end -%>
    - <%= l(:field_description)%>: <%= issue.description %> + <%= l(:field_description)%>: <%= issue.short_description %>
    diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb index 4feddc675..5f507db3c 100644 --- a/app/views/projects/_project.html.erb +++ b/app/views/projects/_project.html.erb @@ -18,18 +18,40 @@

    - <%= link_to @project.watcher_users.count, project_watcherlist_path(project)%> - <%= content_tag('span', l(:label_x_follow_people,:count =>@project.watcher_users.count)) %> -

    -

    - <%= link_to "#{@project.members.count}", project_member_path(@project)%> - <%= content_tag('span', l(:label_x_current_contributors, :count => @project.users.count)) %> -

    -

    - <%= content_tag('span', "#{(@project.repository.nil? || @project.repository.changesets[0].nil?) ? '0' : distance_of_time_in_words(Time.now, @project.repository.changesets[0].committed_on)}", :class => "info") %><%= content_tag('span', l(:label_since_last_commits)) %> -

    -

    - <%= content_tag('span', "#{@project.repository.nil? || @project.project_status.nil? ? '0' : @project.project_status.changesets_count }", :class => "info") %><%= content_tag('span', l(:label_commit_on)) %> + + + + + + + + + + + + + + + + + +
    + <%= link_to @project.watcher_users.count, project_watcherlist_path(project)%> + + <%= content_tag('span', l(:label_x_follow_people,:count =>@project.watcher_users.count)) %> +
    + <%= link_to "#{@project.members.count}", project_member_path(@project)%> + + <%= content_tag('span', l(:label_x_current_contributors, :count => @project.users.count)) %> +
    + <%= content_tag('span', "#{(@project.repository.nil? || @project.repository.changesets[0].nil?) ? '0' : distance_of_time_in_words(Time.now, @project.repository.changesets[0].committed_on)}", :class => "info") %> + + <%= content_tag('span', l(:label_since_last_commits)) %> +
    + <%= content_tag('span', "#{@project.repository.nil? || @project.project_status.nil? ? '0' : @project.project_status.changesets_count }", :class => "info") %> + + <%= content_tag('span', l(:label_commit_on)) %> +

    <% end %> @@ -120,9 +142,9 @@ <%= l(:label_project_grade)%>: <%= link_to(format("%.2f" , finall_project_score ).to_f, - {:controller => 'projects', - :action => 'show_projects_score', - :remote => true, :id => @project.id}, :style=>"color: #EC6300;") %> + {:controller => 'projects', + :action => 'show_projects_score', + :remote => true, :id => @project.id}, :style=>"color: #EC6300;") %> <% end %>
diff --git a/app/views/school/index.html.erb b/app/views/school/index.html.erb index a42844ffb..8a5aa5f49 100644 --- a/app/views/school/index.html.erb +++ b/app/views/school/index.html.erb @@ -71,7 +71,9 @@

<%= link_to "全部学校",school_index_path %>      - 我的学校 + <% if User.current.logged? %> + 我的学校 + <% end %>

  • 请选择省份: diff --git a/app/views/users/_course_form.html.erb b/app/views/users/_course_form.html.erb index f5cada9a8..4d9c58392 100644 --- a/app/views/users/_course_form.html.erb +++ b/app/views/users/_course_form.html.erb @@ -32,7 +32,7 @@

- <%= membership.course.description %> + <%= membership.course.short_description %>

- +
<%= l(:label_user_score) %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= link_to l(:label_user_score) , {:controller => 'users', :action => 'score_new_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.total_score).to_f %> + <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= link_to l(:label_user_score_of_collaboration), {:controller => 'users',:action => 'topic_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %>
<%= link_to l(:label_user_score_of_influence), {:controller => 'users',:action => 'project_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_i %>
<%= link_to l(:label_user_score_of_skill), {:controller => 'users',:action => 'activity_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %>
<%= link_to l(:label_user_score_of_active), {:controller => 'users',:action => 'influence_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
diff --git a/app/views/users/_user_score.html.erb b/app/views/users/_user_score.html.erb index d047c11d0..53f05a2dd 100644 --- a/app/views/users/_user_score.html.erb +++ b/app/views/users/_user_score.html.erb @@ -1,5 +1,5 @@ <%= l(:label_user_grade)%>: -<%= link_to(format("%.2f" , user.user_score_attr.total_score).to_f, {:controller => 'users', +<%= link_to(format("%.2f" , user.user_score_attr.total_score).to_i, {:controller => 'users', :action => 'show_new_score', :remote => true, :id => user.id diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index ec469a5b9..f2fa522cd 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -26,7 +26,7 @@
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %><%= - link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %>
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %> + <%= link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %>
<%= link_to("#{e.user.name}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %><%= - link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %>
<%= link_to("#{e.user.name}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %><%= + link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %>

<%= textilizable act.notes %>

-
<%= link_to(l(:label_goto), user_newfeedback_user_path(e.user_id)) %> -
-

<%= textilizable act.notes %>

+
<%= link_to(l(:label_goto), user_newfeedback_user_path(e.user_id)) %> +
+
-
- <%=(l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> -
-
-
+
+ <%=(l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> +
+
+

<%= h act.description %>

<%= act.description.html_safe %>

@@ -109,7 +109,7 @@
<%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to( l(:label_activity_project)+act.issue.project.name, project_path(act.issue.project.identifier))%> <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.id}: #{act.issue.subject}"), {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"} %>

<%= h act.notes %>

<%= act.notes.html_safe %>

@@ -126,7 +126,7 @@
<%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title(act.title), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %>

<%= h act.long_comments %>

<%= act.long_comments.html_safe %>

@@ -145,11 +145,11 @@

<%= h act.content.truncate(240, omission: '...') %>

+
<%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %>
-
+

+
<%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %>
@@ -177,7 +177,7 @@
<%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id} %>

<%= h act.description %>

<%= act.description.html_safe %>

@@ -193,7 +193,7 @@
<%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %>

<%= textilizable act.description %>

<%= textilizable(act.description) %>

@@ -251,7 +251,7 @@
- @@ -64,23 +64,23 @@
<%= link_to(h(e.user), user_path(e.user)) %> + <%= link_to(h(e.user), user_path(e.user)) %> <% if e.instance_of?(JournalsForMessage)%> <% if e.reply_id == User.current.id%> <%if e.jour_type == 'Bid'%> diff --git a/app/views/users/show_new_score.html.erb b/app/views/users/show_new_score.html.erb index 07e82fd5f..0efae940c 100644 --- a/app/views/users/show_new_score.html.erb +++ b/app/views/users/show_new_score.html.erb @@ -53,7 +53,7 @@ - +
<%= l(:label_user_score) %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= l(:label_user_score) %> : - <%= format("%.2f" , @user.user_score_attr.total_score).to_f %> + <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= l(:label_user_score_of_collaboration) %> : - <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %>
<%= l(:label_user_score_of_influence) %> : - <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_i %>
<%= l(:label_user_score_of_skill) %> : - <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %>
<%= l(:label_user_score_of_active) %> : - <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
diff --git a/app/views/users/user_activities.html.erb b/app/views/users/user_activities.html.erb index faea90fd3..2b4cf8819 100644 --- a/app/views/users/user_activities.html.erb +++ b/app/views/users/user_activities.html.erb @@ -39,8 +39,9 @@
- + + <% end %> -<% end %> +<% end %> <% end %> diff --git a/app/views/users/user_projects.html.erb b/app/views/users/user_projects.html.erb index e16700cd1..66ddcaae2 100644 --- a/app/views/users/user_projects.html.erb +++ b/app/views/users/user_projects.html.erb @@ -30,7 +30,7 @@

- <%= membership.project.description%> + <%= membership.project.short_description%>

diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index c87cc13e1..c3bd120da 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -114,12 +114,17 @@
- <%= image_tag '/images/transparent.png', size: "75x75" %> + <% if get_avatar?(@contest_page) %> + <%= image_tag(url_to_avatar(@contest_page), size: "75x75") %> + <% else %> + <%= image_tag '/images/transparent.png', size: "75x75" %> + <% end %>
- - <%= l(:label_welcome_trustie) %> <%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %> -
+ <% unless @contest_page.nil? %> + <%= @contest_page.title %> , <%= @contest_page.description %> + <% end %> +
diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index cfde8fca4..f6bffe51c 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -51,14 +51,17 @@ <% end %> <% end %> <% end %> - <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> + <% unless @course_page.nil? %> + <%= @course_page.title %> + <% if @school_id.nil? and User.current.user_extensions.school.nil? %> - , <%= l(:label_welcome_trustie_course_description) %> + , <%= @course_page.description %> <% else %> <% if @school_id == "0" %> - , <%= l(:label_welcome_trustie_course_description) %> + , <%= @course_page.description %> <% end %> <% end %> + <% end %>
- <%= image_tag '/images/transparent.png', size: "75x75" %> + + <% if get_avatar?(@first_page) %> + <%= image_tag(url_to_avatar(@first_page), size: "75x75") %> + <% else %> + <%= image_tag '/images/transparent.png', size: "75x75" %> + <% end %> +
- <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_project) %> , <%= l(:label_welcome_trustie_project_description) %> + <% unless @first_page.nil? %> + <%= @first_page.title %> , <%= @first_page.description %> + <% end %>
@@ -114,7 +122,7 @@
<%activities = find_all_activities%> <% activities.each do |event| %> - +
  • <%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %> @@ -125,7 +133,7 @@

    <%= l(:field_updated_on) %><%= time_tag_welcome event.event_datetime %>前     <%= show_event_reply event %>

  • - + <% end %>
    diff --git a/config/configuration.yml b/config/configuration.yml index a98ea3391..4bdd279aa 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -199,6 +199,7 @@ default: # Maximum number of simultaneous AJAX uploads #max_concurrent_ajax_uploads: 2 + #pic_types: "bmp,jpeg,jpg,png,gif" # specific configuration options for production environment # that overrides the default ones diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 36d89da10..276d09336 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -516,6 +516,10 @@ zh: label_project_new_description: '项目可以是软件开发项目,也可以是协作研究项目。' label_project_plural: 项目列表 label_project_score: 项目评分 + label_first_page_made: 首页定制 + label_project_first_page: 项目托管平台首页 + label_course_first_page: 课程实践平台首页 + label_contest_first_page: 竞赛实战平台首页 label_x_projects: zero: 无项目 one: 1 个项目 @@ -563,6 +567,10 @@ zh: label_login_with_open_id_option: 或使用OpenID登录 label_password_lost: 忘记密码 label_home: 主页 + label_web_title: 浏览器标题 + label_site_title: 网站标题 + label_site_description: 网站简介 + label_site_image: 简介图片 #by young label_requirement: 需求 label_new_course: 课程列表 @@ -1220,6 +1228,7 @@ zh: button_export: 导出 label_export_options: "%{export_format} 导出选项" error_attachment_too_big: 该文件无法上传。超过文件大小限制 (%{max_size}) + error_pic_type: "仅支持如下图片格式:" notice_failed_to_save_time_entries: "无法保存下列所选取的 %{total} 个项目中的 %{count} 工时: %{ids}。" label_x_issues: zero: 0 问题 diff --git a/config/routes.rb b/config/routes.rb index 1ad026dc3..dfb8d503b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -559,6 +559,9 @@ RedmineApp::Application.routes.draw do match 'admin', :controller => 'admin', :action => 'index', :via => :get match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get match 'admin/users', :controller => 'admin', :action => 'users', :via => :get + match 'admin/first_page_made',:controller => 'admin',:action => 'first_page_made',:via => [:get,:post] + match 'admin/course_page_made',:controller => 'admin',:action => 'course_page_made',:via => [:get,:post] + match 'admin/contest_page_made',:controller => 'admin',:action => 'contest_page_made',:via => [:get,:post] match 'admin/search', :controller => 'admin', :action => 'search', :via => [:get, :post] match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get match 'admin/info', :controller => 'admin', :action => 'info', :via => :get diff --git a/db/migrate/20140710071720_create_first_pages.rb b/db/migrate/20140710071720_create_first_pages.rb new file mode 100644 index 000000000..fa7d01601 --- /dev/null +++ b/db/migrate/20140710071720_create_first_pages.rb @@ -0,0 +1,17 @@ +# -*coding:utf-8 -*- +class CreateFirstPages < ActiveRecord::Migration + def change + create_table :first_pages do |t| + t.string :web_title + t.string :title + t.string :description + + t.timestamps + end + fp = FirstPage.new + fp.web_title = "Trustie - 为大学生技术创新筑巢" + fp.title = "Trustie在线项目托管平台" + fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" + fp.save + end +end diff --git a/db/migrate/20140710095123_add_cloumn_to_first_page.rb b/db/migrate/20140710095123_add_cloumn_to_first_page.rb new file mode 100644 index 000000000..6720a8aa4 --- /dev/null +++ b/db/migrate/20140710095123_add_cloumn_to_first_page.rb @@ -0,0 +1,9 @@ +class AddCloumnToFirstPage < ActiveRecord::Migration + def change + add_column :first_pages,:type,:string + + fr = FirstPage.all.first + fr.type = "project" + fr.save + end +end diff --git a/db/migrate/20140711010124_alt_column_name.rb b/db/migrate/20140711010124_alt_column_name.rb new file mode 100644 index 000000000..24b784765 --- /dev/null +++ b/db/migrate/20140711010124_alt_column_name.rb @@ -0,0 +1,5 @@ +class AltColumnName < ActiveRecord::Migration + def change + rename_column :first_pages,:type,:page_type + end +end diff --git a/db/migrate/20140711012924_add_contest_and_course_first_page.rb b/db/migrate/20140711012924_add_contest_and_course_first_page.rb new file mode 100644 index 000000000..801219bd5 --- /dev/null +++ b/db/migrate/20140711012924_add_contest_and_course_first_page.rb @@ -0,0 +1,17 @@ +# -*coding:utf-8 -*- +class AddContestAndCourseFirstPage < ActiveRecord::Migration + def change + fp = FirstPage.new + fp.web_title = "" + fp.title = "Trustie在线课程实践平台" + fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。" + fp.page_type = "course" + fp.save + fp1 = FirstPage.new + fp1.web_title = "" + fp1.title = "Trustie在线竞赛实战平台" + fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。" + fp1.page_type = "contest" + fp1.save + end +end diff --git a/db/schema.rb b/db/schema.rb index 109c1f189..fa41ed1d5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140714021812) do +ActiveRecord::Schema.define(:version => 20140711012924) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -379,7 +379,6 @@ ActiveRecord::Schema.define(:version => 20140714021812) do t.text "description" t.datetime "created_on" t.integer "user_id", :default => 0 - t.integer "is_public", :default => 1 end add_index "documents", ["category_id"], :name => "index_documents_on_category_id" @@ -408,6 +407,15 @@ ActiveRecord::Schema.define(:version => 20140714021812) do add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" + create_table "first_pages", :force => true do |t| + t.string "web_title" + t.string "title" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "page_type" + end + create_table "forums", :force => true do |t| t.string "name", :null => false t.string "description", :default => "" diff --git a/lib/redmine.rb b/lib/redmine.rb index e17d657c8..6215a04ba 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -351,6 +351,7 @@ end Redmine::MenuManager.map :admin_menu do |menu| menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural + menu.push :first_page_made, {:controller => 'admin',:action => 'first_page_made'},:caption => :label_first_page_made menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural diff --git a/lib/redmine/configuration.rb b/lib/redmine/configuration.rb index 6723b777e..ba8e91294 100644 --- a/lib/redmine/configuration.rb +++ b/lib/redmine/configuration.rb @@ -21,7 +21,8 @@ module Redmine # Configuration default values @defaults = { 'email_delivery' => nil, - 'max_concurrent_ajax_uploads' => 2 + 'max_concurrent_ajax_uploads' => 2, + 'pic_types' => "bmp,jpeg,jpg,png,gif" } @config = nil diff --git a/public/javascripts/avatars.js b/public/javascripts/avatars.js index 24bc1ee1c..db9a2255e 100644 --- a/public/javascripts/avatars.js +++ b/public/javascripts/avatars.js @@ -140,10 +140,34 @@ function uploadAndAttachFiles(files, inputEl) { if (sizeExceeded) { window.alert(maxFileSizeExceeded); } else { - $.each(files, function() {addFile(inputEl, this, true);}); + uploadAndTypeFiles(files,inputEl); + //$.each(files, function() {addFile(inputEl, this, true);}); } } +function uploadAndTypeFiles(files, inputEl) { + + var enableType = $(inputEl).data('file-type'); + var typeSupportrdMessage = $(inputEl).data('type-support-message'); + if (enableType == null || enableType.trim() == "") + { + $.each(files, function() {addFile(inputEl, this, true);}); + return; + } + var typeSupported = false; + $.each(files, function() { + var a = this.name.split('.'); + var type = a[a.length-1]; + var rs = enableType.indexOf(type); + if(rs >= 0) {typeSupported = true } + }); + if (typeSupported) { + $.each(files, function() {addFile(inputEl, this, true);}); + } else { + window.alert(typeSupportrdMessage + enableType); + } +} + function handleFileDropEvent(e) { $(this).removeClass('fileover'); diff --git a/test/fixtures/first_pages.yml b/test/fixtures/first_pages.yml new file mode 100644 index 000000000..5af4dd417 --- /dev/null +++ b/test/fixtures/first_pages.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + web_title: MyString + title: MyString + description: MyString + +two: + web_title: MyString + title: MyString + description: MyString diff --git a/test/unit/first_page_test.rb b/test/unit/first_page_test.rb new file mode 100644 index 000000000..77e2cc97a --- /dev/null +++ b/test/unit/first_page_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class FirstPageTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end