From f14fcf5d780d99ea72fc31c62e118f553ce7a38e Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 16 Jan 2008 16:31:57 +0000 Subject: [PATCH] per page helper method git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@95 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7 --- app/controllers/application.rb | 10 +++++++++- app/controllers/beers_controller.rb | 2 +- app/controllers/breweries_controller.rb | 2 +- app/controllers/discussions_controller.rb | 4 ++-- app/controllers/pages_controller.rb | 2 +- app/controllers/peoples_controller.rb | 4 ++-- app/controllers/roles_controller.rb | 3 ++- 7 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 854ac72..0ef97e2 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base append_before_filter :authorized? append_before_filter :set_current_people_id - helper_method :logged_in?, :has_permission_for_action? + helper_method :logged_in?, :has_permission_for_action?, :per_page cattr_accessor :current_people_id @@ -73,6 +73,14 @@ class ApplicationController < ActionController::Base @page.allow_discussions = true end + ## + # This will eventually figure out what the People has configured for a per + # page limit of objects. + # + def per_page + 50 + end + protected ## diff --git a/app/controllers/beers_controller.rb b/app/controllers/beers_controller.rb index 9b1e66b..bc67e3b 100644 --- a/app/controllers/beers_controller.rb +++ b/app/controllers/beers_controller.rb @@ -7,7 +7,7 @@ class BeersController < ApplicationController def index @content_title = 'The Beers' @secondary_title = 'Browsing all beers' - @pages, @beers = paginate :beers, :include => 'page', :per_page => 50, + @pages, @beers = paginate :beers, :include => 'page', :per_page => per_page, :order => 'beers.title ASC' @tags = Page.tags(:limit => 25, :order => "name DESC", :owner_type => 'Beer') diff --git a/app/controllers/breweries_controller.rb b/app/controllers/breweries_controller.rb index 49a15f0..eb1e524 100644 --- a/app/controllers/breweries_controller.rb +++ b/app/controllers/breweries_controller.rb @@ -8,7 +8,7 @@ class BreweriesController < ApplicationController @content_title = 'The Breweries' @secondary_title = 'Browsing all breweries' @pages, @breweries = paginate :breweries, :include => 'page', - :order => 'breweries.title ASC', :per_page => 50 + :order => 'breweries.title ASC', :per_page => per_page @tags = Page.tags(:limit => 25, :order => "name DESC", :owner_type => 'Beer') diff --git a/app/controllers/discussions_controller.rb b/app/controllers/discussions_controller.rb index 66606f6..c18933c 100644 --- a/app/controllers/discussions_controller.rb +++ b/app/controllers/discussions_controller.rb @@ -8,7 +8,7 @@ class DiscussionsController < ApplicationController @content_title = 'Discussion Topics' @secondary_title = 'All discussion topics' @pages, @wiki_pages = paginate :pages, :order => 'title ASC', - :conditions => [ 'allow_discussions = ?', true ], :per_page => 25, + :conditions => [ 'allow_discussions = ?', true ], :per_page => per_page, :include => [ 'discussions' ] respond_to do |format| format.html # index.rhtml @@ -21,7 +21,7 @@ class DiscussionsController < ApplicationController @page = Page.find(params[:id], :include => [ 'discussions' ]) @secondary_title = @page.title @pages, @discussions = paginate :discussion, :order => 'created_at ASC', - :conditions => [ 'page_id = ?', @page.id ], :per_page => 25 + :conditions => [ 'page_id = ?', @page.id ], :per_page => per_page respond_to do |format| format.html # show.rhtml format.xml { render :xml => @discussions.to_xml } diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 0b19735..b8165c8 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -13,7 +13,7 @@ class PagesController < ApplicationController cond_ary = [ 'owner_id IS NULL' ] cond_ary << "title <> 'HomePage'" - @pages, @wiki_pages = paginate :page, :per_page => 25, + @pages, @wiki_pages = paginate :page, :per_page => per_page, :order => 'title ASC', :conditions => [ cond_ary.join(' AND ') ] @tags = Page.tags(:limit => 25, :order => "name ASC") diff --git a/app/controllers/peoples_controller.rb b/app/controllers/peoples_controller.rb index ac59540..f502410 100644 --- a/app/controllers/peoples_controller.rb +++ b/app/controllers/peoples_controller.rb @@ -6,8 +6,8 @@ class PeoplesController < ApplicationController # GET /peoples.xml def index @secondary_title = 'Browsing all Peoples' - @pages, @peoples = paginate :people, :per_page => 25, :order => 'title ASC', - :singular_name => 'people' + @pages, @peoples = paginate :people, :per_page => per_page, + :order => 'title ASC', :singular_name => 'people' @tags = Page.tags(:limit => 25, :order => "name DESC", :owner_type => 'People') respond_to do |format| diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index b9cfc71..cc2c870 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -5,7 +5,8 @@ class RolesController < ApplicationController # GET /roles.xml def index @secondary_title = 'Role Administration' - @pages, @roles = paginate :roles, :order => 'name ASC', :per_page => 25 + @pages, @roles = paginate :roles, :order => 'name ASC', + :per_page => per_page respond_to do |format| format.html # index.rhtml format.xml { render :xml => @roles.to_xml }