From 46c806900e535773d1ef4c69881106cd6f6c0733 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Sat, 19 Sep 2015 12:32:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=B4=E5=90=A7=E5=88=97=E8=A1=A8=E5=92=8C?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=88=97=E8=A1=A8=20=E6=8C=89=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E7=9A=84=E8=A7=84=E5=88=99=E6=8E=92=E5=BA=8F=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=EF=BC=8C=E5=A6=82=E6=9E=9C=E7=BF=BB=E9=A1=B5?= =?UTF-8?q?=E4=BA=86=EF=BC=8C=E5=8F=88=E5=9B=9E=E5=88=B0=E4=BA=86=E7=BB=BC?= =?UTF-8?q?=E5=90=88=E6=8E=92=E5=BA=8F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/forums_controller.rb | 14 +++++++++++ app/views/forums/_post_banner.html.erb | 33 ++++++++++++++++++++++++++ app/views/forums/index.html.erb | 18 +++++++------- app/views/forums/index.js.erb | 5 +++- app/views/forums/show.html.erb | 2 +- app/views/forums/show.js.erb | 3 ++- app/views/layouts/_footer.html.erb | 2 +- 7 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 app/views/forums/_post_banner.html.erb diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index a0b66480c..82754810c 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -98,12 +98,21 @@ class ForumsController < ApplicationController def index @offset, @limit = api_offset_and_limit({:limit => 10}) if(params[:reorder_complex]) + @type="reorder_complex" + @str=params[:reorder_complex] @forums_all = Forum.reorder("topic_count #{params[:reorder_complex]},updated_at #{params[:reorder_complex]}") elsif(params[:reorder_popu]) + @type="reorder_popu" + @str=params[:reorder_popu] @forums_all = Forum.reorder("topic_count #{params[:reorder_popu]}") elsif(params[:reorder_time]) + @type="reorder_time" + @str=params[:reorder_time] @forums_all = Forum.reorder("updated_at #{params[:reorder_time]}") else + params[:reorder_complex] = "desc" + @type="reorder_complex" + @str=params[:reorder_complex] @forums_all = Forum.reorder("topic_count desc,updated_at desc") end @forums_count = @forums_all.count @@ -127,14 +136,19 @@ class ForumsController < ApplicationController # 'replies' => "#{Memo.table_name}.replies_count", # 'updated_at' => "COALESCE (last_replies_memos.created_at, #{Memo.table_name}.created_at)" order = "" + @order_str = "" if(params[:reorder_complex]) order = " last_replies_memos.created_at #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}" + @order_str = "reorder_complex="+params[:reorder_complex] elsif(params[:reorder_popu]) order = "replies_count #{params[:reorder_popu]}" + @order_str = "reorder_popu="+params[:reorder_popu] elsif(params[:reorder_time]) order = "#{Memo.table_name}.updated_at #{params[:reorder_time]}" + @order_str = "reorder_time="+params[:reorder_time] else order = "last_replies_memos.created_at desc, #{Memo.table_name}.created_at desc" + @order_str = "reorder_complex=desc" end @memo = Memo.new(:forum => @forum) @topic_count = @forum.topics.count diff --git a/app/views/forums/_post_banner.html.erb b/app/views/forums/_post_banner.html.erb new file mode 100644 index 000000000..2ea128e9d --- /dev/null +++ b/app/views/forums/_post_banner.html.erb @@ -0,0 +1,33 @@ + + +