diff --git a/README.adoc b/README.adoc index 60acb21..109cd28 100644 --- a/README.adoc +++ b/README.adoc @@ -74,33 +74,96 @@ Here are all configurations about this theme. [[header-covers]] === Header Covers -To define custom header cover, set the property `HEADER_COVER` in +You can set cover images for your blog, article, page, tag, category and author. The cover images can be from your relative path or from internet. + +[[blog-cover]] +==== Blog Cover + +The is the cover image for your site main index.html. + +To set blog cover, set the property `HEADER_COVER` in `pelicanconf.py`: [source,python] ---- -HEADER_COVER = 'static/my_image.png' +HEADER_COVER = '/assets/images/blog_cover.png' ---- -This is site level cover image and it will be used If there is no cover -image set in link:#articles[article] level. +[[article-cover]] +==== Article Cover -[[header-color]] +To set different cover image for an article set `cover` metadata in front-matter. -==== Custom Header Covers +[source,python] +---- +:title: With Cover Images +:date: 2018-04-29 00:45 +:author: arul +:category: foo +:tags: footag +:slug: with-cover-images +:cover: /assets/images/article_cover.jpg +---- -For each page, category page, tag page or author page you can set a custom header cover. -To define it, just set the following properties in `pelicanconf.py` +For more refer link:#articles[article] . -Use the page title as defined in metadata for the pages +[[page-cover]] +==== Page Cover + +To set different cover image for a page set `cover` metadata in front-matter. + +[source,python] +---- +:title: Page With Cover Images +:date: 2018-04-29 00:45 +:author: arul +:category: foo +:tags: footag +:slug: page-with-cover-images +:cover: assets/images/page_cover.jpg +---- + +For more refer link:#articles[article] . + +[[tag-cover]] +==== Tag Cover + +To set cover image for a tag, set the property `HEADER_COVERS_BY_TAG` in +`pelicanconf.py`: [source,python] ---- HEADER_COVERS_BY_TAG = {'food': '/images/food.png', 'drinks':'/images/orange-juice.png'} +---- + +[[category-cover]] +==== Category Cover + +To set cover image for a category, set the property `HEADER_COVERS_BY_CATEGORY` in +`pelicanconf.py`: + +[source,python] +---- HEADER_COVERS_BY_CATEGORY = {'food': '/images/junkie-stuff.png'} ---- +[[author-cover]] +==== Author Cover +To set cover image for an author, set the property `AUTHORS_BIO` in `pelicanconf.py`: + +[source,python] +---- +AUTHORS_BIO = { + "zutrinken": { + "cover": "/assets/images/zutrinken-cover.png" + } +} +---- + +For more refer link:#author-bio[author] . + +[[header-color]] === Header Color To define a simple header background color, set the property @@ -114,6 +177,8 @@ HEADER_COLOR = 'black' you can use any valid css color. This will be used if there is no cover image set in link:#articles[article] level and site level. +This property will be used if there is no cover image set to an article, page, tag, category, author. + [[social-urls]] === Social URLs diff --git a/templates/archives.html b/templates/archives.html index 58bd4b7..439ef12 100644 --- a/templates/archives.html +++ b/templates/archives.html @@ -2,6 +2,16 @@ {% block title %}{{ SITENAME }} - Archives{% endblock %} +{% if HEADER_COVER %} + {% if HEADER_COVER|lower|truncate(4, True, '') == "http" %} + {% set selected_cover = HEADER_COVER %} + {% else %} + {% set selected_cover = SITEURL+"/"+HEADER_COVER %} + {% endif %} +{% elif HEADER_COLOR %} + {% set selected_color = HEADER_COLOR %} +{% endif %} + {% block header %} @@ -22,12 +32,12 @@

{{ SITENAME }} - Archives

- {% if HEADER_COVER %} -
- {% elif HEADER_COLOR %} -
+ {% if selected_cover %} +
+ {% elif selected_color %} +
{% else %} -
+
{% endif %}
diff --git a/templates/article.html b/templates/article.html index 525e582..80e6987 100644 --- a/templates/article.html +++ b/templates/article.html @@ -3,53 +3,53 @@ {# #} {% if article.cover %} - {% if article.cover|lower|truncate(4, True, '') == "http" %} - {% set default_cover = article.cover %} - {% else %} - {% set default_cover = SITEURL+"/"+article.cover %} - {% endif %} + {% if article.cover|lower|truncate(4, True, '') == "http" %} + {% set selected_cover = article.cover %} + {% else %} + {% set selected_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 %} + {% if article.og_image|lower|truncate(4, True, '') == "http" %} + {% set selected_cover = article.og_image %} + {% else %} + {% set selected_cover = SITEURL+"/"+article.og_image %} + {% endif %} {% elif HEADER_COVER %} - {% set default_cover = SITEURL+"/"+HEADER_COVER %} -{% endif %} - -{% if article.color %} - {% set default_color = article.color %} + {% if HEADER_COVER|lower|truncate(4, True, '') == "http" %} + {% set selected_cover = HEADER_COVER %} + {% else %} + {% set selected_cover = SITEURL+"/"+HEADER_COVER %} + {% endif %} {% elif HEADER_COLOR %} - {% set default_color = HEADER_COLOR %} + {% set selected_color = HEADER_COLOR %} {% endif %} {% block head %} - {{ super() }} + {{ super() }} - - {% for keyword in article.keywords %} - - {% endfor %} + + {% for keyword in article.keywords %} + + {% endfor %} - {% if description %} - - {% elif article.headline %} - - {% elif article.summary %} - - {% endif %} + {% if description %} + + {% elif article.headline %} + + {% elif article.summary %} + + {% endif %} - {% for author in article.authors %} - - {% endfor %} + {% for author in article.authors %} + + {% endfor %} - {% for tag in article.tags %} - - {% endfor %} + {% for tag in article.tags %} + + {% endfor %} - {% include 'partials/og_article.html' %} - {% include 'partials/jsonld_article.html' %} + {% include 'partials/og_article.html' %} + {% include 'partials/jsonld_article.html' %} {% endblock %} {% block header %} @@ -95,10 +95,10 @@ {% if article.modified %} {% endif %} - {% if default_cover %} -
- {% elif default_color %} -
+ {% if selected_cover %} +
+ {% elif selected_color %} +
{% else %}
{% endif %} diff --git a/templates/author.html b/templates/author.html index 4a53733..51a9415 100644 --- a/templates/author.html +++ b/templates/author.html @@ -3,21 +3,33 @@ {% set author_name = author.name | title %} {% if AUTHORS_BIO and author.name.lower() in AUTHORS_BIO %} - {% 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 %} + {% set author_avatar = AUTHORS_BIO[author.name.lower()].image %} + {% if author_avatar %} + {% if author_avatar|lower|truncate(4, True, '') == "http" %} + {% set selected_avatar = author_avatar %} + {% else %} + {% set selected_avatar = SITEURL+"/"+author_avatar %} {% endif %} + {% endif %} - {% set author_cover = AUTHORS_BIO[author.name.lower()].cover %} - {% if author_cover %} - {% if author_cover|lower|truncate(4, True, '') != "http" %} - {% set author_cover= SITEURL+"/"+author_cover %} - {% endif %} + {% set author_cover = AUTHORS_BIO[author.name.lower()].cover %} + {% if author_cover %} + {% if author_cover|lower|truncate(4, True, '') == "http" %} + {% set selected_cover = author_cover %} + {% else %} + {% set selected_cover = SITEURL+"/"+author_cover %} {% endif %} + {% endif %} - {% set author_name = AUTHORS_BIO[author.name.lower()].name or author.name %} + {% set author_name = AUTHORS_BIO[author.name.lower()].name or author.name %} +{% elif HEADER_COVER %} + {% if HEADER_COVER|lower|truncate(4, True, '') == "http" %} + {% set selected_cover = HEADER_COVER %} + {% else %} + {% set selected_cover = SITEURL+"/"+HEADER_COVER %} + {% endif %} +{% elif HEADER_COLOR %} + {% set selected_color = HEADER_COLOR %} {% endif %} {% block title %}{{ SITENAME }} - Articles by {{ author_name }}{% endblock %} @@ -50,14 +62,12 @@ Menu - {% if AUTHORS_BIO and author.name.lower() in AUTHORS_BIO and author_cover %} -
- {% elif HEADER_COVER %} -
- {% elif HEADER_COLOR %} -
+ {% if selected_cover %} +
+ {% elif selected_color %} +
{% else %} -
+
{% endif %}
@@ -66,9 +76,9 @@