pagination

This commit is contained in:
Nicolas Bally 2012-02-29 14:55:56 +01:00
parent 2ee08bca9c
commit c27e3818fc
5 changed files with 29 additions and 2 deletions

View File

@ -0,0 +1,20 @@
#articles_pagination{
margin-top:40px;
a, .current{
display : inline-block;
padding:5px;
border:1px solid #82B139;
text-decoration:none;
}
div{
padding-left:10px;
}
.current{
border:none;
}
}

View File

@ -7,6 +7,10 @@ class Public::ArticlesController < ApplicationController
def index def index
@articles = Article.recents @articles = Article.recents
@articles = @articles.page(params[:page]).per(10)
@title = "Articles du blog" @title = "Articles du blog"
end end
@ -17,6 +21,7 @@ class Public::ArticlesController < ApplicationController
@category = Category.find_by_slug(params[:slug]) @category = Category.find_by_slug(params[:slug])
@articles = @category.articles.recents @articles = @category.articles.recents
@articles = @articles.page(params[:page]).per(10)
@title = "Articles du blog" @title = "Articles du blog"
@index_title = 'Articles de la catégorie "'+@category.name+'"' @index_title = 'Articles de la catégorie "'+@category.name+'"'
render :action => :index render :action => :index
@ -26,6 +31,7 @@ class Public::ArticlesController < ApplicationController
def archives def archives
@month = Date.parse("#{params[:year]}/#{params[:month]}").beginning_of_month @month = Date.parse("#{params[:year]}/#{params[:month]}").beginning_of_month
@articles = Article.where("enabled = ? and published_at > ? and published_at < ?", true, @month, @month.end_of_month ) @articles = Article.where("enabled = ? and published_at > ? and published_at < ?", true, @month, @month.end_of_month )
@articles = @articles.page(params[:page]).per(10)
@title = "Articles du blog" @title = "Articles du blog"
if [4,8].include?(@month.month) if [4,8].include?(@month.month)
@index_title = 'Articles du mois d\''+l(@month, :format => "%B %Y")+'' @index_title = 'Articles du mois d\''+l(@month, :format => "%B %Y")+''

View File

@ -15,6 +15,7 @@ class Public::TagsController < ApplicationController
if @tag if @tag
@title = "tag : "+@tag.name.to_s @title = "tag : "+@tag.name.to_s
@articles = @tag.recents_articles @articles = @tag.recents_articles
@articles = @articles.page(params[:page]).per(10)
render :template => "public/articles/index" render :template => "public/articles/index"
else else
redirect_to "/", :notice => "La page que vous demandez n'a pas pu être trouvée.<br /><br />Vous avez donc été redirigé sur notre page d'accueil" redirect_to "/", :notice => "La page que vous demandez n'a pas pu être trouvée.<br /><br />Vous avez donc été redirigé sur notre page d'accueil"

View File

@ -6,7 +6,7 @@
-if @index_title -if @index_title
%h1=@index_title %h1=@index_title
=render :partial => "public/articles/article", :collection => @articles, :as => "article" =render :partial => "public/articles/article", :collection => @articles, :as => "article"
#articles_pagination= paginate @articles
-content_for :sidebar do -content_for :sidebar do

View File

@ -33,7 +33,7 @@
-photos = photos.sort {rand(8)} -photos = photos.sort {rand(8)}
-photos = photos.sort {rand(6)} -photos = photos.sort {rand(6)}
-photos = photos.sort {rand(4)} -photos = photos.sort {rand(4)}
-photos = photos[0..5] -photos = photos[0..4]
-photos.each do |photo| -photos.each do |photo|
.slide{:style => "width:1000px;height:460px;"}=link_to image_tag('diaporama/'+("%02d" % photo)+'.jpg', :style => "width:1000px;height:460px;"), "" .slide{:style => "width:1000px;height:460px;"}=link_to image_tag('diaporama/'+("%02d" % photo)+'.jpg', :style => "width:1000px;height:460px;"), ""