rails_tipjar 1.0.1 → 1.0.4

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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsTipjar
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.4"
5
5
  end
data/lib/rails_tipjar.rb CHANGED
@@ -1,22 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "rails_tipjar/version"
4
- require_relative "rails_tipjar/configuration"
5
4
  require_relative "rails_tipjar/engine" if defined?(Rails)
6
5
 
7
6
  module RailsTipjar
8
7
  class Error < StandardError; end
9
-
10
- class << self
11
- attr_accessor :configuration
12
- end
13
-
14
- def self.configure
15
- self.configuration ||= Configuration.new
16
- yield(configuration)
17
- end
18
-
19
- def self.config
20
- self.configuration ||= Configuration.new
21
- end
22
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_tipjar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Paulson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-12 00:00:00.000000000 Z
11
+ date: 2025-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -53,11 +53,10 @@ files:
53
53
  - app/helpers/tipjar_helper.rb
54
54
  - app/views/tipjar/_button.html.erb
55
55
  - app/views/tipjar/_modal.html.erb
56
+ - blog_post.md
56
57
  - config/importmap.rb
57
- - lib/generators/tipjar/install/install_generator.rb
58
- - lib/generators/tipjar/install/templates/tipjar.rb
58
+ - index.html
59
59
  - lib/rails_tipjar.rb
60
- - lib/rails_tipjar/configuration.rb
61
60
  - lib/rails_tipjar/engine.rb
62
61
  - lib/rails_tipjar/version.rb
63
62
  - sig/rails_tipjar.rbs
@@ -1,103 +0,0 @@
1
- require "rails/generators/base"
2
-
3
- module Tipjar
4
- module Generators
5
- class InstallGenerator < Rails::Generators::Base
6
- source_root File.expand_path("templates", __dir__)
7
-
8
- desc "Creates an optional RailsTipjar initializer for backwards compatibility"
9
-
10
- def copy_initializer
11
- if yes?("Do you want to create an initializer file for backwards compatibility? (not recommended - use view helper options instead) [y/N]")
12
- template "tipjar.rb", "config/initializers/tipjar.rb"
13
- end
14
- end
15
-
16
- def add_stimulus_controller
17
- if File.exist?("app/javascript/controllers/index.js")
18
- append_to_file "app/javascript/controllers/index.js" do
19
- <<~JS
20
-
21
- // Register Tip Jar controller
22
- import TipjarController from "tipjar_controller"
23
- application.register("tipjar", TipjarController)
24
- JS
25
- end
26
- else
27
- say "Please manually register the tipjar Stimulus controller in your application", :yellow
28
- end
29
- end
30
-
31
- def add_stylesheet
32
- if File.exist?("app/assets/stylesheets/application.css")
33
- append_to_file "app/assets/stylesheets/application.css" do
34
- <<~CSS
35
-
36
- /* Tip Jar Styles */
37
- @import 'tipjar';
38
- CSS
39
- end
40
- elsif File.exist?("app/assets/stylesheets/application.scss")
41
- append_to_file "app/assets/stylesheets/application.scss" do
42
- <<~SCSS
43
-
44
- // Tip Jar Styles
45
- @import 'tipjar';
46
- SCSS
47
- end
48
- elsif File.exist?("app/assets/stylesheets/application.tailwind.css")
49
- append_to_file "app/assets/stylesheets/application.tailwind.css" do
50
- <<~CSS
51
-
52
- /* Tip Jar Styles */
53
- @import 'tipjar';
54
- CSS
55
- end
56
- else
57
- say "Please manually import 'tipjar' stylesheet in your application", :yellow
58
- end
59
- end
60
-
61
- def add_helper_to_application_controller
62
- inject_into_file "app/controllers/application_controller.rb",
63
- after: "class ApplicationController < ActionController::Base\n" do
64
- " helper TipjarHelper\n"
65
- end
66
- end
67
-
68
- def display_post_install_message
69
- say "\n", :green
70
- say "RailsTipjar has been successfully installed!", :green
71
- say "\n"
72
- say "Next steps:", :yellow
73
- say "1. Create payment links with your preferred provider (Stripe, PayPal, Ko-fi, etc.)", :yellow
74
- say "2. Add the tip jar to your views using the helper", :yellow
75
- say "\n"
76
- say "Example usage in your views:", :cyan
77
- say <<~USAGE
78
- <!-- Simple button with direct link -->
79
- <%= tip_jar payment_link: 'https://your.payment.link' %>
80
-
81
- <!-- With custom options -->
82
- <%= tip_jar payment_link: 'https://your.payment.link',
83
- message: 'Support This Project',
84
- icon: :heart,
85
- color: '#8b5cf6',
86
- pulse: true %>
87
-
88
- <!-- Modal with multiple payment amounts -->
89
- <%= tip_jar payment_links: {
90
- small: 'https://link-5',
91
- medium: 'https://link-10',
92
- large: 'https://link-25'
93
- },
94
- modal_title: 'Support my work',
95
- position: :bottom_left %>
96
- USAGE
97
- say "\n"
98
- say "For more options, see the README: https://github.com/justinpaulson/rails_tipjar", :cyan
99
- say "\n"
100
- end
101
- end
102
- end
103
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RailsTipjar.configure do |config|
4
- # Configure your payment links
5
- # Works with any payment provider: Stripe, PayPal, Ko-fi, Buy Me a Coffee, etc.
6
- #
7
- # Simple mode - just one payment link:
8
- # config.payment_link = "https://your-payment-provider.com/your-link"
9
- #
10
- # Modal mode - multiple payment links for different amounts:
11
- config.payment_links = {
12
- small: "https://REPLACE_WITH_YOUR_PAYMENT_LINK",
13
- medium: "https://REPLACE_WITH_YOUR_PAYMENT_LINK",
14
- large: "https://REPLACE_WITH_YOUR_PAYMENT_LINK",
15
- custom: "https://REPLACE_WITH_YOUR_PAYMENT_LINK"
16
- }
17
-
18
- # Position of the tip jar button
19
- # Options: :bottom_right, :bottom_left, :top_right, :top_left
20
- config.position = :bottom_right
21
-
22
- # Icon to display in the button
23
- # Options: :coffee, :heart, :star, :dollar, or custom SVG string
24
- config.icon = :coffee
25
-
26
- # Theme for the modal
27
- # Options: :light, :dark, :auto
28
- config.theme = :light
29
-
30
- # Button text (shown on hover)
31
- config.button_text = "Buy me a coffee"
32
-
33
- # Modal customization
34
- config.modal_title = "Support my work"
35
- config.modal_description = "Your support helps me continue creating and maintaining this project."
36
-
37
- # Custom tip amounts to display in the modal
38
- config.custom_amounts = [
39
- { amount: 5, label: "$5", default: false },
40
- { amount: 10, label: "$10", default: true },
41
- { amount: 25, label: "$25", default: false },
42
- { amount: 50, label: "$50", default: false }
43
- ]
44
-
45
- # Additional CSS classes for the button
46
- config.button_class = ""
47
-
48
- # Z-index for the button and modal
49
- config.z_index = 1000
50
-
51
- # Enable analytics tracking
52
- # Tracks: button clicks, modal opens, amount selections, and successful tips
53
- # Works with Google Analytics 4 and Plausible out of the box
54
- config.analytics_enabled = false
55
-
56
- # Customize button colors (hex values)
57
- # Default: blue background (#3b82f6) with white text (#ffffff)
58
- # config.color = "#3b82f6"
59
- # config.text_color = "#ffffff"
60
-
61
- # Enable pulsing animation on the button
62
- # Default: false (no animation)
63
- # config.pulse = true
64
- end
@@ -1,171 +0,0 @@
1
- module RailsTipjar
2
- class Configuration
3
- attr_accessor :payment_links, :position, :icon, :theme, :button_text,
4
- :modal_title, :modal_description, :custom_amounts,
5
- :button_class, :z_index, :analytics_enabled, :payment_link,
6
- :use_modal, :color, :text_color, :pulse
7
-
8
- def initialize
9
- # Simple mode - just one link
10
- @payment_link = nil
11
- @use_modal = false # Default to direct link when payment_link is set
12
-
13
- # Legacy modal mode
14
- @payment_links = {}
15
- @position = :bottom_right
16
- @icon = :jar
17
- @theme = :light
18
- @button_text = "Tip Jar"
19
- @modal_title = "Support my work"
20
- @modal_description = "Your support helps me continue creating and maintaining this project."
21
- @custom_amounts = [
22
- { amount: 5, label: "$5", default: false },
23
- { amount: 10, label: "$10", default: true },
24
- { amount: 25, label: "$25", default: false },
25
- { amount: 50, label: "$50", default: false }
26
- ]
27
- @button_class = ""
28
- @z_index = 1000
29
- @analytics_enabled = false
30
- @color = "#3b82f6" # Default blue color
31
- @text_color = "#ffffff" # Default white text color
32
- @pulse = false # Default no pulsing animation
33
- end
34
-
35
- def position_classes
36
- case @position
37
- when :bottom_right
38
- "bottom-4 right-4"
39
- when :bottom_left
40
- "bottom-4 left-4"
41
- when :top_right
42
- "top-4 right-4"
43
- when :top_left
44
- "top-4 left-4"
45
- else
46
- "bottom-4 right-4"
47
- end
48
- end
49
-
50
- def icon_svg
51
- case @icon
52
- when :coffee
53
- '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
54
- <defs>
55
- <style>
56
- @keyframes steam1 {
57
- 0% { opacity: 0; transform: translateY(0) translateX(0); }
58
- 20% { opacity: 0.8; }
59
- 50% { opacity: 0.6; transform: translateY(-3px) translateX(1px); }
60
- 80% { opacity: 0.3; }
61
- 100% { opacity: 0; transform: translateY(-8px) translateX(-1px); }
62
- }
63
- @keyframes steam2 {
64
- 0% { opacity: 0; transform: translateY(0) translateX(0); }
65
- 15% { opacity: 0.7; }
66
- 45% { opacity: 0.5; transform: translateY(-4px) translateX(-1px); }
67
- 75% { opacity: 0.2; }
68
- 100% { opacity: 0; transform: translateY(-9px) translateX(1px); }
69
- }
70
- @keyframes steam3 {
71
- 0% { opacity: 0; transform: translateY(0) translateX(0); }
72
- 25% { opacity: 0.6; }
73
- 55% { opacity: 0.4; transform: translateY(-3px) translateX(0.5px); }
74
- 85% { opacity: 0.1; }
75
- 100% { opacity: 0; transform: translateY(-7px) translateX(-0.5px); }
76
- }
77
- .steam1 { animation: steam1 3s ease-out infinite; }
78
- .steam2 { animation: steam2 3s ease-out infinite 0.5s; }
79
- .steam3 { animation: steam3 3s ease-out infinite 1s; }
80
- </style>
81
- </defs>
82
- <!-- Steam wisps with wavy paths -->
83
- <path class="steam1" d="M8 9c0.5-0.5 0.5-1 0-1.5s-0.5-1 0-1.5s0.5-1 0-1.5" stroke-linecap="round" fill="none" opacity="0"/>
84
- <path class="steam2" d="M12 8.5c-0.3-0.4 -0.3-0.8 0-1.2s0.3-0.8 0-1.2s-0.3-0.8 0-1.2" stroke-linecap="round" fill="none" opacity="0"/>
85
- <path class="steam3" d="M15.5 9c0.4-0.3 0.4-0.7 0-1s-0.4-0.7 0-1s0.4-0.7 0-1" stroke-linecap="round" fill="none" opacity="0"/>
86
- <!-- Coffee cup body -->
87
- <path stroke-linecap="round" stroke-linejoin="round" d="M6 10h12v7a3 3 0 01-3 3H9a3 3 0 01-3-3v-7z"/>
88
- <!-- Cup handle -->
89
- <path stroke-linecap="round" stroke-linejoin="round" d="M18 10h1.5a2.5 2.5 0 010 5H18"/>
90
- <!-- Saucer -->
91
- <path stroke-linecap="round" stroke-linejoin="round" d="M4 20h16"/>
92
- <!-- Coffee surface detail -->
93
- <path stroke-linecap="round" stroke-linejoin="round" d="M8 12h8" opacity="0.3"/>
94
- </svg>'
95
- when :heart
96
- '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
97
- <path stroke-linecap="round" stroke-linejoin="round" d="M21 8.5c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 4 3 6.015 3 8.5c0 7.5 9 11.5 9 11.5s9-4 9-11.5z" />
98
- </svg>'
99
- when :star
100
- '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
101
- <path stroke-linecap="round" stroke-linejoin="round" d="M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z" />
102
- </svg>'
103
- when :dollar
104
- '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
105
- <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v12m-3-2.818l.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
106
- </svg>'
107
- when :jar
108
- '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
109
- <defs>
110
- <style>
111
- @keyframes tipjar-coin-drop-new {
112
- 0% {
113
- transform: translateY(0px);
114
- opacity: 0;
115
- }
116
- 10% {
117
- opacity: 1;
118
- transform: translateY(2px);
119
- }
120
- 30% {
121
- transform: translateY(6px);
122
- }
123
- 50% {
124
- transform: translateY(10px);
125
- opacity: 1;
126
- }
127
- 70% {
128
- transform: translateY(15.5px);
129
- opacity: 1;
130
- }
131
- 75% {
132
- transform: translateY(16.3px);
133
- opacity: 1;
134
- }
135
- 80% {
136
- transform: translateY(15.8px);
137
- opacity: 0.8;
138
- }
139
- 100% {
140
- transform: translateY(16.3px);
141
- opacity: 0;
142
- }
143
- }
144
- .tipjar-coin-drop-new {
145
- animation: tipjar-coin-drop-new 2.5s ease-in-out infinite;
146
- }
147
- </style>
148
- </defs>
149
- <!-- Jar lid -->
150
- <rect x="9.5" y="3" width="5" height="1" rx="0.25" stroke-linecap="round" stroke-linejoin="round"/>
151
- <!-- Jar threads/neck -->
152
- <path stroke-linecap="round" stroke-linejoin="round" d="M10 4v0.8M14 4v0.8"/>
153
- <!-- Jar body - much fatter with short taper -->
154
- <path stroke-linecap="round" stroke-linejoin="round" d="M10 4.8h4M9 5.5c-1 0 -2 0.5 -2 1v12.5a2 2 0 002 2h6a2 2 0 002-2V6.5c0-0.5 -1-1 -2-1"/>
155
- <!-- Coins at bottom - pile -->
156
- <ellipse cx="10.5" cy="18.5" rx="1.5" ry="0.5" stroke-linecap="round"/>
157
- <ellipse cx="13.5" cy="18.3" rx="1.5" ry="0.5" stroke-linecap="round"/>
158
- <ellipse cx="12" cy="17.8" rx="1.5" ry="0.5" stroke-linecap="round"/>
159
- <ellipse cx="11" cy="19" rx="1.3" ry="0.4" stroke-linecap="round"/>
160
- <ellipse cx="13" cy="19" rx="1.3" ry="0.4" stroke-linecap="round"/>
161
- <!-- Falling coin - starts above jar outside -->
162
- <g class="tipjar-coin-drop-new">
163
- <ellipse cx="12" cy="1.5" rx="1.5" ry="0.5" stroke-linecap="round"/>
164
- </g>
165
- </svg>'
166
- else
167
- @icon
168
- end
169
- end
170
- end
171
- end