diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 011be3171..8381170cb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -618,4 +618,23 @@ class ApplicationController < ActionController::Base def _include_layout?(*args) api_request? ? false : super end + + ## Please added code in html. + # + def paginateHelper obj, pre_size=20 + # current_count = pre_size * (params['page'].to_i - 1) if params['page'].to_i > 0 + offset, limit = api_offset_and_limit({:limit => pre_size}) + objs_all = obj + @obj_count = objs_all.count + @obj_pages = Paginator.new @obj_count, limit, params['page'] + offset ||= @obj_pages.offset + if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation + obj.offset(offset).limit(limit).all + elsif obj.kind_of? Array + obj[offset..(offset+limit-1)] + else + logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}" + nil + end + end end diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index af93c0bda..f872582b3 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -44,8 +44,9 @@ class MemosController < ApplicationController format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" } format.json { render json: @memo, status: :created, location: @memo } else + flash[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" # back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id) - format.html { redirect_to back_memo_or_forum_url, notice: "#{l :label_memo_create_fail}" } + format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } format.json { render json: @memo.errors, status: :unprocessable_entity } end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 685003c81..46c21db5d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -781,7 +781,7 @@ class ProjectsController < ApplicationController @subPage_title = l :label_teacher_list @members = searchTeacherAndAssistant(@project) when '2' - @subPage_title = l :label_student_list + @subPage_title = l :label_student_list @members = searchStudent(@project) else @subPage_title = '' @@ -793,7 +793,7 @@ class ProjectsController < ApplicationController @members = @project.member_principals.includes(:roles, :principal).all @members = sort_project_members(@project, @members) end - + @members = paginateHelper @members render :layout => 'base_courses' if @project.project_type == 1 end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 59c52e64e..b62ddb69a 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -131,7 +131,15 @@ module WelcomeHelper #取得论坛数据 def find_hot_forum_topics limit=10 #Memo.order('replies_count DESC').where('replies_count <> 0').limit(limit) - Memo.order('replies_count DESC').where('parent_id IS NULL').limit(limit) + Memo.order('replies_count DESC, created_at DESC').where('parent_id IS NULL').limit(limit) + ## 以下语句会内链接自身查询出最后一条回复时间,没有回复的帖子不会显示 + # Memo.find_by_sql(" + # SELECT memos.*, reply.created_at AS last_reply_date FROM memos AS memos + # INNER JOIN memos + # AS reply ON memos.last_reply_id=reply.id + # WHERE memos.parent_id IS NULL + # ORDER BY memos.replies_count DESC, memos.created_at DESC + # LIMIT #{limit}") end def sort_project_by_hot_rails project_type=0, order_by='grade DESC', limit=15 diff --git a/app/views/forums/_form.html.erb b/app/views/forums/_form.html.erb index d5111e93f..3f6759d00 100644 --- a/app/views/forums/_form.html.erb +++ b/app/views/forums/_form.html.erb @@ -1,20 +1,32 @@ -<%= labelled_form_for(@forum) do |f| %> +
+ <%= labelled_form_for(@forum) do |f| %> <% if @forum.errors.any? %> -
-

<%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:

+
+

<%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:

-
    +
      <% @forum.errors.full_messages.each do |msg| %> -
    • <%= msg %>
    • +
    • <%= msg %>
    • <% end %> -
    -
- <% end %> -
-

<%= f.text_field :name, :required => true %>

-

<%= f.text_field :description, :required => true, :size => 80 %>

- <%= f.submit :value => (l :label_board_new) %> +
-<% end %> + <% end %> +
+
+ <%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share' %> +
+
+ <%= f.text_area :description, :required => true, :rows => 4, :style => 'width: 100%;resize: none;', :class => 'create-share' %> +
+
+ <%= f.submit :value=>(l :label_board_new) ,:class => 'nyan-clean-gray', :style => 'font-size: 14px; padding: 0px 3px' %> + <%= link_to l(:button_back), forums_path,:class => 'nyan-clean-gray',:style => 'font-size: 14px; padding: 0px 3px; color: #000' %> +
+

<%#= f.text_field :name, :required => true %>

+

<%#= f.text_field :description, :required => true, :size => 80 %>

+ <%#= f.submit :value => (l :label_board_new) %> +
+ <% end %> +
diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index f79c44ae9..da813d894 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -6,7 +6,7 @@ <%= l(:label_user_location) %> : <% if User.current.logged? %> - <%= link_to("新建讨论区", new_forum_path, :class => 'icon icon-add') %> + <%= link_to( l(:label_forum_new), new_forum_path, :class => 'icon icon-add') %> <% end %> @@ -19,30 +19,3 @@
<%= render :partial => 'forums/forum_list', :locals => {:forums => @forums} %> - - - diff --git a/app/views/forums/new.html.erb b/app/views/forums/new.html.erb index b1bf778e7..429f34fad 100644 --- a/app/views/forums/new.html.erb +++ b/app/views/forums/new.html.erb @@ -1,6 +1,6 @@ -

<%= l :label_board_new%>

+

<%= l :label_forum_new %>

<%= render 'form' %> -<%= link_to l(:button_back), forums_path %> +<%#= link_to l(:button_back), forums_path %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 1ace56c1a..f7a2976c3 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -148,20 +148,20 @@ - + <%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %> + <%= link_to l(:project_module_files) ,project_files_path(@project) %> + + <%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %> + <%= link_to l(:label_roadmap) ,project_roadmap_path(@project) %> + + + <%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %> <%= link_to l(:label_module_share) ,share_show_path(@project) %> <%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %> <%= link_to l(:label_project_tool_response) ,project_feedback_path(@project) %> - - - - - diff --git a/app/views/projects/_member_list.html.erb b/app/views/projects/_member_list.html.erb index e29dde733..3b81b6615 100644 --- a/app/views/projects/_member_list.html.erb +++ b/app/views/projects/_member_list.html.erb @@ -30,6 +30,7 @@ <%= call_hook(:view_projects_settings_members_table_row, { :project => @project, :member => member}) %> <% end; reset_cycle %> + <% else %>

<%= l(:label_no_data) %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d74cd076a..e6cfac5de 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -513,7 +513,7 @@ zh: label_software_user: 软件创客 label_contest_innovate: 创新竞赛 label_requirement_enterprise: 软件众包 - label_project_module_forums: 讨论区 + label_project_module_forums: 讨论吧 label_new_homework: 作业 label_new_contest: 竞赛 label_requirement_focus: 关注需求 @@ -1735,6 +1735,7 @@ zh: label_borad_project: 项目讨论区 label_borad_course: 课程讨论区 label_memo_new_from_forum: 发布帖子 - label_forum: 讨论区 - label_tags_forum_description: 讨论区描述 - label_tags_forum: 讨论区名称 + label_forum: 讨论吧 + label_forum_new: 新建讨论吧 + label_tags_forum_description: 讨论吧描述 + label_tags_forum: 讨论吧名称 diff --git a/lib/redmine.rb b/lib/redmine.rb index 6f0a36757..e0889576e 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -301,7 +301,7 @@ end Redmine::MenuManager.map :project_menu do |menu| menu.push :overview, { :controller => 'projects', :action => 'show' } # menu.push :activity, { :controller => 'activities', :action => 'index' } - menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id + #menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id # :if => Proc.new { |p| p.shared_versions.any? } menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural # menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new, @@ -314,7 +314,7 @@ Redmine::MenuManager.map :project_menu do |menu| # :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural - menu.push :files, { :controller => 'files', :action => 'index' }, :param => :project_id, :caption => :label_file_new + #menu.push :files, { :controller => 'files', :action => 'index' }, :param => :project_id, :caption => :label_file_new menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil }, :if => Proc.new { |p| p.repository && !p.repository.new_record? && !( !User.current.member_of?(p) && p.hidden_repo ) } menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index d22ae059f..1297cfa5d 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -32,7 +32,7 @@ input[class='whiteButton'], .whiteButton { text-shadow:0px 1px 0px #ffffff; } -input[class='whiteButton'], .whiteButton:hover { +input[class='whiteButton']:hover, .whiteButton:hover { background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f6f6f6), color-stop(1, #ffffff)); background:-moz-linear-gradient(top, #f6f6f6 5%, #ffffff 100%); @@ -46,7 +46,7 @@ input[class='whiteButton'], .whiteButton:hover { } -input[class='whiteButton'], .whiteButton:active { +input[class='whiteButton']:active, .whiteButton:active { position:relative; top:1px; } @@ -110,7 +110,7 @@ input[class='nyan-clean-gray'], .nyan-clean-gray { padding-left:10px; padding-right:10px; } -input[class='nyan-clean-gray'], .nyan-clean-gray:hover { +input[class='nyan-clean-gray']:hover, .nyan-clean-gray:hover { background-color: #dddddd; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #dddddd), color-stop(100%, #bbbbbb)); background-image: -webkit-linear-gradient(top, #dddddd, #bbbbbb); @@ -123,7 +123,7 @@ input[class='nyan-clean-gray'], .nyan-clean-gray:hover { cursor: pointer; text-shadow: 0 1px 0 #ddd; } -input[class='nyan-clean-gray'], .nyan-clean-gray:active { +input[class='nyan-clean-gray']:active, .nyan-clean-gray:active { border: 1px solid #aaa; border-bottom: 1px solid #888; -webkit-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;