Skip to content

Commit

Permalink
#2 support for relative and absolute urls
Browse files Browse the repository at this point in the history
-in author avatar, custom css and js

color metadata support in article

updated the readme
  • Loading branch information
arulrajnet committed Jun 9, 2017
1 parent 309cc57 commit dc1cf00
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 13 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ To define custom header cover, set the property ``HEADER_COVER`` in ``pelicancon
HEADER_COVER = 'static/my_image.png'
```

This is site level cover image and it will be used If there is no cover image set in [article](#articles) level.

#### Header Color

To define a simple header background color, set the property ``HEADER_COLOR`` in ``pelicanconf.py``:
Expand All @@ -67,7 +69,7 @@ To define a simple header background color, set the property ``HEADER_COLOR`` in
HEADER_COLOR = 'black'
```

you can use any valid css color.
you can use any valid css color. This will be used if there is no cover image set in [article](#articles) level and site level.

#### Social URLs

Expand Down Expand Up @@ -154,12 +156,13 @@ Accept many analytics:

#### Articles

- To customize header cover to articles, insert the metadata ``header_cover``.
- To customize header color to articles, insert the metadata ``color``.
- To customize header cover to articles, insert the metadata ``cover``, otherwise ``og_image`` or ``HEADER_COVER`` will be used.
- To customize OpenGraph images, insert the metadata ``og_image``, otherwise
``cover``, ``HEADER_COVER`` or a default image is used.
``cover``, ``HEADER_COVER`` or a [default image](https://github.com/arulrajnet/attila/blob/master/static/images/post-bg.jpg) from theme will be used.
- To customize Twitter card images, insert the metadata ``twitter_image``,
otherwise ``header_cover``, ``HEADER_COVER`` or a default image is used.
Twitter cards are automatically generated if the ``twitter`` icon is configured
otherwise ``header_cover``, ``HEADER_COVER`` or a default image from theme will be used.
Twitter cards will be generated automatically if the ``twitter`` account is configured
in ``SOCIAL``!

All image paths are relative from the site root directory. You can also use
Expand Down
22 changes: 18 additions & 4 deletions templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
{% 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() }}

Expand Down Expand Up @@ -87,8 +93,8 @@ <h1 class="post-title">{{ article.title }}</h1>
{% endif %}
{% if default_cover %}
<div class="post-cover cover" style="background-image: url('{{ default_cover }}')">
{% elif HEADER_COLOR %}
<div class="post-cover cover" style="background-color: {{ HEADER_COLOR }}">
{% 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 %}
Expand Down Expand Up @@ -131,9 +137,17 @@ <h1 class="post-title">{{ article.title }}</h1>
{% for author in article.authors %}
{% if AUTHORS_BIO and author.name.lower() in AUTHORS_BIO %}
<aside class="post-author">
{% if AUTHORS_BIO[author.name.lower()].image %}
{% set author_avatar = AUTHORS_BIO[author.name.lower()].image %}
{% if author_avatar %}

{% if author_avatar|lower|truncate(4, True, '') == "http" %}
{% set author_avatar = author_avatar %}
{% else %}
{% set author_avatar = SITEURL+"/"+author_avatar %}
{% endif %}

<figure class="post-author-avatar">
<img src="{{AUTHORS_BIO[author.name.lower()].image}}" alt="{{author.name | title}}" />
<img src="{{author_avatar}}" alt="{{author.name | title}}" />
</figure>
{% endif %}
<div class="post-author-bio">
Expand Down
11 changes: 9 additions & 2 deletions templates/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,16 @@
<section id="blog-author" class="has-cover" >
<div class="inner">
<aside class="post-author">
{% if AUTHORS_BIO[author.name.lower()].image %}
{% set author_avatar = AUTHORS_BIO[author.name.lower()].image %}
{% if author_avatar %}

{% if author_avatar|lower|truncate(4, True, '') == "http" %}
{% set author_avatar = author_avatar %}
{% else %}
{% set author_avatar = SITEURL+"/"+author_avatar %}
{% endif %}
<figure class="post-author-avatar">
<img src="{{AUTHORS_BIO[author.name.lower()].image}}" alt="{{author.name | title}}" />
<img src="{{author_avatar}}" alt="{{author.name | title}}" />
</figure>
{% endif %}
<div class="post-author-bio">
Expand Down
16 changes: 14 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@
{% if CSS_OVERRIDE %}
<!-- CSS specified by the user -->
{% for css in CSS_OVERRIDE %}
<link href="{{ SITEURL }}/{{ css }}" type="text/css" rel="stylesheet" />

{% if css|lower|truncate(4, True, '') == "http" %}
{% set css = css %}
{% else %}
{% set css = SITEURL+"/"+css %}
{% endif %}

<link href="{{ css }}" type="text/css" rel="stylesheet" />
{% endfor %}
{% endif %}

Expand Down Expand Up @@ -110,7 +117,12 @@
{% if JS_OVERRIDE %}
<!-- Script specified by the user -->
{% for js in JS_OVERRIDE %}
<script type="text/javascript" src="{{ SITEURL }}/{{ js }}"></script>
{% if js|lower|truncate(4, True, '') == "http" %}
{% set js = js %}
{% else %}
{% set js = SITEURL+"/"+js %}
{% endif %}
<script type="text/javascript" src="{{ js }}"></script>
{% endfor %}
{% endif %}
{% include 'partials/analytics.js' %}
Expand Down

0 comments on commit dc1cf00

Please sign in to comment.