cookiesalert 0.1.1
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +109 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/cookiesalert/cookie.js +156 -0
- data/app/assets/javascripts/cookiesalert/cookies_alert.js +26 -0
- data/app/assets/stylesheets/cookiesalert/cookies_alert.css +44 -0
- data/app/views/cookies/_alert.html.erb +6 -0
- data/lib/cookiesalert/version.rb +3 -0
- data/lib/cookiesalert.rb +5 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 967d3c2577ab16cdb328d7effd113a3598581dcab304056e3dc1e70fbe7dfabd
|
4
|
+
data.tar.gz: 4f347183c2da130154a5490f4fb25d9edc07ea830268e7f553dc30cda3fce29c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 48b94cd6d1890e70830676de8b7e4c52993b795d4af8116fa8acfe2512eb8cb21ef25e17c41645f244a248c91860e3a4c38796a13dfb6c73da89d6effec6caf8
|
7
|
+
data.tar.gz: 7db23f9221584e9bb1625916f1379e36af33b0d6ac1e553099ff9a8520d02ab59c64d2dd4d84845a6875fd1c569c19adc9812ce2f81cf7dcc9b795a3614cf8a4
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# Cookies alert
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/cookiesalert)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cookiesalert'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Add in "application.js":
|
20
|
+
```ruby
|
21
|
+
//= require cookiesalert/cookie
|
22
|
+
//= require cookiesalert/cookies_alert
|
23
|
+
```
|
24
|
+
|
25
|
+
Run Javascript check when load/ready:
|
26
|
+
```js
|
27
|
+
$( document ).ready(function() {
|
28
|
+
cookies.check();
|
29
|
+
});
|
30
|
+
```
|
31
|
+
|
32
|
+
Javascript optional parameters for select "#text_div" and add listener in "#button_confirm" for accept cookies:
|
33
|
+
```js
|
34
|
+
cookies.check({
|
35
|
+
div : '#div',
|
36
|
+
btn : '#button',
|
37
|
+
expires : 7 //Days
|
38
|
+
});
|
39
|
+
```
|
40
|
+
|
41
|
+
## Optional template
|
42
|
+
|
43
|
+
Add optional styles in "application.css":
|
44
|
+
```ruby
|
45
|
+
*= require cookiesalert/cookies_alert
|
46
|
+
```
|
47
|
+
|
48
|
+
Import optional view layout:
|
49
|
+
```erb
|
50
|
+
<%= render "cookies/alert", :advice => "Cookies Text", :link => "Link Advice", :button => "Button" %>
|
51
|
+
```
|
52
|
+
|
53
|
+
Render optional parameters:
|
54
|
+
```erb
|
55
|
+
<%= render "cookies/alert", :advice => "Cookies Text", :link => link_to('Link Advice', root_path, target: '_blank'), :button => image_tag('cross_cookies.svg') %>
|
56
|
+
```
|
57
|
+
|
58
|
+
## Used Javascript Linter
|
59
|
+
ESLint file config ".eslintrc.js":
|
60
|
+
```js
|
61
|
+
module.exports = {
|
62
|
+
"env": {
|
63
|
+
"browser": true,
|
64
|
+
"commonjs": true
|
65
|
+
},
|
66
|
+
"extends": "eslint:recommended",
|
67
|
+
"rules": {
|
68
|
+
"indent": [
|
69
|
+
"error",
|
70
|
+
2
|
71
|
+
],
|
72
|
+
"linebreak-style": [
|
73
|
+
"error",
|
74
|
+
"unix"
|
75
|
+
],
|
76
|
+
"quotes": [
|
77
|
+
"error",
|
78
|
+
"single"
|
79
|
+
],
|
80
|
+
"semi": [
|
81
|
+
"error",
|
82
|
+
"always"
|
83
|
+
],
|
84
|
+
"no-undef" : 0
|
85
|
+
}
|
86
|
+
};
|
87
|
+
```
|
88
|
+
|
89
|
+
## Dependences included:
|
90
|
+
-[JavaScript Cookie v2.1.3](https://github.com/js-cookie/js-cookie)
|
91
|
+
|
92
|
+
# Contributing
|
93
|
+
|
94
|
+
Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
95
|
+
|
96
|
+
|
97
|
+
# License
|
98
|
+
|
99
|
+
`cookiesalert` is Copyright © 2018 CodiTramuntana SL. It is free software, and may be redistributed under the terms specified in the LICENSE file.
|
100
|
+
|
101
|
+
# About CodiTramuntana
|
102
|
+
|
103
|
+

|
104
|
+
|
105
|
+
Maintained by [CodiTramuntana](http://www.coditramuntana.com).
|
106
|
+
|
107
|
+
The names and logos for CodiTramuntana are trademarks of CodiTramuntana SL.
|
108
|
+
|
109
|
+
We love open source software!
|
data/Rakefile
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
/*!
|
2
|
+
* JavaScript Cookie v2.1.3
|
3
|
+
* https://github.com/js-cookie/js-cookie
|
4
|
+
*
|
5
|
+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
6
|
+
* Released under the MIT license
|
7
|
+
*/
|
8
|
+
;(function (factory) {
|
9
|
+
var registeredInModuleLoader = false;
|
10
|
+
if (typeof define === 'function' && define.amd) {
|
11
|
+
define(factory);
|
12
|
+
registeredInModuleLoader = true;
|
13
|
+
}
|
14
|
+
if (typeof exports === 'object') {
|
15
|
+
module.exports = factory();
|
16
|
+
registeredInModuleLoader = true;
|
17
|
+
}
|
18
|
+
if (!registeredInModuleLoader) {
|
19
|
+
var OldCookies = window.Cookies;
|
20
|
+
var api = window.Cookies = factory();
|
21
|
+
api.noConflict = function () {
|
22
|
+
window.Cookies = OldCookies;
|
23
|
+
return api;
|
24
|
+
};
|
25
|
+
}
|
26
|
+
}(function () {
|
27
|
+
function extend () {
|
28
|
+
var i = 0;
|
29
|
+
var result = {};
|
30
|
+
for (; i < arguments.length; i++) {
|
31
|
+
var attributes = arguments[ i ];
|
32
|
+
for (var key in attributes) {
|
33
|
+
result[key] = attributes[key];
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return result;
|
37
|
+
}
|
38
|
+
|
39
|
+
function init (converter) {
|
40
|
+
function api (key, value, attributes) {
|
41
|
+
var result;
|
42
|
+
if (typeof document === 'undefined') {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
|
46
|
+
// Write
|
47
|
+
|
48
|
+
if (arguments.length > 1) {
|
49
|
+
attributes = extend({
|
50
|
+
path: '/'
|
51
|
+
}, api.defaults, attributes);
|
52
|
+
|
53
|
+
if (typeof attributes.expires === 'number') {
|
54
|
+
var expires = new Date();
|
55
|
+
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
|
56
|
+
attributes.expires = expires;
|
57
|
+
}
|
58
|
+
|
59
|
+
try {
|
60
|
+
result = JSON.stringify(value);
|
61
|
+
if (/^[\{\[]/.test(result)) {
|
62
|
+
value = result;
|
63
|
+
}
|
64
|
+
} catch (e) {}
|
65
|
+
|
66
|
+
if (!converter.write) {
|
67
|
+
value = encodeURIComponent(String(value))
|
68
|
+
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
69
|
+
} else {
|
70
|
+
value = converter.write(value, key);
|
71
|
+
}
|
72
|
+
|
73
|
+
key = encodeURIComponent(String(key));
|
74
|
+
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
|
75
|
+
key = key.replace(/[\(\)]/g, escape);
|
76
|
+
|
77
|
+
return (document.cookie = [
|
78
|
+
key, '=', value,
|
79
|
+
attributes.expires ? '; expires=' + attributes.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
80
|
+
attributes.path ? '; path=' + attributes.path : '',
|
81
|
+
attributes.domain ? '; domain=' + attributes.domain : '',
|
82
|
+
attributes.secure ? '; secure' : ''
|
83
|
+
].join(''));
|
84
|
+
}
|
85
|
+
|
86
|
+
// Read
|
87
|
+
|
88
|
+
if (!key) {
|
89
|
+
result = {};
|
90
|
+
}
|
91
|
+
|
92
|
+
// To prevent the for loop in the first place assign an empty array
|
93
|
+
// in case there are no cookies at all. Also prevents odd result when
|
94
|
+
// calling "get()"
|
95
|
+
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
96
|
+
var rdecode = /(%[0-9A-Z]{2})+/g;
|
97
|
+
var i = 0;
|
98
|
+
|
99
|
+
for (; i < cookies.length; i++) {
|
100
|
+
var parts = cookies[i].split('=');
|
101
|
+
var cookie = parts.slice(1).join('=');
|
102
|
+
|
103
|
+
if (cookie.charAt(0) === '"') {
|
104
|
+
cookie = cookie.slice(1, -1);
|
105
|
+
}
|
106
|
+
|
107
|
+
try {
|
108
|
+
var name = parts[0].replace(rdecode, decodeURIComponent);
|
109
|
+
cookie = converter.read ?
|
110
|
+
converter.read(cookie, name) : converter(cookie, name) ||
|
111
|
+
cookie.replace(rdecode, decodeURIComponent);
|
112
|
+
|
113
|
+
if (this.json) {
|
114
|
+
try {
|
115
|
+
cookie = JSON.parse(cookie);
|
116
|
+
} catch (e) {}
|
117
|
+
}
|
118
|
+
|
119
|
+
if (key === name) {
|
120
|
+
result = cookie;
|
121
|
+
break;
|
122
|
+
}
|
123
|
+
|
124
|
+
if (!key) {
|
125
|
+
result[name] = cookie;
|
126
|
+
}
|
127
|
+
} catch (e) {}
|
128
|
+
}
|
129
|
+
|
130
|
+
return result;
|
131
|
+
}
|
132
|
+
|
133
|
+
api.set = api;
|
134
|
+
api.get = function (key) {
|
135
|
+
return api.call(api, key);
|
136
|
+
};
|
137
|
+
api.getJSON = function () {
|
138
|
+
return api.apply({
|
139
|
+
json: true
|
140
|
+
}, [].slice.call(arguments));
|
141
|
+
};
|
142
|
+
api.defaults = {};
|
143
|
+
|
144
|
+
api.remove = function (key, attributes) {
|
145
|
+
api(key, '', extend(attributes, {
|
146
|
+
expires: -1
|
147
|
+
}));
|
148
|
+
};
|
149
|
+
|
150
|
+
api.withConverter = init;
|
151
|
+
|
152
|
+
return api;
|
153
|
+
}
|
154
|
+
|
155
|
+
return init(function () {});
|
156
|
+
}));
|
@@ -0,0 +1,26 @@
|
|
1
|
+
var cookies = {
|
2
|
+
div : "#cookies",
|
3
|
+
btn : "#cookies_btn",
|
4
|
+
expires : 365,
|
5
|
+
check : function (obj) {
|
6
|
+
if (obj !== undefined) {
|
7
|
+
cookies.div = obj.div || cookies.div
|
8
|
+
cookies.btn = obj.btn || cookies.btn
|
9
|
+
cookies.expires = obj.expires || cookies.expires
|
10
|
+
}
|
11
|
+
|
12
|
+
if (Cookies.get('cookies_alert') === undefined) {
|
13
|
+
$(cookies.div).css({ visibility : 'visible' })
|
14
|
+
$(cookies.btn).click(function () {
|
15
|
+
cookies.accept()
|
16
|
+
})
|
17
|
+
} else $(cookies.div).css({ visibility : 'hidden' });
|
18
|
+
},
|
19
|
+
accept : function () {
|
20
|
+
Cookies.set('cookies_alert','true', { expires : cookies.expires });
|
21
|
+
$(cookies.div).css({ visibility : 'hidden' })
|
22
|
+
},
|
23
|
+
remove : function () {
|
24
|
+
Cookies.remove('cookies_alert');
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
.cookies-alert {
|
2
|
+
background: #000000;
|
3
|
+
color: #FFFFFF;
|
4
|
+
font-size: 17px;
|
5
|
+
margin: 0;
|
6
|
+
border-radius: 0px;
|
7
|
+
text-align: left;
|
8
|
+
position: fixed;
|
9
|
+
overflow: hidden;
|
10
|
+
visibility: hidden;
|
11
|
+
bottom: 0;
|
12
|
+
left: 0;
|
13
|
+
z-index: 100;
|
14
|
+
width: 100%;
|
15
|
+
display: flex;
|
16
|
+
padding-top: 15px;
|
17
|
+
padding-bottom: 15px;
|
18
|
+
}
|
19
|
+
|
20
|
+
.cookies-content {
|
21
|
+
width: calc(99% - 80px);
|
22
|
+
padding-left: 40px;
|
23
|
+
padding-right: 40px;
|
24
|
+
}
|
25
|
+
.cookies-content a {
|
26
|
+
color: #FFFFFF !important;
|
27
|
+
}
|
28
|
+
.cookies-content a:hover {
|
29
|
+
color: #bfbfbf !important;
|
30
|
+
cursor: pointer;
|
31
|
+
}
|
32
|
+
|
33
|
+
.cookies-alert-btn {
|
34
|
+
float: right;
|
35
|
+
text-decoration: underline;
|
36
|
+
color: #FFFFFF;
|
37
|
+
width: auto;
|
38
|
+
height: 30px;
|
39
|
+
padding-right: 40px;
|
40
|
+
}
|
41
|
+
.cookies-alert-btn:hover {
|
42
|
+
color: #bfbfbf;
|
43
|
+
cursor: pointer;
|
44
|
+
}
|
data/lib/cookiesalert.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cookiesalert
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josep Subils
|
8
|
+
- Isaac Massot
|
9
|
+
- Agustí B.R.
|
10
|
+
autorequire:
|
11
|
+
bindir: exe
|
12
|
+
cert_chain: []
|
13
|
+
date: 2018-10-19 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.13'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.13'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '10.0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '10.0'
|
43
|
+
description: Cookie's Javascript/CSS/View Layout for Alert generator
|
44
|
+
email:
|
45
|
+
- josep.sr@coditramuntana.com
|
46
|
+
- issac.mg@coditramuntana.com
|
47
|
+
- agusti.br@coditramuntana.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- app/assets/javascripts/cookiesalert/cookie.js
|
56
|
+
- app/assets/javascripts/cookiesalert/cookies_alert.js
|
57
|
+
- app/assets/stylesheets/cookiesalert/cookies_alert.css
|
58
|
+
- app/views/cookies/_alert.html.erb
|
59
|
+
- lib/cookiesalert.rb
|
60
|
+
- lib/cookiesalert/version.rb
|
61
|
+
homepage: https://github.com/CodiTramuntana/cookiesalert
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.7.6
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Cookie's Alert generator
|
85
|
+
test_files: []
|