routing_helper.rb 694 B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. module RoutingHelper
  3. extend ActiveSupport::Concern
  4. include Rails.application.routes.url_helpers
  5. include ActionView::Helpers::AssetTagHelper
  6. include Webpacker::Helper
  7. included do
  8. def default_url_options
  9. ActionMailer::Base.default_url_options
  10. end
  11. end
  12. def full_asset_url(source, **options)
  13. source = ActionController::Base.helpers.asset_url(source, **options) unless use_storage?
  14. URI.join(root_url, source).to_s
  15. end
  16. def full_pack_url(source, **options)
  17. full_asset_url(asset_pack_path(source, **options))
  18. end
  19. private
  20. def use_storage?
  21. Rails.configuration.x.use_s3 || Rails.configuration.x.use_swift
  22. end
  23. end