generated sitemaps were invalid according to google web tools

This commit is contained in:
did 2011-03-08 17:20:53 +01:00
parent 78715ddf1e
commit 80f792cfd3
4 changed files with 15 additions and 14 deletions

View File

@ -11,7 +11,6 @@ module Admin
def show def show
@pages = current_site.pages.published @pages = current_site.pages.published
@host = request.host
end end
end end

View File

@ -1,19 +1,20 @@
module Admin::PagesHelper module Admin::PagesHelper
def page_main_url(page, content = nil) def page_main_url(page, options = {})
url = '' if options[:host]
url = "http://#{request.host}"
if page.site.domains.empty? elsif page.site.domains.empty?
url = main_site_url(page.site) url = main_site_url(page.site)
else else
url = "http://#{current_site.domains.first}" url = "http://#{current_site.domains.first}"
url += ":#{request.port}" if request.port != 80
end end
if content.nil? url += ":#{request.port}" if request.port != 80
File.join(url, page.fullpath)
if content = options.delete(:content)
File.join(url, page.fullpath.gsub('content_type_template', ''), content._slug)
else else
File.join(url, page.fullpath.gsub('/content_type_template', ''), content._slug) File.join(url, page.fullpath)
end end
end end

View File

@ -2,7 +2,7 @@ xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
xml.url do xml.url do
xml.loc "http://#{@host}" xml.loc "http://#{request.host}#{":#{request.port}" if request.port != 80}"
xml.priority 1.0 xml.priority 1.0
end 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| page.content_type.contents.visible.each do |c|
xml.url do xml.url do
xml.loc page_main_url(page, c) xml.loc page_main_url(page, { :content => c, :host => true })
xml.lastmod page.updated_at xml.lastmod c.updated_at.to_date.to_s('%Y-%m-%d')
xml.priority 0.9 xml.priority 0.9
end end
end end
else else
xml.url do xml.url do
xml.loc page_main_url(page) xml.loc page_main_url(page, { :host => true })
xml.lastmod page.updated_at xml.lastmod page.updated_at.to_date.to_s('%Y-%m-%d')
xml.priority 0.9 xml.priority 0.9
end end
end end

View File

@ -3,6 +3,7 @@ BOARD:
x pull request #44 x pull request #44
~ editable_elements: inheritable: false (Mattias) => seems to be fixed by Dirk's last pull request (#44) => content tag ~ 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 bug on dates (https://github.com/locomotivecms/engine/issues#issue/48)
x generated sitemaps are invalid (url + date)
- integrate new locomotivecms home - integrate new locomotivecms home
- duostack version - duostack version
- 2 different sites on the same main domain (one in www, the other one in something else) (Raphael Costa) - 2 different sites on the same main domain (one in www, the other one in something else) (Raphael Costa)