diff --git a/app/views/content_viewer/view_page.html.erb b/app/views/content_viewer/view_page.html.erb index 036f6b5..55bca32 100644 --- a/app/views/content_viewer/view_page.html.erb +++ b/app/views/content_viewer/view_page.html.erb @@ -42,6 +42,7 @@ <%= render :partial => 'shared/disabled_enterprise' %> +<%= @plugins.dispatch(:social_buttons_javascript, @page).collect { |content| instance_exec(&content) }.join("") %> <% if NOOSFERO_CONF['addthis_enabled'] %> <%= render :partial => 'addthis' %> <% end %> diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index e966ae3..720733e 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -394,6 +394,12 @@ class Noosfero::Plugin nil end + # -> Adds social networks share buttons to content + # returns = lambda block that creates html code + def social_buttons_javascript(environment) + nil + end + # -> Adds fields to the signup form # returns = proc that creates html code def signup_extra_contents diff --git a/plugins/social_share_privacy/controllers/social_share_privacy_plugin_admin_controller.rb b/plugins/social_share_privacy/controllers/social_share_privacy_plugin_admin_controller.rb new file mode 100644 index 0000000..0968588 --- /dev/null +++ b/plugins/social_share_privacy/controllers/social_share_privacy_plugin_admin_controller.rb @@ -0,0 +1,18 @@ +class SocialSharePrivacyPluginAdminController < AdminController + append_view_path File.join(File.dirname(__FILE__) + '/../views') + + def index + available_networks = Dir[SocialSharePrivacyPlugin.root_path + 'public/javascripts/modules/*.js'].map { |entry| entry.split('/').last.gsub(/\.js$/,'') } + @selected = environment.socialshare + @tags = available_networks - @selected + if request.post? + networks = params[:networks].map{ |network| network.strip } if params[:networks] + environment.socialshare = networks + if environment.save + session[:notice] = _('Saved the selected social buttons') + redirect_to :controller => 'plugins', :action => 'index' + end + end + end + +end diff --git a/plugins/social_share_privacy/lib/ext/environment.rb b/plugins/social_share_privacy/lib/ext/environment.rb new file mode 100644 index 0000000..bf277e4 --- /dev/null +++ b/plugins/social_share_privacy/lib/ext/environment.rb @@ -0,0 +1,8 @@ +require_dependency 'environment' + +class Environment + + settings_items :socialshare, :type => Array, :default => [] + +end + diff --git a/plugins/social_share_privacy/lib/social_share_privacy_plugin.rb b/plugins/social_share_privacy/lib/social_share_privacy_plugin.rb new file mode 100644 index 0000000..3cd560d --- /dev/null +++ b/plugins/social_share_privacy/lib/social_share_privacy_plugin.rb @@ -0,0 +1,24 @@ +class SocialSharePrivacyPlugin < Noosfero::Plugin + + def self.plugin_name + "Social Share Privacy" + end + + def self.plugin_description + _("A plugin that adds share buttons from other networks.") + end + + def stylesheet? + true + end + + def social_buttons_javascript(article) + proc do + javascript_include_tag('plugins/social_share_privacy/javascripts/socialshareprivacy.js') + + javascript_include_tag(environment.socialshare.map { |service| "plugins/social_share_privacy/javascripts/modules/#{service}.js" }) + + javascript_tag("jQuery.fn.socialSharePrivacy.settings.path_prefix = '../../plugins/social_share_privacy/'; jQuery.fn.socialSharePrivacy.settings.order = #{environment.socialshare}; jQuery(document).ready(function () { jQuery('.social-buttons').socialSharePrivacy({perma_option: false, info_link_target: '_blank'});});") + + content_tag(:div, '',:class => "social-buttons") + end + end + +end diff --git a/plugins/social_share_privacy/public/images/box_fbshare.png b/plugins/social_share_privacy/public/images/box_fbshare.png new file mode 100644 index 0000000..0d722c1 Binary files /dev/null and b/plugins/social_share_privacy/public/images/box_fbshare.png differ diff --git a/plugins/social_share_privacy/public/images/box_mail.png b/plugins/social_share_privacy/public/images/box_mail.png new file mode 100644 index 0000000..f2692c0 Binary files /dev/null and b/plugins/social_share_privacy/public/images/box_mail.png differ diff --git a/plugins/social_share_privacy/public/images/box_tumblr.png b/plugins/social_share_privacy/public/images/box_tumblr.png new file mode 100644 index 0000000..1689426 Binary files /dev/null and b/plugins/social_share_privacy/public/images/box_tumblr.png differ diff --git a/plugins/social_share_privacy/public/images/de/dummy_box_facebook.png b/plugins/social_share_privacy/public/images/de/dummy_box_facebook.png new file mode 100644 index 0000000..23000bd Binary files /dev/null and b/plugins/social_share_privacy/public/images/de/dummy_box_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/de/dummy_facebook.png b/plugins/social_share_privacy/public/images/de/dummy_facebook.png new file mode 100644 index 0000000..7a220b8 Binary files /dev/null and b/plugins/social_share_privacy/public/images/de/dummy_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_buffer.png b/plugins/social_share_privacy/public/images/dummy_box_buffer.png new file mode 100644 index 0000000..3b5a630 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_buffer.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_delicious.png b/plugins/social_share_privacy/public/images/dummy_box_delicious.png new file mode 100644 index 0000000..28333a3 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_delicious.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_disqus.png b/plugins/social_share_privacy/public/images/dummy_box_disqus.png new file mode 100644 index 0000000..16f0819 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_disqus.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_facebook.png b/plugins/social_share_privacy/public/images/dummy_box_facebook.png new file mode 100644 index 0000000..5bed654 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_flattr.png b/plugins/social_share_privacy/public/images/dummy_box_flattr.png new file mode 100644 index 0000000..bc22c8f Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_flattr.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_gplus.png b/plugins/social_share_privacy/public/images/dummy_box_gplus.png new file mode 100644 index 0000000..56907e1 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_gplus.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_hackernews.png b/plugins/social_share_privacy/public/images/dummy_box_hackernews.png new file mode 100644 index 0000000..d9b68c3 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_hackernews.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_linkedin.png b/plugins/social_share_privacy/public/images/dummy_box_linkedin.png new file mode 100644 index 0000000..07049e3 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_linkedin.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_pinterest.png b/plugins/social_share_privacy/public/images/dummy_box_pinterest.png new file mode 100644 index 0000000..7523008 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_pinterest.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_reddit.png b/plugins/social_share_privacy/public/images/dummy_box_reddit.png new file mode 100644 index 0000000..80449e9 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_reddit.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_stumbleupon.png b/plugins/social_share_privacy/public/images/dummy_box_stumbleupon.png new file mode 100644 index 0000000..f585e5e Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_stumbleupon.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_twitter.png b/plugins/social_share_privacy/public/images/dummy_box_twitter.png new file mode 100644 index 0000000..84f7c6d Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_twitter.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_box_xing.png b/plugins/social_share_privacy/public/images/dummy_box_xing.png new file mode 100644 index 0000000..5540388 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_box_xing.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_buffer.png b/plugins/social_share_privacy/public/images/dummy_buffer.png new file mode 100644 index 0000000..c0f46eb Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_buffer.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_delicious.png b/plugins/social_share_privacy/public/images/dummy_delicious.png new file mode 100644 index 0000000..c81ef75 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_delicious.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_disqus.png b/plugins/social_share_privacy/public/images/dummy_disqus.png new file mode 100644 index 0000000..d821173 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_disqus.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_facebook.png b/plugins/social_share_privacy/public/images/dummy_facebook.png new file mode 100644 index 0000000..0efb45c Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_flattr.png b/plugins/social_share_privacy/public/images/dummy_flattr.png new file mode 100644 index 0000000..2f1ffa5 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_flattr.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_gplus.png b/plugins/social_share_privacy/public/images/dummy_gplus.png new file mode 100644 index 0000000..5ced5dc Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_gplus.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_gplus_alt.png b/plugins/social_share_privacy/public/images/dummy_gplus_alt.png new file mode 100644 index 0000000..64b9a9e Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_gplus_alt.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_hackernews.png b/plugins/social_share_privacy/public/images/dummy_hackernews.png new file mode 100644 index 0000000..a946131 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_hackernews.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_linkedin.png b/plugins/social_share_privacy/public/images/dummy_linkedin.png new file mode 100644 index 0000000..5d6f965 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_linkedin.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_pinterest.png b/plugins/social_share_privacy/public/images/dummy_pinterest.png new file mode 100644 index 0000000..7ff138d Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_pinterest.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_reddit.png b/plugins/social_share_privacy/public/images/dummy_reddit.png new file mode 100644 index 0000000..6433355 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_reddit.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_stumbleupon.png b/plugins/social_share_privacy/public/images/dummy_stumbleupon.png new file mode 100644 index 0000000..aba0d14 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_stumbleupon.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_twitter.png b/plugins/social_share_privacy/public/images/dummy_twitter.png new file mode 100644 index 0000000..2865660 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_twitter.png differ diff --git a/plugins/social_share_privacy/public/images/dummy_xing.png b/plugins/social_share_privacy/public/images/dummy_xing.png new file mode 100644 index 0000000..5b969f1 Binary files /dev/null and b/plugins/social_share_privacy/public/images/dummy_xing.png differ diff --git a/plugins/social_share_privacy/public/images/es/dummy_box_facebook.png b/plugins/social_share_privacy/public/images/es/dummy_box_facebook.png new file mode 100644 index 0000000..78c4093 Binary files /dev/null and b/plugins/social_share_privacy/public/images/es/dummy_box_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/es/dummy_facebook.png b/plugins/social_share_privacy/public/images/es/dummy_facebook.png new file mode 100644 index 0000000..ce6c90e Binary files /dev/null and b/plugins/social_share_privacy/public/images/es/dummy_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/fbshare.png b/plugins/social_share_privacy/public/images/fbshare.png new file mode 100644 index 0000000..5e2a84c Binary files /dev/null and b/plugins/social_share_privacy/public/images/fbshare.png differ diff --git a/plugins/social_share_privacy/public/images/fr/dummy_box_facebook.png b/plugins/social_share_privacy/public/images/fr/dummy_box_facebook.png new file mode 100644 index 0000000..0ad503e Binary files /dev/null and b/plugins/social_share_privacy/public/images/fr/dummy_box_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/fr/dummy_facebook.png b/plugins/social_share_privacy/public/images/fr/dummy_facebook.png new file mode 100644 index 0000000..772ab1b Binary files /dev/null and b/plugins/social_share_privacy/public/images/fr/dummy_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/fr/dummy_twitter.png b/plugins/social_share_privacy/public/images/fr/dummy_twitter.png new file mode 100644 index 0000000..bae309d Binary files /dev/null and b/plugins/social_share_privacy/public/images/fr/dummy_twitter.png differ diff --git a/plugins/social_share_privacy/public/images/mail.png b/plugins/social_share_privacy/public/images/mail.png new file mode 100644 index 0000000..690cc66 Binary files /dev/null and b/plugins/social_share_privacy/public/images/mail.png differ diff --git a/plugins/social_share_privacy/public/images/nl/dummy_box_facebook.png b/plugins/social_share_privacy/public/images/nl/dummy_box_facebook.png new file mode 100644 index 0000000..77edbee Binary files /dev/null and b/plugins/social_share_privacy/public/images/nl/dummy_box_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/nl/dummy_facebook.png b/plugins/social_share_privacy/public/images/nl/dummy_facebook.png new file mode 100644 index 0000000..b8e15e5 Binary files /dev/null and b/plugins/social_share_privacy/public/images/nl/dummy_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/nl/dummy_twitter.png b/plugins/social_share_privacy/public/images/nl/dummy_twitter.png new file mode 100644 index 0000000..392a5c6 Binary files /dev/null and b/plugins/social_share_privacy/public/images/nl/dummy_twitter.png differ diff --git a/plugins/social_share_privacy/public/images/pt/dummy_box_facebook.png b/plugins/social_share_privacy/public/images/pt/dummy_box_facebook.png new file mode 100644 index 0000000..9f6a226 Binary files /dev/null and b/plugins/social_share_privacy/public/images/pt/dummy_box_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/pt/dummy_box_twitter.png b/plugins/social_share_privacy/public/images/pt/dummy_box_twitter.png new file mode 100644 index 0000000..ad809fd Binary files /dev/null and b/plugins/social_share_privacy/public/images/pt/dummy_box_twitter.png differ diff --git a/plugins/social_share_privacy/public/images/pt/dummy_facebook.png b/plugins/social_share_privacy/public/images/pt/dummy_facebook.png new file mode 100644 index 0000000..6f69ed7 Binary files /dev/null and b/plugins/social_share_privacy/public/images/pt/dummy_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/pt/dummy_twitter.png b/plugins/social_share_privacy/public/images/pt/dummy_twitter.png new file mode 100644 index 0000000..09cae2f Binary files /dev/null and b/plugins/social_share_privacy/public/images/pt/dummy_twitter.png differ diff --git a/plugins/social_share_privacy/public/images/ru/dummy_box_facebook.png b/plugins/social_share_privacy/public/images/ru/dummy_box_facebook.png new file mode 100644 index 0000000..6b43084 Binary files /dev/null and b/plugins/social_share_privacy/public/images/ru/dummy_box_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/ru/dummy_facebook.png b/plugins/social_share_privacy/public/images/ru/dummy_facebook.png new file mode 100644 index 0000000..5a46d95 Binary files /dev/null and b/plugins/social_share_privacy/public/images/ru/dummy_facebook.png differ diff --git a/plugins/social_share_privacy/public/images/settings.png b/plugins/social_share_privacy/public/images/settings.png new file mode 100644 index 0000000..3016b7b Binary files /dev/null and b/plugins/social_share_privacy/public/images/settings.png differ diff --git a/plugins/social_share_privacy/public/images/socialshareprivacy_info.png b/plugins/social_share_privacy/public/images/socialshareprivacy_info.png new file mode 100644 index 0000000..733238d Binary files /dev/null and b/plugins/social_share_privacy/public/images/socialshareprivacy_info.png differ diff --git a/plugins/social_share_privacy/public/images/socialshareprivacy_on_off.png b/plugins/social_share_privacy/public/images/socialshareprivacy_on_off.png new file mode 100644 index 0000000..8e9e725 Binary files /dev/null and b/plugins/social_share_privacy/public/images/socialshareprivacy_on_off.png differ diff --git a/plugins/social_share_privacy/public/images/tumblr.png b/plugins/social_share_privacy/public/images/tumblr.png new file mode 100644 index 0000000..c8c759c Binary files /dev/null and b/plugins/social_share_privacy/public/images/tumblr.png differ diff --git a/plugins/social_share_privacy/public/javascripts/autoload.js b/plugins/social_share_privacy/public/javascripts/autoload.js new file mode 100644 index 0000000..1c43bec --- /dev/null +++ b/plugins/social_share_privacy/public/javascripts/autoload.js @@ -0,0 +1,4 @@ +jQuery(document).ready(function ($) { + $('*[data-social-share-privacy=true]:not([data-init=true])'). + socialSharePrivacy().attr('data-init','true'); +}); diff --git a/plugins/social_share_privacy/public/javascripts/localstorage.js b/plugins/social_share_privacy/public/javascripts/localstorage.js new file mode 100644 index 0000000..239fb1c --- /dev/null +++ b/plugins/social_share_privacy/public/javascripts/localstorage.js @@ -0,0 +1,31 @@ +/* + * jquery.socialshareprivacy.js | 2 Klicks fuer mehr Datenschutz + * + * Copyright (c) 2012 Mathias Panzenböck + * + * is released under the MIT License http://www.opensource.org/licenses/mit-license.php + * + * Spread the word, link to us if you can. + */ +(function ($, undefined) { + "use strict"; + + $.extend($.fn.socialSharePrivacy.settings, { + // Set perma_option to true. + // Initially it is only set to true if jQuery.cookie is available. + perma_option: true, + set_perma_option: function (service_name) { + localStorage.setItem('socialSharePrivacy_'+service_name, 'perma_on'); + }, + del_perma_option: function (service_name) { + localStorage.removeItem('socialSharePrivacy_'+service_name); + }, + // Only one of the two methods "get_perma_options" and "get_perma_option" has + // to be implemented. Though the other has to be set to null, so the default + // cookie based method is not used. + get_perma_options: null, + get_perma_option: function (service_name) { + return localStorage.getItem('socialSharePrivacy_'+service_name) === 'perma_on'; + } + }); +})(jQuery); diff --git a/plugins/social_share_privacy/public/javascripts/modules/buffer.js b/plugins/social_share_privacy/public/javascripts/modules/buffer.js new file mode 100644 index 0000000..93989e2 --- /dev/null +++ b/plugins/social_share_privacy/public/javascripts/modules/buffer.js @@ -0,0 +1,54 @@ +/* + * jquery.socialshareprivacy.js | 2 Klicks fuer mehr Datenschutz + * + * http://www.heise.de/extras/socialshareprivacy/ + * http://www.heise.de/ct/artikel/2-Klicks-fuer-mehr-Datenschutz-1333879.html + * + * Copyright (c) 2011 Hilko Holweg, Sebastian Hilbig, Nicolas Heiringhoff, Juergen Schmidt, + * Heise Zeitschriften Verlag GmbH & Co. KG, http://www.heise.de + * + * Copyright (c) 2012 Mathias Panzenböck + * + * is released under the MIT License http://www.opensource.org/licenses/mit-license.php + * + * Spread the word, link to us if you can. + */ +(function ($, undefined) { + "use strict"; + + function get (self, options, uri, settings, name) { + var value = options[name]; + if (typeof value === "function") { + return value.call(self, options, uri, settings); + } + return String(value); + } + + $.fn.socialSharePrivacy.settings.services.buffer = { + 'status' : true, + 'dummy_line_img' : 'images/dummy_buffer.png', + 'dummy_box_img' : 'images/dummy_box_buffer.png', + 'dummy_alt' : '"Buffer"-Dummy', + 'txt_info' : 'Two clicks for more privacy: The Buffer button will be enabled once you click here. Activating the button already sends data to Buffer – see i.', + 'txt_off' : 'not connected to Buffer', + 'txt_on' : 'connected to Buffer', + 'perma_option' : true, + 'display_name' : 'Buffer', + 'referrer_track' : '', + 'via' : '', + 'text' : $.fn.socialSharePrivacy.getTitle, + 'picture' : $.fn.socialSharePrivacy.getImage, + 'button' : function (options, uri, settings) { + return $('').attr( + 'src', 'https://widgets.bufferapp.com/button/?'+$.param({ + count : settings.layout === 'line' ? 'horizontal' : 'vertical', + via : get(this, options, uri, settings, 'via'), + text : $.fn.socialSharePrivacy.abbreviateText( + get(this, options, uri, settings, 'text'), 120), + picture : get(this, options, uri, settings, 'picture'), + url : uri + options.referrer_track, + source : 'button' + })); + } + }; +})(jQuery); diff --git a/plugins/social_share_privacy/public/javascripts/modules/delicious.js b/plugins/social_share_privacy/public/javascripts/modules/delicious.js new file mode 100644 index 0000000..d8502d4 --- /dev/null +++ b/plugins/social_share_privacy/public/javascripts/modules/delicious.js @@ -0,0 +1,85 @@ +/* + * jquery.socialshareprivacy.js + * + * Copyright (c) 2012 Mathias Panzenböck + * + * is released under the MIT License http://www.opensource.org/licenses/mit-license.php + * + * Code inspired by Delicious Button v1.1: + * http://code.google.com/p/delicious-button/ + * + * Warning: this button uses plaintext http and can be harmful to users under opressive regimes + * + */ +(function ($, undefined) { + "use strict"; + + $.fn.socialSharePrivacy.settings.services.delicious = { + 'status' : true, + 'dummy_line_img' : 'images/dummy_delicious.png', + 'dummy_box_img' : 'images/dummy_box_delicious.png', + 'dummy_alt' : '"Delicious"-Dummy', + 'txt_info' : 'Two clicks for more privacy: The Delicious button will be enabled once you click here. Activating the button already sends data to Delicious – see i.', + 'txt_off' : 'not connected to Delicious', + 'txt_on' : 'connected to Delicious', + 'perma_option' : true, + 'display_name' : 'Delicious', + 'txt_button' : 'Save', + 'referrer_track' : '', + 'title' : $.fn.socialSharePrivacy.getTitle, + 'button' : function (options, uri, settings) { + var $button = $('
'); + var url = uri + options.referrer_track; + + $.ajax({ + url: "http://feeds.delicious.com/v2/json/urlinfo/data", + data: {url: url}, + dataType: "jsonp", + success: function (counts) { + var hash, total_posts, title, txt_button; + for (var i = 0; i < counts.length; ++ i) { + var count = counts[i]; + if (count.url === url) { + total_posts = parseInt(count.total_posts, 10); + hash = count.hash; + title = count.title; + break; + } + } + if (total_posts) txt_button = $.fn.socialSharePrivacy.formatNumber(total_posts); + else txt_button = options.txt_button; + var save_url = "http://delicious.com/save?"+$.param({ + v: "5", + url: url, + title: (typeof options.title === "function" ? + options.title.call(this, options, uri, settings) : + String(options.title)) || title + }); + + $button.html(''); + $button.find('i').text(options.txt_button); + $button.find('b').text(txt_button); + $button.find('a.icon').attr("href", hash ? "http://delicious.com/url/" + hash : save_url); + var $count = $button.find('a.count').attr("href", save_url).click(function (event) { + window.open(save_url + "&noui&jump=close", "delicious", "toolbar=no,width=555,height=555"); + event.preventDefault(); + }); + + if (total_posts) { + $count.hover(function () { + var $self = $(this); + $self.find("b").stop(1, 1).css("display", "none"); + $self.find("i").fadeIn(); + }, function () { + var $self = $(this); + $self.find("i").stop(1, 1).css("display", "none"); + $self.find("b").fadeIn(); + }); + } + } + }); + + return $button; + } + }; +})(jQuery); diff --git a/plugins/social_share_privacy/public/javascripts/modules/disqus.js b/plugins/social_share_privacy/public/javascripts/modules/disqus.js new file mode 100644 index 0000000..f8e60b5 --- /dev/null +++ b/plugins/social_share_privacy/public/javascripts/modules/disqus.js @@ -0,0 +1,77 @@ +/* + * jquery.socialshareprivacy.js + * + * Copyright (c) 2012 Mathias Panzenböck + * + * is released under the MIT License http://www.opensource.org/licenses/mit-license.php + * + */ +(function ($, undefined) { + "use strict"; + + var DISQUSWIDGETS = { + displayCount: function (data) { + $('.social_share_privacy_area .disqus .disqus-widget:not(.init)').each(function () { + var $widget = $(this); + var uri = data.counts[0].id; + if ($widget.attr("data-uri") === uri) { + var key = $widget.attr("data-count"); + var count = data.counts[0][key]; + var text = data.text[key]; + var scount = $.fn.socialSharePrivacy.formatNumber(count); + $widget.attr('title', count === 0 ? text.zero : count === 1 ? text.one : text.multiple.replace('{num}', scount)); + $widget.find('.count a').text(scount); + $widget.addClass('init'); + } + }); + } + }; + + $.fn.socialSharePrivacy.settings.services.disqus = { + 'status' : true, + 'dummy_line_img' : 'images/dummy_disqus.png', + 'dummy_box_img' : 'images/dummy_box_disqus.png', + 'dummy_alt' : '"Disqus"-Dummy', + 'txt_info' : 'Two clicks for more privacy: The Disqus button will be enabled once you click here. Activating the button already sends data to Disqus – see i.', + 'txt_off' : 'not connected to Disqus', + 'txt_on' : 'connected to Disqus', + 'perma_option' : true, + 'display_name' : 'Disqus', + 'referrer_track' : '', + 'shortname' : '', + 'count' : 'comments', + 'onclick' : null, + 'button' : function (options, uri, settings) { + var shortname = options.shortname || window.disqus_shortname || ''; + var $code; + if (settings.layout === 'line') { + $code = $(' '); + } + else { + $code = $(' '); + } + + $code.attr({ + 'data-count' : options.count, + 'data-shortname' : shortname, + 'data-uri' : uri + options.referrer_track + }); + + if (options.onclick) { + $code.find('a').click(typeof options.onclick === "function" ? + options.onclick : new Function("event", options.onclick)); + } + + // this breaks every other usage of the disqus count API: + window.DISQUSWIDGETS = DISQUSWIDGETS; + + $.getScript('https://'+shortname+'.disqus.com/count-data.js?2='+encodeURIComponent(uri + options.referrer_track)); + + return $code; + } + }; +})(jQuery); diff --git a/plugins/social_share_privacy/public/javascripts/modules/facebook.js b/plugins/social_share_privacy/public/javascripts/modules/facebook.js new file mode 100644 index 0000000..d2d05c3 --- /dev/null +++ b/plugins/social_share_privacy/public/javascripts/modules/facebook.js @@ -0,0 +1,81 @@ +/* + * jquery.socialshareprivacy.js | 2 Klicks fuer mehr Datenschutz + * + * http://www.heise.de/extras/socialshareprivacy/ + * http://www.heise.de/ct/artikel/2-Klicks-fuer-mehr-Datenschutz-1333879.html + * + * Copyright (c) 2011 Hilko Holweg, Sebastian Hilbig, Nicolas Heiringhoff, Juergen Schmidt, + * Heise Zeitschriften Verlag GmbH & Co. KG, http://www.heise.de + * + * Copyright (c) 2012 Mathias Panzenböck + * + * is released under the MIT License http://www.opensource.org/licenses/mit-license.php + * + * Spread the word, link to us if you can. + */ +(function ($, undefined) { + "use strict"; + + var locales = {"af":["ZA"],"ar":["AR"],"az":["AZ"],"be":["BY"],"bg":["BG"],"bn":["IN"],"bs":["BA"],"ca":["ES"],"cs":["CZ"],"cy":["GB"],"da":["DK"],"de":["DE"],"el":["GR"],"en":["GB","PI","UD","US"],"eo":["EO"],"es":["ES","LA"],"et":["EE"],"eu":["ES"],"fa":["IR"],"fb":["LT"],"fi":["FI"],"fo":["FO"],"fr":["CA","FR"],"fy":["NL"],"ga":["IE"],"gl":["ES"],"he":["IL"],"hi":["IN"],"hr":["HR"],"hu":["HU"],"hy":["AM"],"id":["ID"],"is":["IS"],"it":["IT"],"ja":["JP"],"ka":["GE"],"km":["KH"],"ko":["KR"],"ku":["TR"],"la":["VA"],"lt":["LT"],"lv":["LV"],"mk":["MK"],"ml":["IN"],"ms":["MY"],"nb":["NO"],"ne":["NP"],"nl":["NL"],"nn":["NO"],"pa":["IN"],"pl":["PL"],"ps":["AF"],"pt":["BR","PT"],"ro":["RO"],"ru":["RU"],"sk":["SK"],"sl":["SI"],"sq":["AL"],"sr":["RS"],"sv":["SE"],"sw":["KE"],"ta":["IN"],"te":["IN"],"th":["TH"],"tl":["PH"],"tr":["TR"],"uk":["UA"],"vi":["VN"],"zh":["CN","HK","TW"]}; + + $.fn.socialSharePrivacy.settings.services.facebook = { + 'status' : true, + 'button_class' : 'fb_like', + 'dummy_line_img' : 'images/dummy_facebook.png', + 'dummy_box_img' : 'images/dummy_box_facebook.png', + 'dummy_alt' : 'Facebook "Like"-Dummy', + 'txt_info' : 'Two clicks for more privacy: The Facebook Like button will be enabled once you click here. Activating the button already sends data to Facebook – see i.', + 'txt_off' : 'not connected to Facebook', + 'txt_on' : 'connected to Facebook', + 'perma_option' : true, + 'display_name' : 'Facebook Like/Recommend', + 'referrer_track' : '', + 'action' : 'like', + 'colorscheme' : 'light', + 'font' : '', + 'button' : function (options, uri, settings) { + // ensure a locale that is supported by facebook + // otherwise facebook renders nothing + var match = /^([a-z]{2})_([A-Z]{2})$/.exec(options.language); + var locale = "en_US"; + + if (match) { + if (match[1] in locales) { + var subs = locales[match[1]]; + if ($.inArray(match[2], subs) !== -1) { + locale = options.language; + } + else { + locale = match[1]+"_"+subs[0]; + } + } + } + else if (options.language in locales) { + locale = options.language+"_"+locales[options.language][0]; + } + + var params = { + locale : locale, + href : uri + options.referrer_track, + send : 'false', + show_faces : 'false', + action : options.action, + colorscheme: options.colorscheme + }; + if (options.font) params.font = options.font; + + if (settings.layout === 'line') { + params.width = '120'; + params.height = '20'; + params.layout = 'button_count'; + } + else { + params.width = 62; + params.height = 61; + params.layout = 'box_count'; + } + return $('').attr( + 'src', 'https://www.facebook.com/plugins/like.php?'+$.param(params)); + } + }; +})(jQuery); diff --git a/plugins/social_share_privacy/public/javascripts/modules/fbshare.js b/plugins/social_share_privacy/public/javascripts/modules/fbshare.js new file mode 100644 index 0000000..09ddc8f --- /dev/null +++ b/plugins/social_share_privacy/public/javascripts/modules/fbshare.js @@ -0,0 +1,38 @@ +/* + * Facebook share module for jquery.socialshareprivacy.js | 2 Klicks fuer mehr Datenschutz + * + * http://www.heise.de/extras/socialshareprivacy/ + * http://www.heise.de/ct/artikel/2-Klicks-fuer-mehr-Datenschutz-1333879.html + * + * Copyright (c) 2011 Hilko Holweg, Sebastian Hilbig, Nicolas Heiringhoff, Juergen Schmidt, + * Heise Zeitschriften Verlag GmbH & Co. KG, http://www.heise.de + * + * Copyright (c) 2012 Mathias Panzenböck + * + * Fbshare module: + * copyright (c) 2013 zzzen.com + * + * is released under the MIT License http://www.opensource.org/licenses/mit-license.php + * + * Spread the word, link to us if you can. + */ +(function ($, undefined) { + "use strict"; + + $.fn.socialSharePrivacy.settings.services.fbshare = { + 'status' : true, + 'privacy' : 'safe', + 'button_class' : 'fbshare', + 'line_img' : 'images/fbshare.png', + 'box_img' : 'images/box_fbshare.png', + 'txt_info' : 'Share via facebook.', + 'txt_button' : 'Facebook Share', + 'display_name' : 'Facebook Share', + 'referrer_track' : '', + 'button' : function (options, uri, settings) { + return $('', {target: '_blank', href: 'https://www.facebook.com/sharer/sharer.php?'+$.param({u:uri + options.referrer_track})}).append( + $('