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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c82aee71a8f615ee75b99c1b14d640b0b09886a73460482efe9e5bba96da02b
4
- data.tar.gz: 19de10e0ac48e27806b38c7ba723089e4492c5b8981107334525fb75157cb61d
3
+ metadata.gz: bd7e4c268fcab12e2382c818aec8ad8c5e10ad5bf66afda6dbb9cd7db0538108
4
+ data.tar.gz: c415fd762eb5438d592516d4b94230592285d192f9f215ed11a17b6795c44675
5
5
  SHA512:
6
- metadata.gz: 96fba69bce87544895ed7b292c953e7295053a180e2ad8b93ecf6c03dc8a970c6639caa4bf59f336a41d0131a0e776ad6105167b55d04dec5d5982b460782967
7
- data.tar.gz: 94a73329dc3ceced61c709b9056b818c1ee7732771505ba1ac5e30daebd76c67b21f21fd6f85e05a0134d1e7725c7d2d194820d57138564f93ca4ba8dc9f55ff
6
+ metadata.gz: c8fcc23aeacb05462eb9d1b6ba9dc702e3e5078a011266ba29dd87ff69ec2fe7e074eb4b27028651fad8ce8f6a56b2c79e4205292e49934f0a31e5cb246f2128
7
+ data.tar.gz: 931173bc2dc60a588315a5a618f521964c0b618ee087a2a99a499cc59940f55fe027e0f238ff05003a435cead05cae1c65d6109d740c21a70cb45349ee933e03
data/MIT-LICENSE CHANGED
@@ -1,6 +1,4 @@
1
- The MIT License (MIT)
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
- [![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
- Micoo (minimal Cookie) is a Rails Engine handling the Cookie consent.
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
- Micoo display a styled text including buttons for
11
- accepting or rejecting usage of cookies.
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" will delete the cookie.
16
+ clicking *Reject* will delete the cookie,
17
+ clicking *Customize* links to administration of cookies.
15
18
 
16
- ## Optional Parameters
19
+ The cookie "cookiesOK" expires after one month.
17
20
 
18
- Optional parameters for *CookiesComponent.new(...)* are:
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(url: root_path)
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 legend.
58
- A configuration file (a sample) may be:
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, text2: [], url: 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
- - @url ||= "/"
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.cookies_path(cookiesOK: :x, url: @url) = accept_text
56
+ a href=helpers.cookies_accept_path = accept_text
61
57
  button
62
- a href=helpers.cookies_path(url: @url) = reject_text
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
@@ -1,12 +1,15 @@
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
6
+
7
+ def reject
8
+ cookies.delete(:cookiesOK)
9
+ redirect_to("/")
10
+ end
9
11
 
10
- redirect_to(params[:url] || "/")
12
+ def customize
13
+ raise "Define your own CookiesController#customize"
11
14
  end
12
15
  end
data/config/routes.rb CHANGED
@@ -1,3 +1,5 @@
1
1
  Rails.application.routes.draw do
2
- get "cookies", to: "cookies#index"
2
+ get "/cookies/accept"
3
+ get "/cookies/reject"
4
+ get "/cookies/customize"
3
5
  end
data/lib/micoo/version.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  module Micoo
2
- VERSION = "0.2.0" # 2024-05-19
2
+ VERSION = "0.4.0" # 2025-06-08
3
+ # VERSION = "0.3.0" # 2024-11-10
4
+ # VERSION = "0.2.0" # 2024-05-19
3
5
  # VERSION = "0.1.3" # 2024-05-06
4
6
  end
@@ -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
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.2.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: 2024-05-19 00:00:00.000000000 Z
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 an Rails engine to handle
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: '0'
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.5.9
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: []