Commit 88902412 authored by berumuron's avatar berumuron
Browse files

Extract function to add articles to a feed

parent 4ca1ff06
......@@ -180,6 +180,28 @@ def extract_yaml_configuration(content):
return {}, content
def add_articles_to_feed(feed, articles):
"""Add article as standard entries to the feed.
"""
for article in articles:
entry = {
"title": article.title(),
"id": f"urn:uuid:{article.uuid()}",
"article_link": article.url(),
"published": article.date(),
"content": article.content(),
}
article_author = article.author()
if article_author:
entry["author"] = article_author
article_update = article.update()
if article_update:
entry["updated"] = article_update
feed.add_entry(entry)
def build_article_from_filepath(filepath, configuration, serie=None):
"""Read a file and initialize an Article from it.
"""
......@@ -414,25 +436,7 @@ def main(environment):
"updated": current_datetime,
}
)
for article in articles:
# and complete it for each article
entry = {
"title": article.title(),
"id": f"urn:uuid:{article.uuid()}",
"article_link": article.url(),
"published": article.date(),
"content": article.content(),
}
article_author = article.author()
if article_author:
entry["author"] = article_author
article_update = article.update()
if article_update:
entry["updated"] = article_update
feed.add_entry(entry)
add_articles_to_feed(feed, articles)
# And write it on the filesystem
feed_filepath = os.path.join(feed_dirpath, "all.atom.xml")
......@@ -454,25 +458,7 @@ def main(environment):
"updated": current_datetime,
}
)
for article in serie_articles:
# and complete it for each article
entry = {
"title": article.title(),
"id": f"urn:uuid:{article.uuid()}",
"article_link": article.url(),
"published": article.date(),
"content": article.content(),
}
article_author = article.author()
if article_author:
entry["author"] = article_author
article_update = article.update()
if article_update:
entry["updated"] = article_update
feed.add_entry(entry)
add_articles_to_feed(feed, serie_articles)
# And write it on the filesystem
feed.write(feed_filepath)
......
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