orbit-basic/app/controllers/application_controller.rb

35 lines
962 B
Ruby

class ApplicationController < ActionController::Base
helper :all
protect_from_forgery
before_filter :set_locale
filter_parameter_logging :password
Liquid::Template.register_filter(SnippetFilter)
def render_liquid_page
if @page
@layout = @page.layout
@page_options ||= {}
@page_content = Liquid::Template.parse( @page.read_attribute( "content_#{I18n.locale}" ) ).render(@page_options)
@layout_content = (@page.layout)? @layout.content : "{{page_content}}"
render :text => Liquid::Template.parse(@layout_content).render( 'page_content' => @page_content )
else
render :text => '404 Not Found'
end
end
def set_locale
# update session if passed
if params[:locale] && VALID_LOCALES.include?( params[:locale] )
session[:locale] = params[:locale]
end
# set locale based on session or default
I18n.locale = session[:locale] || I18n.default_locale
end
end