Skip to content

Commit

Permalink
Met à jour cookies-eu-banner
Browse files Browse the repository at this point in the history
Depuis quelques temps, la bannière d’acceptation des cookies ne
fonctionnait plus sur certains navigateurs, dont Google Chrome.

Ceci était dû à un bug de cookie-eu-banner corrigé par ce commit :
Alex-D/Cookies-EU-banner@44eefd6

Ce commit fait également en sorte que cookies-eu-banner soit toujours
lancé quand on n’est pas en production (lorsque `DEBUG == True`). Cela
évitera les surprises.

=== QA ===

Supprimez le cookie `hasConsent` et actualisez. Vous deviez voir la
banière apparaître une seule fois (elle est implicitement acceptée, si
vous voyez ce que je veut dire).
  • Loading branch information
motet-a authored and artragis committed Sep 22, 2017
1 parent 35d5219 commit e3ea93a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"directories": {
"doc": "doc"
},
"engines" : {
"node" : ">=8.0.0"
"engines": {
"node": ">=8.0.0"
},
"scripts": {
"gulp": "gulp",
Expand All @@ -27,7 +27,7 @@
"homepage": "https://github.com/zestedesavoir/zds-site",
"dependencies": {
"autoprefixer": "7.1.2",
"cookies-eu-banner": "1.2.8",
"cookies-eu-banner": "^1.2.10",
"cssnano": "3.10.0",
"del": "3.0.0",
"gulp": "3.9.1",
Expand Down
24 changes: 13 additions & 11 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -677,17 +677,19 @@ <h2 class="subtitle" {% if schema %}itemprop="description"{% endif %}>{{ headlin


{# Google Analytics #}
{% if app.site.googleAnalyticsID and app.site.googleTagManagerID %}
<script>
new CookiesEuBanner(function(){
dataLayer = [{'gaTrackingId': '{{ app.site.googleAnalyticsID }}'}];
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{{ app.site.googleTagManagerID }}');
});
</script>
{% if debug or app.google_analytics_enabled %}
<script>
new CookiesEuBanner(function(){
{% if app.google_analytics_enabled %}
dataLayer = [{'gaTrackingId': '{{ app.site.googleAnalyticsID }}'}];
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{{ app.site.googleTagManagerID }}');
{% endif %}
});
</script>
{% endif %}


Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,9 @@ convert-source-map@1.X, convert-source-map@^1.1.1:
version "1.5.0"
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5"

cookies-eu-banner@1.2.8:
version "1.2.8"
resolved "https://registry.yarnpkg.com/cookies-eu-banner/-/cookies-eu-banner-1.2.8.tgz#f56da63e3d4cfb865fc4d1fb33395a52df33dbd6"
cookies-eu-banner@^1.2.10:
version "1.2.10"
resolved "https://registry.yarnpkg.com/cookies-eu-banner/-/cookies-eu-banner-1.2.10.tgz#4f97a651644b65ec770f57363b93f3f9af078db0"

core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
Expand Down
11 changes: 10 additions & 1 deletion zds/utils/context_processor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# coding: utf-8

from copy import deepcopy

from django.conf import settings

from git import Repo
Expand Down Expand Up @@ -30,4 +32,11 @@ def app_settings(request):
"""
A context processor with all APP settings.
"""
return {'app': settings.ZDS_APP}
app = deepcopy(settings.ZDS_APP)

app['google_analytics_enabled'] = 'googleAnalyticsID' in app['site'] and \
'googleTagManagerID' in app['site']

return {
'app': app,
}

0 comments on commit e3ea93a

Please sign in to comment.