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): ...@@ -100,7 +100,7 @@ def main(environment):
pages.append(blog_page) pages.append(blog_page)
# And load the main feed # 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) feed = Feed("feeds/all", articles, configuration=configuration)
feeds.append(feed) feeds.append(feed)
......
import os import os
import shutil import shutil
import itertools import itertools
import datetime
import boop.boopsy as boopsy import boop.boopsy as boopsy
from boop.atom import Atom from boop.atom import Atom
...@@ -100,6 +101,11 @@ def write_feed(feed, output_path): ...@@ -100,6 +101,11 @@ def write_feed(feed, output_path):
# We want to sort the articles by publication date # We want to sort the articles by publication date
articles.sort(key=lambda article: article.date(), reverse=True) 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 = Atom()
atom.add_header( atom.add_header(
{ {
...@@ -107,7 +113,7 @@ def write_feed(feed, output_path): ...@@ -107,7 +113,7 @@ def write_feed(feed, output_path):
"self_link": feed.url(), "self_link": feed.url(),
"site_link": feed.site_link(), "site_link": feed.site_link(),
"id": f"urn:uuid:{feed.uuid()}", "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