mirror of
https://github.com/infinum/cookies_eu
synced 2023-03-27 23:21:16 -04:00
Compare commits
26 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3a0ad36b51 | ||
![]() |
82167b3e3d | ||
![]() |
3f91806082 | ||
![]() |
e00e4d39fa | ||
![]() |
cf95a398b7 | ||
![]() |
1827842c03 | ||
![]() |
9e27ef7295 | ||
![]() |
bae2eee30c | ||
![]() |
dc0cc6a0c3 | ||
![]() |
adb8404543 | ||
![]() |
b9b2d20d1b | ||
![]() |
315680a5c7 | ||
![]() |
f46c4ab522 | ||
![]() |
89da8f2c00 | ||
![]() |
644044a8dd | ||
![]() |
c3cec6f75a | ||
![]() |
c26aa6b42d | ||
![]() |
0ab13f6288 | ||
![]() |
70c94cd900 | ||
![]() |
d84fcd4d33 | ||
![]() |
e20a447932 | ||
![]() |
2662ccbc11 | ||
![]() |
a12a7ad110 | ||
![]() |
d6431c065d | ||
![]() |
96bd3d0ab6 | ||
![]() |
3df0f54624 |
12 changed files with 75 additions and 15 deletions
22
README.md
22
README.md
|
@ -7,6 +7,9 @@ Gem to add cookie consent to rails application
|
|||
## Supported languages
|
||||
|
||||
* Albanian
|
||||
* Basque
|
||||
* Bulgarian
|
||||
* Catalan
|
||||
* Croatian
|
||||
* Czech
|
||||
* Danish
|
||||
|
@ -17,8 +20,10 @@ Gem to add cookie consent to rails application
|
|||
* French
|
||||
* German
|
||||
* Greek
|
||||
* Hebrew
|
||||
* Hungarian
|
||||
* Italian
|
||||
* Lithuanian
|
||||
* Norwegian
|
||||
* Polish
|
||||
* Portuguese
|
||||
|
@ -27,8 +32,13 @@ Gem to add cookie consent to rails application
|
|||
* Slovenian
|
||||
* Spanish
|
||||
* Swedish
|
||||
* Turkish
|
||||
* Ukrainian
|
||||
|
||||
## Screenshot
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
Add this line to your application's Gemfile:
|
||||
|
@ -89,6 +99,18 @@ If you wish to customize the style of the div the classes are:
|
|||
.cookies-eu-link /* link */
|
||||
```
|
||||
|
||||
If you wish to customize the HTML, create a folder `cookies_eu`, create a partial `_consent_banner.html.erb` and paste the HTML from [here](app/views/cookies_eu/_consent_banner.html.erb)
|
||||
|
||||
If you wish to run some arbitrary code when the user acknowledges the cookie message, you can register a callback. This is useful if you wish to persist the user's preference to the database.
|
||||
|
||||
```javascript
|
||||
document.addEventListener('cookies-eu-acknowledged', function() {
|
||||
// The user has acknowledged cookies! If they're logged in, make an api call
|
||||
// so we remember their preference.
|
||||
fetch('...');
|
||||
});
|
||||
```
|
||||
|
||||
## Cookies used
|
||||
|
||||
This gem uses a cookie called **cookie_eu_consented** to track whether a user has accepted the cookie notice and whether it needs to be shown again or not.
|
||||
|
|
|
@ -24,10 +24,13 @@ var cookiesEu = {
|
|||
},
|
||||
|
||||
setCookie: function() {
|
||||
Cookies.set('cookie_eu_consented', true, { path: '/', expires: 365 });
|
||||
var isSecure = location.protocol === 'https:';
|
||||
Cookies.set('cookie_eu_consented', true, { path: '/', expires: 365, secure: isSecure });
|
||||
|
||||
var container = document.querySelector('.js-cookies-eu');
|
||||
container.parentNode.removeChild(container);
|
||||
|
||||
document.dispatchEvent(new CustomEvent('cookies-eu-acknowledged'));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
<% if cookies && cookies['cookie_eu_consented'] != 'true' %>
|
||||
<div class="cookies-eu js-cookies-eu">
|
||||
<span class="cookies-eu-content-holder"><%= t('cookies_eu.cookies_text') %></span>
|
||||
<span class="cookies-eu-button-holder">
|
||||
<button class="cookies-eu-ok js-cookies-eu-ok"> <%= t('cookies_eu.ok') %> </button>
|
||||
<% if defined?(link).present? %>
|
||||
<a href="<%= link %>" class="cookies-eu-link" target="<%= defined?(target).present? ? target : '' %>"> <%= t('cookies_eu.learn_more') %> </a>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
<% if cookies.kind_of? ActionDispatch::Cookies::CookieJar %>
|
||||
<% if cookies && cookies['cookie_eu_consented'] != 'true' %>
|
||||
<div class="cookies-eu js-cookies-eu" <%= "dir=rtl" if I18n.exists?('cookies_eu.direction', I18n.locale) && I18n.t("cookies_eu.direction") == "rtl" %>>
|
||||
<span class="cookies-eu-content-holder"><%= t('cookies_eu.cookies_text') %></span>
|
||||
<span class="cookies-eu-button-holder">
|
||||
<button class="cookies-eu-ok js-cookies-eu-ok"> <%= t('cookies_eu.ok') %> </button>
|
||||
<% if defined?(link).present? %>
|
||||
<a href="<%= link %>" class="cookies-eu-link" target="<%= defined?(target).present? ? target : '' %>"> <%= t('cookies_eu.learn_more') %> </a>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% raise Exception.new "'cookies' is a reserved Rails class, please rename your method" %>
|
||||
<% end %>
|
||||
|
|
5
config/locales/bg.yml
Normal file
5
config/locales/bg.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
bg:
|
||||
cookies_eu:
|
||||
cookies_text: "Курабийките ни помагат да доставяме услугите си. Използвайки нашите услуги, вие се съгласявате с нашето използване на курабийки."
|
||||
learn_more: "Научи повече"
|
||||
ok: "ОК"
|
5
config/locales/ca.yml
Normal file
5
config/locales/ca.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
ca:
|
||||
cookies_eu:
|
||||
cookies_text: "Les cookies ens ajuden a oferir els nostres serveis. En utilitzar els nostres serveis, acceptes l'ús de cookies."
|
||||
learn_more: "Més informació"
|
||||
ok: "OK"
|
|
@ -1,5 +1,5 @@
|
|||
el:
|
||||
cookies_eu:
|
||||
cookies_text: "Τα cookies μας βοηθούν να προσφέρουμε τις υπηρεσίες μας. Με την χρησιμοποίηση των υπηρεσιών μας, συμφωνείτε στην χρήση των cookies."
|
||||
cookies_text: "Τα cookies μας βοηθούν να προσφέρουμε τις υπηρεσίες μας. Με την χρήση των υπηρεσιών μας, συμφωνείτε στην χρήση των cookies."
|
||||
learn_more: "Μάθετε περισσότερα"
|
||||
ok: "OK"
|
||||
|
|
5
config/locales/eu.yml
Normal file
5
config/locales/eu.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
eu:
|
||||
cookies_eu:
|
||||
cookies_text: "Cookieek gure zerbitzuak eskaintzen laguntzen digute. Gure zerbitzuak erabiltzerakoan, cookie-erabilera onartzen duzu."
|
||||
learn_more: "Informazio gehiago"
|
||||
ok: "OK"
|
6
config/locales/he.yml
Normal file
6
config/locales/he.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
he:
|
||||
cookies_eu:
|
||||
cookies_text: "העוגיות עוזרות לנו לספק את שירותינו. על ידי השימוש בשירותים שלנו אתה מסכים לשימוש שלנו בעוגיות."
|
||||
learn_more: "למד/י עוד"
|
||||
ok: "בסדר"
|
||||
direction: "rtl"
|
5
config/locales/lt.yml
Normal file
5
config/locales/lt.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
lt:
|
||||
cookies_eu:
|
||||
cookies_text: "Sklandžiam svetainės veikimui, jūsų naršymo patirties gerinimui bei rinkodarai naudojame slapukus. Spausdami sutinku ar toliau naršydami svetainėje, Jūs sutinkate su slapukų įrašymu."
|
||||
learn_more: "Daugiau informacijos"
|
||||
ok: "OK"
|
5
config/locales/tr.yml
Normal file
5
config/locales/tr.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
tr:
|
||||
cookies_eu:
|
||||
cookies_text: "Çerezler, hizmetlerimizi sunmamıza yardımcı oluyor. Hizmetlerimizi kullanarak, çerez kullanımımızı kabul etmiş olursunuz. "
|
||||
learn_more: "Detayları Göster"
|
||||
ok: "Tamam"
|
|
@ -6,8 +6,8 @@ require 'cookies_eu/version'
|
|||
Gem::Specification.new do |spec|
|
||||
spec.name = "cookies_eu"
|
||||
spec.version = CookiesEu::VERSION
|
||||
spec.authors = ["Stjepan Hadjic"]
|
||||
spec.email = ["stjepan.hadjic@infinum.hr"]
|
||||
spec.authors = ["Stjepan Hadjic", "Gabrijel Skoro"]
|
||||
spec.email = ["stjepan.hadjic@infinum.hr", "gabrijel.skoro@gmail.com"]
|
||||
spec.description = %q{Displays a cookie consent}
|
||||
spec.summary = %q{Displays a cookie consent. If you dont disable cokkies in settings, we assume you are ok with us using cookies}
|
||||
spec.homepage = "https://github.com/infinum/cookies_eu"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module CookiesEu
|
||||
VERSION = "1.7.3"
|
||||
VERSION = "1.7.8"
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue