Favourites/Berry Baskets (Greenstone 3)

A favourites/berry basket functionality has been implemented in Greenstone 3. This allows the user to collect up a set of interesting or useful documents as she is browsing through the library. Once they are finished, they can view the basket of links, and email it to themselves.

Favourites - a star is displayed for each document in browsing and searching lists. Clicking the star will add/remove that document from the favourites list.

Berry Baskets - little berries are displayed by each document. Drag a berry on to the basket to add that document.

The basket itself is displayed on the side of the page. Clicking the link in the basket will take you to a full view of the contents of the basket.

Activating Favourites/Berry Baskets

By default, Favourites is active, not Berry Baskets.

The library administrator can change to use Berry Baskets, or disable the functionality altogether by editing options in the web/interfaces/default/interfaceConfig.xml file.

<optionList>
  <option name="favouriteBasket" value="true"/>
  <option name="berryBasket" value="false"/>
</optionList>

Set both to false to disable this completely.

While the functionality is active, it is not turned on for the user by default. (It will be for 3.10 and later). The user can go to Preferences, and turn it on/off.

To make it turned on by default, set a paramDefault in web/sites/localsite/siteConfig.xml.

<format>
  <paramDefault name="favouritebasket" value="on"/>  (or 'berrybasket')
</format>

Customizing Berry Baskets

Metadata

If you want to add an extra metadata field to the display, then you need to specify that metadata in web/sites/localsite/siteConfig.xml. Look for the BerryBasket serviceRack and add a metadataList containing the desired elements. For example:

<serviceRack name="BerryBaskets">
  <metadataList>
    <metadata name="dc.Creator"/>
    <metadata name="dc.Subject"/>
  </metadataList>
</serviceRack>

Then restart Tomcat.

By default, these specified metadata elements will just get added to the item's display, e.g. at the bottom of the metadata lists in the 'text' and 'email' views. Or after the title in the 'full' view.

If you want to customise the display, take a look at the javascript code. web/interfaces/default/js/berrybasket/berrybasket.js, function showBasket() displays the small version on other pages, while web/interfaces/default/js/berrybasket/berrycheckout.js functions showFullView(), showTextView() and showEmail() display the different basket views. In particular, populateUrlsAndMetadata() displays the links plus metadata entries for Text and Email views, and generateDocDisplay() displays the entries for the text view.

Example: Using dc.Title instead of Title in Berry Basket display

By default, the berry basket entries display Title metadata. If the linked item is a section, it will also display the book Title (root_Title).

If we have a collection that doesn't have Title metadata (eg from a CSV spreadsheet), we can modify the code to display dc.Title instead.

1. Edit web/sites/localsite/siteConfig.xml and add dc.Title into the BerryBasket service metadataList:

<serviceRack name="BerryBaskets">
  <metadataList>
    <metadata name="dc.Title"/>
  </metadataList>
</serviceRack>

2. Edit web/interfaces/default/js/berrybasket/berrycheckout.js

Look for generateDocDisplay and edit it:

Replace:
a.href=generateURL(doc);
a.appendChild(document.createTextNode(doc['Title']));
with either:
1. Use this if all documents have dc.Title instead of Title

a.href=generateURL(doc);
a.appendChild(document.createTextNode(doc['dc.Title']));

or:
2. use this if some documents have Title and some have dc.Title

a.href=generateURL(doc);
if (doc['Title']) {
   a.appendChild(document.createTextNode(doc['Title'])); 
} else if (doc['dc.Title']) {
   a.appendChild(document.createTextNode(doc['dc.Title']));
}

This will now display dc.Title instead of Title for the title link to the document in the full view. However, as dc.Title is not defined as one of the standard metadatas, it also gets added to the end of the display. To prevent this, either add it to the default_metas list at the top of the file, or modify generateDocDisplay further.

Replace:
for (var metaItem in doc) {
  if ( !default_metas.includes(metaItem)){
     metadata += " "+metaItem+": "+ doc[metaItem]+" ";
  }
}

with:
for (var metaItem in doc) {
  if ( !default_metas.includes(metaItem) && metaItem != 'dc.Title'){
     metadata += " "+metaItem+": "+ doc[metaItem]+" ";
  }
}

In the text and email view, all metadata is displayed in a list: First the hard-wired ones, then any that are not in the default list. So the dc.Title metadata just gets added to the list. If you added dc.Title to default_metas list as mentioned above, then you need to manually add it to the display to get it to appear.

For example, in populateUrlsAndMetadata(), add in the following:

if (doc['dc.Title']) {
  metadata += "dc.Title: "+doc['dc.Title']+"\n";
}

By default the link in the basket will be to the Greenstone HTML version of the document. You can change this to link to the source document, eg the PDF version.

Edit web/interfaces/default/js/berrybasket/berrycheckout.js.

There are three variables at the top of this file:

var default_link_type = "document"; // or "source"
var source_link_collections = new Array();
var document_link_collections = new Array();

The default_link_type specifies whether links are to the Greenstone versions ("document") or to the source eg PDF versions ("source"); If you then want to have a few collections done the opposite way, use source_link_collections/document_link_collections to list the exceptions.

For example, if most collections use document, but pdfcoll and exampapers use source, then set the variables like this:

var default_link_type = "document";
var source_link_collections = ["pdfcoll", "exampapers"];

Similarly, use document_link_collections to set the exceptions if you have made the default "source".

Setting up the Email Results Functionality

This applies to nightly releases and the upcoming 3.09 release. Emailing the results didn't work properly in 3.08.

Please edit resources/web/global.properties.in (31 July 2018 and later binaries) or resources/web/global.properties (30 July 2018 or earlier binaries). Set your mail server, username and password etc by uncommenting the lines and setting the proper values.

#outgoing mail setup.
#  by default it will use port 25 on localhost. Uncomment and modify 
# these settings to use another mail server
# sample values are for gmail setup
# Note for gmail, you will need to enable account access for less secure apps
# for this to work. https://www.google.com/settings/security/lesssecureapps
#mail.smtp.host=smtp.gmail.com
#mail.smtp.username=xxx@gmail.com
#mail.smtp.password=xxxpassword
# port number,  eg for gmail: 465 (ssl) 587 (tls)
#mail.smtp.port=587
#mail.from=xxx@gmail.com
# set the following to ssl or tls
#mail.security=tls