Module: FilestackRails::ApplicationHelper

Included in:
FormHelper
Defined in:
app/helpers/filestack_rails/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#filestack_image(url, options = {}) ⇒ Object



44
45
46
47
48
# File 'app/helpers/filestack_rails/application_helper.rb', line 44

def filestack_image(url, options = {})
  transform_object = options.delete(:transform)

  image_tag(filestack_image_url(url, transform_object), options)
end

#filestack_image_url(url, transform_object = nil) ⇒ Object



50
51
52
53
54
# File 'app/helpers/filestack_rails/application_helper.rb', line 50

def filestack_image_url(url, transform_object = nil)
  return url unless transform_object
  transform_object.add_external_url(url)
  transform_object.fs_url
end

#filestack_js_include_tagObject



7
8
9
# File 'app/helpers/filestack_rails/application_helper.rb', line 7

def filestack_js_include_tag
  javascript_include_tag(get_filestack_js.url, type: 'text/javascript')
end

#filestack_js_init_tagObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/filestack_rails/application_helper.rb', line 11

def filestack_js_init_tag
  client_name, apikey = get_client_and_api_key
  javascript_string =
    if filestack_js_v3?
      options = { cname: cname }
      policy, signature = get_policy_and_signature
      if policy && signature
        options[:security] = {
          policy: policy,
          signature: signature
        }
      end
      "var #{client_name} = filestack.init('#{apikey}', #{options.to_json});"
    else
      signature_and_policy = get_policy_and_signature_string
      "var #{client_name} = filestack.init('#{apikey}', #{signature_and_policy}, '#{cname}');"
    end
  javascript_tag javascript_string
end

#filestack_picker_element(content, callback, options = {}) ⇒ Object



31
32
33
34
35
36
37
# File 'app/helpers/filestack_rails/application_helper.rb', line 31

def filestack_picker_element(content, callback, options = {})
  picker_options = options[:pickerOptions]
  options.delete(:pickerOptions)
  options[:onclick] = create_javascript_for_picker(callback, picker_options)
  options[:type] = 'button'
  button_tag content, options
end

#filestack_transformObject



39
40
41
42
# File 'app/helpers/filestack_rails/application_helper.rb', line 39

def filestack_transform
  _, apikey = get_client_and_api_key
  get_transform(apikey)
end