Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (22 sloc) 0.754 kB
module Spree
module PinterestHelper
def pin_it_button(product)
return if product.images.empty?
url = escape spree.product_url(product)
media = escape absolute_image_url(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
def absolute_image_url(url)
return url if url.starts_with? "http"
request.protocol + request.host + url
end
end
end
Jump to Line
Something went wrong with that request. Please try again.