Commit b750c318 authored by berumuron's avatar berumuron
Browse files

tec: Refactor is_private feature

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