micoo 0.3.0 → 0.4.0
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 +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +22 -15
- data/app/components/cookies_component.rb +6 -4
- data/app/controllers/cookies.rb +4 -0
- data/config/routes.rb +1 -0
- data/lib/micoo/version.rb +2 -1
- data/lib/micoo/version.rb.bak +2 -1
- metadata +6 -12
- data/app/components/cookies_component.rb.bak +0 -63
- data/app/controllers/cookies.rb.bak +0 -24
- data/config/routes.rb.bak +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd7e4c268fcab12e2382c818aec8ad8c5e10ad5bf66afda6dbb9cd7db0538108
|
4
|
+
data.tar.gz: c415fd762eb5438d592516d4b94230592285d192f9f215ed11a17b6795c44675
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8fcc23aeacb05462eb9d1b6ba9dc702e3e5078a011266ba29dd87ff69ec2fe7e074eb4b27028651fad8ce8f6a56b2c79e4205292e49934f0a31e5cb246f2128
|
7
|
+
data.tar.gz: 931173bc2dc60a588315a5a618f521964c0b618ee087a2a99a499cc59940f55fe027e0f238ff05003a435cead05cae1c65d6109d740c21a70cb45349ee933e03
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -6,18 +6,21 @@
|
|
6
6
|
[](https://github.com/standardrb/standard)
|
7
7
|
[](http://choosealicense.com/licenses/mit/)
|
8
8
|
|
9
|
-
|
9
|
+
_Micoo_ (minimal Cookie) is a Rails Engine handling the Cookie consent.
|
10
10
|
Besides installing the gem just a minimal code is required (see _Usage_).
|
11
11
|
|
12
|
-
|
13
|
-
accepting
|
12
|
+
_Micoo_ display a styled text including buttons for
|
13
|
+
accepting, rejecting and customizing usage of cookies.
|
14
14
|
|
15
15
|
Clicking *Accept* set the cookie "cookiesOK" to "x",
|
16
|
-
clicking *Reject* will delete the cookie
|
16
|
+
clicking *Reject* will delete the cookie,
|
17
|
+
clicking *Customize* links to administration of cookies.
|
17
18
|
|
18
|
-
|
19
|
+
The cookie "cookiesOK" expires after one month.
|
19
20
|
|
20
|
-
Optional
|
21
|
+
## Optional Parameter
|
22
|
+
|
23
|
+
Optional parameter for *CookiesComponent.new(...)* are:
|
21
24
|
|
22
25
|
### _text_
|
23
26
|
|
@@ -28,11 +31,6 @@ Default is:
|
|
28
31
|
>
|
29
32
|
> Click *Accept* if you consent usage of cookies, otherwise click *Reject*.
|
30
33
|
|
31
|
-
### _url_
|
32
|
-
|
33
|
-
Redirection to _url_ will be triggered by clicking *Accept* or *Reject*.
|
34
|
-
Default is *request.url*.
|
35
|
-
|
36
34
|
## Usage
|
37
35
|
|
38
36
|
```ruby
|
@@ -41,6 +39,7 @@ Rails.application.routes.draw do
|
|
41
39
|
...
|
42
40
|
get "/cookies/accept"
|
43
41
|
get "/cookies/reject"
|
42
|
+
get "/cookies/customize
|
44
43
|
...
|
45
44
|
end
|
46
45
|
```
|
@@ -52,17 +51,24 @@ end
|
|
52
51
|
|
53
52
|
def always
|
54
53
|
unless cookies[:cookiesOK] == "x"
|
55
|
-
render CookiesComponent.new
|
54
|
+
render CookiesComponent.new
|
56
55
|
end
|
57
56
|
end
|
58
57
|
...
|
59
58
|
```
|
60
59
|
|
60
|
+
### Customize
|
61
|
+
|
62
|
+
The user should provide functionality for the *Customize* button.
|
63
|
+
|
64
|
+
Button *Customize* can be disabled/hidden by CSS.
|
65
|
+
|
66
|
+
|
61
67
|
## I18n
|
62
68
|
You may provide an "internationalized" text via the _text_ parameter.
|
63
69
|
|
64
|
-
_Micoo_ buttons uses the I18n.translate method for the
|
65
|
-
A configuration file
|
70
|
+
_Micoo_ buttons uses the I18n.translate method for the legends.
|
71
|
+
A configuration file may contain:
|
66
72
|
|
67
73
|
```ruby
|
68
74
|
# config/locales/en.yml
|
@@ -71,6 +77,7 @@ en:
|
|
71
77
|
button:
|
72
78
|
accept: Accept
|
73
79
|
reject: Reject
|
80
|
+
customize: Customize
|
74
81
|
```
|
75
82
|
|
76
83
|
## Installation
|
@@ -84,5 +91,5 @@ gem "micoo"
|
|
84
91
|
and run "bundle install".
|
85
92
|
|
86
93
|
## License
|
87
|
-
Copyright (c) 2024 Dittmar Krall (www.matiq.com),
|
94
|
+
Copyright (c) 2024-2025 Dittmar Krall (www.matiq.com),
|
88
95
|
released under the [MIT license](https://opensource.org/licenses/MIT).
|
@@ -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)
|
7
7
|
unless text
|
8
8
|
text = []
|
9
9
|
text << <<~EOS
|
@@ -17,7 +17,6 @@ class CookiesComponent < ViewComponent::Base
|
|
17
17
|
end
|
18
18
|
|
19
19
|
@text = text
|
20
|
-
@url = url || "/"
|
21
20
|
end
|
22
21
|
|
23
22
|
slim_template <<~HEREDOC
|
@@ -49,12 +48,15 @@ class CookiesComponent < ViewComponent::Base
|
|
49
48
|
#cookies
|
50
49
|
- accept_text = t("micoo.button.accept", default: "Accept")
|
51
50
|
- reject_text = t("micoo.button.reject", default: "Reject")
|
51
|
+
- customize_text = t("micoo.button.customize", default: "Customize")
|
52
52
|
- [@text].flatten.each do |line|
|
53
53
|
p = line.html_safe
|
54
54
|
.buttons
|
55
55
|
button
|
56
|
-
a href=helpers.cookies_accept_path
|
56
|
+
a href=helpers.cookies_accept_path = accept_text
|
57
57
|
button
|
58
|
-
a href=helpers.cookies_reject_path
|
58
|
+
a href=helpers.cookies_reject_path = reject_text
|
59
|
+
button#customize
|
60
|
+
a href=helpers.cookies_customize_path = customize_text
|
59
61
|
HEREDOC
|
60
62
|
end
|
data/app/controllers/cookies.rb
CHANGED
data/config/routes.rb
CHANGED
data/lib/micoo/version.rb
CHANGED
data/lib/micoo/version.rb.bak
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: micoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dittmar Krall
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: combustion
|
@@ -59,17 +58,14 @@ email: dittmar.krall@matiq.com
|
|
59
58
|
executables: []
|
60
59
|
extensions: []
|
61
60
|
extra_rdoc_files:
|
62
|
-
- README.md
|
63
61
|
- MIT-LICENSE
|
62
|
+
- README.md
|
64
63
|
files:
|
65
64
|
- MIT-LICENSE
|
66
65
|
- README.md
|
67
66
|
- app/components/cookies_component.rb
|
68
|
-
- app/components/cookies_component.rb.bak
|
69
67
|
- app/controllers/cookies.rb
|
70
|
-
- app/controllers/cookies.rb.bak
|
71
68
|
- config/routes.rb
|
72
|
-
- config/routes.rb.bak
|
73
69
|
- lib/micoo.rb
|
74
70
|
- lib/micoo/engine.rb
|
75
71
|
- lib/micoo/version.rb
|
@@ -78,23 +74,21 @@ homepage: https://github.com/matique/micoo
|
|
78
74
|
licenses:
|
79
75
|
- MIT
|
80
76
|
metadata: {}
|
81
|
-
post_install_message:
|
82
77
|
rdoc_options: []
|
83
78
|
require_paths:
|
84
79
|
- lib
|
85
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
81
|
requirements:
|
87
|
-
- - "
|
82
|
+
- - "~>"
|
88
83
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
84
|
+
version: '3'
|
90
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
86
|
requirements:
|
92
87
|
- - ">="
|
93
88
|
- !ruby/object:Gem::Version
|
94
89
|
version: '0'
|
95
90
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
97
|
-
signing_key:
|
91
|
+
rubygems_version: 3.6.7
|
98
92
|
specification_version: 4
|
99
93
|
summary: Minimal Cookies Consent Banner.
|
100
94
|
test_files: []
|
@@ -1,63 +0,0 @@
|
|
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
|
@@ -1,24 +0,0 @@
|
|
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.bak
DELETED