From f392fc244fc2579a01516314e0bdc315f4794bea Mon Sep 17 00:00:00 2001 From: fanqiang <316257774@qq.com> Date: Mon, 26 May 2014 11:05:02 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=EF=BC=8C=E8=BF=9B=E5=85=A5=E5=B8=96=E5=AD=90=E5=90=8E=E5=BA=94?= =?UTF-8?q?=E8=AF=A5=E8=BF=9B=E5=85=A5=E6=96=B0=E7=9A=84=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=20=E5=8E=BB=E6=8E=89=E9=A1=B9=E7=9B=AE=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E9=83=A8=E5=88=86=E7=9A=84=E5=8F=91=E5=B8=83=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/open_source_projects/_show_topics.html.erb | 2 +- app/views/open_source_projects/show.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/open_source_projects/_show_topics.html.erb b/app/views/open_source_projects/_show_topics.html.erb index 3ba46394..1339227f 100644 --- a/app/views/open_source_projects/_show_topics.html.erb +++ b/app/views/open_source_projects/_show_topics.html.erb @@ -435,7 +435,7 @@ - +
<%= link_to h(topic.subject), topic.url %><%= link_to h(topic.subject), topic.url, :target => '_blank' %> diff --git a/app/views/open_source_projects/show.html.erb b/app/views/open_source_projects/show.html.erb index d1751dec..ec9d521d 100644 --- a/app/views/open_source_projects/show.html.erb +++ b/app/views/open_source_projects/show.html.erb @@ -32,7 +32,7 @@ <% #= link_to '发布帖子', new_forum_memo_path(@forum), :class => 'icon icon-add' %> - <%= link_to l(:label_memo_new_from_forum), new_open_source_project_relative_memo_path(@open_source_project), :class => 'icon icon-add', + <%#= link_to l(:label_memo_new_from_forum), new_open_source_project_relative_memo_path(@open_source_project), :class => 'icon icon-add', :onclick => 'showAndScrollTo("add-memo", "memo_subject"); return false;' if User.current.logged? %> From 401f09707907f2e36a3c048d6bdb665b216901bd Mon Sep 17 00:00:00 2001 From: fanqiang <316257774@qq.com> Date: Mon, 26 May 2014 11:18:57 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=B8=96=E5=AD=90=E7=9A=84?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E8=80=85=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/open_source_projects/_show_topics.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/open_source_projects/_show_topics.html.erb b/app/views/open_source_projects/_show_topics.html.erb index 1339227f..75feb1d4 100644 --- a/app/views/open_source_projects/_show_topics.html.erb +++ b/app/views/open_source_projects/_show_topics.html.erb @@ -469,11 +469,11 @@ - + From 4b1d7e049d99a5ce45dc170efc6f4885a88de271 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 26 May 2014 14:27:47 +0800 Subject: [PATCH 3/8] 233 --- config/routes.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index dbbc544a..59ed6c39 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -661,5 +661,4 @@ RedmineApp::Application.routes.draw do end end end - get ':controller(/:action(/:id))' end From 6dba5aaae64ab6cf09ee09d7a4c6c702624c52a4 Mon Sep 17 00:00:00 2001 From: fanqiang <316257774@qq.com> Date: Tue, 27 May 2014 08:16:35 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E4=B8=AD=20=20=E5=9B=9E=E5=A4=8D=EF=BC=8C=E5=85=B3=E6=B3=A8?= =?UTF-8?q?=EF=BC=8C=E6=B5=8F=E8=A7=88=E7=9A=84=E9=93=BE=E6=8E=A5=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/open_source_projects/_show_memo.html.erb | 6 +++--- app/views/open_source_projects/_show_topics.html.erb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/open_source_projects/_show_memo.html.erb b/app/views/open_source_projects/_show_memo.html.erb index 63de4213..05a1fc6c 100644 --- a/app/views/open_source_projects/_show_memo.html.erb +++ b/app/views/open_source_projects/_show_memo.html.erb @@ -23,7 +23,7 @@
帖子来源:<%=link_to 'OSChina', topic.url %> - + @@ -33,7 +33,7 @@ - + - - - +
<%= link_to (topic.replies_count), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.replies_count), topic.url, :target => '_blank' %>
回帖 - + @@ -43,7 +43,7 @@ - + - - - + diff --git a/app/views/open_source_projects/_show_topics.html.erb b/app/views/open_source_projects/_show_topics.html.erb index 1a004133..dacc9b01 100644 --- a/app/views/open_source_projects/_show_topics.html.erb +++ b/app/views/open_source_projects/_show_topics.html.erb @@ -467,17 +467,17 @@
<%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
关注 - + diff --git a/app/views/open_source_projects/_show_topics.html.erb b/app/views/open_source_projects/_show_topics.html.erb index 75feb1d4..ebfe9cd1 100644 --- a/app/views/open_source_projects/_show_topics.html.erb +++ b/app/views/open_source_projects/_show_topics.html.erb @@ -439,7 +439,7 @@ diff --git a/app/views/open_source_projects/_show_memo.html.erb b/app/views/open_source_projects/_show_memo.html.erb index 05a1fc6c..5fa9cb9d 100644 --- a/app/views/open_source_projects/_show_memo.html.erb +++ b/app/views/open_source_projects/_show_memo.html.erb @@ -51,17 +51,17 @@
<%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
浏览 - + @@ -449,7 +449,7 @@ - + - - - + - -
<%= link_to (topic.replies_count), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.replies_count), topic.url, :target => '_blank' %>
回帖 - + @@ -459,7 +459,7 @@
<%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
关注 - + From 98444ef01e0e879dee287f018fe9f04125f19915 Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 27 May 2014 08:32:43 +0800 Subject: [PATCH 5/8] remove fuzzy routes|add school missing row --- config/routes.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 59ed6c39..2c786521 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -623,6 +623,10 @@ RedmineApp::Application.routes.draw do ######################## ##added by wen########## #######confusing######## + get 'welcome/search', to: 'welcome#search' + get 'school/index', to: 'school#index' + get 'course/:school_id', to: 'welcome#course' + get 'course/:school_id', to: 'welcome#course' post 'school/get_options/:province', :to => 'school#get_options' get 'school/get_options/:province', :to => 'school#get_options' From a9b88b8e664ef243db8f7077f640bf4588e06723 Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 27 May 2014 08:51:03 +0800 Subject: [PATCH 6/8] issues#show words typo --- app/helpers/issues_helper.rb | 9 ++++----- app/models/issue.rb | 6 +++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 23351d91..5e7f7c18 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -59,12 +59,11 @@ module IssuesHelper def issue_heading(issue) #h("#{issue.tracker} ##{issue.id}") - #h("#{issue.tracker} #{issue.source_from}") + # h("#{issue.tracker} #{issue.source_from}") s = '' - s << ">>" - s << link_to(@issue.project.name+l(:issue_list), project_issues_path(@issue.project)) - s << " >" - s << @issue.source_from + s << link_to(@issue.project.name, project_issues_path(@issue.project)) + s << " > #" + s << @issue.project_index s.html_safe end diff --git a/app/models/issue.rb b/app/models/issue.rb index d2332350..7e899eaf 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1156,7 +1156,11 @@ class Issue < ActiveRecord::Base # back string obj which is belong to project. def source_from "" << self.project.name.to_s << - "#" << (self.project.issues.index(self).to_i + 1).to_s + "#" << project_index + end + + def project_index + (self.project.issues.index(self).to_i + 1).to_s end private From fdf8b5640a6f9deae30e916b0e9e2d9a249bafcf Mon Sep 17 00:00:00 2001 From: fanqiang <316257774@qq.com> Date: Tue, 27 May 2014 09:01:36 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=BE=E7=A4=BAbug?= =?UTF-8?q?=E7=9A=84=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open_source_projects_controller.rb | 105 +++++++++++------- .../open_source_projects/_show_bug.html.erb | 82 ++++++++++++++ .../_show_topics.html.erb | 2 +- .../open_source_projects/showbug.html.erb | 55 +++++++++ config/routes.rb | 31 +++--- 5 files changed, 218 insertions(+), 57 deletions(-) create mode 100644 app/views/open_source_projects/_show_bug.html.erb create mode 100644 app/views/open_source_projects/showbug.html.erb diff --git a/app/controllers/open_source_projects_controller.rb b/app/controllers/open_source_projects_controller.rb index 1ca7ddce..7b933364 100644 --- a/app/controllers/open_source_projects_controller.rb +++ b/app/controllers/open_source_projects_controller.rb @@ -1,8 +1,8 @@ class OpenSourceProjectsController < ApplicationController - + before_filter :find_osp, :only => [:master_apply, :accept_master_apply, :refuse_master_apply] before_filter :require_master, :only => [:master_apply, :accept_master_apply, :refuse_master_apply] - + helper :sort include SortHelper helper :apply_project_masters @@ -22,7 +22,7 @@ class OpenSourceProjectsController < ApplicationController @os_project_count = @open_source_projects.count @os_project_pages = Paginator.new @os_project_count, per_page_option, params['page'] - + @open_source_projects = @open_source_projects.offset(@os_project_pages.offset).limit(@os_project_pages.per_page) # @open_source_projects = OpenSourceProject.all @@ -32,11 +32,11 @@ class OpenSourceProjectsController < ApplicationController format.json { render json: @open_source_projects } end end - + def master_apply @apply = @open_source_project.apply_tips @applicants = @open_source_project.applicants - + respond_to do |format| format.html { render :layout => "base_opensource_p" @@ -49,7 +49,7 @@ class OpenSourceProjectsController < ApplicationController # GET /open_source_projects/1.json def show @open_source_project = OpenSourceProject.find(params[:id]) - + sort_init 'updated_at', 'desc' sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at", 'replies' => "#{RelativeMemo.table_name}.replies_count", @@ -63,9 +63,9 @@ class OpenSourceProjectsController < ApplicationController includes(:last_reply). limit(@topic_pages.per_page). offset(@topic_pages.offset). - order(sort_clause). + order(sort_clause). all - + @bugs = @open_source_project.bugs.limit(6) respond_to do |format| @@ -76,25 +76,22 @@ class OpenSourceProjectsController < ApplicationController end end + def search -def search - end + def showbug + @open_source_project = OpenSourceProject.find(params[:id]) -# added by yiang 暴力添加,请绕道 -def showmemo - @open_source_project = OpenSourceProject.find(params[:id]) - - sort_init 'updated_at', 'desc' - sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at", + sort_init 'updated_at', 'desc' + sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at", 'replies' => "#{RelativeMemo.table_name}.replies_count", 'updated_at' => "COALESCE (last_replies_relative_memos.created_at, #{RelativeMemo.table_name}.created_at)" - @memo = RelativeMemo.new(:open_source_project => @open_source_project) - @topic_count = @open_source_project.topics.count - @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] - @memos = @open_source_project.topics. + @memo = RelativeMemo.new(:open_source_project => @open_source_project) + @topic_count = @open_source_project.bugs.count + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + @memos = @open_source_project.bugs. reorder("#{RelativeMemo.table_name}.sticky DESC"). includes(:last_reply). limit(@topic_pages.per_page). @@ -102,13 +99,42 @@ def showmemo order(sort_clause). all - respond_to do |format| - format.html { - render :layout => "base_opensource_p" - } - format.json { render json: @open_source_project } + respond_to do |format| + format.html { + render :layout => "base_opensource_p" + } + format.json { render json: @open_source_project } + end end -end + + # added by yiang 暴力添加,请绕道 + def showmemo + @open_source_project = OpenSourceProject.find(params[:id]) + + sort_init 'updated_at', 'desc' + sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at", + 'replies' => "#{RelativeMemo.table_name}.replies_count", + 'updated_at' => "COALESCE (last_replies_relative_memos.created_at, #{RelativeMemo.table_name}.created_at)" + + @memo = RelativeMemo.new(:open_source_project => @open_source_project) + @topic_count = @open_source_project.topics.count + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + @memos = @open_source_project.topics. + reorder("#{RelativeMemo.table_name}.sticky DESC"). + includes(:last_reply). + limit(@topic_pages.per_page). + offset(@topic_pages.offset). + order(sort_clause). + all + + respond_to do |format| + format.html { + render :layout => "base_opensource_p" + } + format.json { render json: @open_source_project } + end + end + # GET /open_source_projects/new # GET /open_source_projects/new.json def new @@ -168,52 +194,51 @@ end format.json { head :no_content } end end - + def remove_condition @app_dir = params[:app_dir] @language = params[:language] @created_at = params[:created_at] redirect_to open_source_projects_path(:app_dir => @app_dir, :language => @language, :created_at => @created_at, :name => params[:name]) end - + def search # per_page_option = 10 -# + # # @open_source_projects = OpenSourceProject.filter(@app_dir, @language, @created_at) # @open_source_projects = @open_source_projects.like(params[:name]) if params[:name].present? -# + # # @os_project_count = @open_source_projects.count # @os_project_pages = Paginator.new @os_project_count, per_page_option, params['page'] -# + # # @open_source_projects = @open_source_projects.offset(@os_project_pages.offset).limit(@os_project_pages.per_page) redirect_to open_source_projects_path(:name => params[:name]) end - + def refuse_master_apply @apply = ApplyProjectMaster.where("user_id = ? and apply_id = ? and apply_type = 'OpenSourceProject'", params[:user_id], @open_source_project.id) @apply.first.destory - + redirect_to master_apply_open_source_project_path end - + def accept_master_apply @apply = ApplyProjectMaster.where("user_id = ? and apply_id = ? and apply_type = 'OpenSourceProject'", params[:user_id], @open_source_project.id) if @apply.count == 1 - @apply.first.update_attributes(:status => 2) + @apply.first.update_attributes(:status => 2) end - + redirect_to master_apply_open_source_project_path end - - + private - + def require_master render_403 unless @open_source_project.admin?(User.current) end - + def find_osp @open_source_project = OpenSourceProject.find(params[:id]) render_404 unless @open_source_project.present? diff --git a/app/views/open_source_projects/_show_bug.html.erb b/app/views/open_source_projects/_show_bug.html.erb new file mode 100644 index 00000000..05a1fc6c --- /dev/null +++ b/app/views/open_source_projects/_show_bug.html.erb @@ -0,0 +1,82 @@ + + + +
+ 共有 <%= link_to memos.count %> 个贴子 +
+ <% if memos.any? %> + <% memos.each do |topic| %> +
<%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
浏览
+ + + + + +
<%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) if topic.author%> + <%= image_tag('../images/avatars/User/0', :class => "avatar") unless topic.author%> + + + + + + + + + + + + + + + + + + + + + +
+ <% if topic.url.nil? || topic.url == '' %> + <%= link_to h(topic.subject), open_source_project_relative_memo_path(open_source_project, topic) %> + <% else %> + <%= link_to h(topic.subject), topic.url %> + <% end %> + + + + + + + +
<%= link_to (topic.replies_count), topic.url, :target => '_blank' %>
回帖
+ + + + + + + +
<%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
关注
+ + + + + + + +
<%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
浏览
<%= user_url_and_time topic.username, topic.userhomeurl, topic.created_at %> +
+
帖子来源:<%=link_to 'OSChina', topic.url %> + <%= no_use_link(topic, User.current) %>
+ + <% end %> + + <% else %> +

+ <%= l(:label_no_data) %> +

+ <% end %> + \ No newline at end of file diff --git a/app/views/open_source_projects/_show_topics.html.erb b/app/views/open_source_projects/_show_topics.html.erb index ebfe9cd1..1a004133 100644 --- a/app/views/open_source_projects/_show_topics.html.erb +++ b/app/views/open_source_projects/_show_topics.html.erb @@ -20,7 +20,7 @@
-

项目安全态势

<%= link_to "更多 >>", :controller => "open_source_projects",:action => "showmemo", :id => @open_source_project.id %>
+

项目安全态势

<%= link_to "更多 >>", :controller => "open_source_projects",:action => "showbug", :id => @open_source_project.id %>
    diff --git a/app/views/open_source_projects/showbug.html.erb b/app/views/open_source_projects/showbug.html.erb new file mode 100644 index 00000000..86e8a226 --- /dev/null +++ b/app/views/open_source_projects/showbug.html.erb @@ -0,0 +1,55 @@ + + + +<% #= link_to '发布帖子', new_forum_memo_path(@forum), :class => 'icon icon-add' %> + + <%= link_to l(:label_memo_new_from_forum), new_open_source_project_relative_memo_path(@open_source_project), :class => 'icon icon-add', + :onclick => 'showAndScrollTo("add-memo", "memo_subject"); return false;' if User.current.logged? %> + + +
    + <%#= link_to( + image_tag('edit.png')+l(:label_forum_edit), + {:action => 'edit', :id => @forum}, + :method => 'get', + :title => l(:button_edit) + ) if @forum.editable_by?(User.current) %> + <%#= link_to( + image_tag('delete.png')+'删除讨论区', + {:action => 'destroy', :id => @forum}, + :method => :delete, + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if @forum.destroyable_by?(User.current) %> +
    +<%= render :partial => 'open_source_projects/show_bug', :locals => {:memos => @memos, :open_source_project => @open_source_project} %> +
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2c786521..16132cb6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,11 +18,10 @@ RedmineApp::Application.routes.draw do resources :homework_users - resources :no_uses delete 'no_uses', :to => 'no_uses#delete' - resources :apply_project_masters + resources :apply_project_masters delete 'apply_project_masters', :to => 'apply_project_masters#delete' resources :homework_attach do @@ -42,11 +41,12 @@ RedmineApp::Application.routes.draw do match 'master_apply', via: [:get, :post] match 'accept_master_apply', via: [:get, :post] match 'refuse_master_apply', via: [:get, :post] + match 'showmemo', via: [:get, :post] + match 'showbug', via: [:get, :post] end end mount SeemsRateable::Engine => '/rateable', :as => :rateable - namespace :zipdown do match 'assort' end @@ -56,11 +56,11 @@ RedmineApp::Application.routes.draw do end ##new added by linchun #以发布应用的形式参与竞赛 resources :softapplications do - + collection do match 'new_message', via: :get end - member do + member do match 'create_message' , via: :post end end @@ -89,9 +89,9 @@ RedmineApp::Application.routes.draw do match 'add_softapplication' , via: [:get, :post] match 'create' , via: :post match 'settings' , via: [:get, :post] - end - end - + end + end + resources :stores do collection do match 'search', via: [:get, :post] @@ -321,7 +321,7 @@ RedmineApp::Application.routes.draw do resources :files, :only => [:index, :new, :create] do collection do match "getattachtype" , via: [:get, :post] - #match 'getattachtype/:attachtype', :to => 'files#getattachtype', via: [:get, :post] + #match 'getattachtype/:attachtype', :to => 'files#getattachtype', via: [:get, :post] end end @@ -480,8 +480,8 @@ RedmineApp::Application.routes.draw do collection do match "updateType" , via: [:get, :post] match "renderTag" , via: [:get, :post] - end - end + end + end resources :groups do member do @@ -619,7 +619,6 @@ RedmineApp::Application.routes.draw do match 'calls/:id', :controller => 'bids', :action => 'show', :as => 'respond' match 'contest', :controller => 'bids', :action => 'contests', :as => 'contest' #modified @20140403 - ######################## ##added by wen########## #######confusing######## @@ -632,15 +631,15 @@ RedmineApp::Application.routes.draw do post 'school/get_province', :to => 'school#get_province' get 'school/get_province', :to => 'school#get_province' - + post 'school/get_schoollist/:province', :to => 'school#get_schoollist' get 'school/get_schoollist/:province', :to => 'school#get_schoollist' - + post 'school/search_school/', :to => 'school#search_school' get 'school/search_school/', :to => 'school#search_school' - + post 'school/upload', :to => 'school#upload' - + ######added by nie match 'tags/show_projects_tags',:to => 'tags#show_projects_tags' ########### added by liuping From 4c3e2376f0fba97865e8151a0e453a434a10b262 Mon Sep 17 00:00:00 2001 From: fanqiang <316257774@qq.com> Date: Tue, 27 May 2014 16:25:43 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/relative_memo.rb | 5 +++++ app/views/open_source_projects/_show_bug.html.erb | 10 ++++------ app/views/open_source_projects/_show_memo.html.erb | 8 ++++---- app/views/open_source_projects/_show_topics.html.erb | 8 ++++---- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/models/relative_memo.rb b/app/models/relative_memo.rb index 073d1ca1..f087fce2 100644 --- a/app/models/relative_memo.rb +++ b/app/models/relative_memo.rb @@ -70,6 +70,11 @@ class RelativeMemo < ActiveRecord::Base def cannot_reply_to_locked_topic errors.add :base, l(:label_memo_locked) if root.locked? && self != root end + + def short_content(length = 25) + str = "^(.{,#{length}})[^\n\r]*.*$" + content.gsub(Regexp.new(str), '\1...').strip if content + end # def update_memos_forum # if forum_id_changed? diff --git a/app/views/open_source_projects/_show_bug.html.erb b/app/views/open_source_projects/_show_bug.html.erb index 05a1fc6c..7407c115 100644 --- a/app/views/open_source_projects/_show_bug.html.erb +++ b/app/views/open_source_projects/_show_bug.html.erb @@ -51,20 +51,18 @@
<%= topic.short_content(70) %>
<%= user_url_and_time topic.username, topic.userhomeurl, topic.created_at %> + <%= user_url_and_time topic.username, topic.userhomeurl, topic.created_at %>
帖子来源:<%=link_to 'OSChina', topic.url %> + 帖子来源:<%=link_to 'OSChina', topic.url %> <%= no_use_link(topic, User.current) %> <%= no_use_link(topic, User.current) %>
<%= user_url_and_time topic.username, topic.userhomeurl, topic.created_at %> + <%= user_url_and_time topic.username, topic.userhomeurl, topic.created_at %>
帖子来源:<%=link_to 'OSChina', topic.url %> + 帖子来源:<%=link_to 'OSChina', topic.url %> <%= no_use_link(topic, User.current) %> <%= no_use_link(topic, User.current) %>
<%=user_url_and_time topic.username, topic.userhomeurl, topic.created_at %> + <%=user_url_and_time topic.username, topic.userhomeurl, topic.created_at %>
帖子来源:<%=link_to 'OSChina', topic.url %> + 帖子来源:<%=link_to 'OSChina', topic.url %> <%= no_use_link(topic, User.current) %> <%= no_use_link(topic, User.current) %>