Commit be06f484 authored by berumuron's avatar berumuron
Browse files

add: Allow to force the feed generation

When there were no articles, the main feed was never generated. We now
allow to force its generation through a configuration variable:
`force_feed`
parent 44e6b25b
......@@ -100,7 +100,7 @@ def main(environment):
pages.append(blog_page)
# And load the main feed
if len(articles) > 0:
if len(articles) > 0 or configuration.get("SITE_FORCE_FEED", False):
feed = Feed("feeds/all", articles, configuration=configuration)
feeds.append(feed)
......
import os
import shutil
import itertools
import datetime
import boop.boopsy as boopsy
from boop.atom import Atom
......@@ -100,6 +101,11 @@ def write_feed(feed, output_path):
# We want to sort the articles by publication date
articles.sort(key=lambda article: article.date(), reverse=True)
if articles:
updated = articles[0].update() or articles[0].date()
else:
updated = datetime.datetime.now()
atom = Atom()
atom.add_header(
{
......@@ -107,7 +113,7 @@ def write_feed(feed, output_path):
"self_link": feed.url(),
"site_link": feed.site_link(),
"id": f"urn:uuid:{feed.uuid()}",
"updated": articles[0].update() or articles[0].date(),
"updated": updated,
}
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment