diff --git a/app/controllers/admin/sitemaps_controller.rb b/app/controllers/admin/sitemaps_controller.rb index a52abab7..f4df904a 100644 --- a/app/controllers/admin/sitemaps_controller.rb +++ b/app/controllers/admin/sitemaps_controller.rb @@ -11,7 +11,6 @@ module Admin def show @pages = current_site.pages.published - @host = request.host end end diff --git a/app/helpers/admin/pages_helper.rb b/app/helpers/admin/pages_helper.rb index 65fcd88a..934bfedc 100644 --- a/app/helpers/admin/pages_helper.rb +++ b/app/helpers/admin/pages_helper.rb @@ -1,19 +1,20 @@ module Admin::PagesHelper - def page_main_url(page, content = nil) - url = '' - - if page.site.domains.empty? + def page_main_url(page, options = {}) + if options[:host] + url = "http://#{request.host}" + elsif page.site.domains.empty? url = main_site_url(page.site) else url = "http://#{current_site.domains.first}" - url += ":#{request.port}" if request.port != 80 end - if content.nil? - File.join(url, page.fullpath) + url += ":#{request.port}" if request.port != 80 + + if content = options.delete(:content) + File.join(url, page.fullpath.gsub('content_type_template', ''), content._slug) else - File.join(url, page.fullpath.gsub('/content_type_template', ''), content._slug) + File.join(url, page.fullpath) end end diff --git a/app/views/admin/sitemaps/show.xml.builder b/app/views/admin/sitemaps/show.xml.builder index ff6ff199..670d678c 100644 --- a/app/views/admin/sitemaps/show.xml.builder +++ b/app/views/admin/sitemaps/show.xml.builder @@ -2,7 +2,7 @@ xml.instruct! xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do xml.url do - xml.loc "http://#{@host}" + xml.loc "http://#{request.host}#{":#{request.port}" if request.port != 80}" xml.priority 1.0 end @@ -12,15 +12,15 @@ xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do page.content_type.contents.visible.each do |c| xml.url do - xml.loc page_main_url(page, c) - xml.lastmod page.updated_at + xml.loc page_main_url(page, { :content => c, :host => true }) + xml.lastmod c.updated_at.to_date.to_s('%Y-%m-%d') xml.priority 0.9 end end else xml.url do - xml.loc page_main_url(page) - xml.lastmod page.updated_at + xml.loc page_main_url(page, { :host => true }) + xml.lastmod page.updated_at.to_date.to_s('%Y-%m-%d') xml.priority 0.9 end end diff --git a/doc/TODO b/doc/TODO index 5a1f27d8..ede2514b 100644 --- a/doc/TODO +++ b/doc/TODO @@ -3,6 +3,7 @@ BOARD: x pull request #44 ~ editable_elements: inheritable: false (Mattias) => seems to be fixed by Dirk's last pull request (#44) => content tag x bug on dates (https://github.com/locomotivecms/engine/issues#issue/48) +x generated sitemaps are invalid (url + date) - integrate new locomotivecms home - duostack version - 2 different sites on the same main domain (one in www, the other one in something else) (Raphael Costa)