From 9ae140204f62bae987fddd1fb3eb393e1880bd89 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 1 Mar 2012 10:58:31 +0800 Subject: [PATCH] Fix announcement pagination in front-end --- app/controllers/pages_controller.rb | 6 +++++- lib/parsers/parser_back_end.rb | 2 +- lib/parsers/parser_front_end.rb | 2 +- .../panel/announcement/front_end/bulletins_controller.rb | 6 +++--- .../panel/announcement/front_end/bulletins/index.html.erb | 4 ++-- vendor/built_in_modules/announcement/config/routes.rb | 1 - 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index aa66238d..8ea35391 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -30,7 +30,11 @@ class PagesController < ApplicationController end def index_from_link - redirect_to "/#{@item.full_name}" + if params[:page] + redirect_to "/#{@item.full_name}?page=#{params[:page]}" + else + redirect_to "/#{@item.full_name}" + end end def show_from_link diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index dea65b6a..37c22ed1 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -100,7 +100,7 @@ module ParserBackEnd ret = '' if (tag.attributes["main"] == "true" && !page.module_app.nil?) ret << "
" else part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 305596ed..17468e54 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -127,7 +127,7 @@ module ParserFrontEnd ret << "
" else part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index b71a4609..e840d65f 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -11,15 +11,15 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController def index date_now = Time.now - if params[:bulletin_category_id] - @bulletins = Bulletin.where(:bulletin_category_id => params[:bulletin_category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) + if params[:category_id] + @bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) else @bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) end get_categorys - @current_category = BulletinCategory.from_id(params[:bulletin_category_id]) rescue nil + @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil end def show diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb index d4335e9a..086794b9 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb @@ -28,6 +28,6 @@ <% end %> - -<%= paginate @bulletins %> + +<%= paginate @bulletins, :params => {:inner => 'false'} %> diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index c3a60f74..a604da85 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -10,7 +10,6 @@ Rails.application.routes.draw do resources :tags end namespace :front_end do - root :to => "bulletins#index" resources :bulletins end namespace :widget do