flex/templates/index.html
saagit c205163fd7 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
2020-09-10 08:42:20 -07:00

71 lines
2.3 KiB
HTML

{% extends "base.html" %}
{% block content %}
{% if GOOGLE_ADSENSE and GOOGLE_ADSENSE.ads.index_top %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads-responsive"
data-ad-client="{{ GOOGLE_ADSENSE.ca_id }}"
data-ad-slot="{{ GOOGLE_ADSENSE.ads.index_top }}"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}
{% for article in articles_page.object_list %}
<article>
<header>
<h2><a href="{{ SITEURL }}/{{ article.url }}{% if not DISABLE_URL_HASH %}#{{ article.slug }}{% endif %}">{{ article.title }}</a></h2>
<p>
{{ _('Posted on %(when)s in %(category)s',
when=article.locale_date,
category='<a href="%s/%s">%s</a>'|format(SITEURL, article.category.url, article.category)|safe) }}
{% if article.tags and not HOME_HIDE_TAGS %}
&#8226; {{ _('Tagged with') }}
{% for tag in article.tags %}
<a href="{{ SITEURL }}/{{ tag.url }}">{{ tag }}</a>{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
{% if PLUGINS and 'post_stats' in PLUGINS %}
&#8226; {{ _('%(minutes)s min read', minutes=article.stats['read_mins']) }}
{% endif %}
</p>
</header>
<div>
{% if summarise or article.metadata['summary'] or SUMMARY_MAX_LENGTH %}
{% if article.featured_image %}
<img src="{{ article.featured_image }}">
{% endif %}
{{ article.summary }}
{% if article.content != article.summary %}
<br>
<a class="btn"
href="{{ SITEURL }}/{{ article.url }}{% if not DISABLE_URL_HASH %}#{{ article.slug }}{% endif %}">
{{ _('Continue reading') }}
</a>
{% endif %}
{% else %}
{{ article.content }}
{% endif %}
</div>
{% if not loop.last %}
<hr />
{% endif %}
</article>
{% endfor %}
{% include "partial/pagination.html" %}
{% if GOOGLE_ADSENSE and GOOGLE_ADSENSE.ads.index_bottom %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads-responsive"
data-ad-client="{{ GOOGLE_ADSENSE.ca_id }}"
data-ad-slot="{{ GOOGLE_ADSENSE.ads.index_bottom }}"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}
{% endblock %}