pic_vert_app/app/controllers/public/events_controller.rb
Nicolas Bally 6ac6f91d8f agenda
2015-10-21 15:06:43 +02:00

68 lines
1.3 KiB
Ruby

# -*- encoding : utf-8 -*-
class Public::EventsController < ApplicationController
layout "public"
def index
if params[:month] and params[:year]
@start_list_date = Date.new(params[:year].to_i, params[:month].to_i).beginning_of_month
@end_list_date = @start_list_date
else
@start_list_date = Time.now.beginning_of_month
@end_list_date = @start_list_date + 2.month
end
@title = "Agenda"
end
def category
@category = Category.find_by_slug(params[:slug])
@articles = @category.articles.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 )
@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
end
end