Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for responsive adsense banners #56

Merged
merged 10 commits into from
Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ The minimalist [Pelican](http://blog.getpelican.com/) theme.
- [Piwik](http://piwik.org/)
- [StatusCake](https://www.statuscake.com/)

## Adsense banner
Copy link
Owner

@alexandrevicenzi alexandrevicenzi Sep 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Settings are documented on Wiki.


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).
Expand Down
14 changes: 14 additions & 0 deletions templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{% block content %}
<article class="single">
<header>

<h1 id="{{ article.slug }}">{{ article.title }}</h1>
<p>
{{ _('Posted on %(when)s in %(category)s',
Expand All @@ -26,6 +27,19 @@ <h1 id="{{ article.slug }}">{{ article.title }}</h1>
<div>
{{ article.content }}
</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">
<p>
{% if article.tags %}
Expand Down
26 changes: 26 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,34 @@ <h1><a href="{{ SITEURL }}">{{ SITETITLE }}</a></h1>
{% endfor %}
</ul>
</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>
<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 %}
<nav>
<a href="{{ SITEURL }}">{{ _('Home') }}</a>
Expand Down
12 changes: 12 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,17 @@ <h2><a href="{{ SITEURL }}/{{ article.url }}#{{ article.slug }}">{{ article.titl
</article>
{% 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" %}
{% endblock %}
10 changes: 10 additions & 0 deletions tests/pelicanconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,13 @@
ADD_THIS_ID = 'ra-XX3242XX'

USE_LESS = True

ADSENSE = {
'adClientId' : 'ca-pub-XXXXXXXXXXXXXXXX',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variables should user only _ not camelCase mixed

'adSlot' : {
'aside_250x250' : 'YYYYYYYYYY',
'articleBottom_responsible' : 'XXXXXXXXXX',
'top_responsible' : 'XXXXXXXXXX',
'homeBottom_responsible' : 'XXXXXXXXXX'
}
}