Archive for the ‘Blogroll’ Category

Share your documents in Facebook or Twitter

Diego Spano. Thursday, April 7th, 2011.

Greenstone has a new macro that lets you share documents in social networks or email systems, using Addtoany tool . The new macro is called _shareme_  that belongs to package Global in document.dm. The macro accepts two parameters: _1_ is the title of the link, and _2_ is the link to share. For _2_, the [srclink] is the default option, but any other metadata can be used too. The only requirement is that the value of that metadata must contain a well-formed URL that begins with “http://”.

If _2_ is left blank, then the link will point to the Greenstone version of the document.

You have to edit your format statement and add something like this:_shareme_([dc.Title],[srclink])

and then you will see “Share+, Facebook, Twitter, Mail , LinkedIn” icons.

_Share_ Icons

There is also a brief version called _sharemesmall_ that requires the same parameters and only shows Share+ icon.

_Sharemesmall_ Icons

The macro code is available with version 2.84. If you are using v.2.83 or earlier you have to edit document.dm file and add the following block:

**** Macro code – Begin ****

package Global

# Social network support
# Defined here in document, as the most likely place this will be used in
# within a document view, however its package is 'Global' because you
# might equally want this in a search or browse list

# _1_ = e.g. title
# _2_ = [srclink] or left empty.  If left empty, then it will share the internal GS document

_sharemescript_ {

<script type="text/javascript">
function fullDomainURL(localURL)
\{
return window.location.protocol+'//'+window.location.host+localURL;
\}
</script>

<script type="text/javascript">
var a2a_config = a2a_config || \{ \};
a2a_config.linkname = "_1_";

_If_(_2_,
var srclink = \'_2_\';

//If metadata value is a valid URL that starts with xxx://
// (e.g. any protocol\, http, https\, ftp ...) then that will be the link to share
if (srclink.match(/^[^:]+:\\\/\\\//i)) \{
a2a_config.linkurl = srclink;
\}
else \{
//if metadata value is [srclink] then we have to cut off the 'href' tag label
var href = srclink.match(/href=\"([^\"]*)\"/);
a2a_config.linkurl = fullDomainURL(href[1]);
\}
,
//if no metadata was passed as link\, then the GS version of the document will be used.
a2a_config.linkurl = fullDomainURL("_gwcgi_")+ "?c=_cgiargc_&a=d&d=_cgiargd_";
)
</script>
}

_shareme_ {

<div style=\'padding-left:50px;\' class=\'a2a_kit a2a_default_style\'>
_sharemescript_(_1_,_2_)
<center>
<a class=\'a2a_dd\' href=\'http://www.addtoany.com/share_save\'>Share</a>
<span class=\"a2a_divider\"></span>
<a class=\'a2a_button_facebook\'></a>
<a class=\'a2a_button_twitter\'></a>
<a class=\'a2a_button_email\'></a>
<a class=\'a2a_button_linkedin\'></a>
</center>
<script type=\"text/javascript\" src=\"http://static.addtoany.com/menu/page.js\"></script>
</div>
}

_sharemesmall_ {

<span style=\'padding-left:8px;\' class=\'a2a_kit a2a_default_style\'>
_sharemescript_(_1_,_2_)
<a class=\'a2a_dd\' href=\'http://www.addtoany.com/share_save\'>Share</a>
<script type=\"text/javascript\" src=\"http://static.addtoany.com/menu/page.js\"></script>
</span>
}

**** Macro code – End ****