Commit 3ac3a603 authored by Marien Fressinaud's avatar Marien Fressinaud

add: Provide Websub hub support

parent 2655f54f
......@@ -26,6 +26,9 @@ class Atom:
timespec="seconds"
)
if "hub_link" in attributes:
ET.SubElement(self.feed, "link", href=attributes["hub_link"], rel="hub")
def add_entry(self, attributes):
entry = ET.SubElement(self.feed, "entry")
ET.SubElement(entry, "title").text = attributes["title"]
......
......@@ -12,6 +12,7 @@ def load(configuration_path, environment, output_path):
"SITE_TIMEZONE": "UTC",
"SITE_BLOG_SLUG": "blog",
"SITE_ENVIRONMENT": environment.name.lower(),
"SITE_WEBSUB_HUB": "",
}
if os.path.exists(configuration_path):
......
......@@ -8,6 +8,7 @@ class Feed:
self.meta["FEED_SLUG"] = slug
self.meta["FEED_TITLE"] = configuration["SITE_TITLE"]
self.meta["FEED_SITE_LINK"] = configuration["SITE_URL"]
self.meta["FEED_HUB_LINK"] = configuration["SITE_WEBSUB_HUB"]
for key, value in meta.items():
feed_key = f"FEED_{key.upper()}"
self.meta[feed_key] = value
......@@ -26,6 +27,9 @@ class Feed:
def site_link(self):
return self.meta["FEED_SITE_LINK"]
def hub_link(self):
return self.meta["FEED_HUB_LINK"]
def uuid(self):
return str(uuid.uuid5(uuid.NAMESPACE_URL, self.url()))
......
......@@ -121,16 +121,19 @@ def write_feed(feed, output_path):
else:
updated = datetime.datetime.now()
feed_header = {
"title": feed.title(),
"self_link": feed.url(),
"site_link": feed.site_link(),
"id": f"urn:uuid:{feed.uuid()}",
"updated": updated,
}
if feed.hub_link():
feed_header["hub_link"] = feed.hub_link()
atom = Atom()
atom.add_header(
{
"title": feed.title(),
"self_link": feed.url(),
"site_link": feed.site_link(),
"id": f"urn:uuid:{feed.uuid()}",
"updated": updated,
}
)
atom.add_header(feed_header)
for article in articles:
if article.is_private():
......
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