Support for responsive adsense banners (#56)

Adsense Banners begin
This commit is contained in:
Gustavo Furtado de Oliveira Alves 2016-11-01 02:05:22 -02:00 committed by Alexandre Vicenzi
parent b545f9a56e
commit 5360d3f5f0
5 changed files with 79 additions and 0 deletions

View file

@ -25,6 +25,23 @@ The minimalist [Pelican](http://blog.getpelican.com/) theme.
- [Piwik](http://piwik.org/) - [Piwik](http://piwik.org/)
- [StatusCake](https://www.statuscake.com/) - [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 ## Install
The recommend way to install is over [pelican-themes](https://github.com/getpelican/pelican-themes). The recommend way to install is over [pelican-themes](https://github.com/getpelican/pelican-themes).

View file

@ -12,6 +12,7 @@
{% block content %} {% block content %}
<article class="single"> <article class="single">
<header> <header>
<h1 id="{{ article.slug }}">{{ article.title }}</h1> <h1 id="{{ article.slug }}">{{ article.title }}</h1>
<p> <p>
{{ _('Posted on %(when)s in %(category)s', {{ _('Posted on %(when)s in %(category)s',
@ -26,6 +27,19 @@
<div> <div>
{{ article.content }} {{ article.content }}
</div> </div>
{% if ADSENSE.adClientId and ADSENSE.adSlot.articleBottom_responsible %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="{{ ADSENSE.adClientId }}"
data-ad-slot="{{ ADSENSE.adSlot.articleBottom_responsible }}"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}
<div class="tag-cloud"> <div class="tag-cloud">
<p> <p>
{% if article.tags %} {% if article.tags %}

View file

@ -97,8 +97,34 @@
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
{% if ADSENSE.adClientId and ADSENSE.adSlot.aside_250x250 %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- GF - Aside -->
<ins class="adsbygoogle"
style="display:inline-block;width:250px;height:250px"
data-ad-client="{{ ADSENSE.adClientId }}"
data-ad-slot="{{ ADSENSE.adSlot.aside_250x250 }}"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}
</aside> </aside>
<main> <main>
{% if ADSENSE.adClientId and ADSENSE.adSlot.top_responsible %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="{{ ADSENSE.adClientId }}"
data-ad-slot="{{ ADSENSE.adSlot.top_responsible }}"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}
{% if MAIN_MENU %} {% if MAIN_MENU %}
<nav> <nav>
<a href="{{ SITEURL }}">{{ _('Home') }}</a> <a href="{{ SITEURL }}">{{ _('Home') }}</a>

View file

@ -37,5 +37,17 @@
</article> </article>
{% endfor %} {% endfor %}
{% if ADSENSE.adClientId and ADSENSE.adSlot.homeBottom_responsible %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="{{ ADSENSE.adClientId }}"
data-ad-slot="{{ ADSENSE.adSlot.homeBottom_responsible }}"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}
{% include "partial/pagination.html" %} {% include "partial/pagination.html" %}
{% endblock %} {% endblock %}

View file

@ -77,3 +77,13 @@ GOOGLE_ANALYTICS = "UA-XXXXXX-X"
ADD_THIS_ID = 'ra-XX3242XX' ADD_THIS_ID = 'ra-XX3242XX'
USE_LESS = True USE_LESS = True
ADSENSE = {
'adClientId' : 'ca-pub-XXXXXXXXXXXXXXXX',
'adSlot' : {
'aside_250x250' : 'YYYYYYYYYY',
'articleBottom_responsible' : 'XXXXXXXXXX',
'top_responsible' : 'XXXXXXXXXX',
'homeBottom_responsible' : 'XXXXXXXXXX'
}
}