Class: Alchemy::PagesController

Inherits:
BaseController
  • Object
show all
Includes:
LegacyPageRedirects, OnPageLayout::CallbacksRunner, SiteRedirects
Defined in:
app/controllers/alchemy/pages_controller.rb

Constant Summary collapse

SHOW_PAGE_PARAMS_KEYS =
[
  "action",
  "controller",
  "urlname",
  "locale"
]

Instance Method Summary collapse

Methods included from Modules

included, #module_definition_for, register_module

Methods included from AbilityHelper

#current_ability

Methods included from ConfigurationMethods

#configuration, #multi_language?, #multi_site?, #prefix_locale?

Instance Method Details

#indexObject

The index action gets invoked if one requests ‘/’ or ‘/:locale’

If the locale is the default locale, then it redirects to ‘/’ without the locale.

Loads the current language root page. The current language is either loaded via :locale parameter or, if that’s missing, the default language is used.

If this page is not published then it redirects to the first published descendant it finds.

If no public page can be found it renders a 404 error.



55
56
57
# File 'app/controllers/alchemy/pages_controller.rb', line 55

def index
  show
end

#showObject

The show action gets invoked if one requests ‘/:urlname’ or ‘/:locale/:urlname’

If the locale is the default locale, then it redirects to ‘/’ without the locale.

Loads the page via it’s urlname. If more than one language is published the current language is either loaded via :locale parameter or, if that’s missing, the page language is used and a redirect to the page with prefixed locale happens.

If the requested page is not published then it redirects to the first published descendant it finds. If no public page can be found it renders a 404 error.



70
71
72
73
# File 'app/controllers/alchemy/pages_controller.rb', line 70

def show
  authorize! :show, @page
  render_page if render_fresh_page?
end

#sitemapObject

Renders a search engine compatible xml sitemap.



76
77
78
79
80
81
# File 'app/controllers/alchemy/pages_controller.rb', line 76

def sitemap
  @pages = Page.sitemap
  respond_to do |format|
    format.xml { render layout: "alchemy/sitemap" }
  end
end