toastify 1.0.1 → 1.2.1
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 +4 -4
- data/README.md +1 -5
- data/lib/toastify/application_helper.rb +7 -2
- data/lib/toastify/controller.rb +21 -8
- data/lib/toastify/version.rb +1 -1
- data/lib/toastify.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a0f7f533d69bf852bede962509bd4f893854d59381465e674a84dcc2af573441
|
|
4
|
+
data.tar.gz: 35ead30f183fc0eb86727b710469de755e6bbca6892a00230076a14f3741258e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f5888be3af3cfaf5dbce6d665c392174c3601cb2c14a8210f1ec328b02412aa975deda65e99298cb87ce89dc111223531f506681fa024aabce271ca370b5b53
|
|
7
|
+
data.tar.gz: 55b26d76af3a72a432f726eba31712eea1239acfc2c7cd06e67703692ddfcbd74168da33e6bea43643903a3d2c38314231b8b1924c0be4d66007e2cffe71e6f2
|
data/README.md
CHANGED
|
@@ -10,11 +10,7 @@ It can also be used directly in JavaScript (e.g., `Toastify.success("Saved!")`).
|
|
|
10
10
|
|
|
11
11
|
### Example Images
|
|
12
12
|
|
|
13
|
-
<img width="
|
|
14
|
-
|
|
15
|
-
<img width="338" height="87" alt="Dark Theme Example" src="https://github.com/user-attachments/assets/65671ac6-91d7-471f-9c03-6458023f3ae2" />
|
|
16
|
-
|
|
17
|
-
<img width="339" height="83" alt="Colored Theme Example" src="https://github.com/user-attachments/assets/1c99ffdb-dc3c-4fef-aa16-b7eff08e0cde" />
|
|
13
|
+
<img width="340" height="222" alt="Theme Examples" src="https://github.com/user-attachments/assets/ed0350ef-295d-4ba6-ab51-94a9e071eac4" />
|
|
18
14
|
|
|
19
15
|
## Installation
|
|
20
16
|
|
|
@@ -55,11 +55,13 @@ module Toastify
|
|
|
55
55
|
"error" => "error",
|
|
56
56
|
"info" => "info",
|
|
57
57
|
"warning" => "warning",
|
|
58
|
+
"default" => "default",
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
script_lines = []
|
|
61
62
|
flash.each do |flash_type, message|
|
|
62
63
|
next if flash_type.to_s.start_with?("toast_")
|
|
64
|
+
next unless Toastify::FLASH_KEYS.include?(flash_type.to_s)
|
|
63
65
|
|
|
64
66
|
type = type_map.fetch(flash_type.to_s, "default")
|
|
65
67
|
position = flash[:toast_position] || default_position
|
|
@@ -75,8 +77,11 @@ module Toastify
|
|
|
75
77
|
script_lines << "window.Toastify && window.Toastify.show('#{safe_message}', { type: '#{j(type.to_s)}', position: '#{j(position.to_s)}', autoClose: #{auto_close.to_i}, theme: '#{j(theme.to_s)}', transition: '#{j(transition.to_s)}', closeButton: #{!!close_button}, pauseOnHover: #{!!pause_on_hover}, draggable: #{!!draggable} });"
|
|
76
78
|
end
|
|
77
79
|
|
|
78
|
-
# Discard
|
|
79
|
-
flash.keys.
|
|
80
|
+
# Discard consumed toast flashes only; leave other keys (e.g. :alert) intact
|
|
81
|
+
flash.keys.each do |type|
|
|
82
|
+
next if type.to_s.start_with?("toast_")
|
|
83
|
+
next unless Toastify::FLASH_KEYS.include?(type.to_s)
|
|
84
|
+
|
|
80
85
|
flash.discard(type)
|
|
81
86
|
end
|
|
82
87
|
|
data/lib/toastify/controller.rb
CHANGED
|
@@ -3,26 +3,39 @@ module Toastify
|
|
|
3
3
|
extend ActiveSupport::Concern
|
|
4
4
|
|
|
5
5
|
included do
|
|
6
|
-
after_action :
|
|
6
|
+
after_action :append_toastify_to_response
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
private
|
|
10
10
|
|
|
11
|
-
def
|
|
12
|
-
return unless request.format.turbo_stream?
|
|
11
|
+
def append_toastify_to_response
|
|
12
|
+
return unless request.format.turbo_stream? || turbo_frame_request?
|
|
13
13
|
|
|
14
|
-
toast_flashes = flash.reject
|
|
14
|
+
toast_flashes = flash.reject do |type, _|
|
|
15
|
+
type.to_s.start_with?("toast_") || !Toastify::FLASH_KEYS.include?(type.to_s)
|
|
16
|
+
end
|
|
15
17
|
return unless toast_flashes.any?
|
|
16
18
|
|
|
17
19
|
script_content = helpers.toastify_script_tag
|
|
18
20
|
return if script_content.blank?
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
if request.format.turbo_stream?
|
|
23
|
+
payload = turbo_stream.append("flash-outlet", script_content).to_s
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
if response.body.is_a?(String)
|
|
26
|
+
response.body += payload
|
|
27
|
+
else
|
|
28
|
+
response.body = response.body.to_s + payload
|
|
29
|
+
end
|
|
24
30
|
else
|
|
25
|
-
|
|
31
|
+
body = response.body.to_s
|
|
32
|
+
frame_closing_tag = "</turbo-frame>"
|
|
33
|
+
|
|
34
|
+
if body.include?(frame_closing_tag)
|
|
35
|
+
response.body = body.sub(frame_closing_tag, "#{script_content}#{frame_closing_tag}")
|
|
36
|
+
else
|
|
37
|
+
response.body = body + script_content.to_s
|
|
38
|
+
end
|
|
26
39
|
end
|
|
27
40
|
end
|
|
28
41
|
end
|
data/lib/toastify/version.rb
CHANGED
data/lib/toastify.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: toastify
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- vasanthakumar-a
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|