Skip to content

Commit

Permalink
AdSense improvments
Browse files Browse the repository at this point in the history
See #47.
  • Loading branch information
alexandrevicenzi committed Nov 8, 2016
1 parent b545f9a commit 6120f6b
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The minimalist [Pelican](http://blog.getpelican.com/) theme.
- [AddThis](http://www.addthis.com/)
- [Disqus](https://disqus.com/)
- [Gauges](http://get.gaug.es/)
- [Google AdSense](https://www.google.com.br/adsense/start/) (new in 2.1)
- [Google Analytics](https://www.google.com/analytics/web/)
- [Google Tag Manager](https://www.google.com/tagmanager/)
- [Piwik](http://piwik.org/)
Expand Down
22 changes: 22 additions & 0 deletions static/stylesheet/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,20 @@ ul.social {
}
}

.ads-aside {
display: inline-block;
height: 90px;
width: 70%;
}

.ads-responsive {
display: inline-block;
margin: 6px 0 6px 0;
width: 90%;
height: 70px;
margin-left: 5%;
}

//
// Desktop
//
Expand Down Expand Up @@ -452,4 +466,12 @@ ul.social {
}
}
}

.ads-aside {
height: 250px;
}

.ads-responsive {
height: 90px;
}
}
2 changes: 1 addition & 1 deletion static/stylesheet/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ <h1 id="{{ article.slug }}">{{ article.title }}</h1>
{% endif %}
</p>
</header>

{% if GOOGLE_ADSENSE and GOOGLE_ADSENSE.ads.article_top %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads-responsive"
data-ad-client="{{ GOOGLE_ADSENSE.ca_id }}"
data-ad-slot="{{ GOOGLE_ADSENSE.ads.article_top }}"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}

<div>
{{ article.content }}
</div>
Expand Down Expand Up @@ -55,6 +66,16 @@ <h4>{{ _('You might enjoy') }}</h4>
</div>
{% endif %}

{% if GOOGLE_ADSENSE and GOOGLE_ADSENSE.ads.article_bottom %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads-responsive"
data-ad-client="{{ GOOGLE_ADSENSE.ca_id }}"
data-ad-slot="{{ GOOGLE_ADSENSE.ads.article_bottom }}"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}

{% include "partial/disqus.html" %}
</article>
{% endblock %}
31 changes: 31 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
{% endblock %}

<title>{{ SITENAME }}{% block title %}{% endblock %}</title>

{% if GOOGLE_ADSENSE and GOOGLE_ADSENSE.page_level_ads %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "{{ GOOGLE_ADSENSE.ca_id }}",
enable_page_level_ads: true
});
</script>
{% endif %}
</head>
<body>
{% if GOOGLE_TAG_MANAGER %}
Expand Down Expand Up @@ -97,8 +107,29 @@ <h1><a href="{{ SITEURL }}">{{ SITETITLE }}</a></h1>
{% endfor %}
</ul>
</div>

{% if GOOGLE_ADSENSE and GOOGLE_ADSENSE.ads.aside %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads-aside"
data-ad-client="{{ GOOGLE_ADSENSE.ca_id }}"
data-ad-slot="{{ GOOGLE_ADSENSE.ads.aside }}"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}

</aside>
<main>
{% if GOOGLE_ADSENSE and GOOGLE_ADSENSE.ads.main_menu %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads-responsive"
data-ad-client="{{ GOOGLE_ADSENSE.ca_id }}"
data-ad-slot="{{ GOOGLE_ADSENSE.ads.main_menu }}"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}

{% if MAIN_MENU %}
<nav>
<a href="{{ SITEURL }}">{{ _('Home') }}</a>
Expand Down
23 changes: 23 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{% extends "base.html" %}

{% block content %}

{% if GOOGLE_ADSENSE and GOOGLE_ADSENSE.ads.index_top %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads-responsive"
data-ad-client="{{ GOOGLE_ADSENSE.ca_id }}"
data-ad-slot="{{ GOOGLE_ADSENSE.ads.index_top }}"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}

{% for article in articles_page.object_list %}
<article>
<header>
Expand Down Expand Up @@ -38,4 +49,16 @@ <h2><a href="{{ SITEURL }}/{{ article.url }}#{{ article.slug }}">{{ article.titl
{% endfor %}

{% include "partial/pagination.html" %}

{% if GOOGLE_ADSENSE and GOOGLE_ADSENSE.ads.index_bottom %}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads-responsive"
data-ad-client="{{ GOOGLE_ADSENSE.ca_id }}"
data-ad-slot="{{ GOOGLE_ADSENSE.ads.index_bottom }}"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{% endif %}


{% endblock %}

0 comments on commit 6120f6b

Please sign in to comment.