91 lines
1.4 KiB
Ruby
91 lines
1.4 KiB
Ruby
class ApplicationController < ActionController::Base
|
|
# Prevent CSRF attacks by raising an exception.
|
|
# For APIs, you may want to use :null_session instead.
|
|
protect_from_forgery with: :exception
|
|
|
|
|
|
before_filter :set_image_var
|
|
|
|
before_filter :set_locale
|
|
|
|
|
|
|
|
before_filter :set_provenance
|
|
|
|
def set_provenance
|
|
if params[:c] and params[:c] != ""
|
|
cookies[:provenance_id] = params[:c]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_locale
|
|
# if params[:locale] is nil then I18n.default_locale will be used
|
|
#I18n.locale = params[:locale]#"fr" #
|
|
|
|
I18n.locale = params[:lang] || "fr"
|
|
|
|
@lang = LangSite.find_by_slug I18n.locale.to_s
|
|
end
|
|
|
|
def default_url_options(options={})
|
|
{ :lang => I18n.locale } #
|
|
end
|
|
|
|
def set_image_var
|
|
@page_images_credits = []
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
def moderator?
|
|
true if current_admin
|
|
end
|
|
|
|
|
|
def auth_admin
|
|
if !current_admin
|
|
redirect_to new_admin_admin_auth_path
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_admin
|
|
|
|
if cookies[:admin_remember_token]
|
|
if @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token])
|
|
@current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token])
|
|
else
|
|
cookies[:admin_remember_token] =nil
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
helper_method :current_admin, :moderator?
|
|
|
|
|
|
end
|
|
|