Skip to content

Commit

Permalink
add sitemaps
Browse files Browse the repository at this point in the history
  • Loading branch information
Brett Huneycutt committed Oct 27, 2012
1 parent 7ada061 commit 01a6f8b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
13 changes: 13 additions & 0 deletions app/controllers/sitemaps_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class SitemapsController < ApplicationController
def index
@urls_and_images = {
root_url => [],
photography_details_url => [],
classes_url => [],
about_url => [],
families_url => FamilyPhoto.all.map(&:url),
kids_url => KidPhoto.all.map(&:url),
newborns_url => NewbornPhoto.all.map(&:url),
}
end
end
14 changes: 14 additions & 0 deletions app/views/sitemaps/index.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
xml.instruct!
xml.tag! 'urlset', 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', 'xmlns:image' => "http://www.google.com/schemas/sitemap-image/1.1" do
@urls_and_images.each do |url, images|
xml.url do
xml.loc url
xml.changefreq "weekly"
images.each do |image_url|
xml.image :image do
xml.image :loc, image_url
end
end
end
end
end
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@

# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
match 'photography-details' => 'welcome#photography_details'
match 'sitemap.xml' => 'sitemaps#index'
match 'photography-details' => 'welcome#photography_details', :as => "photography_details"
match 'contact' => 'welcome#contact'
match 'classes' => 'welcome#classes'
match 'kids' => 'welcome#kids'
Expand Down

0 comments on commit 01a6f8b

Please sign in to comment.