fileboost 0.2.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 820b61fe3e68521f6aa18ff54604405a16591022e6bf51e3c05676ee702b68bd
4
- data.tar.gz: cb24ea71429294b6f8ef8e9a5e33019ee147888ff559b6a4e031fe6d1f39a167
3
+ metadata.gz: 75a25ae54b0e37c76e53aac050c9ecec3349ae68177ba50627d0e28ba447864b
4
+ data.tar.gz: 5bbbec4d29a49c78c5b4c4ab322f7b3598a26ca7845af7a51bbfb2da83066335
5
5
  SHA512:
6
- metadata.gz: 31156ad54e654a70966a6cab9b4b80dd0f274eb2949f69b86dd7a4f1a30aaf1649cb4a3de52cf8dbff82ec22ff177df2cdea38fe53b620533af3225a47079170
7
- data.tar.gz: 90942c719df9ea0b565bcce52349ff29b9dfb46b2de6ac965edc736d0a787dab96926fb3a24110724c6c834daae68276e4ef4dea9e46cfd11681d6f7c2d63056
6
+ metadata.gz: fe2d690a0f1978dba962020123532bb619e3bec66818b5afc08682006bc9d43c91ea478766060df3c022ed24f17b5f6c92d0eb72991f9c393e559568bd25d4e3
7
+ data.tar.gz: 99c983aaebabdbdfa70b5c6c3316b64c1eb6e5e1d3fa92bf3282cb8a4dc27d1ae045ff4781373de7ca3ef4556bf7ed12ff978b915db5b0e7c1599af4f7c9dfd7
data/README.md CHANGED
@@ -42,7 +42,7 @@ Fileboost is a Rails gem that provides seamless integration with the Fileboost.d
42
42
  ## Requirements
43
43
 
44
44
  - Ruby 3.0+
45
- - Rails 7.1+
45
+ - Rails 7+
46
46
  - ActiveStorage
47
47
 
48
48
  ## Installation
@@ -83,7 +83,7 @@ Or configure directly in your initializer:
83
83
  Fileboost.configure do |config|
84
84
  config.project_id = ENV["FILEBOOST_PROJECT_ID"]
85
85
  config.token = ENV["FILEBOOST_TOKEN"]
86
-
86
+
87
87
  # Optional: Enable drop-in replacement for Rails image_tag (default: false)
88
88
  config.patch_image_tag = true
89
89
  end
@@ -93,7 +93,7 @@ end
93
93
 
94
94
  ### Drop-in Replacement (Recommended)
95
95
 
96
- Enable `patch_image_tag` in your configuration to automatically optimize ActiveStorage images with your existing `image_tag` calls:
96
+ > Enable `patch_image_tag` in your configuration to automatically optimize ActiveStorage images with your existing `image_tag` calls:
97
97
 
98
98
  ```ruby
99
99
  # config/initializers/fileboost.rb
@@ -121,6 +121,7 @@ With this enabled, your existing Rails code automatically gets Fileboost optimiz
121
121
  ```
122
122
 
123
123
  **Benefits:**
124
+
124
125
  - Zero code changes required for existing ActiveStorage images
125
126
  - Full ActiveStorage variant support with automatic transformation mapping
126
127
  - Automatic fallback to Rails behavior for non-ActiveStorage assets
@@ -235,15 +236,14 @@ Fileboost now provides full support for ActiveStorage variants with automatic tr
235
236
 
236
237
  Fileboost automatically maps ActiveStorage variant transformations to optimized URL parameters:
237
238
 
238
- | ActiveStorage Variant | Fileboost Parameters | Description |
239
- |----------------------|---------------------|-------------|
240
- | `resize_to_limit: [w, h]` | `w=W&h=H&fit=scale-down` | Resize within bounds, preserving aspect ratio |
241
- | `resize_to_fit: [w, h]` | `w=W&h=H&fit=contain` | Resize to fit exactly, with letterboxing if needed |
242
- | `resize_to_fill: [w, h]` | `w=W&h=H&fit=cover` | Resize and crop to fill exactly |
243
- | `resize_and_pad: [w, h]` | `w=W&h=H&fit=pad` | Resize with padding |
244
- | `quality: 85` | `q=85` | JPEG/WebP quality (1-100) |
245
- | `rotate: "-90"` | `r=-90` | Rotation in degrees |
246
-
239
+ | ActiveStorage Variant | Fileboost Parameters | Description |
240
+ | ------------------------- | ------------------------ | -------------------------------------------------- |
241
+ | `resize_to_limit: [w, h]` | `w=W&h=H&fit=scale-down` | Resize within bounds, preserving aspect ratio |
242
+ | `resize_to_fit: [w, h]` | `w=W&h=H&fit=contain` | Resize to fit exactly, with letterboxing if needed |
243
+ | `resize_to_fill: [w, h]` | `w=W&h=H&fit=cover` | Resize and crop to fill exactly |
244
+ | `resize_and_pad: [w, h]` | `w=W&h=H&fit=pad` | Resize with padding |
245
+ | `quality: 85` | `q=85` | JPEG/WebP quality (1-100) |
246
+ | `rotate: "-90"` | `r=-90` | Rotation in degrees |
247
247
 
248
248
  #### Combining Variants with Custom Options
249
249
 
@@ -251,13 +251,13 @@ You can combine variant transformations with additional Fileboost options:
251
251
 
252
252
  ```erb
253
253
  <!-- Variant transformations + additional options -->
254
- <%= image_tag user.avatar.variant(resize_to_limit: [200, 200]),
254
+ <%= image_tag user.avatar.variant(resize_to_limit: [200, 200]),
255
255
  resize: { blur: 5, brightness: 110 } %>
256
256
  <!-- ↓ Combines variant params with additional blur and brightness -->
257
257
 
258
258
  <!-- Override variant parameters -->
259
259
  <%= image_tag post.image.variant(resize_to_limit: [400, 300]),
260
- resize: { w: 500 } %>
260
+ resize: { w: 500 } %>
261
261
  <!-- ↓ Uses h=300&fit=scale-down from variant, but overrides width to 500 -->
262
262
  ```
263
263
 
@@ -5,7 +5,7 @@ module Fileboost
5
5
  # Generate an optimized image tag using Fileboost
6
6
  #
7
7
  # @param asset [ActiveStorage::Blob, ActiveStorage::Attached, ActiveStorage::VariantWithRecord] The ActiveStorage image asset
8
- # @param options [Hash] Image transformation and HTML options
8
+ # @param options [Hash] Accepts a `:resize` hash for transformations plus standard HTML options
9
9
  # @return [String] HTML image tag
10
10
  #
11
11
  # Examples:
@@ -25,7 +25,7 @@ module Fileboost
25
25
  # Generate an optimized URL using Fileboost
26
26
  #
27
27
  # @param asset [ActiveStorage::Blob, ActiveStorage::Attached, ActiveStorage::VariantWithRecord] The ActiveStorage image asset
28
- # @param options [Hash] Image transformation options
28
+ # @param options [Hash] Supports a `:resize` hash for image transformations and an optional `:disposition`
29
29
  # @return [String, nil] The optimized URL or nil if generation failed
30
30
  #
31
31
  # Examples:
@@ -45,7 +45,10 @@ module Fileboost
45
45
  # Extract and normalize transformation parameters
46
46
  transformation_params = extract_transformation_params(asset, options)
47
47
 
48
- # Generate HMAC signature for secure authentication
48
+ # Separate disposition from transformation params for signature generation
49
+ disposition = transformation_params.delete("disposition")
50
+
51
+ # Generate HMAC signature for secure authentication (excluding disposition)
49
52
  signature = Fileboost::SignatureGenerator.generate(
50
53
  asset_path: asset_path,
51
54
  params: transformation_params
@@ -53,8 +56,9 @@ module Fileboost
53
56
 
54
57
  raise SignatureGenerationError, "Failed to generate signature" unless signature
55
58
 
56
- # Add signature to parameters
59
+ # Add signature and disposition back to final URL parameters
57
60
  all_params = transformation_params.merge("sig" => signature)
61
+ all_params["disposition"] = disposition if disposition
58
62
 
59
63
  # Build final URL
60
64
  uri = URI.join(base_url, full_path)
@@ -118,6 +122,11 @@ module Fileboost
118
122
  end
119
123
  end
120
124
 
125
+ disposition = options[:disposition] || options["disposition"]
126
+ if disposition.present?
127
+ params["disposition"] = disposition.to_s.strip.downcase
128
+ end
129
+
121
130
  params
122
131
  end
123
132
 
@@ -1,3 +1,3 @@
1
1
  module Fileboost
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fileboost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bilal budhani