From c205163fd7436e2fc42cbe52626425a88c2cbddc Mon Sep 17 00:00:00 2001 From: saagit <55336016+saagit@users.noreply.github.com> Date: Thu, 27 Aug 2020 19:11:25 -0700 Subject: [PATCH] Fix compatibility with Pelican 4.5.0 when PLUGINS is not set in pelicanconf.py Pelican 4.5.0 changed the plugins mechanism and the default for PLUGINS is now None. The following type of construct is used in a number of places in Flex: {% if 'tipue_search' in PLUGINS %} If PLUGINS is not set in pelicanconf.py, the following exception will be triggered under Pelican 4.5.0: TypeError: argument of type 'NoneType' is not iterable The Pelican maintainers did not intend the examination of PLUGINS by templates to be a stable API (per a discussion on IRC). Per their request, an enhancement request for a mechanism to do this has been submitted here: https://github.com/getpelican/pelican/issues/2797 This commit changes the problematic constructs in Flex to be in the style of: {% if PLUGINS and 'tipue_search' in PLUGINS %} This allows Flex to work with Pelican 4.5.0 even if users do not define PLUGINS. Note that to use the new namespace plugins in Pelican 4.5.0, PLUGINS will have to be left at its default of None. Resolves #245 --- templates/article.html | 2 +- templates/base.html | 6 +++--- templates/index.html | 2 +- templates/partial/neighbors.html | 2 +- templates/search.html | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/article.html b/templates/article.html index e4aaddd..44d3fe1 100644 --- a/templates/article.html +++ b/templates/article.html @@ -30,7 +30,7 @@ when=article.locale_date, category='%s'|format(SITEURL, article.category.url, article.category)|safe) }} - {% if 'post_stats' in PLUGINS %} + {% if PLUGINS and 'post_stats' in PLUGINS %} • {{ _('%(minutes)s min read', minutes=article.stats['read_mins']) }} {% endif %}

diff --git a/templates/base.html b/templates/base.html index b3f208f..10c5400 100644 --- a/templates/base.html +++ b/templates/base.html @@ -69,7 +69,7 @@ href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/pygments/{{ PYGMENTS_STYLE|default('github') }}.min.css"> {% endif %} - {% if 'tipue_search' in PLUGINS %} + {% if PLUGINS and 'tipue_search' in PLUGINS %} @@ -156,7 +156,7 @@ {% if SITESUBTITLE %}

{{ SITESUBTITLE }}

{% endif %} - {% if 'tipue_search' in PLUGINS %} + {% if PLUGINS and 'tipue_search' in PLUGINS %} @@ -280,7 +280,7 @@ {% include 'partial/github.html' %} {% endif %} - {% if 'tipue_search' in PLUGINS %} + {% if PLUGINS and 'tipue_search' in PLUGINS %}