2012-01-09 14:49:59 +00:00
|
|
|
module Locomotive
|
|
|
|
module Public
|
2012-01-16 22:59:59 +00:00
|
|
|
class PagesController < ApplicationController
|
2012-01-09 14:49:59 +00:00
|
|
|
|
|
|
|
include Locomotive::Routing::SiteDispatcher
|
|
|
|
include Locomotive::Render
|
2012-01-17 16:04:45 +00:00
|
|
|
include Locomotive::ActionController::LocaleHelpers
|
2012-01-09 14:49:59 +00:00
|
|
|
|
|
|
|
before_filter :require_site
|
|
|
|
|
2012-01-17 01:53:49 +00:00
|
|
|
before_filter :authenticate_locomotive_account!, :only => [:show_toolbar]
|
2012-01-09 14:49:59 +00:00
|
|
|
|
2012-01-17 01:53:49 +00:00
|
|
|
before_filter :validate_site_membership, :only => [:show_toolbar]
|
|
|
|
|
2012-02-10 00:42:06 +00:00
|
|
|
before_filter :set_toolbar_locale, :only => :show_toolbar
|
2012-01-17 16:04:45 +00:00
|
|
|
|
|
|
|
before_filter :set_locale, :only => [:show, :edit]
|
|
|
|
|
2012-01-17 01:53:49 +00:00
|
|
|
def show_toolbar
|
|
|
|
render :layout => false
|
|
|
|
end
|
2012-01-09 14:49:59 +00:00
|
|
|
|
|
|
|
def show
|
|
|
|
render_locomotive_page
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2012-01-17 01:53:49 +00:00
|
|
|
@editing = true
|
|
|
|
render_locomotive_page
|
2012-01-09 14:49:59 +00:00
|
|
|
end
|
|
|
|
|
2012-01-17 16:04:45 +00:00
|
|
|
protected
|
|
|
|
|
2012-02-10 00:42:06 +00:00
|
|
|
def set_toolbar_locale
|
2012-01-17 16:04:45 +00:00
|
|
|
::I18n.locale = current_locomotive_account.locale rescue Locomotive.config.default_locale
|
2012-02-10 00:42:06 +00:00
|
|
|
::Mongoid::Fields::I18n.locale = session[:content_locale] || current_site.default_locale
|
2012-01-17 16:04:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_locale
|
2012-01-26 01:33:39 +00:00
|
|
|
::Mongoid::Fields::I18n.locale = params[:locale] || current_site.default_locale
|
2012-01-17 16:04:45 +00:00
|
|
|
::I18n.locale = ::Mongoid::Fields::I18n.locale
|
2012-01-26 01:33:39 +00:00
|
|
|
|
|
|
|
self.setup_i18n_fallbacks
|
2012-01-17 16:04:45 +00:00
|
|
|
end
|
|
|
|
|
2012-01-09 14:49:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|