<commit_before>module Filepicker
  module Rails

    module ViewHelpers
      def filepicker_js_include_tag
        javascript_include_tag "//api.filepicker.io/v0/filepicker.js"
      end

      def filepicker_save_button(text, url, mimetype, options = {})
        options[:data] ||= {}
        container = options.delete(:container)
        services = options.delete(:services)
        save_as = options.delete(:save_as_name)

        options[:data]['fp-url'] = url
        options[:data]['fp-apikey'] = ::Rails.application.config.filepicker_rails.api_key
        options[:data]['fp-mimetype'] = mimetype
        options[:data]['fp-option-container'] = container if container
        options[:data]['fp-option-services'] = Array(services).join(",") if services
        options[:data]['fp-option-defaultSaveasName'] = save_as if save_as
        button_tag(text, options)
      end

      # Allows options to be passed to filepicker_image_url and then falls back to normal Rails options for image_tag

      def filepicker_image_tag(url, options={})
        image_tag(filepicker_image_url(url, options), options)
      end

      # w - Resize the image to this width.
      #
      # h - Resize the image to this height.
      #<commit_msg>Remove redundancy and automatically optimize image size<commit_after>module Filepicker
  module Rails

    module ViewHelpers
      def filepicker_js_include_tag
        javascript_include_tag "//api.filepicker.io/v0/filepicker.js"
      end

      def filepicker_save_button(text, url, mimetype, options = {})
        options[:data] ||= {}
        container = options.delete(:container)
        services = options.delete(:services)
        save_as = options.delete(:save_as_name)

        options[:data]['fp-url'] = url
        options[:data]['fp-apikey'] = ::Rails.application.config.filepicker_rails.api_key
        options[:data]['fp-mimetype'] = mimetype
        options[:data]['fp-option-container'] = container if container
        options[:data]['fp-option-services'] = Array(services).join(",") if services
        options[:data]['fp-option-defaultSaveasName'] = save_as if save_as
        button_tag(text, options)
      end

      # Allows options to be passed to filepicker_image_url and then falls back to normal Rails options for image_tag
      # If specifying html width, height, pass it down to filepicker for optimization
      def filepicker_image_tag(url, options={})
        options[:w] = options[:width]
        options[:h] = options[:height]
        image_tag(filepicker_image_url(url, options), options)
      end

      # w - Resize the image to this width.
      #
      # h - Resize the image to this height.
      #
{'fraction_non_alphanumeric': 0.1092468307233408, 'fraction_numerical': 0.0007457121551081282, 'mean_word_length': 3.0104633781763828, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4722229', 'n_tokens_mistral': 774, 'n_tokens_neox': 750, 'n_words': 186}