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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bebc66e37df81808e0e723e937ef19f342cadd794ed572dbd47caa02c579047f
4
- data.tar.gz: baa4e661ed749be3a09d4fc58b76e50c3a7529ac62aa8e0ba9d1c10004b521cb
3
+ metadata.gz: 4938cb799ff2c37284f591c2fe7b2aed39593ed4e0207d019cc0efbeb555bf1b
4
+ data.tar.gz: b3fec0c9a1c4936d081c811082e2e834836f07c2f2a6ffd954e870a37d95ef7f
5
5
  SHA512:
6
- metadata.gz: 64f119463459b058cd4e25b51f1433c764610a5ed8d0f59ea4449a203fed4cafac602ffd813cbcd54a92ff74a96e9b4c3d31a47cfe5ae023387e94f3d482ae15
7
- data.tar.gz: d62a5839834444290c1bae2da4ca8b9c8003b89b8ee8adeff2fc3cd87274e5ba48d4833fcda8f7477006e26cbf81613634d860d2c1f4c485f2bd9cb0d9575089
6
+ metadata.gz: 528a5b5e7ea400c8e2e472f885cf1370d3179f143e713233cf27f65bd0d15ace6643d741940d2a0fb3d29fc599b2b00c7e693621a57641501ff18c9a5afa4c6d
7
+ data.tar.gz: cc35e1eea243242b89c6daedf944252b224f07f4117fb4edeef42ce429373fea603df378b9af9c3c9973e02780016a1b592241fe24c42662de8df7ebe60dd317
data/MIT-LICENSE CHANGED
@@ -1,5 +1,3 @@
1
- The MIT License (MIT)
2
-
3
1
  Copyright (c) 2024 Dittmar Krall (www.matiq.com)
4
2
 
5
3
  Permission is hereby granted, free of charge, to any person obtaining
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Micoo
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/micoo.png)](http://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" will delete the cookie.
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
- Defult is "/".
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: root_path)
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, text2: [], url: 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
- @text2 = text2
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
- - @url ||= "/"
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.cookies_path(cookiesOK: :x, url: @url) Accept
56
+ a href=helpers.cookies_accept_path(url: @url) = accept_text
59
57
  button
60
- a href=helpers.cookies_path(url: @url) Reject
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
@@ -1,12 +1,11 @@
1
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
2
+ def accept
3
+ cookies[:cookiesOK] = {value: "x", expires: 1.month.from_now}
4
+ redirect_to("/")
5
+ end
9
6
 
10
- redirect_to(params[:url] || "/")
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
@@ -1,3 +1,4 @@
1
1
  Rails.application.routes.draw do
2
- get "cookies", to: "cookies#index"
2
+ get "/cookies/accept"
3
+ get "/cookies/reject"
3
4
  end
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ get "cookies", to: "cookies#index"
3
+ end
data/lib/micoo/version.rb CHANGED
@@ -1,3 +1,5 @@
1
1
  module Micoo
2
- VERSION = "0.1.3" # 2024-05-06
2
+ VERSION = "0.3.0" # 2024-11-10
3
+ # VERSION = "0.2.0" # 2024-05-19
4
+ # VERSION = "0.1.3" # 2024-05-06
3
5
  end
@@ -1,5 +1,4 @@
1
1
  module Micoo
2
- VERSION = "0.1.3" # 2024-05-06
3
- # VERSION = "0.1.2" # 2024-05-02
4
- # VERSION = "0.1.1" # 2024-05-01
2
+ VERSION = "0.2.0" # 2024-05-19
3
+ # VERSION = "0.1.3" # 2024-05-06
5
4
  end
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.1.3
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-05-06 00:00:00.000000000 Z
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 an Rails engine to handle
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.9
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: []