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 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%> | +
+
|
+
+ <%= l(:label_no_data) %> +
+ <% end %> +