pin-it-button 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/pin-it-button.rb +53 -0
- metadata +65 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
module PinItButton
|
2
|
+
PINTEREST_SHARE_URL = "http://pinterest.com/pin/create/button"
|
3
|
+
|
4
|
+
class <<self
|
5
|
+
attr_accessor :default_pin_button_options
|
6
|
+
attr_accessor :default_pin_button_html_options
|
7
|
+
end
|
8
|
+
|
9
|
+
def pin_it_button(options = {}, html_options = {})
|
10
|
+
params = pin_options_to_query_string(default_pin_button_options.merge(options))
|
11
|
+
html_opts = default_pin_button_html_options.merge(options)
|
12
|
+
|
13
|
+
html = pin_html_safe_string('')
|
14
|
+
|
15
|
+
# adding it all together to create the link
|
16
|
+
html << link_to("Pin it", pin_html_safe_string(params), html_opts)
|
17
|
+
|
18
|
+
# adding the js script
|
19
|
+
unless @pinified
|
20
|
+
html << pinterest_widgets_js_tag
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_pin_button_html_options
|
25
|
+
{
|
26
|
+
:class => 'pin-it-button',
|
27
|
+
:'count-layout' => 'vertical'
|
28
|
+
}.merge(PinItButton.default_pin_button_html_options || {})
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_pin_button_options
|
32
|
+
{
|
33
|
+
:description => request.url,
|
34
|
+
:media => '',
|
35
|
+
:url => request.url
|
36
|
+
}.merge(PinItButton.default_pin_button_options || {})
|
37
|
+
end
|
38
|
+
|
39
|
+
def pin_options_to_query_string(opts)
|
40
|
+
opts.map{|k,v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v)}"}.join("&")
|
41
|
+
end
|
42
|
+
|
43
|
+
def pinterest_widgets_js_tag
|
44
|
+
@pinified = true
|
45
|
+
pin_html_safe_string('<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>')
|
46
|
+
end
|
47
|
+
|
48
|
+
def pin_html_safe_string(str)
|
49
|
+
@pin_use_html_safe ||= "".respond_to?(:html_safe)
|
50
|
+
@pin_use_html_safe ? str.html_safe : str
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pin-it-button
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 57
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 1
|
10
|
+
version: 0.9.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- willrax
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-03-02 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: a simple way to add the pin it button to sites
|
22
|
+
email: me@willrax.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- lib/pin-it-button.rb
|
31
|
+
homepage: http://rubygems.org/gems/pin-it-button
|
32
|
+
licenses: []
|
33
|
+
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 3
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.8.13
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: Pin it
|
64
|
+
test_files: []
|
65
|
+
|