lib/awestruct/extensions/sitemap.rb in awestruct-0.2.11 vs lib/awestruct/extensions/sitemap.rb in awestruct-0.2.12

- old
+ new

@@ -1,8 +1,8 @@ # Generates a sitemap for search engines. Defaults to /sitemap.xml # Ignores images, css, robots, atoms, javascript files. -# Add a sitemap.yml file to add files that for one reason or +# Add a sitemap.yml file to add files that for one reason or # another won't be hanging off of site (e.g. they're in .htaccess) require 'ostruct' module Awestruct module Extensions @@ -14,33 +14,34 @@ sitemap_pages = [] entries = site.pages entries.each { |entry| sitemap_pages << set_sitemap_data( entry ) if valid_sitemap_entry( entry ) } if entries # Generate sitemap pages for stuff in _config/sitemap.yml - site.sitemap.pages.each do |entry| + site.sitemap.pages.each do |entry| page = Awestruct::Renderable.new( site ) - page.output_path = entry.url - page.date = entry.date( nil ) + page.output_path = entry.url + page.date = entry.date( nil ) page.priority = entry.priority( nil ) page.change_frequency = entry.change_frequency( nil ) sitemap_pages << page end if site.sitemap # Generate the correct urls for each page in the sitemap site.engine.set_urls( sitemap_pages ) - # Create a sitemap.xml file from our template + # Create a sitemap.xml file from our template sitemap = File.join( File.dirname(__FILE__), 'sitemap.xml.haml' ) page = site.engine.load_page( sitemap ) page.output_path = 'sitemap.xml' page.sitemap_entries = sitemap_pages # Add the sitemap to our site site.pages << page end protected + def set_sitemap_data( page ) site = page.site munge_date( page ) page.priority ||= (site.priority or 0.1) page.change_frequency ||= (site.change_frequency or 'never') @@ -76,8 +77,9 @@ page.output_extension != '.png' && page.output_extension != '.jpg' && page.output_extension != '.gif' && page.output_extension != '.js' end + end end end