Anda di halaman 1dari 37

Use the data

you already
have
What you could do if Millennium gave
you the power to do more than just
display this data?
Q: What can I harvest?
Q: What can I use?
title, author, standard numbers
+ persistent URL and patron name
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
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
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>
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?
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.
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/harve
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.
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)
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;}
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/ha
rvester.js"></script>
• Include it after all <!--{recordinfo:}--
> tokens and before <!--{botlogo}--
>
• Now, use the data!
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
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 s
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
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!!!
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>
Google Books Button
This button only appears if a scan of the book (full or
partial) is available
Google Books Viewer
This viewer overlays right on your page.
No need to send your patrons away.
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
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=
– 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
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>
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>
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
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
Rewrite your page
• <script type=“text/javascript”> document.title = "SU library - " +
bib_title; </script>

Before

After
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…
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
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
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
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
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
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
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
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 -->

Anda mungkin juga menyukai