Module: Uploadcare::Rails::ActionView::IncludeTags
- Defined in:
- lib/uploadcare/rails/action_view/include_tags.rb
Instance Method Summary collapse
- #include_uploadcare_widget_from_cdn(options = {}) ⇒ Object (also: #inlude_uploadcare_widget, #uplodacare_widget)
- #uploadcare_settings(options = {}) ⇒ Object
Instance Method Details
#include_uploadcare_widget_from_cdn(options = {}) ⇒ Object Also known as: inlude_uploadcare_widget, uplodacare_widget
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/uploadcare/rails/action_view/include_tags.rb', line 3 def ( = {}) settings = { min: true, version: UPLOADCARE_SETTINGS. }.merge!() minified = settings[:min] ? 'min' : nil path = [ 'widget', settings[:version], 'uploadcare', ['uploadcare', minified, 'js'].compact.join('.') ].join('/') url = URI::HTTPS. build(host: 'ucarecdn.com', path: '/' + path, scheme: :https) javascript_include_tag(url.to_s) end |
#uploadcare_settings(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/uploadcare/rails/action_view/include_tags.rb', line 29 def uploadcare_settings( = {}) settings = UPLOADCARE_SETTINGS..merge!() js_settings = '' settings.each do |k, v| js_settings << if v.is_a?(TrueClass) || v.is_a?(FalseClass) "UPLOADCARE_#{ k.to_s.underscore.upcase } = #{ v };\n" else "UPLOADCARE_#{ k.to_s.underscore.upcase } = \"#{ v }\";\n" end end javascript_tag(js_settings) end |