ecole_eft_app/app/controllers/public/articles_controller.rb
Nicolas Bally 56a0aa9848 initial
2012-06-17 21:11:12 +02:00

61 lines
1.4 KiB
Ruby

# -*- encoding : utf-8 -*-
class Public::ArticlesController < ApplicationController
layout "public"
def index
@articles = Article.before(Date.today).recents
@articles = @articles.page(params[:page]).per(10)
@title = "Articles du blog"
end
def category
@category = Category.find_by_slug(params[:slug])
@articles = @category.articles.before(Date.today).recents
@articles = @articles.page(params[:page]).per(10)
@title = "Articles du blog"
@index_title = 'Articles de la catégorie "'+@category.name+'"'
render :action => :index
end
def archives
@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 ).before(Date.today).recents
@articles = @articles.page(params[:page]).per(10)
@title = "Articles du blog"
if [4,8].include?(@month.month)
@index_title = 'Articles du mois d\''+l(@month, :format => "%B %Y")+''
else
@index_title = 'Articles du mois de '+l(@month, :format => "%B %Y")+''
end
render :action => :index
end
def show
@article = Article.find_by_slug(params[:slug])
if @article and @article.enabled
@title = @article.title
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"
end
end
end