Sha256: 81a7055f9f0517e62e631fd4df4d9aee9d9af040bc0546acae7a1037fe2a291f

Contents?: true

Size: 589 Bytes

Versions: 2

Compression:

Stored size: 589 Bytes

Contents

module Spree
  module PinterestHelper
    def pin_it_button(product)
      return if product.images.blank?

      url = escape request.url
      media = escape product.images.first.attachment.url
      description = escape product.name

      link_to("Pin It",
              "http://pinterest.com/pin/create/button/?url=#{url}&media=#{media}&description=#{description}",
              :class => "pin-it-button",
              "count-layout" => "horizontal").html_safe
    end

    private

    def escape(string)
      URI.escape string, /[^#{URI::PATTERN::UNRESERVED}]/
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_pinterest-0.1.1 app/helpers/spree/pinterest_helper.rb
spree_pinterest-0.1.0 app/helpers/spree/pinterest_helper.rb