Commit b750c318 authored by berumuron's avatar berumuron
Browse files

tec: Refactor is_private feature

parent 3ac3a603
......@@ -100,7 +100,9 @@ def main(environment):
article_filepath, configuration, serie
articles[article_filepath] = article
if not article.is_private():
if serie:
# If the directory contains a serie, we load a feed for the serie
......@@ -122,13 +124,16 @@ def main(environment):
# Load a "blog" page which has access to the list of articles
blog_template_filepath = os.path.join("templates", "blog.html")
blog_articles = [
article for article in articles.values() if not article.is_private()
if os.path.exists(blog_template_filepath):
blog_page = utils.build_blog_page(articles, series, configuration)
blog_page = utils.build_blog_page(blog_articles, series, configuration)
# And load the main feed
if len(articles) > 0 or configuration.get("SITE_FORCE_FEED", False):
feed = Feed("feeds/all", list(articles.values()), configuration=configuration)
if len(blog_articles) > 0 or configuration.get("SITE_FORCE_FEED", False):
feed = Feed("feeds/all", blog_articles, configuration=configuration)
# STEP 2: we write all the pages, articles and feeds
......@@ -64,7 +64,7 @@ class Article:
return pytz.timezone(site_timezone)
def is_private(self):
return self.meta.get("ARTICLE_PRIVATE", False)
return self.meta.get("ARTICLE_PRIVATE", "false") == "true"
def date(self):
if "ARTICLE_DATE" not in self.meta:
......@@ -52,7 +52,6 @@ def build_page_from_filepath(filepath, configuration, basename=None, slug=None):
def build_blog_page(articles, series, configuration):
articles = [article for article in articles.values() if not article.is_private()]
articles.sort(key=lambda article:, reverse=True)
series.sort(key=lambda serie: serie.title(), reverse=False)
......@@ -136,9 +135,6 @@ def write_feed(feed, output_path):
for article in articles:
if article.is_private():
entry = {
"title": article.title(),
"id": f"urn:uuid:{article.uuid()}",
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