Class: Glue::Template::Sitemap
- Defined in:
- lib/glue/template/sitemap.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#<<, #apply_filters, #initialize
Constructor Details
This class inherits a constructor from Glue::Template::Base
Instance Method Details
#save(path) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/glue/template/sitemap.rb', line 4 def save(path) file = File.open(path, "w+") xml = Builder::XmlMarkup.new(:target => file, :indent => 2) xml.instruct! :xml, :version => "1.1", :encoding => "UTF-8" xml.comment! "Generated at #{Time.now.inspect}" self.filters = config[:sitemap][:filters] filtered_items = apply_filters xml.urlset :xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9" do filtered_items.each do || xml.url do xml.loc File.join(config[:site][:base_url], [:path]) xml.lastmod [:updated_at].xmlschema if [:updated_at] xml.changefreq [:frequency] if [:frequency] xml.priority [:priority] if [:priority] end end end file.close end |