Skip to content

Commit

Permalink
Fix cookie consent
Browse files Browse the repository at this point in the history
  • Loading branch information
smolnar committed Aug 21, 2024
1 parent b645284 commit dacbcd1
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ruby 3.3.0
node 20.15.0
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ GEM
net-ssh (7.2.1)
nio4r (2.7.0)
nkf (0.2.0)
nokogiri (1.16.3-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.3-x86_64-linux)
Expand Down Expand Up @@ -493,6 +495,7 @@ GEM
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-23
x86_64-darwin-22
x86_64-linux

Expand Down
101 changes: 89 additions & 12 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,98 @@ $(() => {
});

// Cookie consent
window.addEventListener('load', () => {
if (!window.cookieconsent) return;
window.addEventListener('load', function () {
const language = document.documentElement.lang || 'en';

window.cookieconsent.initialise({
palette: {
popup: {
background: '#8392ac',
text: '#fff',
CookieConsent.run({
categories: {
necessary: {
enabled: true,
readOnly: true,
},
analytics: {
enabled: true,
},
},
content: {
message:
'Táto stránka využíva cookies. V prípade, že nesúhlasíte s ukladaním súborov cookies na Vašom zariadení, prosím, opustite túto stránku.',
dismiss: 'Súhlasím',

language: {
default: language,
translations: {
en: {
consentModal: {
title: 'Cookies',
description:
'We use cookies to ensure you get the best experience on our website. Please choose your preferences.',
acceptAllBtn: 'Accept All',
acceptNecessaryBtn: 'Reject All',
showPreferencesBtn: 'Manage Individual Preferences',
},
preferencesModal: {
title: 'Manage Your Cookie Preferences',
acceptAllBtn: 'Accept All',
acceptNecessaryBtn: 'Reject All',
savePreferencesBtn: 'Accept Current Selection',
closeIconLabel: 'Close Modal',
sections: [
{
title: 'Strictly Necessary Cookies',
description:
'These cookies are essential for the proper functioning of the website and cannot be disabled.',

linkedCategory: 'necessary',
},
{
title: 'Performance and Analytics',
description:
'These cookies collect information about how you use our website. All of the data is anonymized and cannot be used to identify you.',
linkedCategory: 'analytics',
},
{
title: 'More information',
description:
'For any queries in relation to our policy on cookies and your choices, please <a href="mailto:[email protected]">contact us</a>',
},
],
},
},

sk: {
consentModal: {
title: 'Cookies',
description:
'Používame cookies, aby sme zaistili, že na našej webovej stránke získate čo najlepší zážitok. Prosím, vyberte si svoje preferencie.',
acceptAllBtn: 'Prijať všetky',
acceptNecessaryBtn: 'Odmietnuť všetky',
showPreferencesBtn: 'Spravovať individuálne preferencie',
},
preferencesModal: {
title: 'Spravujte svoje preferencie cookies',
acceptAllBtn: 'Prijať všetky',
acceptNecessaryBtn: 'Odmietnuť všetky',
savePreferencesBtn: 'Prijať aktuálny výber',
closeIconLabel: 'Zatvoriť okno',
sections: [
{
title: 'Nevyhnutné cookies',
description:
'Tieto cookies sú nevyhnutné pre správne fungovanie webovej stránky a nemožno ich deaktivovať.',
linkedCategory: 'necessary',
},
{
title: 'Výkon a analytika',
description:
'Tieto cookies zhromažďujú informácie o tom, ako používate našu webovú stránku. Všetky údaje sú anonymizované a nemožno ich použiť na vašu identifikáciu.',
linkedCategory: 'analytics',
},
{
title: 'Viac informácií',
description:
'Pre akékoľvek otázky týkajúce sa našej politiky cookies a vašich možností, prosím <a href="mailto:[email protected]">kontaktujte nás</a>',
},
],
},
},
},
},
showLink: false,
});
});
12 changes: 7 additions & 5 deletions app/views/layouts/welcome.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html>
<head lang="<%= I18n.locale %>">
<html lang="<%= I18n.locale %>">
<head>
<meta charset="utf-8" />
<title><%= t('welcome.title') %></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand All @@ -15,20 +15,22 @@
<meta name="msapplication-TileImage" content="<%= asset_path 'icons/tileicon.png' %>" />
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400&amp;subset=latin,latin-ext" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/orestbida/[email protected]/dist/cookieconsent.css">
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
<%= csrf_meta_tags %>

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-8C6J6P0R19"></script>
<script>
<script async data-category="analytics" data-service="Google Analytics" src="https://www.googletagmanager.com/gtag/js?id=G-8C6J6P0R19"></script>
<script data-category="analytics" data-service="Google Analytics">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-8C6J6P0R19');
</script>

<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/orestbida/[email protected]/dist/cookieconsent.umd.js"></script>
</head>
<body>
<%= yield %>
Expand Down

0 comments on commit dacbcd1

Please sign in to comment.