social_share_privacy 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdb9b1fab6d1ba61c578e4148ba9935b2277fe96
4
- data.tar.gz: 91f5d321ba790778f5c73cb0f644fec7659b1acb
3
+ metadata.gz: 9134f6ca8b71811d5a00c9f0d94906d4cf84450a
4
+ data.tar.gz: 2ca77cbde2bcab3694a53888e410f8dbda07bd6c
5
5
  SHA512:
6
- metadata.gz: a6ea94fbd6087a147f3947ff3693cfdb76269df1e3b87bc5254a3b1c6bffded9052b5a2c4845678508219267faa4f78390e54fab4fae7ce9603222d84056dc13
7
- data.tar.gz: 8a48f1f9b5e831f242476b88cfb679df35e4bdb2a4090ce5edc7c1ab555833572852d4bb1ceafee3c99533b2eb237010b7408344a400ead819bc3f75065acb29
6
+ metadata.gz: 366d03cf313193b6c07928b753175110d5595c6b40dc913298cc81eaf4397046f521353137f1fbf95c4dc29127450ad4e85d728086e673632cb400bccc021076
7
+ data.tar.gz: 6150b2389bf0457b229f46577e2074b0e9aa5f1de6896f81f8ff672067b3466b95886231718db47afb8ad4f43347b74858fab9e7ef3b029438900e38c02a1263
@@ -0,0 +1,13 @@
1
+ module SocialSharePrivacyHelper
2
+ def social_buttons
3
+ options = SocialSharePrivacy.config.eval(request).to_s
4
+ result = []
5
+ result << '<div class="social_buttons"></div>'
6
+ result << javascript_tag do
7
+ result << 'jQuery(document).ready(function($) {'
8
+ result << " $('.social_buttons').socialSharePrivacy(#{options});"
9
+ result << "});"
10
+ end
11
+ raw(result.join("\n"))
12
+ end
13
+ end
@@ -21,6 +21,13 @@ module SocialSharePrivacy
21
21
  end
22
22
  end
23
23
 
24
+ %w{ models controllers helpers }.each do |dir|
25
+ path = File.join(File.dirname(__FILE__), 'app', dir)
26
+ $LOAD_PATH << path
27
+ ActiveSupport::Dependencies.load_paths << path
28
+ ActiveSupport::Dependencies.load_once_paths.delete(path)
29
+ end
30
+
24
31
  module Evaluatable
25
32
 
26
33
  def eval request
@@ -48,7 +55,7 @@ module SocialSharePrivacy
48
55
  unless var.is_a? JSONable
49
56
  var_s = '"' + var_s.gsub(/(["\\])/){ "\\" + $1 } + '"'
50
57
  end
51
- "\"#{var_name.to_s.sub(/^@+/,'')}\":#{var_s}"
58
+ "\"#{var_name.to_s.sub(/^@+/,'').downcase}\":#{var_s}"
52
59
  end
53
60
  json_string += vars.join(',')
54
61
  json_string + '}'
@@ -60,7 +67,7 @@ module SocialSharePrivacy
60
67
  include Evaluatable, JSONable
61
68
 
62
69
  attr_accessor :info_link, :uri
63
-
70
+
64
71
  class Cookie
65
72
 
66
73
  include Evaluatable, JSONable
@@ -80,11 +87,12 @@ module SocialSharePrivacy
80
87
 
81
88
  def initialize
82
89
  loc_s = 'social_share_privacy.' + self.class.name.downcase
83
- @txt_info = I18n.t("#{loc_s}.txt_info")
84
- @txt_help = I18n.t("#{loc_s}.txt_help")
85
- @txt_off = I18n.t("#{loc_s}.txt_off")
86
- @txt_on = I18n.t("#{loc_s}.txt_on")
87
- @txt_help = I18n.t("#{loc_s}.display_name")
90
+ @txt_info = Proc.new { I18n.t("#{loc_s}.txt_info") }
91
+ @txt_help = Proc.new { I18n.t("#{loc_s}.txt_help") }
92
+ @txt_off = Proc.new { I18n.t("#{loc_s}.txt_off") }
93
+ @txt_on = Proc.new { I18n.t("#{loc_s}.txt_on") }
94
+ @display_name = Proc.new { I18n.t("#{loc_s}.display_name") }
95
+ @dummy_button = Proc.new { ActionView::Helpers::AssetTagHelper.path_to_image('social_share_privacy/dummy_' + self.class.name.downcase + '.png')}
88
96
  end
89
97
 
90
98
  def enabled= value
@@ -106,6 +114,13 @@ module SocialSharePrivacy
106
114
 
107
115
  class Facebook < Service
108
116
  attr_accessor :action
117
+
118
+ def eval request
119
+ result = super request
120
+ result.dummy_button = ActionView::Helpers::AssetTagHelper.image_path('social_share_privacy/dummy_facebook_de.png') if result.language == 'de'
121
+ result
122
+ end
123
+
109
124
  end
110
125
 
111
126
  class Twitter < Service
@@ -1,3 +1,3 @@
1
1
  module SocialSharePrivacy
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -80,11 +80,10 @@
80
80
  }
81
81
 
82
82
  // extend jquery with our plugin function
83
- $.fn.socialSharePrivacy = function () {
83
+ $.fn.socialSharePrivacy = function (userOptions) {
84
84
 
85
85
  // Standardwerte des Plug-Ings mit den vom User angegebenen Optionen ueberschreiben
86
- <%= binding.pry %>
87
- var options = <%= SocialSharePrivacy.config.eval(request).to_s %>
86
+ var options = userOptions
88
87
  var facebook_on = (options.services.facebook.status === 'on');
89
88
  var twitter_on = (options.services.twitter.status === 'on');
90
89
  var gplus_on = (options.services.gplus.status === 'on');
@@ -111,7 +110,7 @@
111
110
  if (facebook_on) {
112
111
  var fb_enc_uri = encodeURIComponent(uri + options.services.facebook.referrer_track);
113
112
  var fb_code = '<iframe src="http://www.facebook.com/plugins/like.php?locale=' + options.services.facebook.language + '&amp;href=' + fb_enc_uri + '&amp;send=false&amp;layout=button_count&amp;width=120&amp;show_faces=false&amp;action=' + options.services.facebook.action + '&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:145px; height:21px;" allowTransparency="true"></iframe>';
114
- var fb_dummy_btn = '<img src="<%= if I18n.locale == :de; image_path 'social_share_privacy/dummy_facebook_de.png'; else; image_path 'social_share_privacy/dummy_facebook.png'; end %>" alt="Facebook &quot;Like&quot;-Dummy" class="fb_like_privacy_dummy" />';
113
+ var fb_dummy_btn = '<img src="' + options.services.facebook.dummy_button + '" alt="Facebook &quot;Like&quot;-Dummy" class="fb_like_privacy_dummy" />';
115
114
 
116
115
  context.append('<li class="facebook help_info"><span class="info">' + options.services.facebook.txt_info + '</span><span class="switch off">' + options.services.facebook.txt_off + '</span><div class="fb_like dummy_btn">' + fb_dummy_btn + '</div></li>');
117
116
 
@@ -144,7 +143,7 @@
144
143
  var twitter_enc_uri = encodeURIComponent(uri + options.services.twitter.referrer_track);
145
144
  var twitter_count_url = encodeURIComponent(uri);
146
145
  var twitter_code = '<iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=' + twitter_enc_uri + '&amp;counturl=' + twitter_count_url + '&amp;text=' + text + '&amp;count=horizontal&amp;lang=' + options.services.twitter.language + '" style="width:130px; height:25px;"></iframe>';
147
- var twitter_dummy_btn = '<img src="<%= image_path 'social_share_privacy/dummy_twitter.png' %>" alt="&quot;Tweet this&quot;-Dummy" class="tweet_this_dummy" />';
146
+ var twitter_dummy_btn = '<img src="' + options.services.twitter.dummy_button + '" alt="&quot;Tweet this&quot;-Dummy" class="tweet_this_dummy" />';
148
147
 
149
148
  context.append('<li class="twitter help_info"><span class="info">' + options.services.twitter.txt_info + '</span><span class="switch off">' + options.services.twitter.txt_off + '</span><div class="tweet dummy_btn">' + twitter_dummy_btn + '</div></li>');
150
149
 
@@ -172,7 +171,7 @@
172
171
 
173
172
  // we use the Google+ "asynchronous" code, standard code is flaky if inserted into dom after load
174
173
  var gplus_code = '<div class="g-plusone" data-size="medium" data-href="' + gplus_uri + '"></div><script type="text/javascript">window.___gcfg = {lang: "' + options.services.gplus.language + '"}; (function() { var po = document.createElement("script"); po.type = "text/javascript"; po.async = true; po.src = "https://apis.google.com/js/plusone.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s); })(); </script>';
175
- var gplus_dummy_btn = '<img src="<%= image_path 'social_share_privacy/dummy_gplus.png' %>" alt="&quot;Google+1&quot;-Dummy" class="gplus_one_dummy" />';
174
+ var gplus_dummy_btn = '<img src="' + options.services.gplus.dummy_button '" alt="&quot;Google+1&quot;-Dummy" class="gplus_one_dummy" />';
176
175
 
177
176
  context.append('<li class="gplus help_info"><span class="info">' + options.services.gplus.txt_info + '</span><span class="switch off">' + options.services.gplus.txt_off + '</span><div class="gplusone dummy_btn">' + gplus_dummy_btn + '</div></li>');
178
177
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_share_privacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Reinert
@@ -47,6 +47,7 @@ executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
+ - app/helpers/social_share_privacy_helper.rb
50
51
  - lib/tasks/social_share_privacy_tasks.rake
51
52
  - lib/social_share_privacy.rb
52
53
  - lib/social_share_privacy/version.rb
@@ -61,10 +62,9 @@ files:
61
62
  - vendor/assets/images/social_share_privacy/socialshareprivacy_info.png
62
63
  - vendor/assets/images/social_share_privacy/dummy_facebook_de.png
63
64
  - vendor/assets/images/social_share_privacy/dummy_gplus.png
64
- - vendor/assets/images/social_share_privacy/dummy_gplus_alt.png
65
65
  - vendor/assets/images/social_share_privacy/dummy_facebook.png
66
66
  - vendor/assets/stylesheets/socialshareprivacy.css.erb
67
- - vendor/assets/javascripts/jquery.socialshareprivacy.js.erb
67
+ - vendor/assets/javascripts/jquery.socialshareprivacy.js
68
68
  - MIT-LICENSE
69
69
  - Rakefile
70
70
  - README.rdoc