immosquare-cookies 2.0.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 694f7fd0027c8d40f0d5e70c48c6fed3530b5f30021472b40444eeae546eb657
4
- data.tar.gz: 4e2d753beeb6bb46b6a378afaddcd54b7e2b6973724a0683453756c5f9ec0d2b
3
+ metadata.gz: 9f723d79e7b8c969ce745eea0d42bba0af55779ed76ffba32d65de09b7d625e1
4
+ data.tar.gz: 19839b259634ab1128fe380c5d5c766e8c839c502eae1f17656a072fb616033f
5
5
  SHA512:
6
- metadata.gz: 6b95977905a2fe889033dd0599bd823f3411daef13d6c23aac73443a605c6eae088bac397af971b3077efe1bab16d1063bb96d81f497c0c4490bdb78e7c9a2ef
7
- data.tar.gz: f12933d368965f587a2306695877ffec4f927d3709b20d01a6b26edb35f3a8458bcc5058c5bfedfb565283e25b670ffe91b346d9ebd815bbc0401f3fe7cfcfd4
6
+ metadata.gz: eebb0575d81058002b21c8f6cff7235f623ed1aa4c8b106f15277fa4c45b9244a777c8fd7846c68db12a1c661ccfa3d9b249b6f9aedcb80279c0129de5645af4
7
+ data.tar.gz: f5c1b500dea91531b939799bd93950ece25df803b44375b76d3b5ea5cc4d24bb5985a1bb84fee37ac48c6856bdf72f2fe55f0d1f04c60b844c7a8610bacee98c
@@ -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
- // Since this partial is conditionally rendered server-side, the inline script
41
- // executes immediately each time Turbo inserts it into the DOM.
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.style.display = "none";
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
- cookies.forEach(cookie => {
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 && cookies[cookie_name].blank? %>
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.
@@ -5,5 +5,6 @@ zh-TW:
5
5
  document_name: 隱私權政策
6
6
  document_title: 關於 %{site_name} 的 Cookie
7
7
  link_text: 更多資訊:
8
+ privacy_policy: 隱私權政策
8
9
  refuse: 拒絕
9
10
  text: 歡迎!本網站使用 Cookie 來測量網站流量,以改善其營運和管理,並在您同意的情況下,評估效能並改善您的使用者體驗。我們將您的選擇保存 %{duration_months} 個月。
@@ -5,5 +5,6 @@ zh:
5
5
  document_name: 隐私政策。
6
6
  document_title: 關於 %{site_name} 的 Cookie
7
7
  link_text: 更多信息:
8
+ privacy_policy: 隐私政策。
8
9
  refuse: 拒绝
9
10
  text: 欢迎!本网站使用 cookie 来测量网站流量,以改善其运营和管理,并在您同意的情况下,评估性能并改善您的用户体验。我们将您的选择保存 %{duration_months} 个月。
@@ -1,3 +1,5 @@
1
+ require "rails/engine"
2
+
1
3
  module ImmosquareCookies
2
4
  class Engine < ::Rails::Engine
3
5
 
@@ -1,3 +1,3 @@
1
1
  module ImmosquareCookies
2
- VERSION = "2.0.5".freeze
2
+ VERSION = "2.0.6".freeze
3
3
  end
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.5
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
- description: immosquare Cookies Consent Banner allows Rails developers to effortlessly
13
- integrate a GDPR-compliant cookie consent prompt into their web applications. With
14
- built-in internationalization support and options to customize the banner's appearance
15
- and text, it offers a flexible and user-friendly solution for obtaining user consent.
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
- - !ruby/object:Gem::Version
46
- version: 2.6.0
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
- - !ruby/object:Gem::Version
51
- version: '0'
71
+ -
72
+ - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
52
75
  requirements: []
53
- rubygems_version: 4.0.8
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: []