#110 posted on Thu Sep 15 00:00:00 2011
Diaspora sharing service updated with support for short urls and notes
My Diaspora sharing service, running on iliketoast.net, has been updated to support URL shorteners and notes + some other small changes.
-
URL's are shortened with goo.gl IF they are over 26 in length.
- This can be overriden by adding the parameter 'shorten' with value 'no' to the url sent to the sharing service.
- The shortening is done with jQuery Ajax via http://ggl-shortener.appspot.com/. If it fails for some reason, the sharing continues with the original url.
- Notes (supported by Diaspora bookmarklet) are now supported with the url parameter 'notes'.
- If URL is empty (when received to sharer service), pop up will be given and no redirect will happen to the Diaspora pod.
So all in all a sharing URL has the following parameters:
- url - the URL that is shared
- title - post title
- notes - some text from the post or other notes
- shorten - if this is 'no', no shortening will be done [OPTIONAL]
How to get the notes parameter filled?
Here is the updated code for implementing a sharing button on a page where HTML and JS can be embedded. It will include all text that is currently selected with the mouse in the notes parameter.
<img src="http://iliketoast.net/img/diasporaWebBadge80x15_3.png" border="0" onClick="dshare();">
<script type="text/javascript">
function dshare() {
var url = window.location.href;
var title = document.title;
var txt = '';
if (window.getSelection) {
txt = window.getSelection();
} else if (window.document.getSelection) {
txt = window.document.getSelection();
} else if (window.document.selection) {
txt = window.document.selection.createRange().text;
}
window.open('http://iliketoast.net/dshare.html?url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'¬es='+encodeURIComponent(txt),'dshare','location=no,links=no,scrollbars=no,toolbar=no,width=620,height=400');
return false;
}
</script>
Please let me know if you stumble on any bugs :) I'll be creating an info page about this service soon, will list some more variants of how to add a button to Blogger, WordPress, etc.













Comments (post a comment)