fileboost 0.1.5 → 0.2.0.pre

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: c4fec62d9be1b012648ceccd75eaa24a75c64ce4d3ae2e4d3fa060e08960de70
4
- data.tar.gz: 67fbe1d13e4ec43b47c9517b3acddff6fc7a35a930b670cd15be781474d4824f
3
+ metadata.gz: e41eb33a273bb73c63284223566b994fca3583c8e72c82c0dde3ffc6c19b9adc
4
+ data.tar.gz: 21a0c4088aea9ac6eeb3bb82310d850b99fa718155c0b253798aa5343da46caa
5
5
  SHA512:
6
- metadata.gz: add42effb51bb5a83eaf754365d703ab6c9161f2c8aa7b7297b1aee99194e02f8b706eae6cf04e2f9137683c13c52dc5aa57451a94a7d5dffaa7246b479508a9
7
- data.tar.gz: 56ebbea598301c491c2cfef190c9cdb15716b9621874beb8e5f3a007c4da2ba9c27303cf1784cd89a35daed9039ec81f961849576f588bed975ccebfdd675a15
6
+ metadata.gz: 11b1349683d425b709d351ca165394f86f6ce7db6e71af7359d8c10a8532d2f31843464fa82b4a7da4a98ba792601b97cfa86fa02d08a36e8fe5528defe8622f
7
+ data.tar.gz: df922239b99ecbd4e87e6272908bc85f1ecf6e303faa704e5f5843a991ad783df29f2b6eeccd961a140342b1c7ab6e560ed93eca3222d9a4ae89c3fd690553e6
@@ -1,6 +1,6 @@
1
1
  module Fileboost
2
2
  class Config
3
- attr_accessor :project_id, :token
3
+ attr_accessor :project_id, :token, :patch_image_tag
4
4
 
5
5
  CDN_DOMAIN = "cdn.fileboost.dev"
6
6
  BASE_URL = "https://#{CDN_DOMAIN}"
@@ -8,6 +8,7 @@ module Fileboost
8
8
  def initialize
9
9
  @project_id = ENV["FILEBOOST_PROJECT_ID"]
10
10
  @token = ENV["FILEBOOST_TOKEN"]
11
+ @patch_image_tag = false
11
12
  end
12
13
 
13
14
  def valid?
@@ -5,6 +5,11 @@ module Fileboost
5
5
  initializer "fileboost.action_view" do
6
6
  ActiveSupport.on_load :action_view do
7
7
  include Fileboost::Helpers
8
+
9
+ # Conditionally patch image_tag if enabled in configuration
10
+ if Fileboost.config.patch_image_tag
11
+ prepend Fileboost::ImageTagPatch
12
+ end
8
13
  end
9
14
  end
10
15
  end
@@ -0,0 +1,26 @@
1
+ module Fileboost
2
+ module ImageTagPatch
3
+ def image_tag(source, options = {})
4
+ # If this is an ActiveStorage asset and Fileboost is configured, use fileboost_image_tag
5
+ if valid_activestorage_asset?(source) && Fileboost.config.valid?
6
+ fileboost_image_tag(source, **options)
7
+ else
8
+ # Fall back to Rails' original image_tag for all other cases
9
+ super(source, options)
10
+ end
11
+ rescue
12
+ # If there's any error with Fileboost processing, fall back to original Rails behavior
13
+ super(source, options)
14
+ end
15
+
16
+ private
17
+
18
+ def valid_activestorage_asset?(asset)
19
+ return true if asset.is_a?(ActiveStorage::Blob)
20
+ return true if asset.is_a?(ActiveStorage::Attached)
21
+ return true if asset.is_a?(ActiveStorage::VariantWithRecord)
22
+
23
+ false
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Fileboost
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0.pre"
3
3
  end
data/lib/fileboost.rb CHANGED
@@ -4,6 +4,7 @@ require "fileboost/error_handler"
4
4
  require "fileboost/signature_generator"
5
5
  require "fileboost/url_builder"
6
6
  require "fileboost/helpers"
7
+ require "fileboost/image_tag_patch"
7
8
  require "fileboost/engine"
8
9
 
9
10
  module Fileboost
@@ -16,4 +16,10 @@ Fileboost.configure do |config|
16
16
  # You can also set this via the FILEBOOST_TOKEN environment variable
17
17
  # IMPORTANT: Keep this secret secure and never commit it to version control
18
18
  config.token = ENV["FILEBOOST_TOKEN"] # || "your-secret-token"
19
+
20
+ # Drop-in replacement for Rails image_tag helper
21
+ # When enabled, image_tag will automatically use Fileboost optimization
22
+ # for ActiveStorage assets while falling back to standard Rails behavior
23
+ # for other image sources. Defaults to false.
24
+ # config.patch_image_tag = true
19
25
  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.1.5
4
+ version: 0.2.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - bilal
@@ -138,6 +138,7 @@ files:
138
138
  - lib/fileboost/engine.rb
139
139
  - lib/fileboost/error_handler.rb
140
140
  - lib/fileboost/helpers.rb
141
+ - lib/fileboost/image_tag_patch.rb
141
142
  - lib/fileboost/signature_generator.rb
142
143
  - lib/fileboost/url_builder.rb
143
144
  - lib/fileboost/version.rb