Module: CKEditor5::Rails::Cdn::UrlGenerator
- Extended by:
- ActiveSupport::Concern
- Included in:
- CKBoxBundle, CKEditorBundle
- Defined in:
- lib/ckeditor5/rails/cdn/url_generator.rb
Constant Summary collapse
- CDN_THIRD_PARTY_GENERATORS =
{ jsdelivr: lambda { |bundle, version, path| base_url = "https://cdn.jsdelivr.net/npm/#{bundle}@#{version}/dist" "#{base_url}/#{path.start_with?('translations/') ? '' : 'browser/'}#{path}" }, unpkg: lambda { |bundle, version, path| base_url = "https://unpkg.com/#{bundle}@#{version}/dist" "#{base_url}/#{path.start_with?('translations/') ? '' : 'browser/'}#{path}" } }.freeze
- CDN_COMMERCIAL_GENERATORS =
{ cloud: lambda { |bundle, version, path| domain = bundle == 'ckbox' ? 'ckbox.io' : 'ckeditor.com' "https://cdn.#{domain}/#{bundle}/#{version}/#{path}" } }.freeze
Instance Method Summary collapse
Instance Method Details
#create_cdn_url(bundle, version, path) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ckeditor5/rails/cdn/url_generator.rb', line 33 def create_cdn_url(bundle, version, path) generator = CDN_THIRD_PARTY_GENERATORS[cdn] || CDN_COMMERCIAL_GENERATORS[cdn] || cdn raise ArgumentError, "Unknown provider: #{cdn}" unless generator generator.call(bundle, version, path) end |