This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
2009-05-07 16:53:18 +00:00
|
|
|
class ApplicationController < ActionController::Base
|
|
|
|
|
2009-06-01 06:20:15 +00:00
|
|
|
helper :all
|
|
|
|
protect_from_forgery
|
|
|
|
|
2009-06-19 09:31:10 +00:00
|
|
|
before_filter :set_locale
|
|
|
|
|
2009-06-01 06:20:15 +00:00
|
|
|
filter_parameter_logging :password
|
|
|
|
|
|
|
|
Liquid::Template.register_filter(SnippetFilter)
|
|
|
|
|
|
|
|
def render_liquid_page
|
|
|
|
if @page
|
|
|
|
@layout = @page.layout
|
|
|
|
@page_options ||= {}
|
2009-06-19 09:31:10 +00:00
|
|
|
@page_content = Liquid::Template.parse( @page.read_attribute( "content_#{I18n.locale}" ) ).render(@page_options)
|
2009-06-01 06:20:15 +00:00
|
|
|
@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
|
|
|
|
|
2009-06-19 09:31:10 +00:00
|
|
|
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
|
|
|
|
|
2009-05-07 16:53:18 +00:00
|
|
|
end
|