From eda5121195e9d40785cd9761a72dc3277c438a9c Mon Sep 17 00:00:00 2001 From: ganyiang Date: Wed, 14 May 2014 12:03:50 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9Eosp=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=B8=96=E5=AD=90=E7=9A=84=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=EF=BC=88=E5=BE=85=E6=94=B9=E8=BF=9B=EF=BC=89?= =?UTF-8?q?=202.=E4=BF=AE=E6=94=B9osp=E7=A4=BE=E5=8C=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E7=9A=84[=E5=85=A8=E7=90=83=E7=83=AD=E5=B8=96]=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=95=B0=E9=87=8F=EF=BC=8C=E9=BB=98=E8=AE=A425?= =?UTF-8?q?=E6=9D=A1->10=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open_source_projects_controller.rb | 35 ++++++++- .../open_source_projects/_show_memo.html.erb | 77 +++++++++++++++++++ .../_show_topics.html.erb | 11 ++- .../open_source_projects/showmemo.html.erb | 54 +++++++++++++ 4 files changed, 168 insertions(+), 9 deletions(-) create mode 100644 app/views/open_source_projects/_show_memo.html.erb create mode 100644 app/views/open_source_projects/showmemo.html.erb diff --git a/app/controllers/open_source_projects_controller.rb b/app/controllers/open_source_projects_controller.rb index 4feca7b27..52b81610f 100644 --- a/app/controllers/open_source_projects_controller.rb +++ b/app/controllers/open_source_projects_controller.rb @@ -57,7 +57,7 @@ class OpenSourceProjectsController < ApplicationController @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'] + @topic_pages = Paginator.new @topic_count, 10, params['page'] @memos = @open_source_project.topics. reorder("#{RelativeMemo.table_name}.sticky DESC"). includes(:last_reply). @@ -73,11 +73,40 @@ class OpenSourceProjectsController < ApplicationController format.json { render json: @open_source_project } end end - - def search + + +def search 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 diff --git a/app/views/open_source_projects/_show_memo.html.erb b/app/views/open_source_projects/_show_memo.html.erb new file mode 100644 index 000000000..0314bd3dc --- /dev/null +++ b/app/views/open_source_projects/_show_memo.html.erb @@ -0,0 +1,77 @@ + + + +
+ 共有 <%= link_to memos.count %> 个贴子 +
+ <% if memos.any? %> + <% memos.each do |topic| %> + + + + + + +
<%= 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%> + + + + + + + + + + + + + + + + + + + +
<%= link_to h(topic.subject), open_source_project_relative_memo_path(topic.open_source_project, topic) %> + + + + + + + +
<%= link_to (topic.replies_count), open_source_project_relative_memo_path(topic.open_source_project, topic) %>
回帖
+ + + + + + + +
<%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(topic.open_source_project, topic) %>
关注
+ + + + + + + +
<%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(topic.open_source_project, topic) %>
浏览
帖子来源:<%=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 306e0c8e5..8e958101d 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 @@
-

项目安全态势

More >>
+

项目安全态势

<%= link_to "More >>", :controller => "open_source_projects",:action => "showmemo", :id => @open_source_project.id %>
    @@ -211,7 +211,8 @@
-

技术创新趋势

More >>
+

技术创新趋势

<%= link_to "More >>", :controller => "open_source_projects",:action => "showmemo", :id => @open_source_project.id %> +
    @@ -352,7 +353,8 @@
    -

    全球热帖

    更多>> +

    全球热帖

    + <%= link_to "更多>>", :controller => "open_source_projects",:action => "showmemo", :id => @open_source_project.id %>
    <% if memos.any? %> @@ -408,13 +410,10 @@ <%= no_use_link(topic, User.current) %> - - - <% end %>