def render_feed(all_articles, category="", filter_langs=False): """Render the atom newsfeed""" _ = lambda s: s a = all_articles[:settings.get("FEED_LENGTH", len(all_articles))] author = settings.DEFAULTS['AUTHOR'] updated = datetime.utcnow().isoformat()[0:19] + "Z" link = (settings.URL + category).rstrip("/") + "/" title = settings.get("TITLE", "") if category.startswith("tag/"): title = _(u"Tag \u201C%(tag)s\u201D \u2014 %(title)s") % { 'tag': category[4:], 'title': title } elif category.startswith("archive/"): title = _(u"Archive for %(date)s \u2014 %(title)s") % { 'date': category[8:], 'title': title } elif category != "" and category in settings.CATEGORY: title = _(u"Category \u201C%(category)s\u201D \u2014 %(title)s") % { 'category': settings.CATEGORY[category]['title'], 'title': title } id = settings.URL + category nolang = True template_engine.render_template("_templates/feed.mako", category + "/feed.xml", **locals())
def build(my_settings=None): """Build the final website""" if my_settings is not None: settings.extend(**my_settings) fire_hook("build.start") load_plugins() settings.ORIG_BUILD_TARGET = settings.BUILD_TARGET.rstrip("/") settings.BUILD_TARGET = os.path.abspath(settings.BUILD_TARGET) copy_statics() all_articles = get_articles() articles = [a for a in all_articles \ if "noref" not in a.headers.status] articles.sort() template_engine.set_articles(articles) for article in all_articles: article.save(articles=articles) render(articles) for template in get_templates(): template_engine.render_template(template, template.replace(".mako", ".html"), a=articles, articles=articles) if not glob.glob(settings.BUILD_TARGET+"/index.html*") and \ not glob.glob(settings.BUILD_TARGET+"/index.xhtml*"): template_engine.render_paginated("index", "index.html", a=articles, articles=articles) if not os.path.isfile(settings.BUILD_TARGET+"/feed.xml"): render_feed(articles) template_engine.render_sitemap() template_engine.make_index() fire_hook("build.end") return 0
def render_feed(all_articles, category="", filter_langs=False): """Render the atom newsfeed""" _ = lambda s: s a = all_articles[:settings.get("FEED_LENGTH", len(all_articles))] author = settings.DEFAULTS['AUTHOR'] updated = datetime.utcnow().isoformat()[0:19]+"Z" link = (settings.URL+category).rstrip("/") + "/" title = settings.get("TITLE", "") if category.startswith("tag/"): title = _(u"Tag \u201C%(tag)s\u201D \u2014 %(title)s") % { 'tag': category[4:], 'title': title } elif category.startswith("archive/"): title = _(u"Archive for %(date)s \u2014 %(title)s") % { 'date': category[8:], 'title': title } elif category != "" and category in settings.CATEGORY: title = _(u"Category \u201C%(category)s\u201D \u2014 %(title)s") % { 'category': settings.CATEGORY[category]['title'], 'title': title } id = settings.URL + category nolang = True template_engine.render_template("_templates/feed.mako", category+"/feed.xml", **locals())