open_graph_helper 0.0.3 → 0.1.0

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/README.markdown ADDED
@@ -0,0 +1,145 @@
1
+ # Open Graph Helper
2
+
3
+
4
+ Common [Open Graph](http://developers.facebook.com/docs/opengraph/) meta tag and [Facebook Social Plugin](http://developers.facebook.com/docs/plugins/) tag helpers.
5
+
6
+ There are only small subsets of tags are supported (for now).
7
+
8
+ Pull requests are welcome.
9
+
10
+ The Facebook Social Plugins are rendered in HTML5 version (a `<div>`). Their default options are tuned for Techbang. Override them by passing a Hash; see below.
11
+
12
+ ## Usage
13
+
14
+ Add this to your `Gemfile`:
15
+
16
+ gem 'open_graph_helper'
17
+
18
+ If you want to use the edge version on Github, specify the `:git` option.
19
+
20
+ gem 'open_graph_helper', :git => 'git://github.com/techbang/open_graph_helper.git'
21
+
22
+ And run
23
+
24
+ bundle install
25
+
26
+ to install this plug-in.
27
+
28
+ You need to include JavaScript SDK in your page to make Social Plugin works. See [Facebook JavaScript SDK](http://developers.facebook.com/docs/reference/javascript/) for more details.
29
+
30
+ If you're want to use [Facebooker2](https://github.com/mmangino/facebooker2), please include the SDK by `<%= fb_connect_async_js %>`.
31
+
32
+ The last thing: don't forget to add XML namespaces to the `<html>` tag, or `<meta>` tags won't work.
33
+
34
+ ``` html
35
+ <html xmlns="http://www.w3.org/1999/xhtml"
36
+ xmlns:og="http://ogp.me/ns#"
37
+ xmlns:fb="http://www.facebook.com/2008/fbml">
38
+ ```
39
+
40
+ ## Open Graph meta tags
41
+
42
+
43
+ Examples: (Sample output from [Facebook Open Graph Documentation](http://developers.facebook.com/docs/opengraph/))
44
+
45
+ ``` ruby
46
+ og_title("The Rock")
47
+ #=> <meta property="og:title" content="The Rock"/>
48
+
49
+ og_type("movie") # default is "article"
50
+ #=> <meta property="og:type" content="movie"/>
51
+
52
+ og_url("http://www.imdb.com/title/tt0117500/")
53
+ #=> <meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
54
+
55
+ og_image("http://ia.media-imdb.com/rock.jpg")
56
+ #=> <meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
57
+
58
+ og_site_name("IMDb")
59
+ #=> <meta property="og:site_name" content="IMDb"/>
60
+
61
+ og_description("Lorem Ipsum ...")
62
+ #=> <meta property="og:description" cotent="Lorem Ipsum ..."/>
63
+
64
+ og_fb_admins("123456,789012") # don't send an array
65
+ #=> <meta property="fb:admins" content="123456,789012"/>
66
+
67
+ og_fb_app_id("1234567890")
68
+ #=> <meta property="fb:app_id" content="1234567890"/>
69
+ ```
70
+
71
+ ## Facebook Social Plugins
72
+
73
+ There are some default options that was optimized for [Techbang](http://www.techbang.com.tw) sites and may not suits for your needs. Override them by passing a Hash as the last argument.
74
+
75
+ ### Like Button
76
+
77
+ Usage: `fb_like(like_url, options={})`
78
+
79
+ The default options are:
80
+
81
+ :send => false,
82
+ :layout => "button_count",
83
+ :show_faces => false,
84
+ :width => 90
85
+
86
+ For more options, see [Facebook Like Button Documentation](http://developers.facebook.com/docs/reference/plugins/like/)
87
+
88
+ Example:
89
+
90
+ ``` ruby
91
+ fb_like("http://example.com")
92
+ #=> <div class="fb-like" data-href="http://example.com" data-layout="button_count" data-send="false" data-show-faces="false" data-width="90"></div>
93
+
94
+ fb_like("http://example.com", :width => 120, :layout => "standard")
95
+ #=> <div class="fb-like" data-href="http://example.com" data-layout="standard" data-send="false" data-show-faces="false" data-width="120"></div>
96
+ ```
97
+
98
+ ### Like Box
99
+
100
+ Usage: `fb_like_box(page_url, options={})`
101
+
102
+ The default options are:
103
+
104
+ :width => 240,
105
+ :height => 65,
106
+ :show_faces => false,
107
+ :stream => false,
108
+ :header => true
109
+
110
+ For more options, see [Facebook Like Box Documentation](http://developers.facebook.com/docs/reference/plugins/like-box/)
111
+
112
+ Example:
113
+
114
+ ``` ruby
115
+ fb_like_box("http://www.facebook.com/example")
116
+ #=> <div class="fb-like-box" data-header="true" data-height="65" data-href="http://www.facebook.com/example" data-show-faces="false" data-stream="false" data-width="240"></div>
117
+
118
+ fb_like_box("http://www.facebook.com/example", :width => 180, :show_faces => true)
119
+ #=> <div class="fb-like-box" data-header="true" data-height="65" data-href="http://www.facebook.com/example" data-show-faces="true" data-stream="false" data-width="180"></div>
120
+ ```
121
+
122
+ ### Recommendations
123
+
124
+ Usage: `fb_recommendations(site_url, options={})`
125
+
126
+ The default options are:
127
+
128
+ :width => 300,
129
+ :height => 380,
130
+ :header => false,
131
+ :colorscheme => "light",
132
+ :border_color => "#CCC"
133
+
134
+ For more options, see [Facebook Recommendations Documentation](http://developers.facebook.com/docs/reference/plugins/recommendations/)
135
+
136
+ Example:
137
+
138
+ ``` ruby
139
+ fb_recommendations("www.example.com")
140
+ #=> <div class="fb-recommendations" data-border-color="#CCC" data-colorscheme="light" data-header="false" data-height="380" data-site="www.example.com" data-width="300"></div>
141
+
142
+ fb_recommendations("http://www.facebook.com/example", :header => true, :colorscheme => "dark")
143
+ #=> <div class="fb-recommendations" data-border-color="#CCC" data-colorscheme="dark" data-header="true" data-height="380" data-site="www.example.com" data-width="300"></div>
144
+ ```
145
+
@@ -1,3 +1,3 @@
1
1
  module OpenGraphHelper
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
  require "open_graph_helper/version"
3
3
  require 'open_graph_helper/railtie' if defined?(Rails)
4
4
 
@@ -38,33 +38,51 @@ module OpenGraphHelper
38
38
  tag(:meta, { :property => "fb:admins", :content => content }, true)
39
39
  end
40
40
 
41
- # types: icon, icon_link, button, button_count, box_count
42
- def fb_share_link(share_url, type = "button_count", script = false)
43
- output = link_to("分享", "http://www.facebook.com/sharer.php", :name => "fb_share", :share_url => share_url, :type => type, :class => "facebook fb-share")
44
- output << content_tag(:script, "", :src => "http://static.ak.fbcdn.net/connect.php/js/FB.Share", :type => "text/javascript") if script
45
- output
46
- end
41
+ # types: button_count, standard, box_count
42
+ def fb_like(like_url, custom_options={})
43
+ options = {
44
+ :href => like_url,
45
+ :send => false,
46
+ :layout => "button_count",
47
+ :show_faces => false,
48
+ :width => 90
49
+ }
50
+
51
+ options.merge! custom_options
47
52
 
48
- # types: button_count, standard
49
- def fb_like_iframe(like_url, type = "button_count", size = "85x21")
50
- width, height = size.split("x")
51
- src = "http://www.facebook.com/plugins/like.php?href=#{like_url}&locale=zh_TW&layout=#{type}&show_faces=true&action=like&colorscheme=light&width=#{width}&height=#{height}"
52
- style = "border:none; overflow:hidden; width:#{width}px; height:#{height}px;"
53
- content_tag(:iframe, "", :src => src, :scrolling => "no", :frameborder => "0", :style => style, :allowtransparency => "true")
53
+ content_tag(:div, "", :class => "fb-like", :data => options)
54
54
  end
55
55
 
56
- def fb_likebox_iframe(like_url, size = "240x65")
57
- width, height = size.split("x")
58
- src = "http://www.facebook.com/plugins/likebox.php?href=#{like_url}&connections=0&stream=false&header=true&colorscheme=light&width=#{width}&height=#{height}"
59
- style = "border:none; overflow:hidden; width:#{width}px; height:#{height}px;"
60
- content_tag(:iframe, "", :src => src, :scrolling => "no", :frameborder => "0", :style => style, :allowtransparency => "true")
56
+ def fb_likebox(page_url, custom_options={})
57
+ options = {
58
+ :href => page_url,
59
+ :width => 240,
60
+ :height => 65,
61
+ :show_faces => false,
62
+ :stream => false,
63
+ :header => true
64
+ }
65
+
66
+ options.merge! custom_options
67
+
68
+ content_tag(:div, "", :class => "fb-like-box", :data => options)
61
69
  end
62
70
 
63
- def fb_recommendation_iframe(site_url, size = "300x380")
64
- width, height = size.split("x")
65
- src = "http://www.facebook.com/plugins/recommendations.php?site=#{site_url}&header=false&colorscheme=light&border_color=%23CCCCCC&width=#{width}&height=#{height}"
66
- style = "border:none; overflow:hidden; width:#{width}px; height:#{height}px;"
67
- content_tag(:iframe, "", :src => src, :scrolling => "no", :frameborder => "0", :style => style, :allowtransparency => "true")
71
+ def fb_recommendations(site_url, custom_options={})
72
+ options = {
73
+ :site => site_url,
74
+ :width => 300,
75
+ :height => 380,
76
+ :header => false,
77
+ :colorscheme => "light",
78
+ :border_color => "#CCC"
79
+ # :linktarget => "_blank"
80
+ }
81
+
82
+ options.merge! custom_options
83
+
84
+ content_tag(:div, "", :class => "fb-recommendations", :data => options)
68
85
  end
86
+
69
87
  end
70
88
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_graph_helper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 3
10
- version: 0.0.3
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - xdite
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-26 00:00:00 Z
18
+ date: 2011-12-21 00:00:00 +08:00
19
+ default_executable:
19
20
  dependencies: []
20
21
 
21
22
  description: OpenGraph Helper
@@ -30,11 +31,13 @@ extra_rdoc_files: []
30
31
  files:
31
32
  - .gitignore
32
33
  - Gemfile
34
+ - README.markdown
33
35
  - Rakefile
34
36
  - lib/open_graph_helper.rb
35
37
  - lib/open_graph_helper/railtie.rb
36
38
  - lib/open_graph_helper/version.rb
37
39
  - open_graph_helper.gemspec
40
+ has_rdoc: true
38
41
  homepage: ""
39
42
  licenses: []
40
43
 
@@ -64,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
67
  requirements: []
65
68
 
66
69
  rubyforge_project:
67
- rubygems_version: 1.8.10
70
+ rubygems_version: 1.5.2
68
71
  signing_key:
69
72
  specification_version: 3
70
73
  summary: OpenGraph Helper