Commit 68d1df83 authored by berumuron's avatar berumuron
Browse files

Load feeds before writing articles and pages

parent d24660d6
...@@ -38,10 +38,11 @@ def main(environment): ...@@ -38,10 +38,11 @@ def main(environment):
configuration_path = os.path.join(os.curdir, "configuration.yml") configuration_path = os.path.join(os.curdir, "configuration.yml")
configuration = config.load(configuration_path, environment, output_path) configuration = config.load(configuration_path, environment, output_path)
# STEP 1: we load all the Articles and Pages # STEP 1: we load all the Articles, Pages and Feeds
pages = [] pages = []
articles = [] articles = []
articles_by_series = {} articles_by_series = {}
feeds = []
# Check that index file exists # Check that index file exists
index_filepath = os.path.join(os.curdir, "index.html") index_filepath = os.path.join(os.curdir, "index.html")
...@@ -100,18 +101,7 @@ def main(environment): ...@@ -100,18 +101,7 @@ def main(environment):
blog_page = utils.build_blog_page(articles, configuration) blog_page = utils.build_blog_page(articles, configuration)
pages.append(blog_page) pages.append(blog_page)
# STEP 2: we write all the pages and articles # And load the feeds
for page in pages:
utils.write_content(page, output_path)
print(f"Written page: {page.url()}")
for article in articles:
utils.write_content(article, output_path)
print(f"Written article: {article.url()}")
# STEP 3: we write also the Atom feeds (the main one + the series').
# We start by collecting the different feeds
feeds = []
if len(articles) > 0: if len(articles) > 0:
# The main one... # The main one...
feed = Feed("feeds/all", articles, configuration=configuration) feed = Feed("feeds/all", articles, configuration=configuration)
...@@ -132,6 +122,15 @@ def main(environment): ...@@ -132,6 +122,15 @@ def main(environment):
) )
feeds.append(feed) feeds.append(feed)
# STEP 2: we write all the pages, articles and feeds
for page in pages:
utils.write_content(page, output_path)
print(f"Written page: {page.url()}")
for article in articles:
utils.write_content(article, output_path)
print(f"Written article: {article.url()}")
if len(feeds) > 0: if len(feeds) > 0:
# If we have collected feeds (i.e. we have at least one article), we # If we have collected feeds (i.e. we have at least one article), we
# write them. # write them.
...@@ -139,7 +138,7 @@ def main(environment): ...@@ -139,7 +138,7 @@ def main(environment):
utils.write_feed(feed, output_path) utils.write_feed(feed, output_path)
print(f"Written feed: {feed.url()}") print(f"Written feed: {feed.url()}")
# STEP 4: and we finish by copying the static folder. # STEP 3: and we finish by copying the static folder.
static_dirpath = os.path.join(os.curdir, "static") static_dirpath = os.path.join(os.curdir, "static")
if os.path.isdir(static_dirpath): if os.path.isdir(static_dirpath):
distutils.dir_util.copy_tree(static_dirpath, output_path) distutils.dir_util.copy_tree(static_dirpath, output_path)
......
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