micoo 0.2.0 → 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: 6c82aee71a8f615ee75b99c1b14d640b0b09886a73460482efe9e5bba96da02b
4
- data.tar.gz: 19de10e0ac48e27806b38c7ba723089e4492c5b8981107334525fb75157cb61d
3
+ metadata.gz: 4938cb799ff2c37284f591c2fe7b2aed39593ed4e0207d019cc0efbeb555bf1b
4
+ data.tar.gz: b3fec0c9a1c4936d081c811082e2e834836f07c2f2a6ffd954e870a37d95ef7f
5
5
  SHA512:
6
- metadata.gz: 96fba69bce87544895ed7b292c953e7295053a180e2ad8b93ecf6c03dc8a970c6639caa4bf59f336a41d0131a0e776ad6105167b55d04dec5d5982b460782967
7
- data.tar.gz: 94a73329dc3ceced61c709b9056b818c1ee7732771505ba1ac5e30daebd76c67b21f21fd6f85e05a0134d1e7725c7d2d194820d57138564f93ca4ba8dc9f55ff
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
- Default 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,7 +52,7 @@ Default 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
  ...
@@ -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
@@ -50,15 +49,12 @@ class CookiesComponent < ViewComponent::Base
50
49
  #cookies
51
50
  - accept_text = t("micoo.button.accept", default: "Accept")
52
51
  - reject_text = t("micoo.button.reject", default: "Reject")
53
- - @url ||= "/"
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(url: @url) = accept_text
61
57
  button
62
- a href=helpers.cookies_path(url: @url) = reject_text
58
+ a href=helpers.cookies_reject_path(url: @url) = reject_text
63
59
  HEREDOC
64
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,4 +1,5 @@
1
1
  module Micoo
2
- VERSION = "0.2.0" # 2024-05-19
2
+ VERSION = "0.3.0" # 2024-11-10
3
+ # VERSION = "0.2.0" # 2024-05-19
3
4
  # VERSION = "0.1.3" # 2024-05-06
4
5
  end
@@ -1,3 +1,4 @@
1
1
  module Micoo
2
- VERSION = "0.1.3" # 2024-05-06
2
+ VERSION = "0.2.0" # 2024-05-19
3
+ # VERSION = "0.1.3" # 2024-05-06
3
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.2.0
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-19 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: []