micoo 0.1.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +0 -2
- data/README.md +33 -11
- data/app/components/cookies_component.rb +6 -8
- data/app/components/cookies_component.rb.bak +63 -0
- data/app/controllers/cookies.rb +7 -8
- data/app/controllers/cookies.rb.bak +24 -0
- data/config/routes.rb +2 -1
- data/config/routes.rb.bak +3 -0
- data/lib/micoo/version.rb +3 -1
- data/lib/micoo/version.rb.bak +2 -3
- metadata +10 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4938cb799ff2c37284f591c2fe7b2aed39593ed4e0207d019cc0efbeb555bf1b
|
4
|
+
data.tar.gz: b3fec0c9a1c4936d081c811082e2e834836f07c2f2a6ffd954e870a37d95ef7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 528a5b5e7ea400c8e2e472f885cf1370d3179f143e713233cf27f65bd0d15ace6643d741940d2a0fb3d29fc599b2b00c7e693621a57641501ff18c9a5afa4c6d
|
7
|
+
data.tar.gz: cc35e1eea243242b89c6daedf944252b224f07f4117fb4edeef42ce429373fea603df378b9af9c3c9973e02780016a1b592241fe24c42662de8df7ebe60dd317
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# Micoo
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/micoo.
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/micoo.svg)](http://badge.fury.io/rb/micoo)
|
4
4
|
[![GEM Downloads](https://img.shields.io/gem/dt/micoo?color=168AFE&logo=ruby&logoColor=FE1616)](https://rubygems.org/gems/micoo)
|
5
|
+
[![rake](https://github.com/matique/micoo/actions/workflows/rake.yml/badge.svg)](https://github.com/matique/micoo/actions/workflows/rake.yml)
|
6
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/standardrb/standard)
|
5
7
|
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](http://choosealicense.com/licenses/mit/)
|
6
8
|
|
7
9
|
Micoo (minimal Cookie) is a Rails Engine handling the Cookie consent.
|
@@ -11,7 +13,7 @@ Micoo display a styled text including buttons for
|
|
11
13
|
accepting or rejecting usage of cookies.
|
12
14
|
|
13
15
|
Clicking *Accept* set the cookie "cookiesOK" to "x",
|
14
|
-
clicking *Reject
|
16
|
+
clicking *Reject* will delete the cookie.
|
15
17
|
|
16
18
|
## Optional Parameters
|
17
19
|
|
@@ -22,22 +24,27 @@ Optional parameters for *CookiesComponent.new(...)* are:
|
|
22
24
|
Default is:
|
23
25
|
|
24
26
|
> You may delete and block all cookies from this site,
|
25
|
-
but parts of the site will not work.
|
26
|
-
|
27
|
+
> but parts of the site will not work.
|
28
|
+
>
|
27
29
|
> Click *Accept* if you consent usage of cookies, otherwise click *Reject*.
|
28
30
|
|
29
|
-
### _text2_
|
30
|
-
|
31
|
-
_text2_ may be used to
|
32
|
-
add additional text and links for further description.
|
33
|
-
|
34
31
|
### _url_
|
35
32
|
|
36
33
|
Redirection to _url_ will be triggered by clicking *Accept* or *Reject*.
|
37
|
-
|
34
|
+
Default is *request.url*.
|
38
35
|
|
39
36
|
## Usage
|
40
37
|
|
38
|
+
```ruby
|
39
|
+
# config/routes.rb
|
40
|
+
Rails.application.routes.draw do
|
41
|
+
...
|
42
|
+
get "/cookies/accept"
|
43
|
+
get "/cookies/reject"
|
44
|
+
...
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
41
48
|
```ruby
|
42
49
|
# app/controllers/application_controller.rb (recommended)
|
43
50
|
...
|
@@ -45,12 +52,27 @@ Defult is "/".
|
|
45
52
|
|
46
53
|
def always
|
47
54
|
unless cookies[:cookiesOK] == "x"
|
48
|
-
render CookiesComponent.new(url:
|
55
|
+
render CookiesComponent.new(url: request.url)
|
49
56
|
end
|
50
57
|
end
|
51
58
|
...
|
52
59
|
```
|
53
60
|
|
61
|
+
## I18n
|
62
|
+
You may provide an "internationalized" text via the _text_ parameter.
|
63
|
+
|
64
|
+
_Micoo_ buttons uses the I18n.translate method for the legend.
|
65
|
+
A configuration file (a sample) may be:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
# config/locales/en.yml
|
69
|
+
en:
|
70
|
+
micoo:
|
71
|
+
button:
|
72
|
+
accept: Accept
|
73
|
+
reject: Reject
|
74
|
+
```
|
75
|
+
|
54
76
|
## Installation
|
55
77
|
As usual:
|
56
78
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "view_component"
|
4
4
|
|
5
5
|
class CookiesComponent < ViewComponent::Base
|
6
|
-
def initialize(text: nil,
|
6
|
+
def initialize(text: nil, url: nil)
|
7
7
|
unless text
|
8
8
|
text = []
|
9
9
|
text << <<~EOS
|
@@ -17,8 +17,7 @@ class CookiesComponent < ViewComponent::Base
|
|
17
17
|
end
|
18
18
|
|
19
19
|
@text = text
|
20
|
-
@
|
21
|
-
@url = url
|
20
|
+
@url = url || "/"
|
22
21
|
end
|
23
22
|
|
24
23
|
slim_template <<~HEREDOC
|
@@ -48,15 +47,14 @@ class CookiesComponent < ViewComponent::Base
|
|
48
47
|
}
|
49
48
|
|
50
49
|
#cookies
|
51
|
-
-
|
50
|
+
- accept_text = t("micoo.button.accept", default: "Accept")
|
51
|
+
- reject_text = t("micoo.button.reject", default: "Reject")
|
52
52
|
- [@text].flatten.each do |line|
|
53
53
|
p = line.html_safe
|
54
|
-
- [@text2].flatten.each do |line|
|
55
|
-
p = line.html_safe
|
56
54
|
.buttons
|
57
55
|
button
|
58
|
-
a href=helpers.
|
56
|
+
a href=helpers.cookies_accept_path(url: @url) = accept_text
|
59
57
|
button
|
60
|
-
a href=helpers.
|
58
|
+
a href=helpers.cookies_reject_path(url: @url) = reject_text
|
61
59
|
HEREDOC
|
62
60
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "view_component"
|
4
|
+
|
5
|
+
class CookiesComponent < ViewComponent::Base
|
6
|
+
def initialize(text: nil, url: nil)
|
7
|
+
unless text
|
8
|
+
text = []
|
9
|
+
text << <<~EOS
|
10
|
+
You may delete and block all cookies from this site,
|
11
|
+
but parts of the site will not work.
|
12
|
+
EOS
|
13
|
+
text << <<~EOS
|
14
|
+
Click "Accept" if you consent usage of cookies,
|
15
|
+
otherwise click "Reject".
|
16
|
+
EOS
|
17
|
+
end
|
18
|
+
|
19
|
+
@text = text
|
20
|
+
@url = url
|
21
|
+
end
|
22
|
+
|
23
|
+
slim_template <<~HEREDOC
|
24
|
+
css:
|
25
|
+
div#cookies {
|
26
|
+
background: #000000;
|
27
|
+
font-color: #ffffff;
|
28
|
+
color: white;
|
29
|
+
font-size: 1.2rem;
|
30
|
+
left: 0px;
|
31
|
+
opacity: 40%;
|
32
|
+
position: fixed;
|
33
|
+
right: 0;
|
34
|
+
top: 0;
|
35
|
+
z-index:1000;
|
36
|
+
}
|
37
|
+
div#cookies p {
|
38
|
+
margin: 10px;
|
39
|
+
}
|
40
|
+
div#cookies .buttons {
|
41
|
+
margin: 10px;
|
42
|
+
text-align: center;
|
43
|
+
}
|
44
|
+
div#cookies .buttons a {
|
45
|
+
font-size: 1.2rem;
|
46
|
+
text-decoration: none;
|
47
|
+
}
|
48
|
+
|
49
|
+
#cookies
|
50
|
+
- ic cookies_accept_path
|
51
|
+
- ic cookies_reject_path
|
52
|
+
- accept_text = t("micoo.button.accept", default: "Accept")
|
53
|
+
- reject_text = t("micoo.button.reject", default: "Reject")
|
54
|
+
- @url ||= "/"
|
55
|
+
- [@text].flatten.each do |line|
|
56
|
+
p = line.html_safe
|
57
|
+
.buttons
|
58
|
+
button
|
59
|
+
a href=helpers.cookies_accept_path(url: @url) = accept_text
|
60
|
+
button
|
61
|
+
a href=helpers.cookies_reject_path(url: @url) = reject_text
|
62
|
+
HEREDOC
|
63
|
+
end
|
data/app/controllers/cookies.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
class CookiesController < ActionController::Base
|
2
|
-
def
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
else
|
7
|
-
cookies.delete(sym)
|
8
|
-
end
|
2
|
+
def accept
|
3
|
+
cookies[:cookiesOK] = {value: "x", expires: 1.month.from_now}
|
4
|
+
redirect_to("/")
|
5
|
+
end
|
9
6
|
|
10
|
-
|
7
|
+
def reject
|
8
|
+
cookies.delete(:cookiesOK)
|
9
|
+
redirect_to("/")
|
11
10
|
end
|
12
11
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class CookiesController < ActionController::Base
|
2
|
+
# def index
|
3
|
+
# sym = :cookiesOK
|
4
|
+
# if params[sym] == "x"
|
5
|
+
# cookies[sym] = {value: "x", expires: 1.month.from_now}
|
6
|
+
# else
|
7
|
+
# cookies.delete(sym)
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# redirect_to(params[:url] || "/")
|
11
|
+
# end
|
12
|
+
|
13
|
+
def accept
|
14
|
+
p 2222222222222222
|
15
|
+
cookies[:cookiesOK] = {value: "x", expires: 1.month.from_now}
|
16
|
+
redirect_to("/")
|
17
|
+
end
|
18
|
+
|
19
|
+
def reject
|
20
|
+
p 333333333333
|
21
|
+
cookies.delete(:cookiesOK)
|
22
|
+
redirect_to("/")
|
23
|
+
end
|
24
|
+
end
|
data/config/routes.rb
CHANGED
data/lib/micoo/version.rb
CHANGED
data/lib/micoo/version.rb.bak
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: micoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dittmar Krall
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: combustion
|
@@ -40,20 +40,6 @@ dependencies:
|
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 7.1.3
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 7.1.3
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: ricecream
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
@@ -67,7 +53,7 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
55
|
description: |
|
70
|
-
MICOO (Minimal Cookies) is
|
56
|
+
MICOO (Minimal Cookies) is a Rails engine to handle
|
71
57
|
Cookies consent.
|
72
58
|
email: dittmar.krall@matiq.com
|
73
59
|
executables: []
|
@@ -79,8 +65,11 @@ files:
|
|
79
65
|
- MIT-LICENSE
|
80
66
|
- README.md
|
81
67
|
- app/components/cookies_component.rb
|
68
|
+
- app/components/cookies_component.rb.bak
|
82
69
|
- app/controllers/cookies.rb
|
70
|
+
- app/controllers/cookies.rb.bak
|
83
71
|
- config/routes.rb
|
72
|
+
- config/routes.rb.bak
|
84
73
|
- lib/micoo.rb
|
85
74
|
- lib/micoo/engine.rb
|
86
75
|
- lib/micoo/version.rb
|
@@ -89,7 +78,7 @@ homepage: https://github.com/matique/micoo
|
|
89
78
|
licenses:
|
90
79
|
- MIT
|
91
80
|
metadata: {}
|
92
|
-
post_install_message:
|
81
|
+
post_install_message:
|
93
82
|
rdoc_options: []
|
94
83
|
require_paths:
|
95
84
|
- lib
|
@@ -104,8 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
93
|
- !ruby/object:Gem::Version
|
105
94
|
version: '0'
|
106
95
|
requirements: []
|
107
|
-
rubygems_version: 3.5.
|
108
|
-
signing_key:
|
96
|
+
rubygems_version: 3.5.23
|
97
|
+
signing_key:
|
109
98
|
specification_version: 4
|
110
99
|
summary: Minimal Cookies Consent Banner.
|
111
100
|
test_files: []
|