dscf-marketplace 0.6.9 → 0.6.10

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: 47ccdaa6c3f673186ebd2eded4b02d820ca4a5f04c488289a7ae36fd632e86cf
4
- data.tar.gz: ddc2b3716afba0714a92f9fd3814598eedffd39288a8a01e99eca5c36d320bdc
3
+ metadata.gz: 304ba75880abb6975ba1f97e4268071bafa178d04393d61ff3978c98814f3e3a
4
+ data.tar.gz: 49ba3cbb962c0c515cad40759cdb427fe98e848190b015a48509727b81da774b
5
5
  SHA512:
6
- metadata.gz: 3dfed84c310ca8365fb97fa54fa9dc46fa9a1603119cf2a05ed0a46c0c1de8834792ad6d03a3427feaf123ce2b0e19392f487e45a79a3c0fd00d5c1350e9d521
7
- data.tar.gz: 0b68966531e15177a951d62f3737a91f1246f16ac17a3ce72b716fd7efdf1d995c1443fa594fbeea3dc508e6d5eb065d2d42d11ed18b01e639288bd7ed3d53d0
6
+ metadata.gz: e424c88f7009a765386e4537affad040fa7adeac0196842707eb5fa347bead1c966542f893e4f4eb0b911ba598fb203d02c6020d128ee1451ced4090ad9333e6
7
+ data.tar.gz: 3a8f804ab3749994f2f39c536e495cc7533a866075588c6665ae9ab5af93295d2ffeef48f8063a7ddc6526e9aed30268bc13bd05598899fbfbbb924454244150
@@ -56,15 +56,30 @@ module Dscf
56
56
  end
57
57
 
58
58
  def thumbnail_url
59
- return nil unless thumbnail.attached?
60
- Rails.application.routes.url_helpers.rails_blob_url(thumbnail, host: Rails.application.config.action_mailer.default_url_options[:host])
59
+ attachment_url_for(thumbnail)
61
60
  end
62
61
 
63
62
  def images_urls
64
63
  return [] unless images.attached?
65
- images.map do |image|
66
- Rails.application.routes.url_helpers.rails_blob_url(image, host: Rails.application.config.action_mailer.default_url_options[:host])
64
+ images.map { |image| attachment_url_for(image) }
65
+ end
66
+
67
+ private
68
+ def attachment_url_for(attachment)
69
+ return unless attachment.present?
70
+ return if attachment.respond_to?(:attached?) && !attachment.attached?
71
+
72
+ Rails.application.routes.url_helpers.rails_blob_url(attachment, **active_storage_url_options)
67
73
  end
74
+
75
+ def active_storage_url_options
76
+ url_options = Rails.application.config.x.active_storage_url_options.presence ||
77
+ Rails.application.routes.default_url_options.presence ||
78
+ Rails.application.config.action_controller.default_url_options.presence ||
79
+ Rails.application.config.action_mailer.default_url_options.presence ||
80
+ {}
81
+
82
+ url_options.to_h.symbolize_keys.compact
68
83
  end
69
84
  end
70
85
  end
@@ -10,21 +10,11 @@ module Dscf
10
10
  has_many :supplier_products
11
11
 
12
12
  def thumbnail_url
13
- if object.thumbnail.attached?
14
- ActiveStorage::Current.set(url_options: { host: "dscf.bitscollege.edu.et", protocol: "https", script_name: "/api" }) do
15
- object.thumbnail.url
16
- end
17
- end
13
+ object.thumbnail_url
18
14
  end
19
15
 
20
16
  def image_urls
21
- if object.images.attached?
22
- ActiveStorage::Current.set(url_options: { host: "dscf.bitscollege.edu.et", protocol: "https", script_name: "/api" }) do
23
- object.images.map(&:url)
24
- end
25
- else
26
- []
27
- end
17
+ object.images_urls
28
18
  end
29
19
  end
30
20
  end
@@ -1,7 +1,13 @@
1
1
  Rails.application.configure do
2
- # Set the host for URL generation
3
- config.action_mailer.default_url_options = { host: "dscf.bitscollege.edu.et" }
4
- config.action_controller.default_url_options = { host: "dscf.bitscollege.edu.et" }
2
+ config.x.active_storage_url_options = {
3
+ host: ENV.fetch("ACTIVE_STORAGE_HOST", "dscf-api.bitscollege.edu.et"),
4
+ protocol: ENV.fetch("ACTIVE_STORAGE_PROTOCOL", "https"),
5
+ script_name: ENV.fetch("ACTIVE_STORAGE_SCRIPT_NAME", "/api")
6
+ }
7
+
8
+ config.action_mailer.default_url_options = config.x.active_storage_url_options.dup
9
+ config.action_controller.default_url_options = config.x.active_storage_url_options.dup
10
+ Rails.application.routes.default_url_options.merge!(config.x.active_storage_url_options)
5
11
 
6
12
  config.force_ssl = true
7
13
  end
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Marketplace
3
- VERSION = "0.6.9".freeze
3
+ VERSION = "0.6.10".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dscf-marketplace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-01-01 00:00:00.000000000 Z
10
+ date: 2026-03-09 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails