Sha256: 0cecde2ec9da432329141a04600fd1c11a74ead64302acbdf697602131444066

Contents?: true

Size: 920 Bytes

Versions: 3

Compression:

Stored size: 920 Bytes

Contents

module Workarea
  module Storefront
    module SharesHelper
      def share_product_url(product, options = {})
        product_url(product, options.merge(host: Workarea.config.host))
      end

      def facebook_query_string(url)
        hash_without_blanks_to_query(u: url)
      end

      def twitter_query_string(url, message = nil)
        hash_without_blanks_to_query(url: url, text: message)
      end

      def share_query_string(url, message = nil, image = nil)
        hash_without_blanks_to_query(
          url: url,
          description: message,
          media: image
        )
      end

      def share_analytics_data(type, url)
        {
          event: 'share',
          domEvent: 'click',
          payload: { type: type, url: url }
        }
      end

      private

      def hash_without_blanks_to_query(hash)
        hash.delete_if { |_k, v| v.blank? }.to_query
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-share-1.3.1 app/helpers/workarea/storefront/shares_helper.rb
workarea-share-1.3.0 app/helpers/workarea/storefront/shares_helper.rb
workarea-share-1.2.4 app/helpers/workarea/storefront/shares_helper.rb