Fix Sitemap generation for non-file urls.
Fixes getpelican/pelican-plugins#168.
This commit is contained in:
@@ -128,7 +128,7 @@ class SitemapGenerator(object):
|
|||||||
if getattr(page, 'status', 'published') != 'published':
|
if getattr(page, 'status', 'published') != 'published':
|
||||||
return
|
return
|
||||||
|
|
||||||
page_path = os.path.join(self.output_path, page.url)
|
page_path = os.path.join(self.output_path, page.save_as)
|
||||||
if not os.path.exists(page_path):
|
if not os.path.exists(page_path):
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ class SitemapGenerator(object):
|
|||||||
try:
|
try:
|
||||||
lastdate = self.get_date_modified(page, lastdate)
|
lastdate = self.get_date_modified(page, lastdate)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
warning("sitemap plugin: " + page.url + " has invalid modification date,")
|
warning("sitemap plugin: " + page.save_as + " has invalid modification date,")
|
||||||
warning("sitemap plugin: using date value as lastmod.")
|
warning("sitemap plugin: using date value as lastmod.")
|
||||||
lastmod = format_date(lastdate)
|
lastmod = format_date(lastdate)
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ class SitemapGenerator(object):
|
|||||||
if self.format == 'xml':
|
if self.format == 'xml':
|
||||||
fd.write(XML_URL.format(self.siteurl, page.url, lastmod, chfreq, pri))
|
fd.write(XML_URL.format(self.siteurl, page.url, lastmod, chfreq, pri))
|
||||||
else:
|
else:
|
||||||
fd.write(self.siteurl + '/' + loc + '\n')
|
fd.write(self.siteurl + '/' + page.url + '\n')
|
||||||
|
|
||||||
def get_date_modified(self, page, default):
|
def get_date_modified(self, page, default):
|
||||||
if hasattr(page, 'modified'):
|
if hasattr(page, 'modified'):
|
||||||
@@ -188,7 +188,7 @@ class SitemapGenerator(object):
|
|||||||
self.set_url_wrappers_modification_date(self.context['categories'])
|
self.set_url_wrappers_modification_date(self.context['categories'])
|
||||||
self.set_url_wrappers_modification_date(self.context['tags'])
|
self.set_url_wrappers_modification_date(self.context['tags'])
|
||||||
self.set_url_wrappers_modification_date(self.context['authors'])
|
self.set_url_wrappers_modification_date(self.context['authors'])
|
||||||
|
|
||||||
for article in self.context['articles']:
|
for article in self.context['articles']:
|
||||||
pages += article.translations
|
pages += article.translations
|
||||||
|
|
||||||
@@ -204,7 +204,8 @@ class SitemapGenerator(object):
|
|||||||
FakePage = collections.namedtuple('FakePage',
|
FakePage = collections.namedtuple('FakePage',
|
||||||
['status',
|
['status',
|
||||||
'date',
|
'date',
|
||||||
'url'])
|
'url',
|
||||||
|
'save_as'])
|
||||||
|
|
||||||
for standard_page_url in ['index.html',
|
for standard_page_url in ['index.html',
|
||||||
'archives.html',
|
'archives.html',
|
||||||
@@ -212,7 +213,8 @@ class SitemapGenerator(object):
|
|||||||
'categories.html']:
|
'categories.html']:
|
||||||
fake = FakePage(status='published',
|
fake = FakePage(status='published',
|
||||||
date=self.now,
|
date=self.now,
|
||||||
url=standard_page_url)
|
url=standard_page_url,
|
||||||
|
save_as=standard_page_url)
|
||||||
self.write_url(fake, fd)
|
self.write_url(fake, fd)
|
||||||
|
|
||||||
for page in pages:
|
for page in pages:
|
||||||
|
|||||||
Reference in New Issue
Block a user