use the data you already have

37
Use the Use the data you data you already already have have

Upload: eriksend2750

Post on 10-Apr-2015

135 views

Category:

Documents


1 download

DESCRIPTION

Slides for NWIUG08 presentation

TRANSCRIPT

Page 1: Use the data you already have

Use the data Use the data you already you already

havehave

Page 2: Use the data you already have

What you could do if Millennium gave you the power to do more than just display this data?

Page 3: Use the data you already have

Q: What can I harvest?Q: What can I use?

Page 4: Use the data you already have

title, author, standard numbers+ persistent URL and patron name

Page 5: Use the data you already have

What do I do with it?

• Pass it to another web site or service• Google, WorldCat, the LoC, Amazon, Powell’s,

del.icio.us, Refworks…

• Rewrite and improve your page• Better page title• Better print display• Better bookmarks

Page 6: Use the data you already have

How do I get it?• The easiest pieces of data to harvest are the persistent

link to the record, and the name of a logged in patron• Harvest them with customized wwwoptions• Use JavaScript to create variables you can access with

other scripts• You don’t have to be a JavaScript wizard to do this

Page 7: Use the data you already have

Harvest data with a wwwoption

• The wwwoption ICON_RECORDLINK typically looks like this:• ICON_RECORDLINK=<div class="bibRecordLink"><a

id="recordnum" href="%s" >Permanent URL for this record</a></div>

• Replace it with this:• ICON_RECORDLINK=<script

type="text/javascript">var url_tail = '%s'; var url_full = 'http://library.seattleu.edu' + url_tail;</script>

Page 8: Use the data you already have

Harvest data with a wwwoption

• The wwwoption LOGGEDIN_MSG typically looks like this:• LOGGEDIN_MSG=You are logged into %s as %s

• Replace it with:• LOGGEDIN_MSG=You are logged in %s as <script type="text/javascript">var pName = '%s'; document.write(pName);</script>

• You could get your library name with this technique as well, but that doesn’t change, so why bother?

Page 9: Use the data you already have

Put it to use

• Now I can put this script anywhere in my bib_display.html• <script type="text/javascript"> document.write("Hey " + pName + "!" + " Bookmark this <a href='" + url_full + "'>record</a>."); </script>

• And get this on my page:• Hey Eriksen, Douglas! Bookmark this record.

Page 10: Use the data you already have

That’s cute, but not very useful

• So let’s get useful, by harvesting a whole bunch more data• You can’t do this with wwwoptions, it’s time to

break out the JavaScript• Thankfully, you don’t have to write it from

scratch, you can use mine!• http://www.seattleu.edu/lemlib/nwiug08/

harvester.js

Page 11: Use the data you already have

Pause to give credit

• Adam Brin, from the library at Bryn Mawr, put a script up on the IUG clearinghouse that collects the persistent URL and the book title, and uses them to build a social bookmarking button with the AddThis service

• harvester.js began as a customization of his script, and can still pass the title to an AddThis button, but please don’t hold him responsible if my script uploads all of your patrons’ email addresses to a Russian botnet, and then melts your server.

Page 12: Use the data you already have

harvester.js

• If you haven’t gone crazy with customizations in your catalog, this script should harvest the following:• Title• Author• ISBN• LCCN • OCLC#

• And thanks to your clever new wwwoptions you already have:• Persistent URL• Patron Name (if they have logged in)

Page 13: Use the data you already have

harvester.js

• Scans your page for tables, and collects every row for analysis

• Looks at each row for an identifying label, like “ISSN” in the first cell

• Harvests the text of the second cell as a JavaScript variable and cleans up the text to make it useful

• It can’t find what isn’t there, but it can find what is hidden by style sheets {display:none;}

Page 14: Use the data you already have

harvester.js

• Save the file to your screens directory, then use this code to include it in your bib_display.html file• <script type="text/javascript" src="http://your.server.name/screens/harvester.js"></script>

• Include it after all <!--{recordinfo:}--> tokens and before <!--{botlogo}-->

• Now, use the data!

Page 15: Use the data you already have

Persistent URL

• Nice• Persistent Link

• Cute• Hey Eriksen, Karl D! Bookmark this record.

• Really, really useful• Link to - SU Title: Electronic structure calculations

for solids and molecules

Page 16: Use the data you already have

Persistent URL

• Insert this anywhere after harvester.js• <script type="text/javascript"> document.write("Link to - <a href='" + url_full + "'>SU " + bib_title + "</a>"); </script>

• Now your users have a persistent URL that is easy to find, and easy to bookmark• Link to - SU Title: Electronic structure

calculations for solids and molecules

Page 17: Use the data you already have

Persistent URL

• Bookmarks created from this link will not be named “Your University” or “Your Library Catalog”, they will automatically be named with the title of the book

Page 18: Use the data you already have

Three ways to use your data

• Rewrite your page• Better page titles

• Construct a URL• Link to WorldCat, Amazon, LoC

• Process it in a script• Google Books!!!

Page 19: Use the data you already have

Google Books

• The Google Books API offers a variety of ways to connect your patrons to a scanned books, but they all need to be passed the ISBN or OCLC# as a variable.

• I believe there is no way easier than this:• <div id="google"><script type="text/javascript" src="http://books.google.com/books/previewlib.js"> </script> <script type="text/javascript”> GBS_insertPreviewButtonPopup(bib_ISBN); </script> </div>

Page 20: Use the data you already have

Google Books ButtonThis button only appears if a scan of the book (full or partial) is available

Page 21: Use the data you already have

Google Books ViewerThis viewer overlays right on your page.

No need to send your patrons away.

Page 22: Use the data you already have

Construct a URL

• With a title’s OCLC# you can construct URLs that lead to four very useful resources on WorldCat.org• Other Editions• Formatted Citations• RefWorks Export• Citation File (Endnote) Export• These can also be pointed at a WorldCat Local

installation

Page 23: Use the data you already have

Construct a URL

• For the OCLC# 63186207 these are the URLs:• http://worldcat.org/oclc/63186207/editions/• http://worldcat.org/oclc/63186207?page=citation• http://worldcat.org.proxy.seattleu.edu/oclc/63186207?

page=refworks – Note that I ran this link through my proxy server so RefWorks will recognize my users

• http://worldcat.org/oclc/63186207?page=endnote

• And each can easily be built with JavaScript using the bib_OCLC variable that harvester.js provides

Page 24: Use the data you already have

Construct a URL

• Other Editions• <script type="text/javascript">

document.write("<a href='http://worldcat.org/oclc/" + bib_OCLC + "/editions/' target='_blank'>Search WorldCat for other editions of this title</a>"); </script>

• Formatted Citations• <script type="text/javascript">

document.write("<a href='http://worldcat.org/oclc/" +bib_OCLC + "?page=citation' target='_blank'>Cite this</a>"); </script>

Page 25: Use the data you already have

Construct a URL

• RefWorks Export• <script type="text/javascript">

document.write("<a href='http://worldcat.org.proxy.seattleu.edu/oclc/" + bib_OCLC + "?page=refworks' target='_blank'>Export to Refworks</a>"); </script>

• Citation File Export• <script type="text/javascript">

document.write("<a href='http://worldcat.org/oclc/" + bib_OCLC + "?page=endnote' target='_blank'>Export to a citation file</a>"); </script>

Page 26: Use the data you already have

Construct a URL

• WorldCat xISSN History Visualization Tool • An OCLC Web service to generate a chart showing

the history of a journal with a given ISSN• <script type="text/javascript"> document.write("<a href='http://worldcat.org/xissn/titlehistory?issn=" +bib_ISSN + "' target='_blank'>Title history in WorldCat</a>"); </script>

• Title history in Worldcat for ISSN 1871-5206

Page 27: Use the data you already have

Rewrite your page

• Better page titles• You can customize the <title> element on some

pages, but many pages get a system generated <title>

• In my catalog it looks like this:• <title>Seattle University Libraries/Lemieux</title>

• On a bibliographic display I would like to use the title from the record as my page title

Page 28: Use the data you already have

Rewrite your page

• <script type=“text/javascript”> document.title = "SU library - " + bib_title; </script>

Before

After

Page 29: Use the data you already have

What else can I do?

• Use bib_LCCN and LCCN Permalinks to build a link to the LoC record display

• Use bib_author to build a link to search for the author in WorldCat Identities

• Use bib_ISBN to link to a bookstore like Amazon or Powell’s

• Pass bib_title and url_full to a social bookmarking widget like the AddThis button

• Pass any variable to a search engine or another library catalog, WorldCat.org, LibraryThing, Open Library…

Page 30: Use the data you already have

Questions?

• Q: Where can I get copies of all this code?• A: http://www.seattleu.edu/lemlib/nwiug08/• All the code from this presentation plus several

more complicated examples

Page 31: Use the data you already have

Bonus Examples

• These scripts are not conditional<script type=“text/javascript”> document.write("<a href='http://worldcat.org/xissn/titlehistory?issn=" +bib_ISSN + "' target='_blank'>Title history in WorldCat</a>"); </script>

• If there is no ISSN in the record, this script will insert a broken link in your page

Page 32: Use the data you already have

Conditional content

• Using the exist_ variables in harvester.js we can make the scripts conditional• <script type="text/javascript"> if(exist_ISSN=='1') { document.write("<a href='http://worldcat.org/xissn/titlehistory?issn=" +bib_ISSN + "' target='_blank'>Title history in WorldCat</a>"); } </script>

• Unless there is an ISSN in the record, this script will do nothing

Page 33: Use the data you already have

Insert content outside the flow

• You have to place harvester.js after all of your <!--{recordinfo:}--> tokens, and you have to place these scripts after harvester.js

• This means all you dynamic content comes at the end of your page unless you:• Use CSS to move it around in your layout• Use JavaScript to insert it outside the flow

Page 34: Use the data you already have

Insert content outside the flow

• Put an empty div, with an ID at the location in your page you wish you could insert the content, anywhere after <!--{toplogo}--> even if it is before harvester.js• <div id="xISSN"></div>

• Modify your conditional include script to locate and rewrite the empty div, and include it at the end of the page

Page 35: Use the data you already have

Insert content outside the flow

• Like this:• <script type="text/javascript"> if (exist_ISSN=='1'){

var ISSNdiv = document.getElementById("xISSN");ISSNdiv.innerHTML = "<a href='http://worldcat.org/xissn/titlehistory?issn=" +bib_ISSN + "' target='_blank'>Title history in WorldCat</a><div class='clearer'><hr></div>";

} </script>

• getElementById finds the named div and ISSNdiv.innerHTML = replaces its contents with your link, anywhere on the page

Page 36: Use the data you already have

Social Bookmarking

• Customize a social bookmarking tool, such as the AddThis button

• Use the persistent URL instead of the current URL, use the page title of your choice

Page 37: Use the data you already have

Social Bookmarking

• Source:

<!-- ADDTHIS BUTTON BEGIN --><script type="text/javascript">addthis_pub = 'eriksend'; addthis_brand

= 'SeattleU'; addthis_options = 'email, delicious, facebook, stumbleupon, google, more'; </script>

<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', url_full, bib_title)" onmouseout="addthis_close()" onclick="return addthis_sendto()">

<img src="http://s9.addthis.com/button1-share.gif" width="125" height="16" border="0" alt=""> </a>

<script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>

<!-- ADDTHIS BUTTON END -->