Use haven for GDPR popup instead of cookieconsent

Haven is newer and more well maintained (and also it is actually
open source instead of open core with an upsell to a paid subscrip-
tion). Haven is configured to be 100% *opt-in* for Google Analytics,
which means it does not load or send a hit until the user agrees.

This is mostly a drop-in replacement, but translations need to make
sure the following strings are updated:

- cookieAccept
- cookieDecline
This commit is contained in:
Alan Orth 2020-05-13 13:19:41 +03:00
parent e840f783e7
commit 3b360d2eef
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
18 changed files with 72 additions and 51 deletions

View File

@ -1,6 +0,0 @@
.cc-window{opacity:1;-webkit-transition:opacity 1s ease;transition:opacity 1s ease}.cc-window.cc-invisible{opacity:0}.cc-animate.cc-revoke{-webkit-transition:transform 1s ease;-webkit-transition:-webkit-transform 1s ease;transition:-webkit-transform 1s ease;transition:transform 1s ease;transition:transform 1s ease,-webkit-transform 1s ease}.cc-animate.cc-revoke.cc-top{-webkit-transform:translateY(-2em);transform:translateY(-2em)}.cc-animate.cc-revoke.cc-bottom{-webkit-transform:translateY(2em);transform:translateY(2em)}.cc-animate.cc-revoke.cc-active.cc-top{-webkit-transform:translateY(0);transform:translateY(0)}.cc-animate.cc-revoke.cc-active.cc-bottom{-webkit-transform:translateY(0);transform:translateY(0)}.cc-revoke:hover{-webkit-transform:translateY(0);transform:translateY(0)}.cc-grower{max-height:0;overflow:hidden;-webkit-transition:max-height 1s;transition:max-height 1s}
.cc-revoke,.cc-window{position:fixed;overflow:hidden;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:Helvetica,Calibri,Arial,sans-serif;font-size:16px;line-height:1.5em;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;z-index:9999}.cc-window.cc-static{position:static}.cc-window.cc-floating{padding:2em;max-width:24em;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner{padding:1em 1.8em;width:100%;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.cc-revoke{padding:.5em}.cc-revoke:hover{text-decoration:underline}.cc-header{font-size:18px;font-weight:700}.cc-btn,.cc-close,.cc-link,.cc-revoke{cursor:pointer}.cc-link{opacity:.8;display:inline-block;padding:.2em;text-decoration:underline}.cc-link:hover{opacity:1}.cc-link:active,.cc-link:visited{color:initial}.cc-btn{display:block;padding:.4em .8em;font-size:.9em;font-weight:700;border-width:2px;border-style:solid;text-align:center;white-space:nowrap}.cc-highlight .cc-btn:first-child{background-color:transparent;border-color:transparent}.cc-highlight .cc-btn:first-child:focus,.cc-highlight .cc-btn:first-child:hover{background-color:transparent;text-decoration:underline}.cc-close{display:block;position:absolute;top:.5em;right:.5em;font-size:1.6em;opacity:.9;line-height:.75}.cc-close:focus,.cc-close:hover{opacity:1}
.cc-revoke.cc-top{top:0;left:3em;border-bottom-left-radius:.5em;border-bottom-right-radius:.5em}.cc-revoke.cc-bottom{bottom:0;left:3em;border-top-left-radius:.5em;border-top-right-radius:.5em}.cc-revoke.cc-left{left:3em;right:unset}.cc-revoke.cc-right{right:3em;left:unset}.cc-top{top:1em}.cc-left{left:1em}.cc-right{right:1em}.cc-bottom{bottom:1em}.cc-floating>.cc-link{margin-bottom:1em}.cc-floating .cc-message{display:block;margin-bottom:1em}.cc-window.cc-floating .cc-compliance{-webkit-box-flex:1;-ms-flex:1 0 auto;flex:1 0 auto}.cc-window.cc-banner{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.cc-banner.cc-top{left:0;right:0;top:0}.cc-banner.cc-bottom{left:0;right:0;bottom:0}.cc-banner .cc-message{display:block;-webkit-box-flex:1;-ms-flex:1 1 auto;flex:1 1 auto;max-width:100%;margin-right:1em}.cc-compliance{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:justify;align-content:space-between}.cc-floating .cc-compliance>.cc-btn{-webkit-box-flex:1;-ms-flex:1;flex:1}.cc-btn+.cc-btn{margin-left:.5em}
@media print{.cc-revoke,.cc-window{display:none}}@media screen and (max-width:900px){.cc-btn{white-space:normal}}@media screen and (max-width:414px) and (orientation:portrait),screen and (max-width:736px) and (orientation:landscape){.cc-window.cc-top{top:0}.cc-window.cc-bottom{bottom:0}.cc-window.cc-banner,.cc-window.cc-floating,.cc-window.cc-left,.cc-window.cc-right{left:0;right:0}.cc-window.cc-banner{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner .cc-compliance{-webkit-box-flex:1;-ms-flex:1 1 auto;flex:1 1 auto}.cc-window.cc-floating{max-width:none}.cc-window .cc-message{margin-bottom:1em}.cc-window.cc-banner{-webkit-box-align:unset;-ms-flex-align:unset;align-items:unset}.cc-window.cc-banner .cc-message{margin-right:0}}
.cc-floating.cc-theme-classic{padding:1.2em;border-radius:5px}.cc-floating.cc-type-info.cc-theme-classic .cc-compliance{text-align:center;display:inline;-webkit-box-flex:0;-ms-flex:none;flex:none}.cc-theme-classic .cc-btn{border-radius:5px}.cc-theme-classic .cc-btn:last-child{min-width:140px}.cc-floating.cc-type-info.cc-theme-classic .cc-btn{display:inline-block}
.cc-theme-edgeless.cc-window{padding:0}.cc-floating.cc-theme-edgeless .cc-message{margin:2em;margin-bottom:1.5em}.cc-banner.cc-theme-edgeless .cc-btn{margin:0;padding:.8em 1.8em;height:100%}.cc-banner.cc-theme-edgeless .cc-message{margin-left:1em}.cc-floating.cc-theme-edgeless .cc-btn+.cc-btn{margin-left:0}

File diff suppressed because one or more lines are too long

12
assets/js/haven.umd.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@
- id: cookieLink
translation: ".اعْرَف أَكْثَر"
- id: cookieDismiss
- id: cookieAccept
translation: "!أُوَافِق"
- id: backToTop

View File

@ -28,8 +28,11 @@
- id: cookieLink
translation: "Научете повече."
- id: cookieDismiss
translation: "Разбрах!"
- id: cookieAccept
translation: "Съгласен съм"
- id: cookieDecline
translation: "Не съм съгласен"
- id: backToTop
translation: "Нагоре"

View File

@ -28,8 +28,8 @@
- id: cookieLink
translation: "Weitere Informationen"
- id: cookieDismiss
translation: "OK"
- id: cookieDecline
translation: "Nicht zustimmen"
- id: backToTop
translation: "Zurück zum Anfang"

View File

@ -28,8 +28,11 @@
- id: cookieLink
translation: "Learn more."
- id: cookieDismiss
translation: "Got it!"
- id: cookieAccept
translation: "Agree"
- id: cookieDecline
translation: "Disagree"
- id: backToTop
translation: "Back to top"

View File

@ -28,7 +28,7 @@
- id: cookieLink
translation: "Leer más."
- id: cookieDismiss
- id: cookieAccept
translation: "Comprendido!"
- id: backToTop

View File

@ -28,7 +28,7 @@
- id: cookieLink
translation: ".بیشتر بدانید"
- id: cookieDismiss
- id: cookieAccept
translation: "!متوجه شدم"
- id: backToTop

View File

@ -28,7 +28,7 @@
- id: cookieLink
translation: "En savoir plus."
- id: cookieDismiss
- id: cookieAccept
translation: "J'ai compris !"
- id: backToTop

View File

@ -28,7 +28,7 @@
- id: cookieLink
translation: "Pelajari"
- id: cookieDismiss
- id: cookieAccept
translation: "Paham!"
- id: backToTop

View File

@ -28,7 +28,7 @@
- id: cookieLink
translation: "Lees hier meer"
- id: cookieDismiss
- id: cookieAccept
translation: "OK"
- id: backToTop

View File

@ -28,7 +28,7 @@
- id: cookieLink
translation: "Lær mer."
- id: cookieDismiss
- id: cookieAccept
translation: "Greit!"
- id: backToTop

View File

@ -28,5 +28,5 @@
- id: cookieLink
translation: "Saiba mais."
- id: cookieDismiss
- id: cookieAccept
translation: "Ok!"

View File

@ -28,7 +28,7 @@
- id: cookieLink
translation: "進一步瞭解。"
- id: cookieDismiss
- id: cookieAccept
translation: "知道了!"
- id: backToTop

View File

@ -1,28 +1,38 @@
{{ $cookieConsentStyle := resources.Get "css/cookieconsent.min.css" | resources.Fingerprint }}
<link href="{{ $cookieConsentStyle.Permalink }}" rel="stylesheet" type="text/css"{{ if not .Site.Params.disable_sri }} integrity="{{ $cookieConsentStyle.Data.Integrity }}" crossorigin="anonymous"{{ end }}>
{{ $cookieConsentScript := resources.Get "js/cookieconsent.min.js" | resources.Fingerprint }}
<script src="{{ $cookieConsentScript.Permalink }}"{{ if not .Site.Params.disable_sri }} integrity="{{ $cookieConsentScript.Data.Integrity }}" crossorigin="anonymous"{{ end }} async></script>
{{ $cookieConsentScript := resources.Get "js/haven.umd.min.js" | resources.Fingerprint }}
<script src="{{ $cookieConsentScript.Permalink }}"{{ if not .Site.Params.disable_sri }} integrity="{{ $cookieConsentScript.Data.Integrity }}" crossorigin="anonymous"{{ end }}></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "#428bca",
"text": "#ffffff"
},
"button": {
"background": "#f71559"
}
Haven.create({
notification: {
policyUrl: "{{ .Site.Params.cookie_consent_info_url | absURL }}",
styles: {
background: '#428bca',
textColor: '#ffffff',
buttonBackgroundColor: '#f71559',
buttonTextColor: '#ffffff',
},
},
"content": {
"message": '{{ i18n "cookieMessage" }}',
"dismiss": '{{ i18n "cookieDismiss" }}',
"link": '{{ i18n "cookieLink" }}',
"href": "{{ .Site.Params.cookie_consent_info_url | absURL}}"
translations: {
{{ .Lang }}: {
notification: {
policy: '{{ i18n "cookieLink" }}',
message: '{{ i18n "cookieMessage" }}',
accept: '{{ i18n "cookieAccept" }}',
decline: '{{ i18n "cookieDecline" }}',
}
},
},
"position": "bottom-right"
})});
services: [
{
name: 'google-analytics',
options: {
id: '{{ .Site.Params.googleAnalytics }}',
},
purposes: ['analytics'],
inject: true,
}
]
});
</script>
{{- /* vim: set ts=2 sw=2 et: */}}

12
package-lock.json generated
View File

@ -4,6 +4,12 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@chiiya/haven": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/@chiiya/haven/-/haven-0.6.0.tgz",
"integrity": "sha512-t59swBfV/vxTu3TWedo+2NsniYsuCcLrPRSPs+7NbmMovCZntj+QDjGb+ZIzeYFGVzRfkN8XqRiuwt5/v0X+ng==",
"dev": true
},
"@fortawesome/fontawesome-common-types": {
"version": "0.2.28",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.28.tgz",
@ -1085,12 +1091,6 @@
"integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=",
"dev": true
},
"cookieconsent": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/cookieconsent/-/cookieconsent-3.1.1.tgz",
"integrity": "sha512-v8JWLJcI7Zs9NWrs8hiVldVtm3EBF70TJI231vxn6YToBGj0c9dvdnYwltydkAnrbBMOM/qX1xLFrnTfm5wTag==",
"dev": true
},
"copy-concurrently": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz",

View File

@ -9,7 +9,7 @@
"scripts": {
"build:css": "node-sass --output-style expanded --precision 6 source/scss/style.scss assets/css/style.css.tmp && cleancss --level 1 assets/css/style.css.tmp -o assets/css/style.css",
"build:rtlcss": "rtlcss -s assets/css/style.css.tmp assets/css/style.rtl.css.tmp && cleancss --level 1 assets/css/style.rtl.css.tmp -o assets/css/style.rtl.css",
"build:cookieconsent": "cp node_modules/cookieconsent/build/cookieconsent.min.css assets/css && cp node_modules/cookieconsent/build/cookieconsent.min.js assets/js",
"build:cookieconsent": "cp node_modules/@chiiya/haven/dist/haven.umd.min.js assets/js",
"build:js": "webpack",
"build": "npm run build:css && npm run build:rtlcss && npm run build:js && npm run build:cookieconsent && npm run clean",
"clean": "rm assets/css/style.css.tmp assets/css/style.rtl.css.tmp"
@ -18,12 +18,12 @@
"author": "Alan Orth",
"license": "CC-BY-3.0",
"devDependencies": {
"@chiiya/haven": "^0.6.0",
"@fortawesome/fontawesome-svg-core": "^1.2.28",
"@fortawesome/free-brands-svg-icons": "^5.13.0",
"@fortawesome/free-solid-svg-icons": "^5.13.0",
"bootstrap": "~4.5.0",
"clean-css-cli": "^4.3.0",
"cookieconsent": "^3.1.1",
"node-sass": "^4.14.1",
"rtlcss": "^2.5.0",
"webpack": "^4.43.0",