per page helper method
git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@95 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7master
parent
0ff7cf8172
commit
f14fcf5d78
|
@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
|
||||||
append_before_filter :authorized?
|
append_before_filter :authorized?
|
||||||
append_before_filter :set_current_people_id
|
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
|
cattr_accessor :current_people_id
|
||||||
|
|
||||||
|
@ -73,6 +73,14 @@ class ApplicationController < ActionController::Base
|
||||||
@page.allow_discussions = true
|
@page.allow_discussions = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# This will eventually figure out what the People has configured for a per
|
||||||
|
# page limit of objects.
|
||||||
|
#
|
||||||
|
def per_page
|
||||||
|
50
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -7,7 +7,7 @@ class BeersController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@content_title = 'The Beers'
|
@content_title = 'The Beers'
|
||||||
@secondary_title = 'Browsing all 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'
|
:order => 'beers.title ASC'
|
||||||
@tags = Page.tags(:limit => 25, :order => "name DESC",
|
@tags = Page.tags(:limit => 25, :order => "name DESC",
|
||||||
:owner_type => 'Beer')
|
:owner_type => 'Beer')
|
||||||
|
|
|
@ -8,7 +8,7 @@ class BreweriesController < ApplicationController
|
||||||
@content_title = 'The Breweries'
|
@content_title = 'The Breweries'
|
||||||
@secondary_title = 'Browsing all breweries'
|
@secondary_title = 'Browsing all breweries'
|
||||||
@pages, @breweries = paginate :breweries, :include => 'page',
|
@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",
|
@tags = Page.tags(:limit => 25, :order => "name DESC",
|
||||||
:owner_type => 'Beer')
|
:owner_type => 'Beer')
|
||||||
|
|
|
@ -8,7 +8,7 @@ class DiscussionsController < ApplicationController
|
||||||
@content_title = 'Discussion Topics'
|
@content_title = 'Discussion Topics'
|
||||||
@secondary_title = 'All discussion topics'
|
@secondary_title = 'All discussion topics'
|
||||||
@pages, @wiki_pages = paginate :pages, :order => 'title ASC',
|
@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' ]
|
:include => [ 'discussions' ]
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.rhtml
|
format.html # index.rhtml
|
||||||
|
@ -21,7 +21,7 @@ class DiscussionsController < ApplicationController
|
||||||
@page = Page.find(params[:id], :include => [ 'discussions' ])
|
@page = Page.find(params[:id], :include => [ 'discussions' ])
|
||||||
@secondary_title = @page.title
|
@secondary_title = @page.title
|
||||||
@pages, @discussions = paginate :discussion, :order => 'created_at ASC',
|
@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|
|
respond_to do |format|
|
||||||
format.html # show.rhtml
|
format.html # show.rhtml
|
||||||
format.xml { render :xml => @discussions.to_xml }
|
format.xml { render :xml => @discussions.to_xml }
|
||||||
|
|
|
@ -13,7 +13,7 @@ class PagesController < ApplicationController
|
||||||
|
|
||||||
cond_ary = [ 'owner_id IS NULL' ]
|
cond_ary = [ 'owner_id IS NULL' ]
|
||||||
cond_ary << "title <> 'HomePage'"
|
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 ') ]
|
:order => 'title ASC', :conditions => [ cond_ary.join(' AND ') ]
|
||||||
|
|
||||||
@tags = Page.tags(:limit => 25, :order => "name ASC")
|
@tags = Page.tags(:limit => 25, :order => "name ASC")
|
||||||
|
|
|
@ -6,8 +6,8 @@ class PeoplesController < ApplicationController
|
||||||
# GET /peoples.xml
|
# GET /peoples.xml
|
||||||
def index
|
def index
|
||||||
@secondary_title = 'Browsing all Peoples'
|
@secondary_title = 'Browsing all Peoples'
|
||||||
@pages, @peoples = paginate :people, :per_page => 25, :order => 'title ASC',
|
@pages, @peoples = paginate :people, :per_page => per_page,
|
||||||
:singular_name => 'people'
|
:order => 'title ASC', :singular_name => 'people'
|
||||||
@tags = Page.tags(:limit => 25, :order => "name DESC",
|
@tags = Page.tags(:limit => 25, :order => "name DESC",
|
||||||
:owner_type => 'People')
|
:owner_type => 'People')
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
@ -5,7 +5,8 @@ class RolesController < ApplicationController
|
||||||
# GET /roles.xml
|
# GET /roles.xml
|
||||||
def index
|
def index
|
||||||
@secondary_title = 'Role Administration'
|
@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|
|
respond_to do |format|
|
||||||
format.html # index.rhtml
|
format.html # index.rhtml
|
||||||
format.xml { render :xml => @roles.to_xml }
|
format.xml { render :xml => @roles.to_xml }
|
||||||
|
|
Reference in New Issue