facebook_share 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
+ .rspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- facebook_share (0.0.2)
4
+ facebook_share (0.0.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -38,7 +38,7 @@ Default facebook Share options can be changed with the above code snippet
38
38
 
39
39
  * *appid* - your Facebook application ID that will connect your site to Facebook
40
40
  * *status*. *cookie* and *xfbml* - as described at [FB.init JS SDK](http://developers.facebook.com/docs/reference/javascript/fb.init/)
41
- * *locale* - Facebook locale code representations, ie. en_US, de_DE, pl_PL, etc. The full list of Facebook supported languages is available in http://www.facebook.com/translations/FacebookLocales.xml or at [Facebook Developer Wiki](http://fbdevwiki.com/wiki/Locales)
41
+ * *locale* - Facebook locale code representations, ie. en_US, de_DE, pl_PL, etc. The full list of Facebook supported languages is available in http://www.facebook.com/translations/FacebookLocales.xml or at [Facebook Developer Wiki](http://fbdevwiki.com/wiki/Locales). If your locale has both parts of the string the same, for example "de_DE", "pl_PL", since version 0.0.4 you can put just "de" or "pl", etc. The script **does not** check for validity of given locale.
42
42
  * *selector* - a selector to target Facebook share binding, ".fb_share" by default
43
43
  * any other parameter will be passed to Facebook's **[FB.ui](http://developers.facebook.com/docs/reference/javascript/fb.ui/)** function, so you can use whichever parameters you need, except for *method*, which defaults always to *publish.stream*
44
44
 
@@ -51,6 +51,25 @@ The simplest usage (given you specified your project's Facebook Application ID)
51
51
 
52
52
  That will produce a link "Share on Facebook" with a class of "fb_share" and a corresponding JavaScript script tags initializing Facebook app and sharing method bind to click on that link. By default gem passes ".fb_share" selector to jQuery.
53
53
 
54
+ ## Changelog
55
+
56
+ v0.0.4
57
+
58
+ * Locale guessing, if necessary
59
+
60
+ v0.0.3
61
+
62
+ * Added basic tests
63
+
64
+ v0.0.2
65
+
66
+ * Added global settings
67
+ * Replaced *url* param with *link* to be consistent with Facebook API
68
+
69
+ v0.0.1
70
+
71
+ * First public release
72
+
54
73
  ## Note on patches/pull requests
55
74
 
56
75
  * Fork the project.
@@ -7,10 +7,16 @@ module FacebookShare
7
7
  end
8
8
 
9
9
  def default_facebook_share_options
10
+ # usually you might want to provide your own link anyway
11
+ if defined? request
12
+ link = request.url
13
+ else
14
+ link = "http://railslove.com"
15
+ end
10
16
  {
11
17
  :app_id => "0",
12
18
  :selector => ".fb_share",
13
- :link => request.url,
19
+ :link => link,
14
20
  :locale => "en_US",
15
21
  :display => "popup"
16
22
  }.merge(FacebookShare.default_facebook_share_options || {})
@@ -47,6 +53,7 @@ JS
47
53
 
48
54
  def facebook_connect_js_tag(options = {})
49
55
  options = default_facebook_share_options.merge(options)
56
+ options[:locale] = "#{options[:locale]}_#{options[:locale].upcase}" if /^[a-z]{2}$/.match(options[:locale])
50
57
  html_safe_string("<script type=\"text/javascript\" src=\"https://connect.facebook.net/#{options[:locale]}/all.js\"></script>")
51
58
  end
52
59
 
@@ -1,3 +1,3 @@
1
1
  module FacebookShare
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -46,4 +46,27 @@ describe FacebookShare do
46
46
  it { should_not match(/selector: "/) }
47
47
  end
48
48
  end
49
+
50
+ describe "creating init script" do
51
+ context "when vanilla locale" do
52
+ subject { facebook_connect_js_tag( :locale => "en_US" ) }
53
+
54
+ it { should match(/\/en_US\/all\.js/) }
55
+ it { should_not match(/\/en\/all\.js/) }
56
+ end
57
+
58
+ context "when shortened locale" do
59
+ subject { facebook_connect_js_tag( :locale => "en" ) }
60
+
61
+ it { should match(/\/en_EN\/all\.js/) }
62
+ it { should_not match(/\/en\/all\.js/) }
63
+ end
64
+
65
+ context "when shortened locale 2" do
66
+ subject { facebook_connect_js_tag( :locale => "pl" ) }
67
+
68
+ it { should match(/\/pl_PL\/all\.js/) }
69
+ it { should_not match(/\/pl\/all\.js/) }
70
+ end
71
+ end
49
72
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook_share
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Mike Po\xC5\x82tyn"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-16 00:00:00 +01:00
18
+ date: 2011-02-17 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency