diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 62bef8fb1..2d5149c09 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -361,7 +361,7 @@ private def login_without_softapplication referer = request.headers['Referer'] - require_login unless referer =~ /softapplication/ || referer =~ /memos/ + require_login unless referer =~ /softapplication/ || @attachment.container_type == "Memo" end def renderTag diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index b099a1db5..1b7791ac4 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -54,39 +54,29 @@ class ContestsController < ApplicationController case params[:contest_sort_type] when '0' # modified by longjun - # never use unless and else + # never use unless and else, 将下面重复操作模块化,放在private下 # unless @offset == 0 - if @offset != 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse - else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse - end + # if @offset != 0 + # @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse + # else + # limit = @contest_count % @limit + # limit = @limit if limit == 0 + # @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse + + @contests = index_page_sort(@offset, @limit, @contest_count, @contests, 'contests.commit') + # end @s_state = 0 when '1' - # modified by longjun - # never use unless and else - # unless @offset == 0 - if @offset != 0 - @contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse - else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse - end + + @contests = index_page_sort(@offset, @limit, @contest_count, @contests, 'contests.created_on') @s_state = 1 - when '2' - # modified by longjun - # never use unless and else - # unless @offset == 0 - if @offset != 0 - @contests = @contests.offset(@offset).limit(@limit).all.reverse + # modified by longjun + # 目前只有 0, 1 两个sort_type + # when '2' else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.offset(@offset).limit(@limit).all.reverse - end + # end longjun + + @contests = index_page_sort(@offset, @limit, @contest_count, @contests, '') @s_state = 0 end else @@ -723,5 +713,20 @@ class ContestsController < ApplicationController end end + # added by longjun + # 将index页面中分页排序的方法抽离出来 + def index_page_sort(offset, limit, contest_count, contests, contest_sort_by) + # modified by longjun + # never use unless and else + # unless @offset == 0 + if offset != 0 + contests = contests.reorder(contest_sort_by).offset(offset).limit(limit).all.reverse + else + limit = contest_count % limit + limit = limit if limit == 0 + contests = contests.reorder(contest_sort_by).offset(offset).limit(limit).all.reverse + end + contests + end end diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 1e537ff75..aad575ee5 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -62,7 +62,7 @@ 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]}" + flash.now[: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) pre_count = REPLIES_PER_PAGE diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 38b97a501..f976918d8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -122,12 +122,24 @@ module ApplicationHelper s end + # Generates a link to an attachment. + # Options: + # * :text - Link text (default to attachment filename) + # * :download - Force download (default: false) + def link_to_short_attachment(attachment, options={}) + text = h(truncate(options.delete(:text) || attachment.filename, length: 25, omission: '...')) + route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path + html_options = options.slice!(:only_path) + url = send(route_method, attachment, attachment.filename, options) + link_to text, url, html_options + end + # Generates a link to an attachment. # Options: # * :text - Link text (default to attachment filename) # * :download - Force download (default: false) def link_to_attachment(attachment, options={}) - text = h(truncate(options.delete(:text) || attachment.filename, length: 60, omission: '...')) + text = options.delete(:text) || attachment.filename route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path html_options = options.slice!(:only_path) url = send(route_method, attachment, attachment.filename, options) diff --git a/app/views/attachments/_app_link.html.erb b/app/views/attachments/_app_link.html.erb index 6934b76e1..263f51dc8 100644 --- a/app/views/attachments/_app_link.html.erb +++ b/app/views/attachments/_app_link.html.erb @@ -3,13 +3,15 @@ <% if attachments.count > 1 && attachment != attachments.first%>
                 <% end %> - <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> + <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true -%> <% if attachment.is_text? %> <%= link_to image_tag('magnifier.png'), :controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename %> <% end %> - <%= h(" - #{attachment.description}") unless attachment.description.blank? %> + + <%= h(truncate(" - #{attachment.description}", length: 20, omission: '...')) unless attachment.description.blank? %> + (<%= number_to_human_size attachment.filesize %>) <% end -%> diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 4c4065d09..de43dce4c 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -2,7 +2,7 @@ <% for attachment in attachments %>

- <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> + <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true -%> <% if attachment.is_text? %> <%= link_to image_tag('magnifier.png'), @@ -11,7 +11,9 @@ :id => attachment, :filename => attachment.filename%> <% end %> - <%= h(" - #{attachment.description}") unless attachment.description.blank? %> + + <%= h(truncate(" - #{attachment.description}", length: 20, omission: '...')) unless attachment.description.blank? %> + (<%= number_to_human_size attachment.filesize %>) <% if options[:deletable] %> <% if attachment.container_type == 'HomeworkAttach' %> diff --git a/app/views/contest_notification/show.html.erb b/app/views/contest_notification/show.html.erb index 5664d5398..c4dfc737b 100644 --- a/app/views/contest_notification/show.html.erb +++ b/app/views/contest_notification/show.html.erb @@ -14,7 +14,7 @@ <%=link_to l(:field_homepage), home_path %> > - <%=link_to l(:label_contest_innovate), welcome_contest_path %> > 详情 + <%=link_to l(:label_contest_innovate), welcome_contest_path %> > l(:label_details) diff --git a/app/views/contests/_contest_list.html.erb b/app/views/contests/_contest_list.html.erb index 967d31459..26035aa29 100644 --- a/app/views/contests/_contest_list.html.erb +++ b/app/views/contests/_contest_list.html.erb @@ -41,20 +41,20 @@ + diff --git a/app/views/contests/_form_contest.html.erb b/app/views/contests/_form_contest.html.erb index 68e941a27..513419668 100644 --- a/app/views/contests/_form_contest.html.erb +++ b/app/views/contests/_form_contest.html.erb @@ -62,7 +62,7 @@

- +

<%= f.text_field :deadline, :required => true, diff --git a/app/views/contests/_list_projects.html.erb b/app/views/contests/_list_projects.html.erb index fec4cf24c..2ffecff12 100644 --- a/app/views/contests/_list_projects.html.erb +++ b/app/views/contests/_list_projects.html.erb @@ -78,7 +78,9 @@ <%= l(:label_contest_user) %> <% unless c_project.user.nil? %> - <%= link_to c_project.user.lastname + c_project.user.firstname,user_path(c_project.user) %> + <%= link_to c_project.user.lastname + c_project.user.firstname, + user_path(c_project.user) + %> <% end %> @@ -101,5 +103,7 @@ <% end %> <% end %> -

+ diff --git a/app/views/contests/_new_softapplication.html.erb b/app/views/contests/_new_softapplication.html.erb index 71e5d0568..7bb8c76a8 100644 --- a/app/views/contests/_new_softapplication.html.erb +++ b/app/views/contests/_new_softapplication.html.erb @@ -1,6 +1,6 @@ <%#= error_messages_for 'softapplication' %> -
- <%= f.submit :value => l(:button_change) %> + <%= f.submit :value => l(:button_change) %>  <%= link_to l(:button_back), back_url ,:class => "button-canel",:style => "color: #ffffff;"%> <% end %> -<%= link_to l(:button_back), back_url %> diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 577c3ff7f..5da3c5d63 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -43,11 +43,14 @@ :data => {:confirm => l(:text_are_you_sure)}, :title => l(:button_delete) ) if @memo.destroyable_by?(User.current) %> - - -
<%= label_tag l(:field_subject) %>: <%=h @memo.subject %>
+
 
+ +
+ <%= label_tag l(:field_subject) %>: <%=h @memo.subject %> +
<%= textAreailizable(@memo,:content) %>

diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb index 8dafdf173..0856da976 100644 --- a/app/views/messages/_form.html.erb +++ b/app/views/messages/_form.html.erb @@ -3,44 +3,44 @@ <% replying ||= false %>

- - <% unless replying %> -

- <%= f.text_field :subject, :size => 60, :style => "width: 99%;display:none;", :id => "message_subject" %> -

- <% else %> -

- <%= f.text_field :subject, :size => 60, :style => "width: 99%;display:none;", :id => "message_subject", :readonly => true %> -

- <% end %> -

- <% unless replying %> - <% if @message.safe_attribute? 'sticky' %> + + <% unless replying %> +


+ <%= f.text_field :subject, :size => 60, :style => "width: 99%;", :id => "message_subject" %> +

+ <% else %> +


+ <%= f.text_field :subject, :size => 60, :style => "width: 99%;", :id => "message_subject", :readonly => true %> +

+ <% end %> +

+ <% unless replying %> + <% if @message.safe_attribute? 'sticky' %> <%= f.check_box :sticky %> <%= label_tag 'message_sticky', l(:label_board_sticky) %> - <% end %> - <% if @message.safe_attribute? 'locked' %> + <% end %> + <% if @message.safe_attribute? 'locked' %> <%= f.check_box :locked %> <%= label_tag 'message_locked', l(:label_board_locked) %> - <% end %> + <% end %> <% end %> -

-

-

+

+ -

- <%= text_area :quote,:quote,:style => 'display:none' %> -

-

- <%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %> - <%= f.text_area :content, :cols => 80, :rows => 13, :class => 'wiki-edit', :id => 'message_content' %> -

+
+ <%= text_area :quote,:quote,:style => 'display:none' %> +

+

+ <%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %> + <%= f.text_area :content, :cols => 80, :rows => 13, :class => 'wiki-edit', :id => 'message_content' %> +

- + -

- <%= l(:label_attachment_plural) %> -
- <%= render :partial => 'attachments/form_course', :locals => {:container => @message,:isReply => @isReply} %> -

+

+ <%= l(:label_attachment_plural) %> +
+ <%= render :partial => 'attachments/form_course', :locals => {:container => @message,:isReply => @isReply} %> +

diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index b6fcdf8c9..8165cfb0a 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -157,7 +157,7 @@ <% if User.current.logged? %> <% unless User.current.user_extensions.identity == 1 %> - <%= link_to(l(:label_newtype_contest), {:controller => 'bids', :action => 'new_contest'}, :class => 'icon icon-add') %> + <%= link_to(l(:label_newtype_contest), new_contest_contests_path, :class => 'icon icon-add') %> <% end %> <% end %>    diff --git a/config/locales/zh.yml b/config/locales/zh.yml index f71241223..27589e5f1 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -173,6 +173,7 @@ zh: notice_successful_delete: 删除成功 notice_failed_delete: 删除失败 notice_successful_connection: 连接成功 + notice_successful_join: 加入成功 notice_file_not_found: 您访问的页面不存在或已被删除。 notice_locking_conflict: 数据已被另一位用户更新 notice_not_authorized: 对不起,您无权访问此页面。 @@ -1936,7 +1937,7 @@ zh: label_forum_edit: 编辑讨论区 label_memo_create: 发布 label_memo_new: 新建主题 - label_memo_edit: 修改主题label_board_new + label_memo_edit: 修改主题 label_memo_new_from_forum: 发布帖子 label_forum: 公共贴吧 label_forum_new: 新建贴吧 @@ -2000,9 +2001,12 @@ zh: label_work_deposit_project: 托管项目 label_softapplication_name_condition: 25个汉字以内(50个字符) label_softapplication_description_condition: 125个汉字以内 + label_softapplication_developers_condition: 开发人员超过125个汉字 + label_no_softapplication_developers: 开发人员不能为空 label_user_login_softapplication_board: 您还没有登录,请登录后参与应用评价。 label_contest_description_no: 暂无描述。 label_no_contest_softapplication: 暂无参赛应用 + label_field_correct: 填写正确 label_button_ok: 确定 label_tags_contest: 竞赛标签 label_tags_contest: 竞赛名称 @@ -2124,4 +2128,4 @@ zh: lable_hot_course: 活跃课程 lable_hot_projects: 热门项目 lable_user_active: 用户动态 - lable_bar_active: 贴吧动态 \ No newline at end of file + lable_bar_active: 贴吧动态 diff --git a/config/routes.rb b/config/routes.rb index be65d0eb4..c4584ea7b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -657,7 +657,7 @@ RedmineApp::Application.routes.draw do match 'delete_avatar', :to => 'avatar#delete_image',:via => :post # Endof Tao's code get 'robots.txt', :to => 'welcome#robots' - + match 'welcome/course', :to => 'welcome#course' ##############测试留言功能 fq post 'words/new', :to => 'words#new' post 'words/create', :to => 'words#create' @@ -724,7 +724,7 @@ RedmineApp::Application.routes.draw do # added by young match 'calls', :to => 'bids#index' - match 'calls/:id', :to => 'bid#show', :as => 'respond' + match 'calls/:id', :to => 'bids#show', :as => 'respond' # modified by longjun # bids#contests is not exist # match 'contest', :to => 'bids#contests', :as => 'contest' #modified @20140403 diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 72b379585..1fda63f93 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2794,3 +2794,19 @@ div.repos_explain{ padding-top: 20px; padding-bottom: 20px; } + +.button-canel{ + padding-bottom: 5px; + width: auto; + height: 25px; + font-family: '微软雅黑',Arial,Helvetica,sans-serif; + font-size: 12px; + color: #ffffff; + padding: 3px 9px; + background: #15bccf; + border-radius: 4px; + border: 1px solid #15bccf; + box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.2), 0px 0px 2px rgb(255, 255, 255) inset; + text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2), 0px 1px 0px rgb(255, 255, 255); + cursor: pointer; +}