attila_pelican_theme/templates/article.html
Brandon DeRosier 472f835f9a Implement AUTHOR_BIO "name" and "cover" fields. (#16)
* Implement AUTHOR_BIO "name" and "cover" fields.

In the theme readme, there's are "name" and "cover" fields in the
AUTHOR_BIO example, but these two fields weren't implemented yet.

Instead, the author page was displaying the author entry through
the title Jinja2 filter (which doesn't work so well for surnames like
mine, which contains multiple capital letters ;) ), and the cover
image was being used for the avatar image. This change uses the
"name" and "cover" fields for these, respectfully.

The cover image on the author page will also gracefully fall back
to the site default if an author cover isn't specified as well.

* Correct name author name display in post loop

* Set author name if author bio not set

default author name string will be title and that can be override form auther bio name
2017-12-02 23:15:03 -08:00

228 lines
11 KiB
HTML

{% extends "base.html" %}
{% block title %}{{ article.title }}{% endblock %}
{# <!-- Choosing cover image --> #}
{% if article.cover %}
{% if article.cover|lower|truncate(4, True, '') == "http" %}
{% set default_cover = article.cover %}
{% else %}
{% set default_cover = SITEURL+"/"+article.cover %}
{% endif %}
{% elif article.og_image %}
{% if article.og_image|lower|truncate(4, True, '') == "http" %}
{% set default_cover = article.og_image %}
{% else %}
{% set default_cover = SITEURL+"/"+article.og_image %}
{% endif %}
{% elif HEADER_COVER %}
{% set default_cover = SITEURL+"/"+HEADER_COVER %}
{% endif %}
{% if article.color %}
{% set default_color = article.color %}
{% elif HEADER_COLOR %}
{% set default_color = HEADER_COLOR %}
{% endif %}
{% block head %}
{{ super() }}
<link href="{{ SITEURL }}/{{ article.url }}" rel="canonical" />
{% for keyword in article.keywords %}
<meta name="keywords" content="{{keyword}}" >
{% endfor %}
{% if description %}
<meta name="description" content="{{ description }}">
{% elif article.headline %}
<meta name="description" content="{{ article.headline }}">
{% elif article.summary %}
<meta name="description" content="{{ article.summary|striptags|truncate(140) }}">
{% endif %}
{% for author in article.authors %}
<meta name="author" content="{{ author }}">
{% endfor %}
{% for tag in article.tags %}
<meta name="tags" content="{{tag}}">
{% endfor %}
{% include 'partials/og_article.html' %}
{% include 'partials/jsonld_article.html' %}
{% endblock %}
{% block header %}
<!-- Progressbar -->
<div class="progress-container">
<span class="progress-bar"></span>
</div>
<!-- Page Header -->
<!-- Set your background image for this header on the line below. -->
<header id="post-header" class="has-cover">
<div class="inner">
<nav id="navigation">
{% if SITE_LOGO %}
<span class="blog-logo">
<a href="{{ SITEURL }}/"><img src="{{SITE_LOGO}}" alt="Blog Logo" /></a>
</span>
{% else %}
<span id="home-button" class="nav-button">
<a class="home-button" href="{{ SITEURL }}/" title="Home"><i class="ic ic-arrow-left"></i> Home</a>
</span>
{% endif %}
<span id="menu-button" class="nav-button">
<a class="menu-button"><i class="ic ic-menu"></i> Menu</a>
</span>
</nav>
<h1 class="post-title">{{ article.title }}</h1>
<!-- TODO : Proper class for headline -->
{% if article.headline %}
<span class="blog-description">{{ article.headline }}</h3>
{% endif %}
<span class="post-meta">
{% for author in article.authors %}
{% set author_name = author.name | title %}
{% if AUTHORS_BIO and author.name.lower() in AUTHORS_BIO %}
{% set author_name = AUTHORS_BIO[author.name.lower()].name or author.name %}
{% endif %}
<a href="{{ SITEURL }}/{{ author.url }}">{{ author_name }}</a>
{% endfor %}
| <time datetime="{{ article.locale_date }}">{{ article.locale_date }}</time>
</span>
<!-- TODO : Modified check -->
{% if article.modified %}
<span class="post-meta"> | Updated on {{ article.locale_modified }}</span>
{% endif %}
{% if default_cover %}
<div class="post-cover cover" style="background-image: url('{{ default_cover }}')">
{% elif default_color %}
<div class="post-cover cover" style="background-color: {{ default_color }}">
{% else %}
<div class="post-cover cover" style="background-image: url('{{ SITEURL }}/{{ THEME_STATIC_DIR }}/images/post-bg.jpg')">
{% endif %}
</div>
</header>
{% endblock header %}
{% block content %}
<!-- Post content -->
<main class="content" role="main">
<article class="post">
<div class="inner">
<section class="post-content">
{{article.content}}
</section>
<section class="post-info">
<div class="post-share">
<a class="twitter" href="https://twitter.com/share?text={{ article.title }}&amp;url={{ SITEURL }}/{{ article.url }}" onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
<i class="ic ic-twitter"></i><span class="hidden">Twitter</span>
</a>
<a class="facebook" href="https://www.facebook.com/sharer/sharer.php?u={{ SITEURL }}/{{ article.url }}" onclick="window.open(this.href, 'facebook-share','width=580,height=296');return false;">
<i class="ic ic-facebook"></i><span class="hidden">Facebook</span>
</a>
<a class="googleplus" href="https://plus.google.com/share?url={{ SITEURL }}/{{ article.url }}" onclick="window.open(this.href, 'google-plus-share', 'width=490,height=530');return false;">
<i class="ic ic-googleplus"></i><span class="hidden">Google+</span>
</a>
<div class="clear"></div>
</div>
{% if article.tags %}
<aside class="post-tags">
{% for tag in article.tags %}<a href="{{ SITEURL }}/{{ tag.url }}">{{ tag | escape }}</a>{% if not loop.last %}{% endif %}{% endfor %}
</aside>
{% endif %}
<div class="clear"></div>
{% for author in article.authors %}
{% if AUTHORS_BIO and author.name.lower() in AUTHORS_BIO %}
<aside class="post-author">
{% set author_name = AUTHORS_BIO[author.name.lower()].name or author.name %}
{% set author_avatar = AUTHORS_BIO[author.name.lower()].image %}
{% if author_avatar %}
{% if author_avatar|lower|truncate(4, True, '') != "http" %}
{% set author_avatar = SITEURL+"/"+author_avatar %}
{% endif %}
<figure class="post-author-avatar">
<img src="{{author_avatar}}" alt="{{author_name}}" />
</figure>
{% endif %}
<div class="post-author-bio">
<h4 class="post-author-name"><a href="{{ SITEURL }}/{{author.url}}">{{author_name}}</a></h4>
{% if AUTHORS_BIO[author.name.lower()].bio %}
<p class="post-author-about">{{AUTHORS_BIO[author.name.lower()].bio}}</p>
{% endif %}
{% if AUTHORS_BIO[author.name.lower()].location %}
<span class="post-author-location"><i class="ic ic-location"></i> {{AUTHORS_BIO[author.name.lower()].location}}</span>
{% endif %}
{% if AUTHORS_BIO[author.name.lower()].website %}
<span class="post-author-website"><a href="{{AUTHORS_BIO[author.name.lower()].website}}"><i class="ic ic-link"></i> Website</a></span>
{% endif %}
{% if AUTHORS_BIO[author.name.lower()].twitter %}
<span class="post-author-twitter"><a target="_blank" href="https://twitter.com/{{AUTHORS_BIO[author.name.lower()].twitter}}"><i class="ic ic-twitter"></i> Twitter</a></span>
{% endif %}
{% if AUTHORS_BIO[author.name.lower()].facebook %}
<span class="post-author-facebook"><a target="_blank" href="https://facebook.com/{{AUTHORS_BIO[author.name.lower()].facebook}}"><i class="ic ic-facebook"></i> Facebook</a></span>
{% endif %}
</div>
<div class="clear"></div>
</aside>
{% endif %}
{% endfor %}
</section>
{% if DISQUS_SITENAME and SITEURL and article.status != "draft" %}
<script type="text/javascript">
var disqus = '{{ DISQUS_SITENAME }}';
var disqus_shortname = '{{ DISQUS_SITENAME }}';
{% if article.disqus_identifier %}
var disqus_identifier = '{{ article.disqus_identifier }}';
{% else %}
var disqus_identifier = '/{{ article.url }}';
{% endif %}
var disqus_url = '{{ SITEURL }}/{{ article.url }}';
</script>
<noscript>Please enable JavaScript to view the comments.</noscript>
<section class="post-comments">
{% if article.disqus_identifier %}
<a id="show-disqus" class="post-comments-activate" data-disqus-identifier="{{ article.disqus_identifier }}" >Show Comments</a>
{% else %}
<a id="show-disqus" class="post-comments-activate" data-disqus-identifier="/{{ article.url }}" >Show Comments</a>
{% endif %}
<div id="disqus_thread"></div>
</section>
{% endif %}
<aside class="post-nav">
{% if article.next_article %}
<a class="post-nav-next" href="{{ SITEURL }}/{{ article.next_article.url}}">
<section class="post-nav-teaser">
<i class="ic ic-arrow-left"></i>
<h2 class="post-nav-title">{{ article.next_article.title }}</h2>
<p class="post-nav-excerpt">{{ article.next_article.summary|striptags|truncate(90) }}</p>
</section>
</a>
{% endif %}
{% if article.prev_article %}
<a class="post-nav-prev" href="{{ SITEURL }}/{{ article.prev_article.url}}">
<section class="post-nav-teaser">
<i class="ic ic-arrow-right"></i>
<h2 class="post-nav-title">{{ article.prev_article.title }}</h2>
<p class="post-nav-excerpt">{{ article.prev_article.summary|striptags|truncate(90) }}</p>
</section>
</a>
{% endif %}
<div class="clear"></div>
</aside>
</div>
</article>
</main>
{% endblock content %}