micoo 0.2.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 -3
- data/README.md +37 -23
- data/app/components/cookies_component.rb +6 -8
- data/app/controllers/cookies.rb +11 -8
- data/config/routes.rb +3 -1
- data/lib/micoo/version.rb +3 -1
- data/lib/micoo/version.rb.bak +3 -1
- metadata +7 -24
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
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Copyright (c) 2024 Dittmar Krall (www.matiq.com)
|
1
|
+
Copyright (c) 2024-2025 Dittmar Krall (www.matiq.com)
|
4
2
|
|
5
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
4
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
# Micoo
|
2
2
|
|
3
|
-
[](http://badge.fury.io/rb/micoo)
|
4
4
|
[](https://rubygems.org/gems/micoo)
|
5
|
+
[](https://github.com/matique/micoo/actions/workflows/rake.yml)
|
6
|
+
[](https://github.com/standardrb/standard)
|
5
7
|
[](http://choosealicense.com/licenses/mit/)
|
6
8
|
|
7
|
-
|
9
|
+
_Micoo_ (minimal Cookie) is a Rails Engine handling the Cookie consent.
|
8
10
|
Besides installing the gem just a minimal code is required (see _Usage_).
|
9
11
|
|
10
|
-
|
11
|
-
accepting
|
12
|
+
_Micoo_ display a styled text including buttons for
|
13
|
+
accepting, rejecting and customizing 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,
|
17
|
+
clicking *Customize* links to administration of cookies.
|
15
18
|
|
16
|
-
|
19
|
+
The cookie "cookiesOK" expires after one month.
|
17
20
|
|
18
|
-
Optional
|
21
|
+
## Optional Parameter
|
22
|
+
|
23
|
+
Optional parameter for *CookiesComponent.new(...)* are:
|
19
24
|
|
20
25
|
### _text_
|
21
26
|
|
22
27
|
Default is:
|
23
28
|
|
24
29
|
> You may delete and block all cookies from this site,
|
25
|
-
but parts of the site will not work.
|
26
|
-
|
30
|
+
> but parts of the site will not work.
|
31
|
+
>
|
27
32
|
> Click *Accept* if you consent usage of cookies, otherwise click *Reject*.
|
28
33
|
|
29
|
-
### _text2_
|
30
|
-
|
31
|
-
_text2_ may be used to
|
32
|
-
add additional text and links for further description.
|
33
|
-
|
34
|
-
### _url_
|
35
|
-
|
36
|
-
Redirection to _url_ will be triggered by clicking *Accept* or *Reject*.
|
37
|
-
Default is "/".
|
38
|
-
|
39
34
|
## Usage
|
40
35
|
|
36
|
+
```ruby
|
37
|
+
# config/routes.rb
|
38
|
+
Rails.application.routes.draw do
|
39
|
+
...
|
40
|
+
get "/cookies/accept"
|
41
|
+
get "/cookies/reject"
|
42
|
+
get "/cookies/customize
|
43
|
+
...
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
41
47
|
```ruby
|
42
48
|
# app/controllers/application_controller.rb (recommended)
|
43
49
|
...
|
@@ -45,17 +51,24 @@ Default is "/".
|
|
45
51
|
|
46
52
|
def always
|
47
53
|
unless cookies[:cookiesOK] == "x"
|
48
|
-
render CookiesComponent.new
|
54
|
+
render CookiesComponent.new
|
49
55
|
end
|
50
56
|
end
|
51
57
|
...
|
52
58
|
```
|
53
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
|
+
|
54
67
|
## I18n
|
55
68
|
You may provide an "internationalized" text via the _text_ parameter.
|
56
69
|
|
57
|
-
_Micoo_ buttons uses the I18n.translate method for the
|
58
|
-
A configuration file
|
70
|
+
_Micoo_ buttons uses the I18n.translate method for the legends.
|
71
|
+
A configuration file may contain:
|
59
72
|
|
60
73
|
```ruby
|
61
74
|
# config/locales/en.yml
|
@@ -64,6 +77,7 @@ en:
|
|
64
77
|
button:
|
65
78
|
accept: Accept
|
66
79
|
reject: Reject
|
80
|
+
customize: Customize
|
67
81
|
```
|
68
82
|
|
69
83
|
## Installation
|
@@ -77,5 +91,5 @@ gem "micoo"
|
|
77
91
|
and run "bundle install".
|
78
92
|
|
79
93
|
## License
|
80
|
-
Copyright (c) 2024 Dittmar Krall (www.matiq.com),
|
94
|
+
Copyright (c) 2024-2025 Dittmar Krall (www.matiq.com),
|
81
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,8 +17,6 @@ class CookiesComponent < ViewComponent::Base
|
|
17
17
|
end
|
18
18
|
|
19
19
|
@text = text
|
20
|
-
@text2 = text2
|
21
|
-
@url = url
|
22
20
|
end
|
23
21
|
|
24
22
|
slim_template <<~HEREDOC
|
@@ -50,15 +48,15 @@ class CookiesComponent < ViewComponent::Base
|
|
50
48
|
#cookies
|
51
49
|
- accept_text = t("micoo.button.accept", default: "Accept")
|
52
50
|
- reject_text = t("micoo.button.reject", default: "Reject")
|
53
|
-
-
|
51
|
+
- customize_text = t("micoo.button.customize", default: "Customize")
|
54
52
|
- [@text].flatten.each do |line|
|
55
53
|
p = line.html_safe
|
56
|
-
- [@text2].flatten.each do |line|
|
57
|
-
p = line.html_safe
|
58
54
|
.buttons
|
59
55
|
button
|
60
|
-
a href=helpers.
|
56
|
+
a href=helpers.cookies_accept_path = accept_text
|
61
57
|
button
|
62
|
-
a href=helpers.
|
58
|
+
a href=helpers.cookies_reject_path = reject_text
|
59
|
+
button#customize
|
60
|
+
a href=helpers.cookies_customize_path = customize_text
|
63
61
|
HEREDOC
|
64
62
|
end
|
data/app/controllers/cookies.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
class CookiesController < ActionController::Base
|
2
|
-
def
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
def accept
|
3
|
+
cookies[:cookiesOK] = {value: "x", expires: 1.month.from_now}
|
4
|
+
redirect_to("/")
|
5
|
+
end
|
6
|
+
|
7
|
+
def reject
|
8
|
+
cookies.delete(:cookiesOK)
|
9
|
+
redirect_to("/")
|
10
|
+
end
|
9
11
|
|
10
|
-
|
12
|
+
def customize
|
13
|
+
raise "Define your own CookiesController#customize"
|
11
14
|
end
|
12
15
|
end
|
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
|
@@ -40,20 +39,6 @@ dependencies:
|
|
40
39
|
version: '0'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
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
42
|
requirement: !ruby/object:Gem::Requirement
|
58
43
|
requirements:
|
59
44
|
- - ">="
|
@@ -67,14 +52,14 @@ dependencies:
|
|
67
52
|
- !ruby/object:Gem::Version
|
68
53
|
version: '0'
|
69
54
|
description: |
|
70
|
-
MICOO (Minimal Cookies) is
|
55
|
+
MICOO (Minimal Cookies) is a Rails engine to handle
|
71
56
|
Cookies consent.
|
72
57
|
email: dittmar.krall@matiq.com
|
73
58
|
executables: []
|
74
59
|
extensions: []
|
75
60
|
extra_rdoc_files:
|
76
|
-
- README.md
|
77
61
|
- MIT-LICENSE
|
62
|
+
- README.md
|
78
63
|
files:
|
79
64
|
- MIT-LICENSE
|
80
65
|
- README.md
|
@@ -89,23 +74,21 @@ homepage: https://github.com/matique/micoo
|
|
89
74
|
licenses:
|
90
75
|
- MIT
|
91
76
|
metadata: {}
|
92
|
-
post_install_message:
|
93
77
|
rdoc_options: []
|
94
78
|
require_paths:
|
95
79
|
- lib
|
96
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
81
|
requirements:
|
98
|
-
- - "
|
82
|
+
- - "~>"
|
99
83
|
- !ruby/object:Gem::Version
|
100
|
-
version: '
|
84
|
+
version: '3'
|
101
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
86
|
requirements:
|
103
87
|
- - ">="
|
104
88
|
- !ruby/object:Gem::Version
|
105
89
|
version: '0'
|
106
90
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
108
|
-
signing_key:
|
91
|
+
rubygems_version: 3.6.7
|
109
92
|
specification_version: 4
|
110
93
|
summary: Minimal Cookies Consent Banner.
|
111
94
|
test_files: []
|