Permalink
Browse files

Added all locale pages to sitemap except hidden pages and drafts. Clo…

…ses GH-585. Closes GH-586.
  • Loading branch information...
1 parent 7db3cc4 commit 60501e3b230f8b298aac31e26bbad7c2afff53d9 @rocksolidwebdesign rocksolidwebdesign committed Apr 5, 2011
Showing with 23 additions and 15 deletions.
  1. +18 −14 app/views/sitemap/index.xml.builder
  2. +5 −1 core/app/controllers/sitemap_controller.rb
@@ -2,21 +2,25 @@ xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
- @pages.each do |page|
- # exclude sites that are external to our own domain.
- page_url = if page.url.is_a?(Hash)
- # This is how most pages work without being overriden by link_url
- page.url.merge({:only_path => false})
- elsif page.url.to_s !~ /^http/
- # handle relative link_url addresses.
- "#{request.protocol}#{request.host_with_port}#{page.url}"
- end
+ @locales.each do |locale|
+ ::I18n.locale = locale
+ @pages = Page.live.in_menu.includes(:parts)
+ @pages.each do |page|
+ # exclude sites that are external to our own domain.
+ page_url = if page.url.is_a?(Hash)
+ # This is how most pages work without being overriden by link_url
+ page.url.merge({:only_path => false})
+ elsif page.url.to_s !~ /^http/
+ # handle relative link_url addresses.
+ [request.protocol, request.host_with_port, page.url].join
+ end
- # Add XML entry only if there is a valid page_url found above.
- xml.url do
- xml.loc url_for(page_url)
- xml.lastmod page.updated_at.to_date
- end if page_url.present?
+ # Add XML entry only if there is a valid page_url found above.
+ xml.url do
+ xml.loc url_for(page_url)
+ xml.lastmod page.updated_at.to_date
+ end if page_url.present? and page.show_in_menu?
+ end
end
end
@@ -6,7 +6,11 @@ def index
respond_to do |format|
format.xml do
- @pages = Page.live.includes(:parts)
+ @locales = if defined?(::Refinery::I18n) && ::Refinery::I18n.enabled?
+ ::Refinery::I18n.frontend_locales
+ else
+ [::I18n.locale]
+ end
end
end
end

0 comments on commit 60501e3

Please sign in to comment.