add option for displaying author(s) to Posted line in index and article templates

This commit is contained in:
Rajan Patel 2019-01-07 12:31:34 -05:00
parent 953ede091b
commit 9dbcca35a6
2 changed files with 26 additions and 2 deletions

View file

@ -19,7 +19,19 @@
{% endif %}
<h1 id="{{ article.slug }}">{{ article.title }}</h1>
<p>
{{ _('Posted on %(when)s in %(category)s',
{% if not SHOW_POST_AUTHOR %}
{% set auth_str = '' %}
{% else %}
{% set auth_str = [] %}
{% for auth in article.authors %}
{{ auth_str.append('<a href="%s/%s">%s</a>'|format(SITEURL, auth.url, auth)|safe) or ''}}
{% else %}
{{ auth_str.append('<a href="%s/%s">%s</a>'|format(SITEURL, article.author.url, article.author)|safe) or ''}}
{% endfor %}
{% set auth_str = ' by ' ~ auth_str|join(', ') %}
{% endif %}
{{ _('Posted%(auth_str)s on %(when)s in %(category)s',
auth_str=auth_str,
when=article.locale_date,
category='<a href="%s/%s">%s</a>'|format(SITEURL, article.category.url, article.category)|safe) }}

View file

@ -17,7 +17,19 @@
<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',
{% if not SHOW_POST_AUTHOR %}
{% set auth_str = '' %}
{% else %}
{% set auth_str = [] %}
{% for auth in article.authors %}
{{ auth_str.append('<a href="%s/%s">%s</a>'|format(SITEURL, auth.url, auth)|safe) or ''}}
{% else %}
{{ auth_str.append('<a href="%s/%s">%s</a>'|format(SITEURL, article.author.url, article.author)|safe) or ''}}
{% endfor %}
{% set auth_str = ' by ' ~ auth_str|join(', ') %}
{% endif %}
{{ _('Posted%(auth_str)s on %(when)s in %(category)s',
auth_str=auth_str,
when=article.locale_date,
category='<a href="%s/%s">%s</a>'|format(SITEURL, article.category.url, article.category)|safe) }}