def export(self): page_count = len(self.urls) url_str = '\n'.join(unicode(s) for s in self.urls if s) content = util.parseTemplateString(self.SM_CONTENT_TPL, (page_count, url_str)) util.logInfo( 'Sitemap:' ) export_file = self.site.generateDeployFilePath('sitemap.xml', assign=True) with open(export_file, 'w') as fp: fp.write(content) util.logInfo( ' => %s', self.site.getRelativePath(export_file) )
def addUrl(self, loc, lastmod = None, changefreq = 'monthly', priority = '0.5'): if not loc: return lastmod = util.toUTCISO8601( lastmod ) url = util.parseTemplateString(self.SM_UPL_TPL, (loc, lastmod)) self.urls.append(url)