From 4759ecd011c2f1a81f9ae9fd73513a152f94d281 Mon Sep 17 00:00:00 2001 From: frascu Date: Thu, 4 Aug 2022 18:13:16 +0200 Subject: [PATCH 1/4] add cookie banner --- assets/css/common/main.css | 46 ++++++++++++ i18n/it.yaml | 12 +++ layouts/partials/head.html | 4 + .../partials/templates/cookie-consent.html | 75 +++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 layouts/partials/templates/cookie-consent.html diff --git a/assets/css/common/main.css b/assets/css/common/main.css index 50022ac1..6aca8a69 100644 --- a/assets/css/common/main.css +++ b/assets/css/common/main.css @@ -66,3 +66,49 @@ div.highlight:hover .copy-code, pre:hover .copy-code { display: block; } + +#cookie-notice { + font-size: medium; + padding: 0.5rem 1rem; + display: none; + text-align: center; + position: fixed; + bottom: 0; + left: 20px; + padding-top: 15; + padding-bottom: 10px; + width: 100%; + background: rgb(70, 70, 70); + color: rgba(255,255,255,0.8); +} + +#cookie-notice a { + font-weight: 600; + display: inline-flex; + cursor: pointer; + margin-left: 0.5rem; +} + +#cookie-notice-accept { + color:rgb(86, 228, 58); +} + +#cookie-notice-deny { + color:rgb(243, 34, 34); +} + +@media (max-width: 767px) { + #cookie-notice span { + display: block; + padding-top: 3px; + margin-bottom: 1rem; + } + #cookie-notice a { + position: relative; + bottom: 4px; + } + #cookie-notice { + left: 0px; + } +} + \ No newline at end of file diff --git a/i18n/it.yaml b/i18n/it.yaml index ef41db4e..b81d85b3 100644 --- a/i18n/it.yaml +++ b/i18n/it.yaml @@ -25,3 +25,15 @@ - id: code_copied translation: "copiato!" + +- id: cookie_approve + translation: "Accetta" + +- id: cookie_deny + translation: "Rifiuta" + +- id: cookie_more_info + translation: "Più Info" + +- id: cookie_message + translation: "Vorrei utilizzare cookie e script di terze parti per migliorare la funzionalità di questo sito web." \ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 35257fc7..b704d95c 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -163,7 +163,11 @@ {{- /* Misc */}} {{- if hugo.IsProduction | or (eq site.Params.env "production") }} +{{- if eq .Site.Params.cookieEnabled true }} +{{- template "partials/templates/cookie-consent.html" . }} +{{- else }} {{- template "_internal/google_analytics.html" . }} +{{- end -}} {{- template "partials/templates/opengraph.html" . }} {{- template "partials/templates/twitter_cards.html" . }} {{- template "partials/templates/schema_json.html" . }} diff --git a/layouts/partials/templates/cookie-consent.html b/layouts/partials/templates/cookie-consent.html new file mode 100644 index 00000000..6d79f3a2 --- /dev/null +++ b/layouts/partials/templates/cookie-consent.html @@ -0,0 +1,75 @@ + + + \ No newline at end of file From 8a6e2954620cfd207d0fee28c21c30b2abb89e63 Mon Sep 17 00:00:00 2001 From: frascu Date: Tue, 6 Sep 2022 10:51:09 +0200 Subject: [PATCH 2/4] add en and it translation for cookie --- i18n/en.yaml | 12 ++++++++++++ i18n/it.yaml | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/i18n/en.yaml b/i18n/en.yaml index 3a1e2151..075d066a 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -31,3 +31,15 @@ - id: code_copied translation: "copied!" + +- id: cookie_approve + translation: "Approve" + +- id: cookie_deny + translation: "Deny" + +- id: cookie_more_info + translation: "More Info" + +- id: cookie_message + translation: "We would like to use third party cookies and scripts to improve the functionality of this website." \ No newline at end of file diff --git a/i18n/it.yaml b/i18n/it.yaml index b81d85b3..3520bb33 100644 --- a/i18n/it.yaml +++ b/i18n/it.yaml @@ -36,4 +36,4 @@ translation: "Più Info" - id: cookie_message - translation: "Vorrei utilizzare cookie e script di terze parti per migliorare la funzionalità di questo sito web." \ No newline at end of file + translation: "Vorremmo utilizzare cookie e script di terze parti per migliorare la funzionalità di questo sito web." \ No newline at end of file From 3c8534f47ada46f02ee1f81b9dbd480a71ec7c89 Mon Sep 17 00:00:00 2001 From: frascu Date: Wed, 7 Sep 2022 10:37:30 +0200 Subject: [PATCH 3/4] rename cookieEnabled to cookieBannerEnabled --- layouts/partials/head.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index b704d95c..661250ca 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -163,7 +163,7 @@ {{- /* Misc */}} {{- if hugo.IsProduction | or (eq site.Params.env "production") }} -{{- if eq .Site.Params.cookieEnabled true }} +{{- if eq .Site.Params.cookieBannerEnabled true }} {{- template "partials/templates/cookie-consent.html" . }} {{- else }} {{- template "_internal/google_analytics.html" . }} From 6e83054b5a9b5a36cd841e668e0b1d8bec44eaed Mon Sep 17 00:00:00 2001 From: frascu Date: Thu, 12 Jan 2023 13:39:08 +0100 Subject: [PATCH 4/4] change cookie message --- i18n/en.yaml | 2 +- i18n/it.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/i18n/en.yaml b/i18n/en.yaml index 075d066a..e86c9811 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -42,4 +42,4 @@ translation: "More Info" - id: cookie_message - translation: "We would like to use third party cookies and scripts to improve the functionality of this website." \ No newline at end of file + translation: "I would like to use third party cookies and scripts to improve the functionalities of this website." \ No newline at end of file diff --git a/i18n/it.yaml b/i18n/it.yaml index 3520bb33..11ac8ced 100644 --- a/i18n/it.yaml +++ b/i18n/it.yaml @@ -36,4 +36,4 @@ translation: "Più Info" - id: cookie_message - translation: "Vorremmo utilizzare cookie e script di terze parti per migliorare la funzionalità di questo sito web." \ No newline at end of file + translation: "Vorrei utilizzare cookie e script di terze parti per migliorare le funzionalità di questo sito web." \ No newline at end of file