Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expires tag to sitemap for expired content #126

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/sitemap_generator/builder/sitemap_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def initialize(path, options={})
path = sitemap.location.path_in_public
end

SitemapGenerator::Utilities.assert_valid_keys(options, :priority, :changefreq, :lastmod, :host, :images, :video, :geo, :news, :videos, :mobile, :alternate, :alternates, :pagemap)
SitemapGenerator::Utilities.assert_valid_keys(options, :priority, :changefreq, :lastmod, :expires, :host, :images, :video, :geo, :news, :videos, :mobile, :alternate, :alternates, :pagemap)
SitemapGenerator::Utilities.reverse_merge!(options, :priority => 0.5, :changefreq => 'weekly', :lastmod => Time.now, :images => [], :news => {}, :videos => [], :mobile => false, :alternates => [])
raise "Cannot generate a url without a host" unless SitemapGenerator::Utilities.present?(options[:host])

Expand All @@ -54,6 +54,7 @@ def initialize(path, options={})
:priority => options[:priority],
:changefreq => options[:changefreq],
:lastmod => options[:lastmod],
:expires => options[:expires],
:host => options[:host],
:loc => loc,
:images => prepare_images(options[:images], options[:host]),
Expand All @@ -72,9 +73,10 @@ def to_xml(builder=nil)
builder.url do
builder.loc self[:loc]
builder.lastmod w3c_date(self[:lastmod]) if self[:lastmod]
builder.expires w3c_date(self[:expires]) if self[:expires]
builder.changefreq self[:changefreq].to_s if self[:changefreq]
builder.priority format_float(self[:priority]) if self[:priority]

unless SitemapGenerator::Utilities.blank?(self[:news])
news_data = self[:news]
builder.news:news do
Expand Down