immosquare-cookies 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/immosquare-cookies.scss +5 -8
- data/app/views/immosquare-cookies/_consent_banner.html.erb +37 -7
- data/config/locales/immosquare-cookies.nl.yml +1 -0
- data/config/locales/immosquare-cookies.pl.yml +1 -1
- data/config/locales/immosquare-cookies.zh-TW.yml +1 -0
- data/config/locales/immosquare-cookies.zh.yml +1 -0
- data/lib/immosquare-cookies/engine.rb +2 -0
- data/lib/immosquare-cookies/version.rb +1 -1
- metadata +54 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f723d79e7b8c969ce745eea0d42bba0af55779ed76ffba32d65de09b7d625e1
|
|
4
|
+
data.tar.gz: 19839b259634ab1128fe380c5d5c766e8c839c502eae1f17656a072fb616033f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eebb0575d81058002b21c8f6cff7235f623ed1aa4c8b106f15277fa4c45b9244a777c8fd7846c68db12a1c661ccfa3d9b249b6f9aedcb80279c0129de5645af4
|
|
7
|
+
data.tar.gz: f5c1b500dea91531b939799bd93950ece25df803b44375b76d3b5ea5cc4d24bb5985a1bb84fee37ac48c6856bdf72f2fe55f0d1f04c60b844c7a8610bacee98c
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
@use "sass:color";
|
|
2
|
-
|
|
3
1
|
#immosquare-cookies-container {
|
|
4
2
|
--immosquare-cookies-color: #004b99;
|
|
3
|
+
--immosquare-cookies-color-hover: color-mix(in srgb, var(--immosquare-cookies-color), black 10%);
|
|
5
4
|
--immosquare-cookies-bg: #f8f9fa;
|
|
6
5
|
--immosquare-cookies-border: #dee2e6;
|
|
7
6
|
--immosquare-cookies-text: #6c757d;
|
|
8
|
-
--immosquare-cookies-primary: #0d6efd;
|
|
9
|
-
--immosquare-cookies-secondary: #6c757d;
|
|
10
7
|
--immosquare-cookies-btn-color: white;
|
|
11
8
|
}
|
|
12
9
|
|
|
@@ -58,7 +55,7 @@
|
|
|
58
55
|
font-weight: 700;
|
|
59
56
|
|
|
60
57
|
&:hover {
|
|
61
|
-
color:
|
|
58
|
+
color: var(--immosquare-cookies-color-hover);
|
|
62
59
|
text-decoration: underline;
|
|
63
60
|
}
|
|
64
61
|
}
|
|
@@ -91,15 +88,15 @@
|
|
|
91
88
|
box-shadow 0.15s ease-in-out;
|
|
92
89
|
|
|
93
90
|
&:hover {
|
|
94
|
-
background-color:
|
|
95
|
-
border-color:
|
|
91
|
+
background-color: var(--immosquare-cookies-color-hover);
|
|
92
|
+
border-color: var(--immosquare-cookies-color-hover);
|
|
96
93
|
color: var(--immosquare-cookies-btn-color);
|
|
97
94
|
text-decoration: none;
|
|
98
95
|
}
|
|
99
96
|
|
|
100
97
|
&:focus {
|
|
101
98
|
outline: 0;
|
|
102
|
-
box-shadow: 0 0 0 0.2rem
|
|
99
|
+
box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--immosquare-cookies-color), transparent 75%);
|
|
103
100
|
}
|
|
104
101
|
}
|
|
105
102
|
|
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
cookie_name = defined?(key) ? key : "_immosquare_consented"
|
|
3
3
|
duration_months = defined?(duration_months) && duration_months.to_i.between?(1, 12) ? duration_months.to_i : 6
|
|
4
4
|
cookies_to_remove = [] if !defined?(cookies_to_remove)
|
|
5
|
+
##============================================================##
|
|
6
|
+
## The banner is always rendered, hidden once a choice is stored, so
|
|
7
|
+
## that a "Manage cookies" link can reopen it: any link to
|
|
8
|
+
## `#immosquare-cookies` shows it again.
|
|
9
|
+
##============================================================##
|
|
10
|
+
consent_stored = cookies.present? && cookies[cookie_name].present?
|
|
5
11
|
%>
|
|
6
12
|
|
|
7
|
-
<%= content_tag(:div, :id => "immosquare-cookies-container", :data => {
|
|
13
|
+
<%= content_tag(:div, :id => "immosquare-cookies-container", :hidden => consent_stored, :data => {
|
|
8
14
|
:name => cookie_name,
|
|
9
15
|
:duration_months => duration_months,
|
|
10
16
|
:cookies_to_remove => cookies_to_remove
|
|
@@ -37,18 +43,17 @@ cookies_to_remove = [] if !defined?(cookies_to_remove)
|
|
|
37
43
|
<script>
|
|
38
44
|
// Using an IIFE instead of DOMContentLoaded for Turbo Drive compatibility.
|
|
39
45
|
// Turbo replaces the <body> on navigation without firing DOMContentLoaded again.
|
|
40
|
-
//
|
|
41
|
-
// executes
|
|
46
|
+
// The partial is rendered on every page (hidden once consent is stored), so the
|
|
47
|
+
// inline script executes each time Turbo inserts it into the DOM.
|
|
42
48
|
(() => {
|
|
43
49
|
const cookieContainer = document.getElementById("immosquare-cookies-container");
|
|
44
50
|
const cookieName = cookieContainer.dataset.name;
|
|
45
51
|
const cookieDurationMonths = cookieContainer.dataset.durationMonths;
|
|
46
52
|
const cookiesToRemove = cookieContainer.dataset.cookiesToRemove ? JSON.parse(cookieContainer.dataset.cookiesToRemove) : [];
|
|
47
|
-
const cookies = document.cookie.split(";");
|
|
48
53
|
|
|
49
54
|
// Handle the cookie consent
|
|
50
55
|
const handleCookieConsent = (consentGiven) => {
|
|
51
|
-
cookieContainer.
|
|
56
|
+
cookieContainer.hidden = true;
|
|
52
57
|
const expiresString = new Date(Date.now() + cookieDurationMonths * 30 * 24 * 60 * 60 * 1000).toUTCString();
|
|
53
58
|
|
|
54
59
|
// Set the cookie for the consent banner
|
|
@@ -61,8 +66,10 @@ cookies_to_remove = [] if !defined?(cookies_to_remove)
|
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
// Disable the cookies that are not necessary if the user does not consent
|
|
69
|
+
// Read at refusal time: cookies set after page load (e.g. _ga after an
|
|
70
|
+
// earlier acceptance, before the banner is reopened) must be removed too.
|
|
64
71
|
if(!consentGiven && cookiesToRemove && cookiesToRemove.length > 0){
|
|
65
|
-
|
|
72
|
+
document.cookie.split(";").forEach(cookie => {
|
|
66
73
|
const cookieParts = cookie.split("=");
|
|
67
74
|
const currentCookieName = cookieParts[0].trim();
|
|
68
75
|
const currentCookieValue = cookieParts[1] ? cookieParts[1].trim() : '';
|
|
@@ -97,6 +104,29 @@ cookies_to_remove = [] if !defined?(cookies_to_remove)
|
|
|
97
104
|
|
|
98
105
|
document.getElementById("immosquare-cookies-refuse").addEventListener("click", function() { handleCookieConsent(false); });
|
|
99
106
|
document.getElementById("immosquare-cookies-accept").addEventListener("click", function() { handleCookieConsent(true); });
|
|
107
|
+
|
|
108
|
+
// Reopen the banner from any link to #immosquare-cookies ("Manage cookies").
|
|
109
|
+
// The listener lives on document, which Turbo keeps across navigations:
|
|
110
|
+
// registered once, it looks the container up again on each click.
|
|
111
|
+
if (!window.immosquareCookiesManageListener) {
|
|
112
|
+
window.immosquareCookiesManageListener = true;
|
|
113
|
+
document.addEventListener("click", (event) => {
|
|
114
|
+
const link = event.target.closest("a[href$='#immosquare-cookies']");
|
|
115
|
+
const container = document.getElementById("immosquare-cookies-container");
|
|
116
|
+
if (!link || !container) return;
|
|
117
|
+
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
container.hidden = false;
|
|
120
|
+
document.getElementById("immosquare-cookies-accept")?.focus();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// A banner reopened then left without a choice must not come back open
|
|
124
|
+
// from the browser back-forward cache while a choice is stored.
|
|
125
|
+
window.addEventListener("pagehide", () => {
|
|
126
|
+
const container = document.getElementById("immosquare-cookies-container");
|
|
127
|
+
if (container && document.cookie.split(";").some((cookie) => cookie.trim().startsWith(`${container.dataset.name}=`))) container.hidden = true;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
100
130
|
})();
|
|
101
131
|
</script>
|
|
102
|
-
<% end if cookies
|
|
132
|
+
<% end if cookies %>
|
|
@@ -5,5 +5,6 @@ nl:
|
|
|
5
5
|
document_name: Privacybeleid.
|
|
6
6
|
document_title: Over cookies op %{site_name}
|
|
7
7
|
link_text: "Meer informatie:"
|
|
8
|
+
privacy_policy: Privacybeleid.
|
|
8
9
|
refuse: Weigeren
|
|
9
10
|
text: Welkom! Deze site gebruikt cookies om het siteverkeer te meten om de werking en het beheer ervan te verbeteren en, met uw toestemming, om de prestaties te evalueren en uw gebruikerservaring te verbeteren. We bewaren uw keuze gedurende %{duration_months} maanden.
|
|
@@ -7,4 +7,4 @@ pl:
|
|
|
7
7
|
link_text: "Więcej informacji:"
|
|
8
8
|
privacy_policy: Polityka prywatności.
|
|
9
9
|
refuse: Odrzuć
|
|
10
|
-
text: Witamy! Ta strona wykorzystuje pliki cookie do pomiaru ruchu w celu poprawy jej działania i zarządzania oraz, za Twoją zgodą, do analizy wydajności i ulepszania korzystania z serwisu. Twój wybór przechowujemy przez %{duration_months} miesięcy.
|
|
10
|
+
text: Witamy! Ta strona wykorzystuje pliki cookie do pomiaru ruchu w celu poprawy jej działania i zarządzania oraz, za Twoją zgodą, do analizy wydajności i ulepszania korzystania z serwisu. Twój wybór przechowujemy przez %{duration_months} miesięcy.
|
metadata
CHANGED
|
@@ -1,56 +1,79 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: immosquare-cookies
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- immosquare
|
|
7
|
+
- immosquare
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
-
dependencies:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: railties
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: "6.0"
|
|
20
|
+
-
|
|
21
|
+
- "<"
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: "1000.0"
|
|
24
|
+
type: :runtime
|
|
25
|
+
prerelease: false
|
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
27
|
+
requirements:
|
|
28
|
+
-
|
|
29
|
+
- ">="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: "6.0"
|
|
32
|
+
-
|
|
33
|
+
- "<"
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: "1000.0"
|
|
36
|
+
description: "immosquare Cookies Consent Banner allows Rails developers to effortlessly integrate a GDPR-compliant cookie consent prompt into their web applications. With built-in internationalization support and options to customize the banner's appearance and text, it offers a flexible and user-friendly solution for obtaining user consent."
|
|
16
37
|
email:
|
|
17
|
-
- jules@immosquare.com
|
|
38
|
+
- jules@immosquare.com
|
|
18
39
|
executables: []
|
|
19
40
|
extensions: []
|
|
20
41
|
extra_rdoc_files: []
|
|
21
42
|
files:
|
|
22
|
-
- app/assets/stylesheets/immosquare-cookies.scss
|
|
23
|
-
- app/views/immosquare-cookies/_consent_banner.html.erb
|
|
24
|
-
- config/locales/immosquare-cookies.en.yml
|
|
25
|
-
- config/locales/immosquare-cookies.es.yml
|
|
26
|
-
- config/locales/immosquare-cookies.fr.yml
|
|
27
|
-
- config/locales/immosquare-cookies.it.yml
|
|
28
|
-
- config/locales/immosquare-cookies.nl.yml
|
|
29
|
-
- config/locales/immosquare-cookies.pl.yml
|
|
30
|
-
- config/locales/immosquare-cookies.zh-TW.yml
|
|
31
|
-
- config/locales/immosquare-cookies.zh.yml
|
|
32
|
-
- lib/immosquare-cookies.rb
|
|
33
|
-
- lib/immosquare-cookies/engine.rb
|
|
34
|
-
- lib/immosquare-cookies/version.rb
|
|
35
|
-
homepage: https://github.com/immosquare/immosquare-cookies
|
|
43
|
+
- app/assets/stylesheets/immosquare-cookies.scss
|
|
44
|
+
- app/views/immosquare-cookies/_consent_banner.html.erb
|
|
45
|
+
- config/locales/immosquare-cookies.en.yml
|
|
46
|
+
- config/locales/immosquare-cookies.es.yml
|
|
47
|
+
- config/locales/immosquare-cookies.fr.yml
|
|
48
|
+
- config/locales/immosquare-cookies.it.yml
|
|
49
|
+
- config/locales/immosquare-cookies.nl.yml
|
|
50
|
+
- config/locales/immosquare-cookies.pl.yml
|
|
51
|
+
- config/locales/immosquare-cookies.zh-TW.yml
|
|
52
|
+
- config/locales/immosquare-cookies.zh.yml
|
|
53
|
+
- lib/immosquare-cookies.rb
|
|
54
|
+
- lib/immosquare-cookies/engine.rb
|
|
55
|
+
- lib/immosquare-cookies/version.rb
|
|
56
|
+
homepage: "https://github.com/immosquare/immosquare-cookies"
|
|
36
57
|
licenses:
|
|
37
|
-
- MIT
|
|
58
|
+
- MIT
|
|
38
59
|
metadata: {}
|
|
39
60
|
rdoc_options: []
|
|
40
61
|
require_paths:
|
|
41
|
-
- lib
|
|
62
|
+
- lib
|
|
42
63
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
64
|
requirements:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
-
|
|
66
|
+
- ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 3.2.6
|
|
47
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
70
|
requirements:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
71
|
+
-
|
|
72
|
+
- ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: "0"
|
|
52
75
|
requirements: []
|
|
53
|
-
rubygems_version: 4.
|
|
76
|
+
rubygems_version: 4.1.1
|
|
54
77
|
specification_version: 4
|
|
55
78
|
summary: A customizable cookie consent banner for Rails applications.
|
|
56
79
|
test_files: []
|