Sha256: 078b27628b3e4b89c663419a3f2906623620423de1d267fa311432873f842519

Contents?: true

Size: 1.56 KB

Versions: 19

Compression:

Stored size: 1.56 KB

Contents

xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'

xml.urlset :xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9' do
  @cms_site.pages.published.each do |page|
    xml.url do
      xml.loc [request.protocol.gsub('//', ''), page.url].join
      # just take some guesses the closer to the root means higher priority
      # start subtracting 0.1 for every additional child page, max out at 0.1
      # "/" splits to 0, "/child_page" splits to 2, hence weird max -1
      xml.priority [1 - (0.1 * ( ( [page.full_path.split("/").count, 1].max - 1 ) ) ), 0.1].max
      xml.lastmod page.updated_at.strftime('%Y-%m-%d')
    end
  end

  ComfortableMexicanLoveseat.seo_custom_paths.each do |options|
    site_path = Comfy::Cms::Site.many? ? [@cms_site.path].join + '/' : ''
    custom_path = [site_path + options[:path]].join
    xml.url do
      xml.loc [request.protocol, request.host_with_port, '/', custom_path].join
      xml.priority [1 - (0.1 * ( ( [custom_path.split("/").count, 1].max - 1 ) ) ), 0.1].max
      xml.lastmod options[:last_modified]
    end
  end

  ComfortableMexicanLoveseat.seo_resource_paths.each do |options|
    resource_class = options[:resource_class].kind_of?(String) ? options[:resource_class].constantize : options[:resource_class]
    resource_class_name = options[:resource_class].kind_of?(String) ? options[:resource_class] : options[:resource_class].name
    resource_class.where(options[:filter]).each do |obj|
      xml.url do
        xml.loc polymorphic_url(obj)
        xml.lastmod obj.updated_at.strftime('%Y-%m-%d')
      end
    end
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
comfortable_mexican_loveseat-0.1.1 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.1.0 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.23 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.22 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.21 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.20 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.19 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.18 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.17 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.16 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.15 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.14 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.13 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.12 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.11 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.10 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.9 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.8 app/views/comfy/cms/content/render_sitemap.xml.builder
comfortable_mexican_loveseat-0.0.7 app/views/comfy/cms/content/render_sitemap.xml.builder