From 94877e033b37e4d226528af935f45d4119f283d6 Mon Sep 17 00:00:00 2001 From: Brendan Wholihan Date: Thu, 18 Oct 2012 19:55:00 +0100 Subject: [PATCH] So that Authors display and output can be disabled for single user sites, allow the AUTHOR setting to be set to an empty string ''. An author is needed, but was defaults to OS user, or 'John Doe'. If a blank author is provided, it generated authors/.html file, and templates display just "by " Updated generators.py and templates to ignore Authors objects which have a blank name --- pelican/generators.py | 11 ++++++----- pelican/themes/notmyidea/templates/article_infos.html | 2 +- pelican/themes/simple/templates/article.html | 2 +- pelican/themes/simple/templates/index.html | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pelican/generators.py b/pelican/generators.py index 461c8b46..3056d6f7 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -223,11 +223,12 @@ class ArticlesGenerator(Generator): """Generate Author pages.""" author_template = self.get_template('author') for aut, articles in self.authors: - dates = [article for article in self.dates if article in articles] - write(aut.save_as, author_template, self.context, - author=aut, articles=articles, dates=dates, - paginated={'articles': articles, 'dates': dates}, - page_name=u'author/%s' % aut) + if aut.name: # ignore authors with blank names + dates = [article for article in self.dates if article in articles] + write(aut.save_as, author_template, self.context, + author=aut, articles=articles, dates=dates, + paginated={'articles': articles, 'dates': dates}, + page_name=u'author/%s' % aut) def generate_drafts(self, write): """Generate drafts pages.""" diff --git a/pelican/themes/notmyidea/templates/article_infos.html b/pelican/themes/notmyidea/templates/article_infos.html index a1993a09..78326fd1 100644 --- a/pelican/themes/notmyidea/templates/article_infos.html +++ b/pelican/themes/notmyidea/templates/article_infos.html @@ -3,7 +3,7 @@ {{ article.locale_date }} - {% if article.author %} + {% if article.author.name %}
By {{ article.author }}
diff --git a/pelican/themes/simple/templates/article.html b/pelican/themes/simple/templates/article.html index 16c34266..349b3107 100644 --- a/pelican/themes/simple/templates/article.html +++ b/pelican/themes/simple/templates/article.html @@ -10,7 +10,7 @@ {{ article.locale_date }} - {% if article.author %} + {% if article.author.name %}
By {{ article.author }}
diff --git a/pelican/themes/simple/templates/index.html b/pelican/themes/simple/templates/index.html index dfdb0b45..ec278c4b 100644 --- a/pelican/themes/simple/templates/index.html +++ b/pelican/themes/simple/templates/index.html @@ -11,7 +11,7 @@

{{ article.title }}

{{ article.summary }}