Skip to content

Commit

Permalink
PA-348: Put all the sitemap files except the index under a common dir…
Browse files Browse the repository at this point in the history
…ectory
  • Loading branch information
mlandauer committed Jul 31, 2012
1 parent 268b1a2 commit d633b87
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public/getinvolved.html
public/index.html
public/stylesheets/compiled
public/sitemap.xml
public/sitemap*.xml.gz
public/sitemaps/sitemap*.xml.gz
public/javascripts/all.js
public/javascripts/mxn_bundle.js
webrat.log
Expand Down
4 changes: 2 additions & 2 deletions app/models/sitemap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Sitemap
def initialize(root_url, root_path, logger = Logger.new(STDOUT))
@root_url, @root_path, @logger = root_url, root_path, logger

#FileUtils.mkdir_p "#{@root_path}/sitemaps"
FileUtils.mkdir_p "#{@root_path}/sitemaps"

# Index of current sitemap file
@index = 0
Expand Down Expand Up @@ -130,7 +130,7 @@ def sitemap_index_relative_path
end

def sitemap_relative_path
"sitemap#{@index + 1}.xml.gz"
"sitemaps/sitemap#{@index + 1}.xml.gz"
end

# Notify the search engines (like Google, Yahoo, etc..) of the new sitemap
Expand Down
6 changes: 3 additions & 3 deletions spec/models/sitemap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
file1.should_receive(:<<).with("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
file1.should_receive(:<<).with("<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">")
file1.should_receive(:<<).with("<sitemap>")
file1.should_receive(:<<).with("<loc>http://domain.org/sitemap1.xml.gz</loc>")
file1.should_receive(:<<).with("<loc>http://domain.org/sitemaps/sitemap1.xml.gz</loc>")
file1.should_receive(:<<).with("<lastmod>2010-02-01T00:00:00+00:00</lastmod>")
file1.should_receive(:<<).with("</sitemap>")
file1.should_receive(:<<).with("</sitemapindex>")
file1.should_receive(:close)

file2 = mock("file2")
Zlib::GzipWriter.should_receive(:open).with("#{public}/sitemap1.xml.gz").and_return(file2)
Zlib::GzipWriter.should_receive(:open).with("#{public}/sitemaps/sitemap1.xml.gz").and_return(file2)
file2.should_receive(:<<).with("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
file2.should_receive(:<<).with("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">")
file2.should_receive(:<<).with("<url><loc>http://domain.org/</loc><changefreq>hourly</changefreq><lastmod>2010-02-01T00:00:00+00:00</lastmod></url>")
Expand All @@ -49,7 +49,7 @@
it "should have the path to one of the sitemaps" do
public = Rails.root.join('public').to_s
s = Sitemap.new("http://domain.org", public, @logger)
s.sitemap_relative_path.should == "sitemap1.xml.gz"
s.sitemap_relative_path.should == "sitemaps/sitemap1.xml.gz"
s.finish
end

Expand Down

0 comments on commit d633b87

Please sign in to comment.