From 5360d3f5f048022e8a83f4389bbe2e3a9239b8b9 Mon Sep 17 00:00:00 2001 From: Gustavo Furtado de Oliveira Alves Date: Tue, 1 Nov 2016 02:05:22 -0200 Subject: [PATCH] Support for responsive adsense banners (#56) Adsense Banners begin --- README.md | 17 +++++++++++++++++ templates/article.html | 14 ++++++++++++++ templates/base.html | 26 ++++++++++++++++++++++++++ templates/index.html | 12 ++++++++++++ tests/pelicanconf.py | 10 ++++++++++ 5 files changed, 79 insertions(+) diff --git a/README.md b/README.md index 825efd2..421599c 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,23 @@ The minimalist [Pelican](http://blog.getpelican.com/) theme. - [Piwik](http://piwik.org/) - [StatusCake](https://www.statuscake.com/) +## Adsense banner + +The theme supports responsive adsense banners on the top/bottom of articles and index. And a 250x250 banner in aside. +To configure it create a responsive banner and a 250x250 banner on your adsense account and set this on your pelicanconf. + +```javascript +ADSENSE = { + 'adClientId' : '<< YOUR AD CLIENT>>', + 'adSlot' : { + 'aside_250x250' : '<< AD-SLOT FOR THE 250X250 BANNER >>', + 'articleBottom_responsible' : '<< AD-SLOT FOR THE RESPONSIBLE BANNER >>', + 'top_responsible' : '<< AD-SLOT FOR THE RESPONSIBLE BANNER >>', + 'homeBottom_responsible' : '<< AD-SLOT FOR THE RESPONSIBLE BANNER >>' + } +} +``` + ## Install The recommend way to install is over [pelican-themes](https://github.com/getpelican/pelican-themes). diff --git a/templates/article.html b/templates/article.html index 521a1ad..a2e1c7b 100644 --- a/templates/article.html +++ b/templates/article.html @@ -12,6 +12,7 @@ {% block content %}
+

{{ article.title }}

{{ _('Posted on %(when)s in %(category)s', @@ -26,6 +27,19 @@

{{ article.content }}
+ + {% if ADSENSE.adClientId and ADSENSE.adSlot.articleBottom_responsible %} + + + + {% endif %} +

{% if article.tags %} diff --git a/templates/base.html b/templates/base.html index 214ba04..ab033b6 100644 --- a/templates/base.html +++ b/templates/base.html @@ -97,8 +97,34 @@ {% endfor %}

+ + {% if ADSENSE.adClientId and ADSENSE.adSlot.aside_250x250 %} + + + + + {% endif %} +
+ + {% if ADSENSE.adClientId and ADSENSE.adSlot.top_responsible %} + + + + {% endif %} + {% if MAIN_MENU %}
{% endfor %} +{% if ADSENSE.adClientId and ADSENSE.adSlot.homeBottom_responsible %} + + + +{% endif %} + {% include "partial/pagination.html" %} {% endblock %} diff --git a/tests/pelicanconf.py b/tests/pelicanconf.py index 9fa3233..45b4466 100644 --- a/tests/pelicanconf.py +++ b/tests/pelicanconf.py @@ -77,3 +77,13 @@ GOOGLE_ANALYTICS = "UA-XXXXXX-X" ADD_THIS_ID = 'ra-XX3242XX' USE_LESS = True + +ADSENSE = { + 'adClientId' : 'ca-pub-XXXXXXXXXXXXXXXX', + 'adSlot' : { + 'aside_250x250' : 'YYYYYYYYYY', + 'articleBottom_responsible' : 'XXXXXXXXXX', + 'top_responsible' : 'XXXXXXXXXX', + 'homeBottom_responsible' : 'XXXXXXXXXX' + } +}