cookiesalert 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/app/assets/javascripts/cookiesalert/cookie.js +69 -62
- data/lib/cookiesalert/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6af23f235b2cb6e9a3a86fbb357d2d49185b85fb6c69d9637cf7798133f5d482
|
4
|
+
data.tar.gz: 319c2c81ccbf0bacd29aee8605e803dfde99977fb52ceb55cd60f17fad96298c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9fa8455245fad2e2854b4fe574481f91c5908853a1142ee4d8b0ec8549e8600fb694502d77489d5c534a56523b4cfc78fb770bb6a49ad99b7d23104a65244de
|
7
|
+
data.tar.gz: 72846ac61604fd5aef471ee4c6ef1075843d24a15496737e66c7d3017808f0a51653441a1a7f7bc6a57cf16564b7b849c3f6c7c61db92fb85527a9010cd9cb3a
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Cookies alert
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/cookiesalert.svg)](https://badge.fury.io/rb/cookiesalert)
|
4
|
+
|
5
|
+
Easily add a Cookie consent banner, upon the user’s first visit to the site, to alert the users about the cookies and get consent for setting them.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -29,7 +31,7 @@ $( document ).ready(function() {
|
|
29
31
|
});
|
30
32
|
```
|
31
33
|
|
32
|
-
Javascript optional parameters
|
34
|
+
Javascript optional parameters to select "#text_div" and add listener in "#button_confirm" to accept cookies:
|
33
35
|
```js
|
34
36
|
cookies.check({
|
35
37
|
div : '#div',
|
@@ -47,12 +49,12 @@ Add optional styles in "application.css":
|
|
47
49
|
|
48
50
|
Import optional view layout:
|
49
51
|
```erb
|
50
|
-
<%= render "cookies/alert", :
|
52
|
+
<%= render "cookies/alert", advice: "Cookies Text", link: "Link Advice", button: "Button" %>
|
51
53
|
```
|
52
54
|
|
53
55
|
Render optional parameters:
|
54
56
|
```erb
|
55
|
-
<%= render "cookies/alert", :
|
57
|
+
<%= render "cookies/alert", advice: "Cookies Text", link: link_to('Link Advice', root_path, target: '_blank'), button: image_tag('cross_cookies.svg') %>
|
56
58
|
```
|
57
59
|
|
58
60
|
## Used Javascript Linter
|
@@ -87,7 +89,7 @@ module.exports = {
|
|
87
89
|
```
|
88
90
|
|
89
91
|
## Dependences included:
|
90
|
-
-[JavaScript Cookie v2.
|
92
|
+
- [JavaScript Cookie v2.2.0](https://github.com/js-cookie/js-cookie)
|
91
93
|
|
92
94
|
# Contributing
|
93
95
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
/*!
|
2
|
-
* JavaScript Cookie v2.
|
2
|
+
* JavaScript Cookie v2.2.0
|
3
3
|
* https://github.com/js-cookie/js-cookie
|
4
4
|
*
|
5
5
|
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
6
6
|
* Released under the MIT license
|
7
7
|
*/
|
8
8
|
;(function (factory) {
|
9
|
-
var registeredInModuleLoader
|
9
|
+
var registeredInModuleLoader;
|
10
10
|
if (typeof define === 'function' && define.amd) {
|
11
11
|
define(factory);
|
12
12
|
registeredInModuleLoader = true;
|
@@ -36,117 +36,124 @@
|
|
36
36
|
return result;
|
37
37
|
}
|
38
38
|
|
39
|
+
function decode (s) {
|
40
|
+
return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
|
41
|
+
}
|
42
|
+
|
39
43
|
function init (converter) {
|
40
|
-
function api
|
41
|
-
|
44
|
+
function api() {}
|
45
|
+
|
46
|
+
function set (key, value, attributes) {
|
42
47
|
if (typeof document === 'undefined') {
|
43
48
|
return;
|
44
49
|
}
|
45
50
|
|
46
|
-
|
51
|
+
attributes = extend({
|
52
|
+
path: '/'
|
53
|
+
}, api.defaults, attributes);
|
54
|
+
|
55
|
+
if (typeof attributes.expires === 'number') {
|
56
|
+
attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
|
57
|
+
}
|
47
58
|
|
48
|
-
|
49
|
-
|
50
|
-
path: '/'
|
51
|
-
}, api.defaults, attributes);
|
59
|
+
// We're using "expires" because "max-age" is not supported by IE
|
60
|
+
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
|
52
61
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
62
|
+
try {
|
63
|
+
var result = JSON.stringify(value);
|
64
|
+
if (/^[\{\[]/.test(result)) {
|
65
|
+
value = result;
|
57
66
|
}
|
67
|
+
} catch (e) {}
|
58
68
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}
|
64
|
-
} catch (e) {}
|
69
|
+
value = converter.write ?
|
70
|
+
converter.write(value, key) :
|
71
|
+
encodeURIComponent(String(value))
|
72
|
+
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
65
73
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
74
|
+
key = encodeURIComponent(String(key))
|
75
|
+
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
|
76
|
+
.replace(/[\(\)]/g, escape);
|
77
|
+
|
78
|
+
var stringifiedAttributes = '';
|
79
|
+
for (var attributeName in attributes) {
|
80
|
+
if (!attributes[attributeName]) {
|
81
|
+
continue;
|
82
|
+
}
|
83
|
+
stringifiedAttributes += '; ' + attributeName;
|
84
|
+
if (attributes[attributeName] === true) {
|
85
|
+
continue;
|
71
86
|
}
|
72
87
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
attributes.domain ? '; domain=' + attributes.domain : '',
|
82
|
-
attributes.secure ? '; secure' : ''
|
83
|
-
].join(''));
|
88
|
+
// Considers RFC 6265 section 5.2:
|
89
|
+
// ...
|
90
|
+
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
91
|
+
// character:
|
92
|
+
// Consume the characters of the unparsed-attributes up to,
|
93
|
+
// not including, the first %x3B (";") character.
|
94
|
+
// ...
|
95
|
+
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
84
96
|
}
|
85
97
|
|
86
|
-
|
98
|
+
return (document.cookie = key + '=' + value + stringifiedAttributes);
|
99
|
+
}
|
87
100
|
|
88
|
-
|
89
|
-
|
101
|
+
function get (key, json) {
|
102
|
+
if (typeof document === 'undefined') {
|
103
|
+
return;
|
90
104
|
}
|
91
105
|
|
106
|
+
var jar = {};
|
92
107
|
// To prevent the for loop in the first place assign an empty array
|
93
|
-
// in case there are no cookies at all.
|
94
|
-
// calling "get()"
|
108
|
+
// in case there are no cookies at all.
|
95
109
|
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
96
|
-
var rdecode = /(%[0-9A-Z]{2})+/g;
|
97
110
|
var i = 0;
|
98
111
|
|
99
112
|
for (; i < cookies.length; i++) {
|
100
113
|
var parts = cookies[i].split('=');
|
101
114
|
var cookie = parts.slice(1).join('=');
|
102
115
|
|
103
|
-
if (cookie.charAt(0) === '"') {
|
116
|
+
if (!json && cookie.charAt(0) === '"') {
|
104
117
|
cookie = cookie.slice(1, -1);
|
105
118
|
}
|
106
119
|
|
107
120
|
try {
|
108
|
-
var name = parts[0]
|
109
|
-
cookie = converter.read
|
110
|
-
|
111
|
-
cookie.replace(rdecode, decodeURIComponent);
|
121
|
+
var name = decode(parts[0]);
|
122
|
+
cookie = (converter.read || converter)(cookie, name) ||
|
123
|
+
decode(cookie);
|
112
124
|
|
113
|
-
if (
|
125
|
+
if (json) {
|
114
126
|
try {
|
115
127
|
cookie = JSON.parse(cookie);
|
116
128
|
} catch (e) {}
|
117
129
|
}
|
118
130
|
|
131
|
+
jar[name] = cookie;
|
132
|
+
|
119
133
|
if (key === name) {
|
120
|
-
result = cookie;
|
121
134
|
break;
|
122
135
|
}
|
123
|
-
|
124
|
-
if (!key) {
|
125
|
-
result[name] = cookie;
|
126
|
-
}
|
127
136
|
} catch (e) {}
|
128
137
|
}
|
129
138
|
|
130
|
-
return
|
139
|
+
return key ? jar[key] : jar;
|
131
140
|
}
|
132
141
|
|
133
|
-
api.set =
|
142
|
+
api.set = set;
|
134
143
|
api.get = function (key) {
|
135
|
-
return
|
144
|
+
return get(key, false /* read as raw */);
|
136
145
|
};
|
137
|
-
api.getJSON = function () {
|
138
|
-
return
|
139
|
-
json: true
|
140
|
-
}, [].slice.call(arguments));
|
146
|
+
api.getJSON = function (key) {
|
147
|
+
return get(key, true /* read as json */);
|
141
148
|
};
|
142
|
-
api.defaults = {};
|
143
|
-
|
144
149
|
api.remove = function (key, attributes) {
|
145
|
-
|
150
|
+
set(key, '', extend(attributes, {
|
146
151
|
expires: -1
|
147
152
|
}));
|
148
153
|
};
|
149
154
|
|
155
|
+
api.defaults = {};
|
156
|
+
|
150
157
|
api.withConverter = init;
|
151
158
|
|
152
159
|
return api;
|
data/lib/cookiesalert/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookiesalert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Subils
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-02-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -77,8 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
|
81
|
-
rubygems_version: 2.7.6
|
80
|
+
rubygems_version: 3.0.2
|
82
81
|
signing_key:
|
83
82
|
specification_version: 4
|
84
83
|
summary: Cookie's Alert generator
|