Class: Postnhost::SitemapController

Inherits:
ApplicationController show all
Defined in:
app/controllers/postnhost/sitemap_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



3
4
5
6
7
8
9
10
# File 'app/controllers/postnhost/sitemap_controller.rb', line 3

def show
  sitemap_builder = Postnhost::SitemapBuilder.new(request:, site_url: current_setting.effective_site_url.presence || request.base_url)
  sitemap_xml = Rails.cache.fetch(sitemap_builder.cache_key, expires_in: 1.hour) do
    sitemap_builder.call
  end

  render xml: sitemap_xml
end

#stylesheetObject



12
13
14
15
# File 'app/controllers/postnhost/sitemap_controller.rb', line 12

def stylesheet
  path = Postnhost::Engine.root.join("app/assets/xsl/sitemap.xsl")
  send_file path, type: "application/xslt+xml", disposition: "inline"
end