simple_cookies 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: 5ebc672c68d8b4082f37238d8376ebdbb39b6f15
4
- data.tar.gz: 8564d2fe2b46015eff5f67b28b9c731847083511
3
+ metadata.gz: ce88c5b764c71c6b9dd917e2e1e19735adb83648
4
+ data.tar.gz: bcf450ed0b7571f9262ee9f46cd1e4d0a7fbcae0
5
5
  SHA512:
6
- metadata.gz: 8864fc885d7190a4f43057cdb462edb5d14b62e561cd53c6d0437d3cc9cba5eb6e58c8af3175b5f26784d406e153720c309dd7c01bac74bf9b357964869e397a
7
- data.tar.gz: 9d3669817a2409499569d73d827d3798722bfa4a771f6a07abff54ce26d2c6f4f4bcb2ad4813450f264100ba9bb8b9e6e6e4bcc32405205c35cb469cb512b507
6
+ metadata.gz: 7f67aee4eeb1cff8337a88b4d63d46d0322080533f6c1b5bc2f061c4934b3518872a35fdf6839fc1b66a564858f7e99ebf3b7faa22895ff453ed4bf46a1755a1
7
+ data.tar.gz: 6f408c215e5a63710080609d2936d476db8d72bbe1c3d22de7e1234b44425786bd99dd930c90b0aa285d82db8d8db017f1825b9553161daa2293bc09dab5e31d
data/.gitignore ADDED
@@ -0,0 +1,63 @@
1
+ # General
2
+ .DS_Store
3
+ .AppleDouble
4
+ .LSOverride
5
+
6
+ # Icon must end with two \r
7
+ Icon
8
+
9
+
10
+ # Thumbnails
11
+ ._*
12
+
13
+ # Files that might appear in the root of a volume
14
+ .DocumentRevisions-V100
15
+ .fseventsd
16
+ .Spotlight-V100
17
+ .TemporaryItems
18
+ .Trashes
19
+ .VolumeIcon.icns
20
+ .com.apple.timemachine.donotpresent
21
+
22
+ # Directories potentially created on remote AFP share
23
+ .AppleDB
24
+ .AppleDesktop
25
+ Network Trash Folder
26
+ Temporary Items
27
+ .apdisk
28
+
29
+ # Ruby
30
+ *.gem
31
+ *.rbc
32
+ /.config
33
+ /coverage/
34
+ /InstalledFiles
35
+ /pkg/
36
+ /spec/reports/
37
+ /spec/examples.txt
38
+ /test/tmp/
39
+ /test/version_tmp/
40
+ /tmp/
41
+
42
+ # Used by dotenv library to load environment variables.
43
+ # .env
44
+
45
+ ## Documentation cache and generated files:
46
+ /.yardoc/
47
+ /_yardoc/
48
+ /doc/
49
+ /rdoc/
50
+
51
+ ## Environment normalization:
52
+ /.bundle/
53
+ /vendor/bundle
54
+ /lib/bundler/man/
55
+
56
+ # for a library or gem, you might want to ignore these files since the code is
57
+ # intended to run in multiple environments; otherwise, check them in:
58
+ Gemfile.lock
59
+ .ruby-version
60
+ .ruby-gemset
61
+
62
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
63
+ .rvmrc
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+
3
+ MIT License
4
+
5
+ Copyright (c) 2017 Micaël Dekleyn.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Simple Cookies
2
+
3
+ A simple gem to display cookies consent !
4
+
5
+ ## Installation
6
+
7
+ Simple Cookies is distributed as a gem, which is how it should be used in your app.
8
+
9
+ Include the gem in your Gemfile:
10
+
11
+ ```ruby
12
+ gem 'simple_cookies'
13
+ ```
14
+
15
+ Install assets file in application.js:
16
+
17
+ //= require simple_cookies
18
+
19
+ And in application.css:
20
+
21
+ *= require simple-cookies
22
+
23
+ Or, if you have application.scss:
24
+
25
+ @import "simple-cookies";
26
+
27
+ ## Usage
28
+
29
+ In your view add
30
+
31
+ ```ruby
32
+ <%= render 'simple_cookies/consent', appname: "App name", klass: 'top' %>
33
+ ```
34
+
35
+ ## Default style
36
+
37
+ Simple Cookies comes with some customization.
38
+ Here are css class :
39
+
40
+ full : make simple-cookies box full width of browser. Default is 375px.
41
+
42
+ top || bottom : position the box at the top or bottom of the window.
43
+
44
+ content-centered : center content inside the box. Default content is left align.
45
+
46
+ ## CSS class and customization
47
+
48
+ You can customize the box by overriding css.
49
+
50
+ "Simple cookies" contains 4 elements :
51
+
52
+ ```html
53
+ div#simple-cookies
54
+ h1
55
+ p
56
+ a.simple-cookies-accept
57
+ ```
@@ -0,0 +1,7 @@
1
+ <% if request.cookies && request.cookies['simple_cookies_consented'] != 'true' %>
2
+ <section id="simple-cookies" class="<%= klass if klass.present? %>">
3
+ <h1>Pour rendre votre visite plus agréable, <%= appname %> utilise des cookies.</h1>
4
+ <p>En poursuivant votre navigation sur ce site, vous acceptez l'utilisation de cookies.</p>
5
+ <a href="#" class="simple-cookies-accept">OK</a>
6
+ </section>
7
+ <% end %>
@@ -0,0 +1,18 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'simple_cookies'
5
+ s.version = "0.0.3"
6
+ s.date = '2017-10-20'
7
+ s.summary = "A simple gem to display cookies consent !"
8
+ s.description = "A simple gem to display cookies consent ! If you don't disable cookies, we assume you are ok with app's cookies policy."
9
+ s.authors = ["Micael Dekleyn"]
10
+ s.email = 'micael.dekleyn@gmail.com'
11
+ s.files = ["lib/simple_cookies.rb"]
12
+ s.homepage = 'http://rubygems.org/gems/simple_cookies'
13
+ s.license = 'MIT'
14
+
15
+ s.add_dependency "railties", ">= 4.2.0"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ end
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ //////////////////
4
+ ////// simpleCookies object definition
5
+ //////////////////
6
+ var simpleCookies = {
7
+ init: function() {
8
+ var simpleCookiesButton = document.querySelector('.simple-cookies-accept');
9
+
10
+ if (simpleCookiesButton) {
11
+ this.addListener(simpleCookiesButton);
12
+ }
13
+ },
14
+
15
+ //////////////////
16
+ ////// Event listener with support for old browsers
17
+ //////////////////
18
+ addListener: function(target) {
19
+ //////////////////
20
+ ////// Support for old browsers IE < 9
21
+ //////////////////
22
+ if (target.attachEvent) {
23
+ target.attachEvent('onclick', this.setCookie);
24
+ } else {
25
+ target.addEventListener('click', this.setCookie, false);
26
+ }
27
+ },
28
+
29
+ //////////////////
30
+ ////// Method to return cookie's value
31
+ //////////////////
32
+ getCookies: function() {
33
+ var name = "simple_cookies_consented=",
34
+ decodedCookie = decodeURIComponent(document.cookie),
35
+ cookieArray = decodedCookie.split(';');
36
+
37
+ for(var i = 0; i < cookieArray.length; i++) {
38
+ var c = cookieArray[i];
39
+
40
+ while (c.charAt(0) == ' ') {
41
+ c = c.substring(1);
42
+ }
43
+
44
+ if (c.indexOf(name) == 0) {
45
+ return c.substring(name.length, c.length);
46
+ }
47
+ }
48
+ return "";
49
+ },
50
+
51
+ //////////////////
52
+ ////// Set cookie with one year validity
53
+ //////////////////
54
+ setCookie: function(cookie) {
55
+ var date = new Date();
56
+ date.setTime(date.getTime() + (365*24*60*60*1000));
57
+ var expires = "expires="+ date.toUTCString();
58
+ var value = true;
59
+
60
+ document.cookie = "simple_cookies_consented=" + value + ";" + expires + ";path=/";
61
+
62
+ var container = document.getElementById('simple-cookies');
63
+ container.parentNode.removeChild(container);
64
+ }
65
+ };
66
+
67
+ (function() {
68
+ //////////////////
69
+ ////// Support for old browsers IE < 9
70
+ //////////////////
71
+ if (window.addEventListener) {
72
+ window.addEventListener('load', function(){
73
+ simpleCookies.init();
74
+ }, false);
75
+ } else if (window.attachEvent) {
76
+ window.attachEvent('onload', function(){
77
+ simpleCookies.init();
78
+ });
79
+ }
80
+ })();
@@ -0,0 +1,61 @@
1
+ #simple-cookies{
2
+ display: block;
3
+ position: fixed;
4
+ width: 375px;
5
+ margin: 0 auto;
6
+ padding: 16px;
7
+ background-color: #fff;
8
+ z-index: 1000;
9
+
10
+ &.full{
11
+ width: 100%;
12
+ }
13
+
14
+ &.top{
15
+ top: 0;
16
+ border-bottom: 4px solid #2ecc71;
17
+ }
18
+
19
+ &.bottom{
20
+ bottom: 0;
21
+ border-top: 4px solid #2ecc71;
22
+ }
23
+
24
+ &.content-centered{
25
+ text-align: center;
26
+
27
+ .simple-cookies-accept{
28
+ margin-left: auto;
29
+ margin-right: auto;
30
+ }
31
+ }
32
+
33
+ h1{
34
+ font-size: 24px;
35
+ font-weight: bold;
36
+ }
37
+
38
+ p{
39
+ font-size: 16px;
40
+ margin-top: 8px;
41
+ }
42
+
43
+ .simple-cookies-accept{
44
+ display: block;
45
+ width: 64px;
46
+ margin-top: 16px;
47
+ padding: 8px 0;
48
+ text-align: center;
49
+ color: #fff;
50
+ background-color: #2ecc71;
51
+ border-radius: 8px;
52
+
53
+ &:hover{
54
+ background-color: lighten(#27ae60, 10%);
55
+ }
56
+
57
+ &:active{
58
+ background-color: #27ae60;
59
+ }
60
+ }
61
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_cookies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micael Dekleyn
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-10-20 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
13
27
  description: A simple gem to display cookies consent ! If you don't disable cookies,
14
28
  we assume you are ok with app's cookies policy.
15
29
  email: micael.dekleyn@gmail.com
@@ -17,7 +31,14 @@ executables: []
17
31
  extensions: []
18
32
  extra_rdoc_files: []
19
33
  files:
34
+ - ".gitignore"
35
+ - LICENSE
36
+ - README.md
37
+ - app/views/simple_cookies/_consent.html.erb
20
38
  - lib/simple_cookies.rb
39
+ - simple_cookies.gemspec
40
+ - vendor/assets/javascripts/simple_cookies.js
41
+ - vendor/assets/stylesheets/simple-cookies.scss
21
42
  homepage: http://rubygems.org/gems/simple_cookies
22
43
  licenses:
23
44
  - MIT