social_share_privacy 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 26a84917b7f8dd4f521456455a0c696ed4875271
4
+ data.tar.gz: c42a2c83d5de278b6b89e0391873b9187d589203
5
+ SHA512:
6
+ metadata.gz: 8b79910becefb2e14b7f9f7688a2c0ea74a999394962636cf4d69718a2d688d7c719c25fd4141d6f24c22c355c5d4466ed3e350827ff8b70f9ae0ac6e6f6d2e4
7
+ data.tar.gz: 8d5eddd86e1b8feb0fc36b0f294558fe2402e83f2eb9f09af097213c54c727ad4f4c8117593e252ca8ebfcfc4df4798de8b3f53d1363e57f0de85f9bd8243040
@@ -1,22 +1,26 @@
1
1
  en:
2
2
  social_share_privacy:
3
+ txt_help: Text
3
4
  facebook:
4
5
  txt_info: |
5
6
  2 Clicks for more privacy: The button will become active only after you click here. After it's active you can recommend this page on Facebook. Data is transfered to third parties upon activation -> see i.
6
7
  txt_off: not connected to Facebook
7
8
  txt_on: connected to Facebook
9
+ txt_help: Text
8
10
  display_name: Facebook
9
11
  twitter:
10
12
  txt_info: |
11
13
  2 Clicks for more privacy: The button will become active only after you click here. After it's active you can tweet this page. Data is transfered to third parties upon activation -> see i.
12
14
  txt_off: not connected to Twitter
13
15
  txt_on: connected to Twitter
16
+ txt_help: Text
14
17
  display_name: Twitter
15
18
  gplus:
16
19
  txt_info: |
17
20
  2 Clicks for more privacy: The button will become active only after you click here. After it's active you can +1 this page on Google+. Data is transfered to third parties upon activation -> see i.
18
21
  txt_off: not connected to Google+
19
22
  txt_on: connected to Google+
23
+ txt_help: Text
20
24
  display_name: Google+
21
25
  txt_help: |
22
26
  If you activate these fields with a click information will be sent to Facebook, Twitter or Google to the US and possibly stored there. You can learn more by clicking the i.
@@ -0,0 +1,39 @@
1
+ SocialSharePrivacy.configure do |config|
2
+
3
+ config.info_link = 'http://www.heise.de/ct/artikel/2-Klicks-fuer-mehr-Datenschutz-1333879.html'
4
+
5
+ config.uri = Proc.new {|request| request.url}
6
+
7
+ config.cookie do |cookie|
8
+ cookie.path = '/'
9
+ cookie.domain = Proc.new {|request| request.host}
10
+ cookie.expires = 365
11
+ end
12
+
13
+ config.services do |services|
14
+
15
+ services.facebook do |facebook|
16
+ facebook.status = true
17
+ facebook.perma_option = true
18
+ facebook.referrer_track = ''
19
+ facebook.language = Proc.new { I18n.locale }
20
+ facebook.action = :recommend
21
+ end
22
+
23
+ services.twitter do |twitter|
24
+ twitter.status = true
25
+ twitter.perma_option = true
26
+ twitter.referrer_track = ''
27
+ twitter.language = Proc.new { I18n.locale }
28
+ end
29
+
30
+ services.gplus do |gplus|
31
+ gplus.status = true
32
+ gplus.perma_option = true
33
+ gplus.referrer_track = ''
34
+ gplus.language = Proc.new { I18n.locale }
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -1,3 +1,3 @@
1
1
  module SocialSharePrivacy
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -1,8 +1,153 @@
1
+ class Object
2
+ def deep_clone
3
+ begin
4
+ result = self.clone
5
+ self.instance_variables.each do |var_name|
6
+ var = self.instance_variable_get var_name
7
+ result.instance_variable_set var_name, var.deep_clone
8
+ end
9
+ result
10
+ rescue TypeError
11
+ self
12
+ end
13
+ end
14
+ end
15
+
1
16
  module SocialSharePrivacy
2
- module Generators
17
+ #module Generators
18
+ #end
19
+ #module Rails
20
+ #class Engine < ::Rails::Engine
21
+ #end
22
+ #end
23
+
24
+ module Evaluatable
25
+
26
+ def eval request
27
+ result = self.deep_clone
28
+ result.instance_variables.each do |var_name|
29
+ var = result.instance_variable_get var_name
30
+ if var.is_a? Proc
31
+ result.instance_variable_set var_name, var.call(request)
32
+ elsif var.is_a? Evaluatable
33
+ result.instance_variable_set var_name, var.eval(request)
34
+ end
35
+ end
36
+ result
37
+ end
38
+
39
+ end
40
+
41
+ module JSONable
42
+
43
+ def to_s
44
+ json_string = '{'
45
+ vars = self.instance_variables.map do |var_name|
46
+ var = self.instance_variable_get var_name
47
+ var_s = var.to_s
48
+ unless var.is_a? JSONable
49
+ var_s = '"' + var_s.gsub(/(["\\])/){ "\\" + $1 } + '"'
50
+ end
51
+ "\"#{var_name.to_s.sub(/^@+/,'')}\":#{var_s}"
52
+ end
53
+ json_string += vars.join(',')
54
+ json_string + '}'
55
+ end
3
56
  end
4
- module Rails
5
- class Engine < ::Rails::Engine
57
+
58
+ class Config
59
+
60
+ include Evaluatable, JSONable
61
+
62
+ attr_accessor :info_link, :uri
63
+
64
+ class Cookie
65
+
66
+ include Evaluatable, JSONable
67
+ attr_accessor :path, :domain, :expires
6
68
  end
69
+
70
+ class Services
71
+
72
+ include Evaluatable, JSONable
73
+
74
+ class Service
75
+
76
+ include Evaluatable, JSONable
77
+
78
+ attr_accessor :referrer_track, :language
79
+ attr_reader :status, :perma_option
80
+
81
+ def initialize
82
+ 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")
88
+ end
89
+
90
+ def enabled= value
91
+ if value
92
+ @status = 'on'
93
+ else
94
+ @status = 'off'
95
+ end
96
+ end
97
+
98
+ def perma_option= value
99
+ if value
100
+ @perma_option = 'on'
101
+ else
102
+ @perma_option = 'off'
103
+ end
104
+ end
105
+ end
106
+
107
+ class Facebook < Service
108
+ attr_accessor :action
109
+ end
110
+
111
+ class Twitter < Service
112
+ end
113
+
114
+ class Gplus < Service
115
+ end
116
+
117
+ def facebook
118
+ yield(@facebook ||= Facebook.new)
119
+ end
120
+
121
+ def twitter
122
+ yield(@twitter ||= Twitter.new)
123
+ end
124
+
125
+ def gplus
126
+ yield(@gplus ||= Twitter.new)
127
+ end
128
+ end
129
+
130
+ def initialize
131
+ @txt_help = Proc.new { I18n.t('social_share_privacy.txt_help') }
132
+ @txt_perma = Proc.new { I18n.t('social_share_privacy.txt_perma') }
133
+ end
134
+
135
+ def cookie
136
+ yield(@cookie ||= Cookie.new)
137
+ end
138
+
139
+ def services
140
+ yield(@services ||= Services.new)
141
+ end
142
+
143
+ end
144
+
145
+ def self.config
146
+ @@config ||= Config.new
147
+ end
148
+
149
+ def self.configure
150
+ yield(config)
7
151
  end
152
+
8
153
  end
@@ -1,4 +1,3 @@
1
- <% include ::Rails::ERB::Util %>
2
1
  /*
3
2
  * jquery.socialshareprivacy.js | 2 Klicks fuer mehr Datenschutz
4
3
  *
@@ -81,54 +80,10 @@
81
80
  }
82
81
 
83
82
  // extend jquery with our plugin function
84
- $.fn.socialSharePrivacy = function (settings) {
85
- var defaults = {
86
- 'services' : {
87
- 'facebook' : {
88
- 'status' : 'on',
89
- 'txt_info' : '<%= h(I18n.t('social_share_privacy.facebook.txt_info')) %>',
90
- 'txt_fb_off' : '<%= h(I18n.t('social_share_privacy.facebook.txt_off')) %>',
91
- 'txt_fb_on' : '<%= h(I18n.t('social_share_privacy.facebook.txt_on')) %>',
92
- 'perma_option' : 'on',
93
- 'display_name' : '<%= h(I18n.t('social_share_privacy.facebook.display_name')) %>',
94
- 'referrer_track' : '',
95
- 'language' : '<%= I18n.locale.to_s %>',
96
- 'action' : 'recommend'
97
- },
98
- 'twitter' : {
99
- 'status' : 'on',
100
- 'txt_info' : '<%= h(I18n.t('social_share_privacy.twitter.txt_info')) %>',
101
- 'txt_twitter_off' : '<%= h(I18n.t('social_share_privacy.twitter.txt_off')) %>',
102
- 'txt_twitter_on' : '<%= h(I18n.t('social_share_privacy.twitter.txt_on')) %>',
103
- 'perma_option' : 'on',
104
- 'display_name' : '<%= h(I18n.t('social_share_privacy.twitter.display_name')) %>',
105
- 'referrer_track' : '',
106
- 'tweet_text' : getTweetText,
107
- 'language' : '<%= I18n.locale.to_s %>'
108
- },
109
- 'gplus' : {
110
- 'status' : 'on',
111
- 'txt_info' : '<%= h(I18n.t('social_share_privacy.gplus.txt_info')) %>',
112
- 'txt_gplus_off' : '<%= h(I18n.t('social_share_privacy.gplus.txt_off')) %>',
113
- 'txt_gplus_on' : '<%= h(I18n.t('social_share_privacy.gplus.txt_on')) %>',
114
- 'perma_option' : 'on',
115
- 'display_name' : '<%= h(I18n.t('social_share_privacy.gplus.display_name')) %>',
116
- 'referrer_track' : '',
117
- 'language' : '<%= I18n.locale.to_s %>'
118
- }
119
- },
120
- 'info_link' : 'http://www.heise.de/ct/artikel/2-Klicks-fuer-mehr-Datenschutz-1333879.html',
121
- 'txt_help' : '<%= h(I18n.t('social_share_privacy.txt_help')) %>',
122
- 'settings_perma' : '<%= h(I18n.t('social_share_privacy.settings_perma')) %>'
123
- 'cookie_path' : '/',
124
- 'cookie_domain' : document.location.host,
125
- 'cookie_expires' : '365',
126
- 'uri' : getURI
127
- };
83
+ $.fn.socialSharePrivacy = function () {
128
84
 
129
85
  // Standardwerte des Plug-Ings mit den vom User angegebenen Optionen ueberschreiben
130
- var options = $.extend(true, defaults, settings);
131
-
86
+ var options = <%= SocialSharePrivacy.config.eval(request).to_s %>
132
87
  var facebook_on = (options.services.facebook.status === 'on');
133
88
  var twitter_on = (options.services.twitter.status === 'on');
134
89
  var gplus_on = (options.services.gplus.status === 'on');
@@ -157,18 +112,18 @@
157
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>';
158
113
  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" />';
159
114
 
160
- context.append('<li class="facebook help_info"><span class="info">' + options.services.facebook.txt_info + '</span><span class="switch off">' + options.services.facebook.txt_fb_off + '</span><div class="fb_like dummy_btn">' + fb_dummy_btn + '</div></li>');
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>');
161
116
 
162
117
  var $container_fb = $('li.facebook', context);
163
118
 
164
119
  $('li.facebook div.fb_like img.fb_like_privacy_dummy,li.facebook span.switch', context).bind('click', function () {
165
120
  if ($container_fb.find('span.switch').hasClass('off')) {
166
121
  $container_fb.addClass('info_off');
167
- $container_fb.find('span.switch').addClass('on').removeClass('off').html(options.services.facebook.txt_fb_on);
122
+ $container_fb.find('span.switch').addClass('on').removeClass('off').html(options.services.facebook.txt_on);
168
123
  $container_fb.find('img.fb_like_privacy_dummy').replaceWith(fb_code);
169
124
  } else {
170
125
  $container_fb.removeClass('info_off');
171
- $container_fb.find('span.switch').addClass('off').removeClass('on').html(options.services.facebook.txt_fb_off);
126
+ $container_fb.find('span.switch').addClass('off').removeClass('on').html(options.services.facebook.txt_off);
172
127
  $container_fb.find('.fb_like').html(fb_dummy_btn);
173
128
  }
174
129
  });
@@ -190,18 +145,18 @@
190
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>';
191
146
  var twitter_dummy_btn = '<img src="<%= image_path 'social_share_privacy/dummy_twitter.png' %>" alt="&quot;Tweet this&quot;-Dummy" class="tweet_this_dummy" />';
192
147
 
193
- context.append('<li class="twitter help_info"><span class="info">' + options.services.twitter.txt_info + '</span><span class="switch off">' + options.services.twitter.txt_twitter_off + '</span><div class="tweet dummy_btn">' + twitter_dummy_btn + '</div></li>');
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>');
194
149
 
195
150
  var $container_tw = $('li.twitter', context);
196
151
 
197
152
  $('li.twitter div.tweet img,li.twitter span.switch', context).bind('click', function () {
198
153
  if ($container_tw.find('span.switch').hasClass('off')) {
199
154
  $container_tw.addClass('info_off');
200
- $container_tw.find('span.switch').addClass('on').removeClass('off').html(options.services.twitter.txt_twitter_on);
155
+ $container_tw.find('span.switch').addClass('on').removeClass('off').html(options.services.twitter.txt_on);
201
156
  $container_tw.find('img.tweet_this_dummy').replaceWith(twitter_code);
202
157
  } else {
203
158
  $container_tw.removeClass('info_off');
204
- $container_tw.find('span.switch').addClass('off').removeClass('on').html(options.services.twitter.txt_twitter_off);
159
+ $container_tw.find('span.switch').addClass('off').removeClass('on').html(options.services.twitter.txt_off);
205
160
  $container_tw.find('.tweet').html(twitter_dummy_btn);
206
161
  }
207
162
  });
@@ -218,18 +173,18 @@
218
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>';
219
174
  var gplus_dummy_btn = '<img src="<%= image_path 'social_share_privacy/dummy_gplus.png' %>" alt="&quot;Google+1&quot;-Dummy" class="gplus_one_dummy" />';
220
175
 
221
- context.append('<li class="gplus help_info"><span class="info">' + options.services.gplus.txt_info + '</span><span class="switch off">' + options.services.gplus.txt_gplus_off + '</span><div class="gplusone dummy_btn">' + gplus_dummy_btn + '</div></li>');
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>');
222
177
 
223
178
  var $container_gplus = $('li.gplus', context);
224
179
 
225
180
  $('li.gplus div.gplusone img,li.gplus span.switch', context).bind('click', function () {
226
181
  if ($container_gplus.find('span.switch').hasClass('off')) {
227
182
  $container_gplus.addClass('info_off');
228
- $container_gplus.find('span.switch').addClass('on').removeClass('off').html(options.services.gplus.txt_gplus_on);
183
+ $container_gplus.find('span.switch').addClass('on').removeClass('off').html(options.services.gplus.txt_on);
229
184
  $container_gplus.find('img.gplus_one_dummy').replaceWith(gplus_code);
230
185
  } else {
231
186
  $container_gplus.removeClass('info_off');
232
- $container_gplus.find('span.switch').addClass('off').removeClass('on').html(options.services.gplus.txt_gplus_off);
187
+ $container_gplus.find('span.switch').addClass('off').removeClass('on').html(options.services.gplus.txt_off);
233
188
  $container_gplus.find('.gplusone').html(gplus_dummy_btn);
234
189
  }
235
190
  });
@@ -266,13 +221,13 @@
266
221
  {
267
222
 
268
223
  // Cookies abrufen
269
- var cookie_list = document.cookie.split(';');
224
+ var cookie.list = document.cookie.split(';');
270
225
  var cookies = '{';
271
226
  var i = 0;
272
- for (; i < cookie_list.length; i += 1) {
273
- var foo = cookie_list[i].split('=');
227
+ for (; i < cookie.list.length; i += 1) {
228
+ var foo = cookie.list[i].split('=');
274
229
  cookies += '"' + $.trim(foo[0]) + '":"' + $.trim(foo[1]) + '"';
275
- if (i < cookie_list.length - 1) {
230
+ if (i < cookie.list.length - 1) {
276
231
  cookies += ',';
277
232
  }
278
233
  }
@@ -286,7 +241,7 @@
286
241
  $container_settings_info.find('.settings_info_menu').removeClass('perma_option_off');
287
242
 
288
243
  // Perma-Optionen-Icon (.settings) und Formular (noch versteckt) einbinden
289
- $container_settings_info.find('.settings_info_menu').append('<span class="settings">Einstellungen</span><form><fieldset><legend>' + options.settings_perma + '</legend></fieldset></form>');
244
+ $container_settings_info.find('.settings_info_menu').append('<span class="settings">Einstellungen</span><form><fieldset><legend>' + options.txt_perma + '</legend></fieldset></form>');
290
245
 
291
246
 
292
247
  // Die Dienste mit <input> und <label>, sowie checked-Status laut Cookie, schreiben
@@ -336,13 +291,13 @@
336
291
  $($container_settings_info.find('fieldset input')).bind('click', function (event) {
337
292
  var click = event.target.id;
338
293
  var service = click.substr(click.lastIndexOf('_') + 1, click.length);
339
- var cookie_name = 'socialSharePrivacy_' + service;
294
+ var cookie.name = 'socialSharePrivacy_' + service;
340
295
 
341
296
  if ($('#' + event.target.id + ':checked').length) {
342
- cookieSet(cookie_name, 'perma_on', options.cookie_expires, options.cookie_path, options.cookie_domain);
297
+ cookieSet(cookie.name, 'perma_on', options.cookie.expires, options.cookie.path, options.cookie.domain);
343
298
  $('form fieldset label[for=' + click + ']', context).addClass('checked');
344
299
  } else {
345
- cookieDel(cookie_name, 'perma_on', options.cookie_path, options.cookie_domain);
300
+ cookieDel(cookie.name, 'perma_on', options.cookie.path, options.cookie.domain);
346
301
  $('form fieldset label[for=' + click + ']', context).removeClass('checked');
347
302
  }
348
303
  });
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_share_privacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
5
- prerelease:
4
+ version: 0.1.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Joakim Reinert
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-29 00:00:00.000000000 Z
11
+ date: 2013-03-31 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.1'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '3.1'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: sqlite3
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: Provides the heise socialshareprivacy plugin for the rails asset pipeline.
@@ -55,6 +50,8 @@ files:
55
50
  - lib/tasks/social_share_privacy_tasks.rake
56
51
  - lib/social_share_privacy.rb
57
52
  - lib/social_share_privacy/version.rb
53
+ - lib/generators/templates/social_share_privacy.rb
54
+ - lib/generators/templates/helpers/social_share_privacy_helper.rb
58
55
  - lib/generators/templates/en_social_share_privacy.yml
59
56
  - lib/generators/templates/de_social_share_privacy.yml
60
57
  - lib/generators/social_share_privacy/install_generator.rb
@@ -107,27 +104,26 @@ files:
107
104
  - test/dummy/config.ru
108
105
  homepage: https://github.com/supasnashbuhl/social-share-privacy
109
106
  licenses: []
107
+ metadata: {}
110
108
  post_install_message:
111
109
  rdoc_options: []
112
110
  require_paths:
113
111
  - lib
114
112
  required_ruby_version: !ruby/object:Gem::Requirement
115
- none: false
116
113
  requirements:
117
- - - ! '>='
114
+ - - '>='
118
115
  - !ruby/object:Gem::Version
119
116
  version: '0'
120
117
  required_rubygems_version: !ruby/object:Gem::Requirement
121
- none: false
122
118
  requirements:
123
- - - ! '>='
119
+ - - '>='
124
120
  - !ruby/object:Gem::Version
125
121
  version: '0'
126
122
  requirements: []
127
123
  rubyforge_project:
128
- rubygems_version: 1.8.25
124
+ rubygems_version: 2.0.0
129
125
  signing_key:
130
- specification_version: 3
126
+ specification_version: 4
131
127
  summary: Adds the heise social share privacy plugin to the asset pipeline
132
128
  test_files:
133
129
  - test/test_helper.rb