Class: Alchemy::SitemapController
- Inherits:
-
BaseController
- Object
- BaseController
- Alchemy::SitemapController
- Includes:
- SiteRedirects
- Defined in:
- app/controllers/alchemy/sitemap_controller.rb
Overview
Renders a search engine compatible XML sitemap.
The sitemap contains absolute urls, so it has to follow the site's primary host redirect just like a page request does.
Constant Summary collapse
- TEMPLATE =
Still the pages template, because apps override it at that path.
TODO: Move to alchemy/sitemap/show in Alchemy 9.0, together with the deprecated PagesController#sitemap.
"alchemy/pages/sitemap"
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/alchemy/sitemap_controller.rb', line 18 def show if sitemap_caching_enabled? expires_in sitemap_max_age, public: true # The etag is checked before the pages are loaded, so a revalidating # client only costs us the cache key queries, not a full render. return unless stale?(etag: sitemap_cache_key, public: true) @sitemap_cache_key = sitemap_cache_key @sitemap_max_age = sitemap_max_age end # Left unloaded on purpose. The template wraps the urls in a fragment # cache, so a cache hit never runs this query. @pages = Page.sitemap render template: TEMPLATE, layout: "alchemy/sitemap" end |