Permalink
Browse files

Adding a sitemap

  • Loading branch information...
1 parent 33b4842 commit 61a40c23b8cde9bc2a3f0fd5fc9245584b887f66 @danielweinmann committed Feb 12, 2012
Showing with 44 additions and 0 deletions.
  1. +6 −0 app/controllers/events_controller.rb
  2. +37 −0 app/views/events/sitemap.xml.builder
  3. +1 −0 config/routes.rb
@@ -24,4 +24,10 @@ def create
end
end
+ def sitemap
+ @happening = Event.happening.all
+ @upcoming = Event.upcoming.all
+ @past = Event.past.all
+ end
+
end
@@ -0,0 +1,37 @@
+xml.instruct!
+xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
+
+ xml.url do
+ xml.loc "http://tangoportoalegre.com.br"
+ xml.priority 1.0
+ xml.changefreq "daily"
+ end
+
+ @happening.each do |event|
+ xml.url do
+ xml.loc event.url
+ xml.priority 0.8
+ xml.changefreq "daily"
+ xml.lastmod event.updated_at.to_date
+ end
+ end
+
+ @upcoming.each do |event|
+ xml.url do
+ xml.loc event.url
+ xml.priority 0.6
+ xml.changefreq "daily"
+ xml.lastmod event.updated_at.to_date
+ end
+ end
+
+ @past.each do |event|
+ xml.url do
+ xml.loc event.url
+ xml.priority 0.4
+ xml.changefreq "daily"
+ xml.lastmod event.updated_at.to_date
+ end
+ end
+
+end
View
@@ -4,6 +4,7 @@
end
root to: "events#index"
+ match '/sitemap' => "events#sitemap", :as => :sitemap
resources :events, only: [:index, :create]

0 comments on commit 61a40c2

Please sign in to comment.