micoo 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +22 -0
- data/README.md +66 -0
- data/app/components/cookies_component.rb +62 -0
- data/app/controllers/cookies.rb +12 -0
- data/config/routes.rb +3 -0
- data/lib/micoo/engine.rb +4 -0
- data/lib/micoo/version.rb +3 -0
- data/lib/micoo/version.rb.bak +5 -0
- data/lib/micoo.rb +3 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bebc66e37df81808e0e723e937ef19f342cadd794ed572dbd47caa02c579047f
|
4
|
+
data.tar.gz: baa4e661ed749be3a09d4fc58b76e50c3a7529ac62aa8e0ba9d1c10004b521cb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64f119463459b058cd4e25b51f1433c764610a5ed8d0f59ea4449a203fed4cafac602ffd813cbcd54a92ff74a96e9b4c3d31a47cfe5ae023387e94f3d482ae15
|
7
|
+
data.tar.gz: d62a5839834444290c1bae2da4ca8b9c8003b89b8ee8adeff2fc3cd87274e5ba48d4833fcda8f7477006e26cbf81613634d860d2c1f4c485f2bd9cb0d9575089
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Dittmar Krall (www.matiq.com)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Micoo
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/micoo.png)](http://badge.fury.io/rb/micoo)
|
4
|
+
[![GEM Downloads](https://img.shields.io/gem/dt/micoo?color=168AFE&logo=ruby&logoColor=FE1616)](https://rubygems.org/gems/micoo)
|
5
|
+
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](http://choosealicense.com/licenses/mit/)
|
6
|
+
|
7
|
+
Micoo (minimal Cookie) is a Rails Engine handling the Cookie consent.
|
8
|
+
Besides installing the gem just a minimal code is required (see _Usage_).
|
9
|
+
|
10
|
+
Micoo display a styled text including buttons for
|
11
|
+
accepting or rejecting usage of cookies.
|
12
|
+
|
13
|
+
Clicking *Accept* set the cookie "cookiesOK" to "x",
|
14
|
+
clicking *Reject" will delete the cookie.
|
15
|
+
|
16
|
+
## Optional Parameters
|
17
|
+
|
18
|
+
Optional parameters for *CookiesComponent.new(...)* are:
|
19
|
+
|
20
|
+
### _text_
|
21
|
+
|
22
|
+
Default is:
|
23
|
+
|
24
|
+
> You may delete and block all cookies from this site,
|
25
|
+
but parts of the site will not work.
|
26
|
+
|
27
|
+
> Click *Accept* if you consent usage of cookies, otherwise click *Reject*.
|
28
|
+
|
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
|
+
Defult is "/".
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
# app/controllers/application_controller.rb (recommended)
|
43
|
+
...
|
44
|
+
before_action :always
|
45
|
+
|
46
|
+
def always
|
47
|
+
unless cookies[:cookiesOK] == "x"
|
48
|
+
render CookiesComponent.new(url: root_path)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
...
|
52
|
+
```
|
53
|
+
|
54
|
+
## Installation
|
55
|
+
As usual:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
# Gemfile
|
59
|
+
gem "micoo"
|
60
|
+
```
|
61
|
+
|
62
|
+
and run "bundle install".
|
63
|
+
|
64
|
+
## License
|
65
|
+
Copyright (c) 2024 Dittmar Krall (www.matiq.com),
|
66
|
+
released under the [MIT license](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "view_component"
|
4
|
+
|
5
|
+
class CookiesComponent < ViewComponent::Base
|
6
|
+
def initialize(text: nil, text2: [], 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
|
+
@text2 = text2
|
21
|
+
@url = url
|
22
|
+
end
|
23
|
+
|
24
|
+
slim_template <<~HEREDOC
|
25
|
+
css:
|
26
|
+
div#cookies {
|
27
|
+
background: #000000;
|
28
|
+
font-color: #ffffff;
|
29
|
+
color: white;
|
30
|
+
font-size: 1.2rem;
|
31
|
+
left: 0px;
|
32
|
+
opacity: 40%;
|
33
|
+
position: fixed;
|
34
|
+
right: 0;
|
35
|
+
top: 0;
|
36
|
+
z-index:1000;
|
37
|
+
}
|
38
|
+
div#cookies p {
|
39
|
+
margin: 10px;
|
40
|
+
}
|
41
|
+
div#cookies .buttons {
|
42
|
+
margin: 10px;
|
43
|
+
text-align: center;
|
44
|
+
}
|
45
|
+
div#cookies .buttons a {
|
46
|
+
font-size: 1.2rem;
|
47
|
+
text-decoration: none;
|
48
|
+
}
|
49
|
+
|
50
|
+
#cookies
|
51
|
+
- @url ||= "/"
|
52
|
+
- [@text].flatten.each do |line|
|
53
|
+
p = line.html_safe
|
54
|
+
- [@text2].flatten.each do |line|
|
55
|
+
p = line.html_safe
|
56
|
+
.buttons
|
57
|
+
button
|
58
|
+
a href=helpers.cookies_path(cookiesOK: :x, url: @url) Accept
|
59
|
+
button
|
60
|
+
a href=helpers.cookies_path(url: @url) Reject
|
61
|
+
HEREDOC
|
62
|
+
end
|
data/config/routes.rb
ADDED
data/lib/micoo/engine.rb
ADDED
data/lib/micoo.rb
ADDED
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: micoo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dittmar Krall
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: combustion
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
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
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: |
|
70
|
+
MICOO (Minimal Cookies) is an Rails engine to handle
|
71
|
+
Cookies consent.
|
72
|
+
email: dittmar.krall@matiq.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files:
|
76
|
+
- README.md
|
77
|
+
- MIT-LICENSE
|
78
|
+
files:
|
79
|
+
- MIT-LICENSE
|
80
|
+
- README.md
|
81
|
+
- app/components/cookies_component.rb
|
82
|
+
- app/controllers/cookies.rb
|
83
|
+
- config/routes.rb
|
84
|
+
- lib/micoo.rb
|
85
|
+
- lib/micoo/engine.rb
|
86
|
+
- lib/micoo/version.rb
|
87
|
+
- lib/micoo/version.rb.bak
|
88
|
+
homepage: https://github.com/matique/micoo
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubygems_version: 3.5.9
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Minimal Cookies Consent Banner.
|
111
|
+
test_files: []
|