Instantly share code, notes, and snippets.
Last active
October 12, 2015 08:08
-
Save panzi/3997239 to your computer and use it in GitHub Desktop.
Social Share Privacy for Blogger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" type="text/css" href="http://panzi.github.io/SocialSharePrivacy/stylesheets/jquery.socialshareprivacy.min.css" /> | |
<style type="text/css"> | |
#share { | |
position: absolute; | |
top: 110px; | |
left: -120px; | |
opacity: 0.3; | |
-webkit-transition: opacity 0.5s linear; | |
-moz-transition: opacity 0.5s linear; | |
-ms-transition: opacity 0.5s linear; | |
-o-transition: opacity 0.5s linear; | |
transition: opacity 0.5s linear; | |
} | |
#share:hover { | |
opacity: 1; | |
} | |
</style> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<script type="text/javascript" src="http://panzi.github.io/SocialSharePrivacy/javascripts/jquery.cookies.js"></script> | |
<script type="text/javascript" src="http://panzi.github.io/SocialSharePrivacy/javascripts/jquery.socialshareprivacy.min.js"></script> | |
<script type="text/javascript"> | |
// <![CDATA[ | |
// deactivate services you do not want: | |
$.fn.socialSharePrivacy.settings.services.flattr.status = false; | |
$.fn.socialSharePrivacy.settings.services.disqus.status = false; | |
$(document).ready(function () { | |
var absurl = $.fn.socialSharePrivacy.absurl; | |
var data = _WidgetManager._GetAllData(); | |
var options = { | |
layout: 'box', | |
path_prefix: 'http://panzi.github.com/SocialSharePrivacy/', | |
title: data.blog.pageName || data.blog.pageTitle || data.blog.title, | |
uri: data.blog.canonicalUrl, | |
language: data.blog.locale | |
}; | |
var $post = $('*[itemscope][itemtype="http://schema.org/BlogPosting"]'); | |
if ($post.length === 1 && data.blog.canonicalUrl !== data.blog.canonicalHomepageUrl) { | |
var $text = $post.find("*[itemprop~=articleBody]").contents(); | |
options.description = $.trim($.map($text, function (e) { | |
var nodeName = (e.nodeName||'').toLowerCase(); | |
switch (nodeName) { | |
case 'script': | |
case 'style': return ''; | |
case 'br': return '\n'; | |
case 'p': return $.text(e) + '\n'; | |
default: | |
if (e.className === 'gist') { | |
return $.map($.find('.line-data .line',e), function (e) { | |
return $.text(e)+'\n'; | |
}).join(""); | |
} | |
return $.text(e); | |
} | |
}).join('')).replace(/\n(\s*\n)+/g,'\n\n'); | |
if (options.description.length > 600) { | |
var abbrev = options.description.slice(0,597); | |
if (/^\w+$/.test(options.description.slice(596,598))) { | |
var match = /^(.*)\s\S*$/.exec(abbrev); | |
if (match) { | |
abbrev = match[1]; | |
} | |
} | |
options.description = $.trim(abbrev) + "\u2026"; | |
} | |
options.image = $post.find("a[imageanchor=1]").attr("href") || | |
$post.find("img:not(.icon-action)").sort(function (a,b) { | |
var $a = $(a), $b = $(b), A = $a.outerWidth() * $a.outerHeight(), B = $b.outerWidth() * $b.outerHeight(); | |
return B - A; | |
}).attr("src"); | |
} | |
else { | |
options.description = $.trim($("header .description").text()) || options.title; | |
options.image = $('header img, img.profile-img').attr('src'); | |
} | |
if (options.image) { | |
options.image = absurl(options.image); | |
options.services = {tumblr: {type: 'photo'}}; | |
} | |
var $share = $('<div id="share"></div>').css({ | |
position: 'absolute', | |
top: '110px', | |
left: '-120px' | |
}); | |
$('.main-inner').append($('<div id="share"></div>').socialSharePrivacy(options)); | |
}); | |
// ]]> | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" type="text/css" href="http://panzi.github.io/SocialSharePrivacy/stylesheets/jquery.socialshareprivacy.min.css" /> | |
<style type="text/css"> | |
#share { | |
position: absolute; | |
top: 110px; | |
left: -120px; | |
opacity: 0.3; | |
-webkit-transition: opacity 0.5s linear; | |
-moz-transition: opacity 0.5s linear; | |
-ms-transition: opacity 0.5s linear; | |
-o-transition: opacity 0.5s linear; | |
transition: opacity 0.5s linear; | |
} | |
#share:hover { | |
opacity: 1; | |
} | |
</style> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<script type="text/javascript" src="http://panzi.github.io/SocialSharePrivacy/javascripts/jquery.cookies.js"></script> | |
<script type="text/javascript" src="http://panzi.github.io/SocialSharePrivacy/javascripts/jquery.socialshareprivacy.min.js"></script> | |
<script type="text/javascript"> | |
// <![CDATA[ | |
// deactivate services you do not want: | |
$.fn.socialSharePrivacy.settings.services.disqus.status = false; | |
$(document).ready(function () { | |
var absurl = $.fn.socialSharePrivacy.absurl; | |
var data = _WidgetManager._GetAllData(); | |
var options = { | |
layout: 'box', | |
path_prefix: 'http://panzi.github.com/SocialSharePrivacy/', | |
title: data.blog.pageName || data.blog.pageTitle || data.blog.title, | |
uri: data.blog.canonicalUrl, | |
language: data.blog.locale, | |
services: { | |
flattr: { | |
// replace this with your flattr id: | |
uid: '__FLATTR_UID__' | |
} | |
} | |
}; | |
var $post = $('*[itemscope][itemtype="http://schema.org/BlogPosting"]'); | |
if ($post.length === 1 && data.blog.canonicalUrl !== data.blog.canonicalHomepageUrl) { | |
var $tags = $post.find('a[rel=tag]'); | |
var tags = []; | |
for (var i = 0; i < $tags.length; ++ i) { | |
var tag = $.text($tags[i]).replace(/[^a-z]/ig,''); | |
if (tag) { | |
tags.push(tag); | |
} | |
} | |
if (tags.length > 0) options.services.flattr.tags = tags.join(','); | |
var $text = $post.find("*[itemprop~=articleBody]").contents(); | |
options.description = $.trim($.map($text, function (e) { | |
var nodeName = (e.nodeName||'').toLowerCase(); | |
switch (nodeName) { | |
case 'script': | |
case 'style': return ''; | |
case 'br': return '\n'; | |
case 'p': return $.text(e) + '\n'; | |
default: | |
if (e.className === 'gist') { | |
return $.map($.find('.line-data .line',e), function (e) { | |
return $.text(e)+'\n'; | |
}).join(""); | |
} | |
return $.text(e); | |
} | |
}).join('')).replace(/\n(\s*\n)+/g,'\n\n'); | |
if (options.description.length > 600) { | |
var abbrev = options.description.slice(0,597); | |
if (/^\w+$/.test(options.description.slice(596,598))) { | |
var match = /^(.*)\s\S*$/.exec(abbrev); | |
if (match) { | |
abbrev = match[1]; | |
} | |
} | |
options.description = $.trim(abbrev) + "\u2026"; | |
} | |
options.image = $post.find("a[imageanchor=1]").attr("href") || | |
$post.find("img:not(.icon-action)").sort(function (a,b) { | |
var $a = $(a), $b = $(b), A = $a.outerWidth() * $a.outerHeight(), B = $b.outerWidth() * $b.outerHeight(); | |
return B - A; | |
}).attr("src"); | |
} | |
else { | |
options.description = $.trim($("header .description").text()) || options.title; | |
options.image = $('header img, img.profile-img').attr('src'); | |
} | |
if (options.image) { | |
options.image = absurl(options.image); | |
options.services.tumblr = {type: 'photo'}; | |
} | |
$('.main-inner').append($('<div id="share"></div>').socialSharePrivacy(options)); | |
}); | |
// ]]> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment