shimmer 0.0.38 → 0.0.39

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: 902f5e484bf8f16867c9467eb8c98b81120ff6b7997b26128c73b5d46109bb8c
4
- data.tar.gz: 3c23f32feedb88261af4fcfefa304b57dee51a0804e247b78e52ee89b7c2c25c
3
+ metadata.gz: ce6a8f2755f2ecf1a72a5479b02680ff472fcfa20c6dba2d803b74a890f658ed
4
+ data.tar.gz: be9cdd04667dcfa600e169fa8de84362bfc49d9a4f9a091cd85e51a956b34079
5
5
  SHA512:
6
- metadata.gz: 49348ee549734616e4ddc2a11a4cb11080adc6268c116017dfcf3536e5aaefd2db960b8eb8833127d77ea90fd5015dcc575b3f7c5ebf33784fcd2a6e58b06338
7
- data.tar.gz: 99102aaed6f59ae09035a1ec6e564d0098816af2919382530289e99e19280195218887b60aaf3ba6cf020db370c6e018cbaa7fe591d184318d410f37275eddb0
6
+ metadata.gz: 8b1eabd56dff0492b4bce93b45b5138631d1520c573dd5437787ce20c03d74b7a3f8740c19b9684700f24f4e11658bf7d2ad7c2f20abb0f51dc0468a4320a6d9
7
+ data.tar.gz: ca0b557d85b89749770a57f4e5b58c6f8ada7ed27b43742a82c23a3e6f46ba5b17c13577ea3fa029c1ce600e40f2ffc021bcaad93533e7750ade24e1192fa24c
data/README.md CHANGED
@@ -187,6 +187,12 @@ a href=popover_path(new_post_path, placement: :left)
187
187
 
188
188
  This will request `new_post_path` and display it left of the anchor thanks to PopperJS.
189
189
 
190
+ > [!TIP]
191
+ > If you want to make sure that your modal content is only available if requested through Shimmer, you can use the built in `enfore_modal` method as a `before_action`. It will return a _422 Unprocessable Content_ status if users (or bots) access the page directly.
192
+ > ```rb
193
+ > before_action :enforce_modal, only: [:popover]
194
+ > ```
195
+
190
196
  ### Remote Navigation
191
197
 
192
198
  Remote navigation takes Hotwire to the next level with built-in navigation actions, integrated with modals and popovers.
@@ -4,6 +4,8 @@ module Shimmer
4
4
  module RemoteNavigation
5
5
  extend ActiveSupport::Concern
6
6
 
7
+ class RemoteNavigationError < StandardError; end
8
+
7
9
  included do
8
10
  def ui
9
11
  @ui ||= RemoteNavigator.new(self)
@@ -45,7 +47,17 @@ module Shimmer
45
47
  end
46
48
 
47
49
  def enforce_modal
48
- raise "trying to render a modal from a regular request" unless shimmer_request?
50
+ return if shimmer_request?
51
+
52
+ raise RemoteNavigationError.new("You may only render a modal from a Shimmer request.")
53
+ end
54
+
55
+ rescue_from RemoteNavigationError do |exception|
56
+ if Rails.env.development?
57
+ render plain: exception.message, status: :unprocessable_entity
58
+ else
59
+ head :unprocessable_entity
60
+ end
49
61
  end
50
62
  end
51
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shimmer
4
- VERSION = "0.0.38"
4
+ VERSION = "0.0.39"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.38
4
+ version: 0.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Ravens
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-23 00:00:00.000000000 Z
11
+ date: 2024-10-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: