Class: CmsLiteController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CmsLiteController
- Defined in:
- app/controllers/cms_lite_controller.rb
Instance Method Summary collapse
- #choose_layout(content_key) ⇒ Object
- #render_content_page(cms_lite_path, request_layout = '') ⇒ Object
- #show_page ⇒ Object
- #show_protected_page ⇒ Object
Instance Method Details
#choose_layout(content_key) ⇒ Object
31 32 33 34 35 |
# File 'app/controllers/cms_lite_controller.rb', line 31 def choose_layout(content_key) layout = CmsLite.cms_layouts[content_key] layout = CmsLite.cms_layouts[:default] if layout.blank? layout ||= 'application' end |
#render_content_page(cms_lite_path, request_layout = '') ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/cms_lite_controller.rb', line 14 def render_content_page(cms_lite_path, request_layout = '') path = File.join(RAILS_ROOT, CmsLite::CONTENT_PATH, cms_lite_path, I18n.locale.to_s, params[:content_key], params[:content_page].join('/')) format = params[:format] || 'htm' content_page = Dir.glob("#{path}.#{format}").first content_page = Dir.glob("#{path}").first if content_page.nil? content_page = Dir.glob("#{path}.*").first if content_page.nil? raise CmsLite::Exceptions::MissingTemplateError, "Could not find template for: '#{path}'" if content_page.nil? respond_to do |format| format.html { render :file => content_page, :layout => choose_layout(params[:content_key]) } format.js { render :file => content_page, :layout => false } format.xml { render :file => content_page, :layout => false } end rescue CmsLite::Exceptions::MissingTemplateError => ex render :file => "#{RAILS_ROOT}/public/404.html", :status => 404 end |
#show_page ⇒ Object
6 7 8 |
# File 'app/controllers/cms_lite_controller.rb', line 6 def show_page render_content_page(CmsLite::PAGES_PATH) end |
#show_protected_page ⇒ Object
10 11 12 |
# File 'app/controllers/cms_lite_controller.rb', line 10 def show_protected_page render_content_page(CmsLite::PROTECTED_PAGES_PATH) end |