Class: Alchemy::PagesController

Inherits:
BaseController
  • Object
show all
Includes:
LegacyPageRedirects, LocaleRedirects, OnPageLayout::CallbacksRunner, PageRedirects, 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.


53
54
55
# File 'app/controllers/alchemy/pages_controller.rb', line 53

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.


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

def show
  if redirect_url.present?
    redirect_permanently_to redirect_url
  else
    authorize! :show, @page
    render_page if render_fresh_page?
  end
end

#sitemapObject

Renders a search engine compatible xml sitemap.


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

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