shimmer 0.0.37 → 0.0.39

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: 48d1c88d49cf870d7a44235454ca682ea4b510cf215c8e990c65d4c511cc122c
4
- data.tar.gz: 29497228d74e28e72234713c28d72a6a72e08fd6ee133648dc0ba3396be0448c
3
+ metadata.gz: ce6a8f2755f2ecf1a72a5479b02680ff472fcfa20c6dba2d803b74a890f658ed
4
+ data.tar.gz: be9cdd04667dcfa600e169fa8de84362bfc49d9a4f9a091cd85e51a956b34079
5
5
  SHA512:
6
- metadata.gz: b8a1a0460e3ab70d8857ce5d95f969a316ffcdb783de4c39efd4ea70791be107ebcad9b7b898bb87c5866631ca4098e8b20e872f595611a57c5b7d6f8b785828
7
- data.tar.gz: 05c6b79f3fc057af3ae444b914ae5955699d24787608c7658521233f88fcd972546ad0390ede351ed59bd4262d73fd69dfd3e03089b01d4f3dcdf7dca10b429b
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.
@@ -3,8 +3,8 @@
3
3
  module Shimmer
4
4
  class SitemapsController < ActionController::Base
5
5
  def show
6
- path = "sitemaps/#{params.require(:path)}.gz"
7
- filename = "sitemap_#{params[:path]}.xml.gz"
6
+ path = request.path[1..]
7
+ filename = path.gsub("/", "-")
8
8
 
9
9
  send_data ActiveStorage::Blob.service.download(path), filename: filename, type: "application/gzip", disposition: "attachment"
10
10
  end
@@ -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
@@ -4,7 +4,7 @@ module Shimmer
4
4
  class SitemapAdapter
5
5
  def write(location, raw_data)
6
6
  SitemapGenerator::FileAdapter.new.write(location, raw_data)
7
- ActiveStorage::Blob.service.upload("sitemaps/#{location.path_in_public}", File.open(location.path))
7
+ ActiveStorage::Blob.service.upload(location.path_in_public, File.open(location.path))
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shimmer
4
- VERSION = "0.0.37"
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.37
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-07-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: