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
@pages = current_site.pages.published
@host = request.host
end
end

View File

@ -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

View File

@ -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

View File

@ -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)