Commit 3ac3a603 authored by berumuron's avatar berumuron
Browse files

add: Provide Websub hub support

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