Commit f6743658 authored by berumuron's avatar berumuron
Browse files

Generate update for feeds based on last article

parent 4d969ab9
...@@ -4,9 +4,6 @@ import os ...@@ -4,9 +4,6 @@ import os
import sys import sys
import distutils.dir_util import distutils.dir_util
import locale import locale
import datetime
import pytz
import boop.boopfeed as boopfeed import boop.boopfeed as boopfeed
import boop.environment as environment import boop.environment as environment
...@@ -122,30 +119,27 @@ def main(environment): ...@@ -122,30 +119,27 @@ def main(environment):
site_url = configuration["SITE_URL"] site_url = configuration["SITE_URL"]
site_uuid = configuration["SITE_UUID"] site_uuid = configuration["SITE_UUID"]
site_title = configuration["SITE_TITLE"] site_title = configuration["SITE_TITLE"]
site_timezone = configuration["SITE_TIMEZONE"]
timezone = pytz.timezone(site_timezone)
current_datetime = datetime.datetime.now(tz=timezone)
feed_dirpath = os.path.join(output_path, "feeds") feed_dirpath = os.path.join(output_path, "feeds")
os.mkdir(feed_dirpath) os.mkdir(feed_dirpath)
# Build the main Atom feed if len(articles) > 0:
feed = boopfeed.Atom() # Build the main Atom feed
feed.add_header( feed = boopfeed.Atom()
{ feed.add_header(
"title": site_title, {
"self_link": f"{site_url}feeds/all.atom.xml", "title": site_title,
"site_link": site_url, "self_link": f"{site_url}feeds/{feed_filename}",
"id": f"urn:uuid:{site_uuid}", "site_link": site_url,
"updated": current_datetime, "id": f"urn:uuid:{site_uuid}",
} "updated": articles[0].update() or articles[0].date(),
) }
utils.add_articles_to_feed(feed, articles) )
utils.add_articles_to_feed(feed, articles)
# And write it on the filesystem feed_filepath = os.path.join(feed_dirpath, "all.atom.xml")
feed_filepath = os.path.join(feed_dirpath, "all.atom.xml") feed.write(feed_filepath)
feed.write(feed_filepath) print(f"Written feed: {site_url}feeds/{feed_filename}")
print(f"Written feed: {site_url}feeds/all.atom.xml")
# Now, build the feeds for series (same process) # Now, build the feeds for series (same process)
for serie, serie_articles in articles_by_series.items(): for serie, serie_articles in articles_by_series.items():
...@@ -159,12 +153,11 @@ def main(environment): ...@@ -159,12 +153,11 @@ def main(environment):
"self_link": f"{site_url}feeds/{feed_filename}", "self_link": f"{site_url}feeds/{feed_filename}",
"site_link": serie.url(), "site_link": serie.url(),
"id": f"urn:uuid:{serie.uuid()}", "id": f"urn:uuid:{serie.uuid()}",
"updated": current_datetime, "updated": serie_articles[0].update() or serie_articles[0].date(),
} }
) )
utils.add_articles_to_feed(feed, serie_articles) utils.add_articles_to_feed(feed, serie_articles)
# And write it on the filesystem
feed.write(feed_filepath) feed.write(feed_filepath)
print(f"Written feed: {site_url}feeds/{feed_filename}") print(f"Written feed: {site_url}feeds/{feed_filename}")
......
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