Index: /gs3-extensions/hathitrust-downloadfrom/trunk/CONFIGURE.sh
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/CONFIGURE.sh	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/CONFIGURE.sh	(revision 26436)
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+echo -e "\
+  o conf makepl_arg \"LIB=$HTEXPORT_HOME/cpan-installed/lib \
+    INSTALLSITEMAN1DIR=$HTEXPORT_HOME/cpan-installed/man/man1 \
+    INSTALLSITEMAN3DIR=$HTEXPORT_HOME/cpan-installed/man/man3\"\n\
+  o conf make_install_arg UNINST=0 \n\
+  o conf commit " | perl -MCPAN -we shell
Index: /gs3-extensions/hathitrust-downloadfrom/trunk/DEVEL.bash
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/DEVEL.bash	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/DEVEL.bash	(revision 26436)
@@ -0,0 +1,6 @@
+echo "+ Need to ensure CPAN install has parameters to local area"
+echo "+ through LIB INSTALLSITEMAN1DIR and INSTALLSITEMAN3DIR to be with HTEXPORT_HOME/cpan-installed area"
+
+#export LIB=$PERL5LIB:$HTEXPORT_HOME/cpan-installed/lib 
+#export INSTALLSITEMAN1DIR=$PERL5LIB:$HTEXPORT_HOME/cpan-installed/man/man1 
+#export INSTALLSITEMAN3DIR=$PERL5LIB:$HTEXPORT_HOME/cpan-installed/man/man3
Index: /gs3-extensions/hathitrust-downloadfrom/trunk/README.txt
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/README.txt	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/README.txt	(revision 26436)
@@ -0,0 +1,38 @@
+
+
+*****
+*
+* Install required packages.  Example syntax:
+*
+*    perl -MCPAN -we 'install "Net::FTP"'
+*
+*****
+
+-----
+Other useful examples:
+-----"
+
+
+To reconfigure CPAN settings:
+
+   o conf init"
+
+
+To push through the values needed for the custom install:
+
+  o conf makepl_arg "LIB=$HTEXPORT_HOME/cpan-installed/lib \
+      INSTALLSITEMAN1DIR=$HTEXPORT_HOME/cpan-installed/man/man1 \
+      INSTALLSITEMAN3DIR=$HTEXPORT_HOME/cpan-installed/man/man3" 
+
+  o conf make_install_arg UNINST=0 
+
+  o conf commit 
+
+
+To do a Forced install:
+
+  perl -MCPAN -e "CPAN::Shell->force(qw(install IO::Socket::SSL));
+
+
+
+
Index: /gs3-extensions/hathitrust-downloadfrom/trunk/SETUP.bash
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/SETUP.bash	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/SETUP.bash	(revision 26436)
@@ -0,0 +1,36 @@
+
+## Based on:
+##  http://linuxgazette.net/139/okopnik.html
+## (a local version of the page is available in the 'docs' folder
+##  as 'Installing-Perl-Modules-Under-User_Control.html)
+
+export HTEXPORT_HOME=`pwd`
+echo "Set HTEXPORT_HOME to $HTEXPORT_HOME"
+
+echo "+ Adding in HTEXPORT_HOME/cpan-installed to Perl's runtime environment (PERL5LIB)"
+
+if [ -z "$PERL5LIB" ] ; then
+	# If PERL5LIB wasn't previously defined, set it...
+	export PERL5LIB=$HTEXPORT_HOME/cpan-installed/lib
+else
+	# ...otherwise, extend it.
+	export PERL5LIB=$PERL5LIB:$HTEXPORT_HOME/cpan-installed/lib
+fi
+
+
+if [ ! -d "cpan-installed" ] ; then
+    echo "++ Creating directory 'cpan-install'"
+    mkdir "cpan-installed"
+fi
+
+
+for d in lib man man/man1 man/man3 ; do
+  fd="$HTEXPORT_HOME/cpan-installed/$d"
+  if [ ! -d "$fd" ] ; then
+    echo "++ Creating directory '$fd'"
+    mkdir "$fd"
+  fi
+done
+
+
+cat README.txt | sed "s%\$HTEXPORT_HOME%$HTEXPORT_HOME%g"
Index: /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control.html
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control.html	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control.html	(revision 26436)
@@ -0,0 +1,337 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"><head>
+<title>Installing Perl Modules as a Non-Root User LG #139</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" href="Installing-Perl-Modules-Under-User-Control_files/lg.css" type="text/css" media="screen, projection">
+<link rel="alternate" type="application/rss+xml" title="LG RSS" href="http://linuxgazette.net/139/lg.rss">
+<link rel="alternate" type="application/rdf+xml" title="LG RDF" href="http://linuxgazette.net/139/lg.rdf">
+<link rel="alternate" type="application/atom+xml" title="LG Atom" href="http://linuxgazette.net/139/lg.atom.xml">
+<link rel="shortcut icon" href="http://linuxgazette.net/favicon.ico">
+
+<style type="text/css" media="screen, projection">
+<!--
+
+-->
+</style>
+
+</head>
+<body>
+
+<a href="http://linuxgazette.net/">
+<img src="Installing-Perl-Modules-Under-User-Control_files/newlogo-blank-200-gold2.jpg" id="logo" alt="Linux Gazette">
+</a>
+<p id="fun">...making Linux just a little more fun!</p>
+
+<div id="navigation">
+<table summary="masthead" width="100%">
+<tbody><tr>
+<td colspan="3" style="font-size: 10px; font-weight: bold" align="center">
+<a href="http://linuxgazette.net/index.html">Home</a>
+<a href="http://linuxgazette.net/">Main Site</a>
+<a href="http://linuxgazette.net/faq/index.html">FAQ</a>
+
+<a href="http://linuxgazette.net/lg_index.html">Site Map</a>
+<a href="http://linuxgazette.net/mirrors.html">Mirrors</a>
+<a href="http://linuxgazette.net/mirrors.html">Translations</a>
+<a href="http://linuxgazette.net/search.html">Search</a>
+<a href="http://linuxgazette.net/archives.html">Archives</a>
+<a href="http://linuxgazette.net/authors/index.html">Authors</a>
+<a href="http://lists.linuxgazette.net/mailman/listinfo/">Mailing Lists</a>
+<a href="http://linuxgazette.net/jobs.html">Join Us!</a>
+<a href="http://linuxgazette.net/contact.html">Contact Us</a>
+
+<hr style="border: 1px inset #000033" width="99%">
+</td>
+</tr>
+<tr>
+<td style="font-size: 10px; font-weight: bold" align="left" width="40%">
+The Free International Online Linux Monthly
+</td>
+<td style="font-size: 10px; font-weight: bold" align="center" width="20%">
+ISSN: 1934-371X
+</td>
+<td style="font-size: 10px; font-weight: bold" align="right" width="40%">
+Main site: <a href="http://linuxgazette.net/">http://linuxgazette.net</a> 
+</td>
+</tr></tbody></table>
+</div>
+
+
+<div id="breadcrumbs1">
+
+<a href="http://linuxgazette.net/index.html">Home</a> &gt; 
+<a href="http://linuxgazette.net/139/index.html">June 2007 (#139)</a> &gt; 
+Article
+
+</div>
+
+<div class="articlecontent1">
+<div class="content">
+
+<div id="previousnexttop">
+<a href="http://linuxgazette.net/139/jordan.html">&lt;-- prev</a> | <a href="http://linuxgazette.net/139/peterson.html">next --&gt;</a>
+</div>
+
+<h1>Installing Perl Modules as a Non-Root User</h1>
+<p id="by"><b>By <a href="http://linuxgazette.net/authors/okopnik.html">Ben Okopnik</a></b></p>
+
+<h3>Introduction</h3>
+
+<p>
+If you use Perl for anything more complex than the traditional (and boring)
+generation of "Hello, World", then it's also likely that you're familiar
+with those wonderful work-saving devices - Perl modules. Furthermore,
+chances are that you're also familiar with CPAN, the <a href="http://cpan.org/">Comprehensive Perl Archive Network</a>, and the
+easy interface to it that is provided by the CPAN module. That all works
+just great - assuming that you a) run a sensible modern OS like Linux, and
+b) have root access to the machine you're using (or have a friendly and
+cooperative sysadmin). But what if those assumptions don't hold true? What
+if, for example, you have a shell account on a machine run by some
+mega-corporation that doesn't feel like installing the
+Foo::Bar::Zotz::Blagger-0.01 module in their /usr/lib/perl? I, for one,
+can't blame them; a system-wide installation could open them up to unknown
+bugs galore. When your interests and theirs conflict, you lose every time -
+since they own the system.
+</p>
+
+<p>
+So, what can we do if we really, really need that module but can't get it
+installed on a system-wide basis? The answer is to install it elsewhere -
+in some directory where you have write permissions.
+</p>
+
+<h3>Configuring the Environment</h3>
+
+<p>
+Clearly, if you're not root, you're not going to be able to save the files
+to their default locations under '/usr/' - which is where they would
+normally go.  Therefore, we need to tell Perl where to find the modules
+that we'll install. Fortunately, this is the easy part: just decide on the
+location where you'll install the modules, create that directory if it
+doesn't already exist, append '/lib' to its name, and set the PERL5LIB
+variable to that string. E.g., if you're using Bash, then edit your
+~/.bash_profile and add the following:
+</p>
+
+<pre>if [ -z "$PERL5LIB" ]
+then
+	# If PERL5LIB wasn't previously defined, set it...
+	PERL5LIB=~/myperl/lib
+else
+	# ...otherwise, extend it.
+	PERL5LIB=$PERL5LIB:~/myperl/lib
+fi
+
+MANPATH=$MANPATH:~/myperl/man
+
+export PERL5LIB MANPATH
+</pre>
+
+<p>
+Now, create the three necessary directories:
+</p>
+
+<pre>mkdir -p ~/myperl/lib
+mkdir -p ~/myperl/man/man{1,3}
+</pre>
+
+<p>
+After you've logged out and back in, Perl will treat that location as a
+part of @INC (the list of directories to search for libraries and modules.)
+If you want to confirm that it's actually happened, just execute the
+following and use your directory name as the argument to 'grep':
+</p>
+
+<pre>perl -wle'print for grep /myperl/, @INC'
+</pre>
+
+<h3>Installing the Modules</h3>
+
+<pre>perl -MCPAN -we 'shell'
+</pre>
+
+<p>
+First, you'll need to configure the CPAN module. If you've never done this,
+it's really simple; just execute the above at your command line, and you're
+on your way. Some people have referred to it as a "pecking chicken" install
+(that is, if you set a chicken over the 'Enter' key and it then keeps
+pecking at the key, it'll get through the installation successfully). For
+our purposes, however, we need to make two small modifications to the
+standard procedure: when the script asks you for any extra arguments for
+Makefile.PL, you need to supply it with the following list (assuming that
+you chose '~/myperl' as your private lib directory):
+</p>  
+
+<pre>LIB=~/myperl/lib INSTALLSITEMAN1DIR=~/myperl/man/man1 INSTALLSITEMAN3DIR=~/myperl/man/man3
+</pre>
+
+<p>
+You also need to make sure that the UNINST parameter is turned off; you can
+do this by setting 'UNINST=0' when that question comes up during the
+installation. (This is the default behavior unless you set it, but you
+might as well make sure.)
+</p>
+
+<p>
+If you had already configured the CPAN shell at some point in the past, you
+simply need to modify the configuration. Again, start the shell as above,
+and issue the following commands at the "cpan&gt; " prompt:
+</p>
+
+<p>
+``
+o conf makepl_arg "LIB=~/myperl/lib INSTALLSITEMAN1DIR=~/myperl/man/man1 INSTALLSITEMAN3DIR=~/myperl/man/man3"
+o conf make_install_arg UNINST=0
+o conf commit
+''
+</p>
+
+<p>
+and you're done. From this point forward, using the CPAN shell (or any of
+the other CPAN functions and methods) should work just like usual:
+</p>
+
+<pre># Invoke the shell
+perl -MCPAN -we shell
+
+# Install the Net::FTP module
+perl -MCPAN -we 'install "Net::FTP"'
+
+# Update all outdated modules on this system
+perl -MCPAN -we 'CPAN::Shell-&gt;install(CPAN::Shell-&gt;r)'
+</pre>
+
+
+<h3>Conclusion</h3>
+
+<p>
+Both the CPAN module and its documentation - which are, incidentally,
+included as part of the standard Perl installation - have always been good,
+but they've become even better in the recent years. If you have not taken
+the time to become familiar with them, you should do so, since the end result
+will be a great savings in time and effort. The CPAN itself should also be
+your first stop before you embark on any complex project - I've wasted many
+an hour trying to accomplish some task only to find out later (or part-way
+through the project, if I was lucky) that a module to perform that task
+already exists. Give it a shot - and happy hacking!
+</p>
+
+<p></p>
+<script type="text/javascript">
+digg_url = 'http://linuxgazette.net/139/okopnik.html';
+digg_title = 'Installing Perl Modules as a Non-Root User';
+digg_bodytext = 'If you use Perl for anything more complex than the traditional (and boring)
+generation of "Hello, World", then it\'s also likely that you\'re familiar
+with those wonderful work-saving devices - Perl modules. Furthermore,
+chances are that you\'re also familiar with CPAN, the <a
+href="http://cpan.org/">Comprehensive Perl Archive Network</a>, and the
+easy interface to it that is provided by the CPAN module. That all works
+just great - assuming that you a) run a sensible modern OS like Linux, and
+b) have root access to the machine you\'re using (or have a friendly and
+cooperative sysadmin). But what if those assumptions don\'t hold true? What
+if, for example, you have a shell account on a machine run by some
+mega-corporation that doesn\'t feel like installing the
+Foo::Bar::Zotz::Blagger-0.01 module in their /usr/lib/perl? I, for one,
+can\'t blame them; a system-wide installation could open them up to unknown
+bugs galore. When your interests and theirs conflict, you lose every time -
+since they own the system.';
+digg_topic = 'programming';
+</script>
+<script src="Installing-Perl-Modules-Under-User-Control_files/diggthis.js" type="text/javascript"></script> 
+
+
+
+<p class="talkback">
+Talkback: <a href="mailto:tag@lists.linuxgazette.net?subject=Talkback:139/okopnik.html">Discuss this article with The Answer Gang</a>
+</p>
+
+<!-- *** BEGIN author bio *** -->
+<!-- *** BEGIN bio *** -->
+<hr>
+<p>
+<img alt="picture" src="Installing-Perl-Modules-Under-User-Control_files/okopnik.jpg" class="bio" align="left" hspace="10" vspace="10">
+</p>
+
+<p>
+Ben is the Editor-in-Chief for Linux Gazette and a member of The Answer Gang.
+</p>
+
+<p>
+<em>
+Ben was born in Moscow, Russia in 1962. He became interested in electricity
+at the tender age of six, promptly demonstrated it by sticking a fork into
+a socket and starting a fire, and has been falling down technological
+mineshafts ever since. He has been working with computers since the Elder
+Days, when they had to be built by soldering parts onto printed circuit
+boards and programs had to fit into 4k of memory. He would gladly pay good
+money to any psychologist who can cure him of the recurrent nightmares.
+</em>
+</p>
+
+<p>
+<em>
+His subsequent experiences include creating software in nearly a dozen
+languages, network and database maintenance during the approach of a
+hurricane, and writing articles for publications ranging from sailing
+magazines to technological journals. After a seven-year Atlantic/Caribbean
+cruise under sail and passages up and down the East coast of the US, he is
+currently anchored in St. Augustine, Florida. He works as a technical
+instructor for Sun Microsystems and a private Open Source consultant/Web
+developer. His current set of hobbies includes flying, yoga, martial arts,
+motorcycles, writing, and Roman history; his Palm Pilot is crammed full of
+alarms, many of which contain exclamation points.
+</em>
+</p>
+
+<p>
+<em>
+He has been working with Linux since 1997, and credits it with his complete
+loss of interest in waging nuclear warfare on parts of the Pacific Northwest.
+</em>
+</p>
+
+<br clear="all">
+<!-- *** END bio *** -->
+
+<!-- *** END author bio *** -->
+
+<div id="articlefooter">
+
+<p>
+Copyright Â© 2007, Ben Okopnik. Released under the <a href="http://linuxgazette.net/copying.html">Open Publication License</a>
+unless otherwise noted in the body of the article. Linux Gazette is not
+produced, sponsored, or endorsed by its prior host, SSC, Inc.
+</p>
+
+<p>
+Published in Issue 139 of Linux Gazette, June 2007
+</p>
+
+</div>
+
+<div id="previousnextbottom">
+<a href="http://linuxgazette.net/139/jordan.html">&lt;-- prev</a> | <a href="http://linuxgazette.net/139/peterson.html">next --&gt;</a>
+</div>
+
+</div>
+</div>
+
+<script src="Installing-Perl-Modules-Under-User-Control_files/urchin.js" type="text/javascript">
+</script>
+<script type="text/javascript">
+_uacct = "UA-1204316-1";
+urchinTracker();
+</script>
+
+
+
+
+
+
+
+<img src="Installing-Perl-Modules-Under-User-Control_files/tux_86x95_indexed.png" id="tux" alt="Tux">
+
+
+
+
+</body></html>
Index: /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control_files/diggthis.js
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control_files/diggthis.js	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control_files/diggthis.js	(revision 26436)
@@ -0,0 +1,1 @@
+http://digg.com/
Index: /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control_files/lg.css
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control_files/lg.css	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control_files/lg.css	(revision 26436)
@@ -0,0 +1,337 @@
+body {
+	font:12px verdana, arial, helvetica, sans-serif;
+	/*background-color:#ffff88;*/
+	background-color:#f4f1bf;
+	color:#000000;
+}
+
+a:link {
+	color:#00c;
+	text-decoration:underline;
+}
+a:visited {
+	color:#551a8b;
+	text-decoration:underline;
+}
+
+
+
+#logo {
+	position:relative;
+	/*top:5px;*/
+	border:1px solid black;
+}
+
+#twdtlogo {
+	border:1px solid black;
+	margin-bottom:20px;
+}
+
+
+#tux {
+	position:absolute;
+	top:3px;
+	left:80%;
+}
+
+#navigation a {
+	margin-left:4px;
+}
+
+#navigation {
+	border:1px solid black;
+	padding-left:5px;
+	padding-right:5px;
+	padding-top:3px;
+	padding-bottom:3px;
+	margin:10px 0 4px;
+	background:#FFFFFF;
+
+	/* width:83%; */
+	/* width:97%; */
+	width:88%;
+	
+	position:relative;
+	/*left:8px;*/
+	/*top:96px;*/
+
+	text-align:right;
+
+}
+
+#navigation a:link {
+	font:11px verdana, arial, helvetica, sans-serif;
+	text-decoration:underline;
+}
+
+#navigation a:visited {
+	font:11px verdana, arial, helvetica, sans-serif;
+	text-decoration:underline;
+}
+
+.plate {
+	top:105px;
+}
+
+.content-right {
+	border:1px solid black;
+	/* padding:20px; */
+    padding: 0px !important;
+	background-color:#FFFFFF;
+}
+
+.content {
+	border:1px solid black;
+	padding:20px;
+	background-color:#FFFFFF;
+}
+
+.content blockquote {
+	font-size: 12px;
+}
+
+.articlecontent {
+	position: absolute;
+	/*top: 180px;*/
+	top: 143px;
+	width:84%;
+}
+
+.articlecontent1 {
+	position: relative;
+	/*top: 143px;*/
+	/*top: 114px;*/
+	width:85%;
+	left:2%;
+	margin-top:5px;
+}
+
+.fullpagediv {
+	width:87%;
+	margin-top: 40px;
+	*margin-top: 51px; /* IE 7 Hack */
+}
+
+.content h3 {
+	font-size:14px;
+}
+
+.content h2 {
+	font-size:16px;
+}
+
+.content h1 {
+	font-size:19px;
+	text-align:center;
+}
+
+.content i, em {
+	line-height: 1em;
+}
+
+/* .content pre {
+	font-family: verdana, sans-serif;
+	font-size:110%;
+} */
+
+.articlecontent h1 {
+	font-size:19px;
+	text-align:center;
+}
+
+.editorial {
+	font-style: italic;
+	color: #009900;
+}
+
+.bio {
+	margin-right: 20px;
+}
+
+.sig {
+	/* text-align: top; */
+	margin-top: 50px;
+	margin-bottom: -30px;
+}
+
+.cartoon {
+	text-align: center;
+	margin-bottom: 30px;
+	margin-top: 30px;
+}
+
+.cartoon img {
+	border: none;
+	width: 700px;
+}
+
+.cartoon1 {
+	text-align: center;
+	margin-bottom: 30px;
+	margin-top: 30px;
+}
+
+.cartoon1 img {
+	border: none;
+	max-height: 300px;
+}
+
+#by {
+	text-align:center;
+}
+
+#breadcrumbs {
+	margin-top:5px;
+	position:absolute;
+	/*top:160px;*/
+	/*top:124px;*/
+	top:129px;
+	*top:140px; /* Another IE7 hack */
+	left:20px;
+	padding:0px;
+	margin:0px;
+	font:11px verdana, arial, helvetica, sans-serif;
+}
+
+#breadcrumbs1 {
+	position:relative;
+	/*top:124px;*/
+	/*top:160px;*/
+	left:20px;
+	margin:0;
+	padding:0px;
+	font:11px verdana, arial, helvetica, sans-serif;
+}
+
+#breadcrumbs a:link {
+	font:11px verdana, arial, helvetica, sans-serif;
+	color:#00c;
+	text-decoration:underline;
+}
+
+#breadcrumbs1 a:link {
+	font:11px verdana, arial, helvetica, sans-serif;
+	color:#00c;
+	text-decoration:underline;
+}
+
+#breadcrumbs a:visited {
+	font:11px verdana, arial, helvetica, sans-serif;
+	color:#551a8b;
+	text-decoration:underline;
+}
+
+#breadcrumbs1 a:visited {
+	font:11px verdana, arial, helvetica, sans-serif;
+	color:#551a8b;
+	text-decoration:underline;
+}
+
+pre.code {
+	background-color:#f4f1bf;
+	border:1px solid black;
+	padding:10px;
+	font-size: 95%;
+	overflow: auto;
+}
+
+#previousnexttop {
+	width:90%;
+	text-align:right;
+}
+
+#previousnextbottom {
+	width:90%;
+	text-align:right;
+	margin-top:30px;
+}
+
+#articlefooter {
+	font-size:10px;
+	font-weight:bold;
+	margin-top:20px;
+}
+#articlefooter p {
+	padding:0px;
+	margin:0px;
+}
+
+
+#fun {
+	font-size:17px;
+	font-weight:bold;
+	font-style:italic;
+	position:absolute;
+	top:40px;
+	left:31%;
+	margin:0px;
+	padding:0px;
+}
+
+.irc {
+    background-color:#f4f1bf;
+    border:black solid 1px;
+	padding: 20px;
+	margin: 20px;
+}
+
+.irc td {
+	font-family: sans-serif;
+	font-size: 80%;
+	vertical-align: top;
+}
+
+.irc td#q {
+	width: 200px;
+	font-weight: bold;
+	color: blue;
+}
+
+.irc td#r {
+	width: 200px;
+	font-weight: bold;
+	color: green;
+}
+
+.irc td#other {
+	width: 200px;
+	font-weight: bold;
+}
+
+.talkback {
+	margin-top: 40px;
+	padding: 10px;
+	background-color: lightgray;
+	font-size: 15px;
+	font-weight: bold;
+	text-align: center;
+	border: 1px solid black;
+}
+
+.talkback a {
+	text-decoration: none;
+	color: green;
+}
+
+#news h2 {
+	color: green;
+	text-align: center;
+}
+
+#news h3 {
+	color: green;
+}
+
+.pullquotes table {
+	width: 85%;
+	margin: 5 auto;
+}
+
+.pullquotes td {
+	padding: 10px 20px;
+}
+
+.pullquotes strong {
+	font-size: 13px;
+}
+
Index: /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control_files/urchin.js
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control_files/urchin.js	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/docs/Installing-Perl-Modules-Under-User-Control_files/urchin.js	(revision 26436)
@@ -0,0 +1,695 @@
+//-- Google Analytics Urchin Module
+//-- Copyright 2007 Google, All Rights Reserved.
+
+//-- Urchin On Demand Settings ONLY
+var _uacct="";			// set up the Urchin Account
+var _userv=1;			// service mode (0=local,1=remote,2=both)
+
+//-- UTM User Settings
+var _ufsc=1;			// set client info flag (1=on|0=off)
+var _udn="auto";		// (auto|none|domain) set the domain name for cookies
+var _uhash="on";		// (on|off) unique domain hash for cookies
+var _utimeout="1800";   	// set the inactive session timeout in seconds
+var _ugifpath="/__utm.gif";	// set the web path to the __utm.gif file
+var _utsp="|";			// transaction field separator
+var _uflash=1;			// set flash version detect option (1=on|0=off)
+var _utitle=1;			// set the document title detect option (1=on|0=off)
+var _ulink=0;			// enable linker functionality (1=on|0=off)
+var _uanchor=0;			// enable use of anchors for campaign (1=on|0=off)
+var _utcp="/";			// the cookie path for tracking
+var _usample=100;		// The sampling % of visitors to track (1-100).
+
+//-- UTM Campaign Tracking Settings
+var _uctm=1;			// set campaign tracking module (1=on|0=off)
+var _ucto="15768000";		// set timeout in seconds (6 month default)
+var _uccn="utm_campaign";	// name
+var _ucmd="utm_medium";		// medium (cpc|cpm|link|email|organic)
+var _ucsr="utm_source";		// source
+var _uctr="utm_term";		// term/keyword
+var _ucct="utm_content";	// content
+var _ucid="utm_id";		// id number
+var _ucno="utm_nooverride";	// don't override
+
+//-- Auto/Organic Sources and Keywords
+var _uOsr=new Array();
+var _uOkw=new Array();
+_uOsr[0]="google";	_uOkw[0]="q";
+_uOsr[1]="yahoo";	_uOkw[1]="p";
+_uOsr[2]="msn";		_uOkw[2]="q";
+_uOsr[3]="aol";		_uOkw[3]="query";
+_uOsr[4]="aol";		_uOkw[4]="encquery";
+_uOsr[5]="lycos";	_uOkw[5]="query";
+_uOsr[6]="ask";		_uOkw[6]="q";
+_uOsr[7]="altavista";	_uOkw[7]="q";
+_uOsr[8]="netscape";	_uOkw[8]="query";
+_uOsr[9]="cnn";	_uOkw[9]="query";
+_uOsr[10]="looksmart";	_uOkw[10]="qt";
+_uOsr[11]="about";	_uOkw[11]="terms";
+_uOsr[12]="mamma";	_uOkw[12]="query";
+_uOsr[13]="alltheweb";	_uOkw[13]="q";
+_uOsr[14]="gigablast";	_uOkw[14]="q";
+_uOsr[15]="voila";	_uOkw[15]="rdata";
+_uOsr[16]="virgilio";	_uOkw[16]="qs";
+_uOsr[17]="live";	_uOkw[17]="q";
+_uOsr[18]="baidu";	_uOkw[18]="wd";
+_uOsr[19]="alice";	_uOkw[19]="qs";
+_uOsr[20]="yandex";	_uOkw[20]="text";
+_uOsr[21]="najdi";	_uOkw[21]="q";
+_uOsr[22]="aol";	_uOkw[22]="q";
+_uOsr[23]="club-internet"; _uOkw[23]="query";
+_uOsr[24]="mama";	_uOkw[24]="query";
+_uOsr[25]="seznam";	_uOkw[25]="q";
+_uOsr[26]="search";	_uOkw[26]="q";
+_uOsr[27]="wp";	_uOkw[27]="szukaj";
+_uOsr[28]="onet";	_uOkw[28]="qt";
+_uOsr[29]="netsprint";	_uOkw[29]="q";
+_uOsr[30]="google.interia";	_uOkw[30]="q";
+_uOsr[31]="szukacz";	_uOkw[31]="q";
+_uOsr[32]="yam";	_uOkw[32]="k";
+_uOsr[33]="pchome";	_uOkw[33]="q";
+_uOsr[34]="kvasir";	_uOkw[34]="searchExpr";
+_uOsr[35]="sesam";	_uOkw[35]="q";
+_uOsr[36]="ozu"; _uOkw[36]="q";
+_uOsr[37]="terra"; _uOkw[37]="query";
+_uOsr[38]="nostrum"; _uOkw[38]="query";
+_uOsr[39]="mynet"; _uOkw[39]="q";
+_uOsr[40]="ekolay"; _uOkw[40]="q";
+_uOsr[41]="search.ilse"; _uOkw[41]="search_for";
+_uOsr[42]="bing"; _uOkw[42]="q";
+
+//-- Auto/Organic Keywords to Ignore
+var _uOno=new Array();
+//_uOno[0]="urchin";
+//_uOno[1]="urchin.com";
+//_uOno[2]="www.urchin.com";
+
+//-- Referral domains to Ignore
+var _uRno=new Array();
+//_uRno[0]=".urchin.com";
+
+//-- **** Don't modify below this point ***
+var _uff,_udh,_udt,_ubl=0,_udo="",_uu,_ufns=0,_uns=0,_ur="-",_ufno=0,_ust=0,_ubd=document,_udl=_ubd.location,_udlh="",_uwv="1.4";
+var _ugifpath2="http://www.google-analytics.com/__utm.gif";
+if (_udl.hash) _udlh=_udl.href.substring(_udl.href.indexOf('#'));
+if (_udl.protocol=="https:") _ugifpath2="https://ssl.google-analytics.com/__utm.gif";
+if (!_utcp || _utcp=="") _utcp="/";
+function urchinTracker(page) {
+ if (_udl.protocol=="file:") return;
+ if (_uff && (!page || page=="")) return;
+ var a,b,c,xx,v,z,k,x="",s="",f=0,nv=0;
+ var nx=" expires="+_uNx()+";";
+ var dc=_ubd.cookie;
+ _udh=_uDomain();
+ if (!_uVG()) return;
+ _uu=Math.round(Math.random()*2147483647);
+ _udt=new Date();
+ _ust=Math.round(_udt.getTime()/1000);
+ a=dc.indexOf("__utma="+_udh+".");
+ b=dc.indexOf("__utmb="+_udh);
+ c=dc.indexOf("__utmc="+_udh);
+ if (_udn && _udn!="") { _udo=" domain="+_udn+";"; }
+ if (_utimeout && _utimeout!="") {
+  x=new Date(_udt.getTime()+(_utimeout*1000));
+  x=" expires="+x.toGMTString()+";";
+ }
+ if (_ulink) {
+  if (_uanchor && _udlh && _udlh!="") s=_udlh+"&";
+  s+=_udl.search;
+  if(s && s!="" && s.indexOf("__utma=")>=0) {
+   if (!(_uIN(a=_uGC(s,"__utma=","&")))) a="-";
+   if (!(_uIN(b=_uGC(s,"__utmb=","&")))) b="-";
+   if (!(_uIN(c=_uGC(s,"__utmc=","&")))) c="-";
+   v=_uGC(s,"__utmv=","&");
+   z=_uGC(s,"__utmz=","&");
+   k=_uGC(s,"__utmk=","&");
+   xx=_uGC(s,"__utmx=","&");
+   if ((k*1) != ((_uHash(a+b+c+xx+z+v)*1)+(_udh*1))) {_ubl=1;a="-";b="-";c="-";xx="-";z="-";v="-";}
+   if (a!="-" && b!="-" && c!="-") f=1;
+   else if(a!="-") f=2;
+  }
+ }
+ if(f==1) {
+  _ubd.cookie="__utma="+a+"; path="+_utcp+";"+nx+_udo;
+  _ubd.cookie="__utmb="+b+"; path="+_utcp+";"+x+_udo;
+  _ubd.cookie="__utmc="+c+"; path="+_utcp+";"+_udo;
+ } else if (f==2) {
+  a=_uFixA(s,"&",_ust);
+  _ubd.cookie="__utma="+a+"; path="+_utcp+";"+nx+_udo;
+  _ubd.cookie="__utmb="+_udh+"; path="+_utcp+";"+x+_udo;
+  _ubd.cookie="__utmc="+_udh+"; path="+_utcp+";"+_udo;
+  _ufns=1;
+ } else if (a>=0 && b>=0 && c>=0) {
+   b = _uGC(dc,"__utmb="+_udh,";");
+   b = ("-" == b) ? _udh : b;  
+  _ubd.cookie="__utmb="+b+"; path="+_utcp+";"+x+_udo;
+ } else {
+  if (a>=0) a=_uFixA(_ubd.cookie,";",_ust);
+  else {
+   a=_udh+"."+_uu+"."+_ust+"."+_ust+"."+_ust+".1";
+   nv=1;
+  }
+  _ubd.cookie="__utma="+a+"; path="+_utcp+";"+nx+_udo;
+  _ubd.cookie="__utmb="+_udh+"; path="+_utcp+";"+x+_udo;
+  _ubd.cookie="__utmc="+_udh+"; path="+_utcp+";"+_udo;
+  _ufns=1;
+ }
+ if (_ulink && xx && xx!="" && xx!="-") {
+   xx=_uUES(xx);
+   if (xx.indexOf(";")==-1) _ubd.cookie="__utmx="+xx+"; path="+_utcp+";"+nx+_udo;
+ }
+ if (_ulink && v && v!="" && v!="-") {
+  v=_uUES(v);
+  if (v.indexOf(";")==-1) _ubd.cookie="__utmv="+v+"; path="+_utcp+";"+nx+_udo;
+ }
+ var wc=window;
+ var c=_ubd.cookie;
+ if(wc && wc.gaGlobal && wc.gaGlobal.dh==_udh){
+  var g=wc.gaGlobal;
+  var ua=c.split("__utma="+_udh+".")[1].split(";")[0].split(".");
+  if(g.sid)ua[3]=g.sid;
+  if(nv>0){
+   ua[2]=ua[3];
+   if(g.vid){
+    var v=g.vid.split(".");
+    ua[0]=v[0];
+    ua[1]=v[1];
+   }
+  }
+  _ubd.cookie="__utma="+_udh+"."+ua.join(".")+"; path="+_utcp+";"+nx+_udo;
+ }
+ _uInfo(page);
+ _ufns=0;
+ _ufno=0;
+ if (!page || page=="") _uff=1;
+}
+function _uGH() {
+ var hid;
+ var wc=window;
+ if (wc && wc.gaGlobal && wc.gaGlobal.hid) {
+  hid=wc.gaGlobal.hid;
+ } else {
+  hid=Math.round(Math.random()*0x7fffffff);
+  if (!wc.gaGlobal) wc.gaGlobal={};
+  wc.gaGlobal.hid=hid;
+ }
+ return hid;
+}
+function _uInfo(page) {
+ var p,s="",dm="",pg=_udl.pathname+_udl.search;
+ if (page && page!="") pg=_uES(page,1);
+ _ur=_ubd.referrer;
+ if (!_ur || _ur=="") { _ur="-"; }
+ else {
+  dm=_ubd.domain;
+  if(_utcp && _utcp!="/") dm+=_utcp;
+  p=_ur.indexOf(dm);
+  if ((p>=0) && (p<=8)) { _ur="0"; }
+  if (_ur.indexOf("[")==0 && _ur.lastIndexOf("]")==(_ur.length-1)) { _ur="-"; }
+ }
+ s+="&utmn="+_uu;
+ if (_ufsc) s+=_uBInfo();
+ if (_uctm) s+=_uCInfo();
+ if (_utitle && _ubd.title && _ubd.title!="") s+="&utmdt="+_uES(_ubd.title);
+ if (_udl.hostname && _udl.hostname!="") s+="&utmhn="+_uES(_udl.hostname);
+ if (_usample && _usample != 100) s+="&utmsp="+_uES(_usample);
+ s+="&utmhid="+_uGH();
+ s+="&utmr="+_ur;
+ s+="&utmp="+pg;
+ if ((_userv==0 || _userv==2) && _uSP()) {
+  var i=new Image(1,1);
+  i.src=_ugifpath+"?"+"utmwv="+_uwv+s;
+  i.onload=function() { _uVoid(); }
+ }
+ if ((_userv==1 || _userv==2) && _uSP()) {
+  var i2=new Image(1,1);
+  i2.src=_ugifpath2+"?"+"utmwv="+_uwv+s+"&utmac="+_uacct+"&utmcc="+_uGCS();
+  i2.onload=function() { _uVoid(); }
+ }
+ return;
+}
+function _uVoid() { return; }
+function _uCInfo() {
+ if (!_ucto || _ucto=="") { _ucto="15768000"; }
+ if (!_uVG()) return;
+ var c="",t="-",t2="-",t3="-",o=0,cs=0,cn=0,i=0,z="-",s="";
+ if (_uanchor && _udlh && _udlh!="") s=_udlh+"&";
+ s+=_udl.search;
+ var x=new Date(_udt.getTime()+(_ucto*1000));
+ var dc=_ubd.cookie;
+ x=" expires="+x.toGMTString()+";";
+ if (_ulink && !_ubl) {
+  z=_uUES(_uGC(s,"__utmz=","&"));
+  if (z!="-" && z.indexOf(";")==-1) { _ubd.cookie="__utmz="+z+"; path="+_utcp+";"+x+_udo; return ""; }
+ }
+ z=dc.indexOf("__utmz="+_udh+".");
+ if (z>-1) { z=_uGC(dc,"__utmz="+_udh+".",";"); }
+ else { z="-"; }
+ t=_uGC(s,_ucid+"=","&");
+ t2=_uGC(s,_ucsr+"=","&");
+ t3=_uGC(s,"gclid=","&");
+ if ((t!="-" && t!="") || (t2!="-" && t2!="") || (t3!="-" && t3!="")) {
+  if (t!="-" && t!="") c+="utmcid="+_uEC(t);
+  if (t2!="-" && t2!="") { if (c != "") c+="|"; c+="utmcsr="+_uEC(t2); }
+  if (t3!="-" && t3!="") { if (c != "") c+="|"; c+="utmgclid="+_uEC(t3); }
+  t=_uGC(s,_uccn+"=","&");
+  if (t!="-" && t!="") c+="|utmccn="+_uEC(t);
+  else c+="|utmccn=(not+set)";
+  t=_uGC(s,_ucmd+"=","&");
+  if (t!="-" && t!="") c+="|utmcmd="+_uEC(t);
+  else  c+="|utmcmd=(not+set)";
+  t=_uGC(s,_uctr+"=","&");
+  if (t!="-" && t!="") c+="|utmctr="+_uEC(t);
+  else { t=_uOrg(1); if (t!="-" && t!="") c+="|utmctr="+_uEC(t); }
+  t=_uGC(s,_ucct+"=","&");
+  if (t!="-" && t!="") c+="|utmcct="+_uEC(t);
+  t=_uGC(s,_ucno+"=","&");
+  if (t=="1") o=1;
+  if (z!="-" && o==1) return "";
+ }
+ if (c=="-" || c=="") { c=_uOrg(); if (z!="-" && _ufno==1)  return ""; }
+ if (c=="-" || c=="") { if (_ufns==1)  c=_uRef(); if (z!="-" && _ufno==1)  return ""; }
+ if (c=="-" || c=="") {
+  if (z=="-" && _ufns==1) { c="utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)"; }
+  if (c=="-" || c=="") return "";
+ }
+ if (z!="-") {
+  i=z.indexOf(".");
+  if (i>-1) i=z.indexOf(".",i+1);
+  if (i>-1) i=z.indexOf(".",i+1);
+  if (i>-1) i=z.indexOf(".",i+1);
+  t=z.substring(i+1,z.length);
+  if (t.toLowerCase()==c.toLowerCase()) cs=1;
+  t=z.substring(0,i);
+  if ((i=t.lastIndexOf(".")) > -1) {
+   t=t.substring(i+1,t.length);
+   cn=(t*1);
+  }
+ }
+ if (cs==0 || _ufns==1) {
+  t=_uGC(dc,"__utma="+_udh+".",";");
+  if ((i=t.lastIndexOf(".")) > 9) {
+   _uns=t.substring(i+1,t.length);
+   _uns=(_uns*1);
+  }
+  cn++;
+  if (_uns==0) _uns=1;
+  _ubd.cookie="__utmz="+_udh+"."+_ust+"."+_uns+"."+cn+"."+c+"; path="+_utcp+"; "+x+_udo;
+ }
+ if (cs==0 || _ufns==1) return "&utmcn=1";
+ else return "&utmcr=1";
+}
+function _uRef() {
+ if (_ur=="0" || _ur=="" || _ur=="-") return "";
+ var i=0,h,k,n;
+ if ((i=_ur.indexOf("://"))<0 || _uGCse()) return "";
+ h=_ur.substring(i+3,_ur.length);
+ if (h.indexOf("/") > -1) {
+  k=h.substring(h.indexOf("/"),h.length);
+  if (k.indexOf("?") > -1) k=k.substring(0,k.indexOf("?"));
+  h=h.substring(0,h.indexOf("/"));
+ }
+ h=h.toLowerCase();
+ n=h;
+ if ((i=n.indexOf(":")) > -1) n=n.substring(0,i);
+ for (var ii=0;ii<_uRno.length;ii++) {
+  if ((i=n.indexOf(_uRno[ii].toLowerCase())) > -1 && n.length==(i+_uRno[ii].length)) { _ufno=1; break; }
+ }
+ if (h.indexOf("www.")==0) h=h.substring(4,h.length);
+ return "utmccn=(referral)|utmcsr="+_uEC(h)+"|"+"utmcct="+_uEC(k)+"|utmcmd=referral";
+}
+function _uOrg(t) {
+ if (_ur=="0" || _ur=="" || _ur=="-") return "";
+ var i=0,h,k;
+ if ((i=_ur.indexOf("://"))<0 || _uGCse()) return "";
+ h=_ur.substring(i+3,_ur.length);
+ if (h.indexOf("/") > -1) {
+  h=h.substring(0,h.indexOf("/"));
+ }
+ for (var ii=0;ii<_uOsr.length;ii++) {
+  if (h.toLowerCase().indexOf(_uOsr[ii].toLowerCase()) > -1) {
+   if ((i=_ur.indexOf("?"+_uOkw[ii]+"=")) > -1 || (i=_ur.indexOf("&"+_uOkw[ii]+"=")) > -1) {
+    k=_ur.substring(i+_uOkw[ii].length+2,_ur.length);
+    if ((i=k.indexOf("&")) > -1) k=k.substring(0,i);
+    for (var yy=0;yy<_uOno.length;yy++) {
+     if (_uOno[yy].toLowerCase()==k.toLowerCase()) { _ufno=1; break; }
+    }
+    if (t) return _uEC(k);
+    else return "utmccn=(organic)|utmcsr="+_uEC(_uOsr[ii])+"|"+"utmctr="+_uEC(k)+"|utmcmd=organic";
+   }
+  }
+ }
+ return "";
+}
+function _uGCse() {
+ var h,p;
+ h=p=_ur.split("://")[1];
+ if(h.indexOf("/")>-1) {
+  h=h.split("/")[0];
+  p=p.substring(p.indexOf("/")+1,p.length);
+ }
+ if(p.indexOf("?")>-1) {
+  p=p.split("?")[0];
+ }
+ if(h.toLowerCase().indexOf("google")>-1) {
+  if(_ur.indexOf("?q=")>-1 || _ur.indexOf("&q=")>-1) {
+   if (p.toLowerCase().indexOf("cse")>-1) {
+    return true;
+   }
+  }
+ }
+}
+function _uBInfo() {
+ var sr="-",sc="-",ul="-",fl="-",cs="-",je=1;
+ var n=navigator;
+ if (self.screen) {
+  sr=screen.width+"x"+screen.height;
+  sc=screen.colorDepth+"-bit";
+ } else if (self.java) {
+  var j=java.awt.Toolkit.getDefaultToolkit();
+  var s=j.getScreenSize();
+  sr=s.width+"x"+s.height;
+ }
+ if (n.language) { ul=n.language.toLowerCase(); }
+ else if (n.browserLanguage) { ul=n.browserLanguage.toLowerCase(); }
+ je=n.javaEnabled()?1:0;
+ if (_uflash) fl=_uFlash();
+ if (_ubd.characterSet) cs=_uES(_ubd.characterSet);
+ else if (_ubd.charset) cs=_uES(_ubd.charset);
+ return "&utmcs="+cs+"&utmsr="+sr+"&utmsc="+sc+"&utmul="+ul+"&utmje="+je+"&utmfl="+fl;
+}
+function __utmSetTrans() {
+ var e;
+ if (_ubd.getElementById) e=_ubd.getElementById("utmtrans");
+ else if (_ubd.utmform && _ubd.utmform.utmtrans) e=_ubd.utmform.utmtrans;
+ if (!e) return;
+ var l=e.value.split("UTM:");
+ var i,i2,c;
+ if (_userv==0 || _userv==2) i=new Array();
+ if (_userv==1 || _userv==2) { i2=new Array(); c=_uGCS(); }
+
+ for (var ii=0;ii<l.length;ii++) {
+  l[ii]=_uTrim(l[ii]);
+  if (l[ii].charAt(0)!='T' && l[ii].charAt(0)!='I') continue;
+  var r=Math.round(Math.random()*2147483647);
+  if (!_utsp || _utsp=="") _utsp="|";
+  var f=l[ii].split(_utsp),s="";
+  if (f[0].charAt(0)=='T') {
+   s="&utmt=tran"+"&utmn="+r;
+   f[1]=_uTrim(f[1]); if(f[1]&&f[1]!="") s+="&utmtid="+_uES(f[1]);
+   f[2]=_uTrim(f[2]); if(f[2]&&f[2]!="") s+="&utmtst="+_uES(f[2]);
+   f[3]=_uTrim(f[3]); if(f[3]&&f[3]!="") s+="&utmtto="+_uES(f[3]);
+   f[4]=_uTrim(f[4]); if(f[4]&&f[4]!="") s+="&utmttx="+_uES(f[4]);
+   f[5]=_uTrim(f[5]); if(f[5]&&f[5]!="") s+="&utmtsp="+_uES(f[5]);
+   f[6]=_uTrim(f[6]); if(f[6]&&f[6]!="") s+="&utmtci="+_uES(f[6]);
+   f[7]=_uTrim(f[7]); if(f[7]&&f[7]!="") s+="&utmtrg="+_uES(f[7]);
+   f[8]=_uTrim(f[8]); if(f[8]&&f[8]!="") s+="&utmtco="+_uES(f[8]);
+  } else {
+   s="&utmt=item"+"&utmn="+r;
+   f[1]=_uTrim(f[1]); if(f[1]&&f[1]!="") s+="&utmtid="+_uES(f[1]);
+   f[2]=_uTrim(f[2]); if(f[2]&&f[2]!="") s+="&utmipc="+_uES(f[2]);
+   f[3]=_uTrim(f[3]); if(f[3]&&f[3]!="") s+="&utmipn="+_uES(f[3]);
+   f[4]=_uTrim(f[4]); if(f[4]&&f[4]!="") s+="&utmiva="+_uES(f[4]);
+   f[5]=_uTrim(f[5]); if(f[5]&&f[5]!="") s+="&utmipr="+_uES(f[5]);
+   f[6]=_uTrim(f[6]); if(f[6]&&f[6]!="") s+="&utmiqt="+_uES(f[6]);
+  }
+  if (_udl.hostname && _udl.hostname!="") s+="&utmhn="+_uES(_udl.hostname);
+  if (_usample && _usample != 100) s+="&utmsp="+_uES(_usample);
+
+  if ((_userv==0 || _userv==2) && _uSP()) {
+   i[ii]=new Image(1,1);
+   i[ii].src=_ugifpath+"?"+"utmwv="+_uwv+s;
+   i[ii].onload=function() { _uVoid(); }
+  }
+  if ((_userv==1 || _userv==2) && _uSP()) {
+   i2[ii]=new Image(1,1);
+   i2[ii].src=_ugifpath2+"?"+"utmwv="+_uwv+s+"&utmac="+_uacct+"&utmcc="+c;
+   i2[ii].onload=function() { _uVoid(); }
+  }
+ }
+ return;
+}
+function _uFlash() {
+ var f="-",n=navigator;
+ if (n.plugins && n.plugins.length) {
+  for (var ii=0;ii<n.plugins.length;ii++) {
+   if (n.plugins[ii].name.indexOf('Shockwave Flash')!=-1) {
+    f=n.plugins[ii].description.split('Shockwave Flash ')[1];
+    break;
+   }
+  }
+ } else {
+  var fl;
+  try {
+   fl = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
+   f = fl.GetVariable("$version");
+  } catch(e) {}
+  if (f == "-") {
+   try {
+    fl = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
+    f = "WIN 6,0,21,0";
+    fl.AllowScriptAccess = "always";
+    f = fl.GetVariable("$version");
+   } catch(e) {}
+  }
+  if (f == "-") {
+   try {
+    fl = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+    f = fl.GetVariable("$version");
+   } catch(e) {}
+  }
+  if (f != "-") {
+   f = f.split(" ")[1].split(",");
+   f = f[0] + "." + f[1] + " r" + f[2];
+  }
+ }
+ return f;
+}
+function __utmLinkerUrl(l,h) {
+ var p,k,a="-",b="-",c="-",x="-",z="-",v="-";
+ var dc=_ubd.cookie;
+ var iq = l.indexOf("?");
+ var ih = l.indexOf("#");
+ var url=l;
+ if (dc) {
+  a=_uES(_uGC(dc,"__utma="+_udh+".",";"));
+  b=_uES(_uGC(dc,"__utmb="+_udh,";"));
+  c=_uES(_uGC(dc,"__utmc="+_udh,";"));
+  x=_uES(_uGC(dc,"__utmx="+_udh,";"));
+  z=_uES(_uGC(dc,"__utmz="+_udh+".",";"));
+  v=_uES(_uGC(dc,"__utmv="+_udh+".",";"));
+  k=(_uHash(a+b+c+x+z+v)*1)+(_udh*1);
+  p="__utma="+a+"&__utmb="+b+"&__utmc="+c+"&__utmx="+x+"&__utmz="+z+"&__utmv="+v+"&__utmk="+k;
+ }
+ if (p) {
+  if (h && ih>-1) return;
+  if (h) { url=l+"#"+p; }
+  else {
+   if (iq==-1 && ih==-1) url=l+"?"+p;
+   else if (ih==-1) url=l+"&"+p;
+   else if (iq==-1) url=l.substring(0,ih-1)+"?"+p+l.substring(ih);
+   else url=l.substring(0,ih-1)+"&"+p+l.substring(ih);
+  }
+ }
+ return url;
+}
+function __utmLinker(l,h) {
+ if (!_ulink || !l || l=="") return;
+ _udl.href=__utmLinkerUrl(l,h);
+}
+function __utmLinkPost(f,h) {
+ if (!_ulink || !f || !f.action) return;
+ f.action=__utmLinkerUrl(f.action, h);
+ return;
+}
+function __utmSetVar(v) {
+ if (!v || v=="") return;
+ if (!_udo || _udo == "") {
+  _udh=_uDomain();
+  if (_udn && _udn!="") { _udo=" domain="+_udn+";"; }
+ }
+ if (!_uVG()) return;
+ var r=Math.round(Math.random() * 2147483647);
+ _ubd.cookie="__utmv="+_udh+"."+_uES(v)+"; path="+_utcp+"; expires="+_uNx()+";"+_udo;
+ var s="&utmt=var&utmn="+r;
+ if (_usample && _usample != 100) s+="&utmsp="+_uES(_usample);
+ if ((_userv==0 || _userv==2) && _uSP()) {
+  var i=new Image(1,1);
+  i.src=_ugifpath+"?"+"utmwv="+_uwv+s;
+  i.onload=function() { _uVoid(); }
+ }
+ if ((_userv==1 || _userv==2) && _uSP()) {
+  var i2=new Image(1,1);
+  i2.src=_ugifpath2+"?"+"utmwv="+_uwv+s+"&utmac="+_uacct+"&utmcc="+_uGCS();
+  i2.onload=function() { _uVoid(); }
+ }
+}
+function _uGCS() {
+ var t,c="",dc=_ubd.cookie;
+ if ((t=_uGC(dc,"__utma="+_udh+".",";"))!="-") c+=_uES("__utma="+t+";+");
+ if ((t=_uGC(dc,"__utmx="+_udh,";"))!="-") c+=_uES("__utmx="+t+";+");
+ if ((t=_uGC(dc,"__utmz="+_udh+".",";"))!="-") c+=_uES("__utmz="+t+";+");
+ if ((t=_uGC(dc,"__utmv="+_udh+".",";"))!="-") c+=_uES("__utmv="+t+";");
+ if (c.charAt(c.length-1)=="+") c=c.substring(0,c.length-1);
+ return c;
+}
+function _uGC(l,n,s) {
+ if (!l || l=="" || !n || n=="" || !s || s=="") return "-";
+ var i,i2,i3,c="-";
+ i=l.indexOf(n);
+ i3=n.indexOf("=")+1;
+ if (i > -1) {
+  i2=l.indexOf(s,i); if (i2 < 0) { i2=l.length; }
+  c=l.substring((i+i3),i2);
+ }
+ return c;
+}
+function _uDomain() {
+ if (!_udn || _udn=="" || _udn=="none") { _udn=""; return 1; }
+ if (_udn=="auto") {
+  var d=_ubd.domain;
+  if (d.substring(0,4)=="www.") {
+   d=d.substring(4,d.length);
+  }
+  _udn=d;
+ }
+ _udn = _udn.toLowerCase(); 
+ if (_uhash=="off") return 1;
+ return _uHash(_udn);
+}
+function _uHash(d) {
+ if (!d || d=="") return 1;
+ var h=0,g=0;
+ for (var i=d.length-1;i>=0;i--) {
+  var c=parseInt(d.charCodeAt(i));
+  h=((h << 6) & 0xfffffff) + c + (c << 14);
+  if ((g=h & 0xfe00000)!=0) h=(h ^ (g >> 21));
+ }
+ return h;
+}
+function _uFixA(c,s,t) {
+ if (!c || c=="" || !s || s=="" || !t || t=="") return "-";
+ var a=_uGC(c,"__utma="+_udh+".",s);
+ var lt=0,i=0;
+ if ((i=a.lastIndexOf(".")) > 9) {
+  _uns=a.substring(i+1,a.length);
+  _uns=(_uns*1)+1;
+  a=a.substring(0,i);
+  if ((i=a.lastIndexOf(".")) > 7) {
+   lt=a.substring(i+1,a.length);
+   a=a.substring(0,i);
+  }
+  if ((i=a.lastIndexOf(".")) > 5) {
+   a=a.substring(0,i);
+  }
+  a+="."+lt+"."+t+"."+_uns;
+ }
+ return a;
+}
+function _uTrim(s) {
+  if (!s || s=="") return "";
+  while ((s.charAt(0)==' ') || (s.charAt(0)=='\n') || (s.charAt(0,1)=='\r')) s=s.substring(1,s.length);
+  while ((s.charAt(s.length-1)==' ') || (s.charAt(s.length-1)=='\n') || (s.charAt(s.length-1)=='\r')) s=s.substring(0,s.length-1);
+  return s;
+}
+function _uEC(s) {
+  var n="";
+  if (!s || s=="") return "";
+  for (var i=0;i<s.length;i++) {if (s.charAt(i)==" ") n+="+"; else n+=s.charAt(i);}
+  return n;
+}
+function __utmVisitorCode(f) {
+ var r=0,t=0,i=0,i2=0,m=31;
+ var a=_uGC(_ubd.cookie,"__utma="+_udh+".",";");
+ if ((i=a.indexOf(".",0))<0) return;
+ if ((i2=a.indexOf(".",i+1))>0) r=a.substring(i+1,i2); else return "";  
+ if ((i=a.indexOf(".",i2+1))>0) t=a.substring(i2+1,i); else return "";  
+ if (f) {
+  return r;
+ } else {
+  var c=new Array('A','B','C','D','E','F','G','H','J','K','L','M','N','P','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9');
+  return c[r>>28&m]+c[r>>23&m]+c[r>>18&m]+c[r>>13&m]+"-"+c[r>>8&m]+c[r>>3&m]+c[((r&7)<<2)+(t>>30&3)]+c[t>>25&m]+c[t>>20&m]+"-"+c[t>>15&m]+c[t>>10&m]+c[t>>5&m]+c[t&m];
+ }
+}
+function _uIN(n) {
+ if (!n) return false;
+ for (var i=0;i<n.length;i++) {
+  var c=n.charAt(i);
+  if ((c<"0" || c>"9") && (c!=".")) return false;
+ }
+ return true;
+}
+function _uES(s,u) {
+ if (typeof(encodeURIComponent) == 'function') {
+  if (u) return encodeURI(s);
+  else return encodeURIComponent(s);
+ } else {
+  return escape(s);
+ }
+}
+function _uUES(s) {
+ if (typeof(decodeURIComponent) == 'function') {
+  return decodeURIComponent(s);
+ } else {
+  return unescape(s);
+ }
+}
+function _uVG() {
+ if((_udn.indexOf("www.google.") == 0 || _udn.indexOf(".google.") == 0 || _udn.indexOf("google.") == 0) && _utcp=='/' && _udn.indexOf("google.org")==-1) {
+  return false;
+ }
+ return true;
+}
+function _uSP() {
+ var s=100;
+ if (_usample) s=_usample;
+ if(s>=100 || s<=0) return true;
+ return ((__utmVisitorCode(1)%10000)<(s*100));
+}
+function urchinPathCopy(p){
+ var d=document,nx,tx,sx,i,c,cs,t,h,o;
+ cs=new Array("a","b","c","v","x","z");
+ h=_uDomain(); if (_udn && _udn!="") o=" domain="+_udn+";";
+ nx=_uNx()+";";
+ tx=new Date(); tx.setTime(tx.getTime()+(_utimeout*1000));
+ tx=tx.toGMTString()+";";
+ sx=new Date(); sx.setTime(sx.getTime()+(_ucto*1000));
+ sx=sx.toGMTString()+";";
+ for (i=0;i<6;i++){
+  t=" expires=";
+  if (i==1) t+=tx; else if (i==2) t=""; else if (i==5) t+=sx; else t+=nx;
+  c=_uGC(d.cookie,"__utm"+cs[i]+"="+h,";");
+  if (c!="-") d.cookie="__utm"+cs[i]+"="+c+"; path="+p+";"+t+o;
+ }
+}
+function _uCO() {
+ if (!_utk || _utk=="" || _utk.length<10) return;
+ var d='www.google.com';
+ if (_utk.charAt(0)=='!') d='analytics.corp.google.com';
+ _ubd.cookie="GASO="+_utk+"; path="+_utcp+";"+_udo;
+ var sc=document.createElement('script');
+ sc.type='text/javascript';
+ sc.id="_gasojs";
+ sc.src='https://'+d+'/analytics/reporting/overlay_js?gaso='+_utk+'&'+Math.random();
+ document.getElementsByTagName('head')[0].appendChild(sc);  
+}
+function _uGT() {
+ var h=location.hash, a;
+ if (h && h!="" && h.indexOf("#gaso=")==0) {
+  a=_uGC(h,"gaso=","&");
+ } else {
+  a=_uGC(_ubd.cookie,"GASO=",";");
+ }
+ return a;
+}
+var _utk=_uGT();
+if (_utk && _utk!="" && _utk.length>10 && _utk.indexOf("=")==-1) {
+ if (window.addEventListener) {
+  window.addEventListener('load', _uCO, false); 
+ } else if (window.attachEvent) { 
+  window.attachEvent('onload', _uCO);
+ }
+}
+
+function _uNx() {
+  return (new Date((new Date()).getTime()+63072000000)).toGMTString();
+}
Index: /gs3-extensions/hathitrust-downloadfrom/trunk/htc-catalog-search.pl
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/htc-catalog-search.pl	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/htc-catalog-search.pl	(revision 26436)
@@ -0,0 +1,198 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+
+use LWP;
+
+use OAuth::Lite::Consumer;
+use OAuth::Lite::AuthMethod;
+
+use WWW::Mechanize;
+
+# use CGI;
+
+
+sub data_api
+{
+    my ($doc_id) = @_;
+
+    #my $access_key = 'PUBLIC_OAUTH_CONSUMER_KEY';
+    #my $secret_key = 'PUBLIC_OAUTH_CONSUMER_SECRET';
+
+    my $access_key = '7e6ee38bae';                   # PUBLIC_OAUTH_CONSUMER_KEY
+    my $secret_key = 'e0429c0394385486249b4a230702'; # PUBLIC_OAUTH_CONSUMER_SECRET
+
+    #my $request_url = 'http://babel.hathitrust.org/cgi/htd/dapiserver';
+    #my $request_url = "http://babel.hathitrust.org/cgi/htd/meta/mdp.39015019203879";
+    my $request_url = "http://babel.hathitrust.org/cgi/htd/pagemeta/mdp.39015000000128/12";
+
+
+    my $consumer = OAuth::Lite::Consumer->new( 'consumer_key' => $access_key,
+					       'consumer_secret' => $secret_key,
+					       'auth_method' => OAuth::Lite::AuthMethod::URL_QUERY );
+
+    my $response = $consumer->request( 'method' => 'GET',
+				       'url' => $request_url,
+ #	  			       'params' => { 'hello' => 'world' } 
+	);
+
+#    print CGI::header();
+
+#    print "<p><b>[CLIENT] sent this URL to server:</b><br/>";
+#    print $consumer->oauth_request->uri;
+    
+#    print "<p><b>[CLIENT] received this HTTP response from server:</b><br/>";
+#    print $response->status_line;
+    
+    if ($response->is_success) {
+#	print "<br/><b>[CLIENT] received this content response from server:</b><blockquote>" .
+#	    $response->content . "</blockquote>";
+
+	print "Recieved content:\n";
+	print "------\n";
+
+	print $response->content()
+    }
+    else {
+	print STDERR "**** Failed to retrieval any content from URL:\n";
+	print STDERR "         ", $consumer->oauth_request->uri, "\n";
+	print STDERR "**** Status: ", print $response->status_line, "\n";
+	
+    }
+
+
+##    print STDERR "*****\n ", $consumer->oauth_request->uri, "\n";
+}
+
+
+sub bibliographic_api
+{
+    my ($catalog_id) = @_;
+    
+    my $catalog_json = "$catalog_id.json";
+    my $base_url = "http://catalog.hathitrust.org/api/volumes/full/recordnumber";
+    my $url = "$base_url/$catalog_json";
+
+    my $ua = LWP::UserAgent->new();
+#    $ua->agent("Greenstone DL Ingest");
+
+    # make request
+    my $request = HTTP::Request->new(GET => $url);
+
+    # get response
+    my $response = $ua->request($request);
+
+    if ($response->is_success()) {
+
+	my $content_type = $response->content_type();
+	
+	my $content = $response->content();
+
+	my $group_by_dir = "output";
+
+	if (!-d $group_by_dir) {
+	    print "Creating '$group_by_dir'\n";
+	    mkdir($group_by_dir);
+	}
+
+	my @group_by = ($catalog_id =~ m/\d{1,2}/g);
+
+	while (my $next_subdir = shift @group_by) {
+	    $group_by_dir .= "/$next_subdir";
+	    if (!-d $group_by_dir) {
+		mkdir($group_by_dir);
+	    }
+
+	    last if (scalar(@group_by)==1);	    
+	}
+
+	my $ofilename = "$group_by_dir/$catalog_json";
+	if (!-e $ofilename) {
+	    if (open(JOUT,">$ofilename")) {
+		
+		print JOUT $content;
+		print JOUT "\n";
+		close(JOUT);
+	    }
+	    else {
+		print STDERR "Error: Failed to open $ofilename\n";
+		print STDERR "!$\n";
+	    }
+	}
+	else {
+	    print STDOUT "$ofilename already exists.  Skipping.\n";
+	}
+    }
+    else 
+    {
+	print STDERR "Error: Failed to retrieve $url\n";
+	print STDERR "-----\n";
+	print STDERR "Status line: ", $response->status_line(), "\n";
+	print STDERR "    ", $response->content(),"\n";
+    }
+}
+
+
+
+sub main
+{
+
+    my ($argv_ref) = @_;
+
+    my $query=join("+",@$argv_ref) || "zealand";
+    
+    my $base_url = "http://catalog.hathitrust.org/Search/Home?checkspelling=true&type=all&submit=&type=all&sethtftonly=true";
+    my $url = $base_url . "&lookfor=" . $query;
+
+    my $mech = WWW::Mechanize->new();
+    $mech->get($url);
+    
+    my $next_link = $mech->find_link( text_regex => qr/^Next\s+/);
+    
+    my $count=0;
+    
+    while (defined($next_link)) {
+
+
+	my $catalog_links    = $mech->find_all_links(text_regex => qr/^Catalog Record\s*/);
+#    my $full_links       = $mech->find_all_links(text_regex => qr/^Full view\s*$/,
+#						 url_regex => qr/hdl\.handle\.net/);
+#    my $restricted_links = $mech->find_all_links(text_regex => qr/^Limited \(search-only\)/,  
+#						 url_regex => qr/hdl\.handle\.net/);
+
+	my $num_catalog_links    = scalar(@$catalog_links);
+#    my $num_full_links       = scalar(@$full_links);
+#    my $num_restricted_links = scalar(@$restricted_links);
+
+#    print "+++++ num cat links $num_catalog_links: num full = $num_full_links, num restricted = $num_restricted_links\n";
+
+	
+	foreach my $cat_link (@$catalog_links) {
+	    my $cat_url = $cat_link->url();
+	    my ($cat_id) = ($cat_url =~ m/\/([^\/]*)$/);
+	    print "cat id = $cat_id\n";
+	    bibliographic_api($cat_id);
+	}
+
+
+	$url = $next_link->url();
+	
+	$mech->get($url);
+	$next_link = $mech->find_link( text_regex => qr/^Next\s+/);
+
+	$count++;
+	
+##	last if ($count==1);
+
+	print "Away to Process link: $url\n"; 
+
+    }
+    
+}
+
+
+main(\@ARGV);
+
+
+
Index: /gs3-extensions/hathitrust-downloadfrom/trunk/htc-get-pd-docs.pl
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/htc-get-pd-docs.pl	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/htc-get-pd-docs.pl	(revision 26436)
@@ -0,0 +1,484 @@
+#!/usr/bin/perl -w
+
+use strict;
+no strict 'refs'; # allow filehandles to be variables and viceversa
+
+use warnings;
+
+use Encode;
+use JSON;
+
+# use LWP;
+
+use OAuth::Lite::Consumer;
+use OAuth::Lite::AuthMethod;
+
+use URI::Escape;
+
+sub _data_api
+{
+    my ($mode,$htid,$opt_seq,$opt_params) = @_;
+
+    my $access_key = '7e6ee38bae';                   
+    my $secret_key = 'e0429c0394385486249b4a230702'; 
+
+    my $request_url = "http://babel.hathitrust.org/cgi/htd/$mode/$htid";
+
+    $request_url .= "/$opt_seq" if (defined $opt_seq);
+
+    my $consumer = OAuth::Lite::Consumer->new( 'consumer_key' => $access_key,
+					       'consumer_secret' => $secret_key,
+					       'auth_method' => OAuth::Lite::AuthMethod::URL_QUERY );
+
+    my $response = $consumer->request( 'method' => 'GET',
+				       'url' => $request_url,
+				       'params' => $opt_params );
+    
+    if (!$response->is_success()) {
+	print STDERR "**** Failed to retrieval any content from URL:\n";
+	print STDERR "         ", $consumer->oauth_request->uri, "\n";
+	print "------\n";
+	print STDERR "**** Status:  ", $response->status_line, "\n";
+	print "------\n";
+	print STDERR "**** Content: ", $response->content, "\n";
+	print "------\n";
+	
+	$response = undef;
+    }
+
+    return $response;
+}
+
+
+sub pageimage_data_api
+{
+    my ($htid,$seq_num,$ofilename) = @_;
+
+    if (!-f $ofilename) {
+	print STDERR "Downloading PageImage $htid/$seq_num\n";
+
+	my $response = _data_api("pageimage",$htid, $seq_num );
+	my $content = $response->content();
+
+	if (open(IMGOUT,">$ofilename")) {       
+	    binmode(IMGOUT);	   
+	    print IMGOUT $content;
+	    close(IMGOUT);
+	}
+	else {
+	    print STDERR "Error: Failed to open $ofilename for binary output\n";
+	    print STDERR "       $!\n";
+	}    
+    }
+    else {
+	print STDERR "Skipping PageImage data API request\n";
+	print STDERR "=> downloaded file $ofilename already exists\n";
+    }
+}
+    
+
+
+sub pageocr_data_api
+{
+    my ($htid,$seq_num,$ofilename) = @_;
+
+    my $content = undef;
+
+    if (((defined $ofilename) && (!-f $ofilename))
+	|| (!defined $ofilename)) {
+	print STDERR "Downloading PageOCR (text) $htid/$seq_num\n";
+	    
+	my $response = _data_api("pageocr",$htid, $seq_num );
+	$content = $response->content();
+	
+	if (open(TXTOUT,">$ofilename")) {       
+	    print TXTOUT $content;
+	    close(TXTOUT);
+	}
+	else {
+	    print STDERR "Error: Failed to open $ofilename for binary output\n";
+	    print STDERR "       $!\n";
+	}    
+    }
+    else {
+	print STDERR "Skipping PageOCR Data API request\n";
+	print STDERR "=> Using cached version of file:\n    $ofilename\n";
+	
+	if (open(JSIN,"<$ofilename")) {
+	    binmode(JSIN,":utf8");
+
+	    my $line;
+	    while (defined ($line=<JSIN>)) {
+		$content .= $line;
+	    }
+	    close(JSIN);
+	}
+	else {
+	    print STDERR "Error: Failed to open cached file $ofilename for input\n";
+	    print STDERR "       $!\n";
+	}
+    }
+
+    return $content;
+}
+    
+sub json_structure_data_api
+{
+    my ($htid,$ofilename) = @_;
+
+    my $json_content = "";
+
+    if (!-f $ofilename) {
+	print STDERR "Downloading METS structure record for $htid\n";
+
+	my $response = _data_api("structure",$htid, undef, {'alt' => "json"} );
+	$json_content = $response->content();
+
+	if (open(JSOUT,">$ofilename")) {
+	    binmode(JSOUT,":utf8");
+	    print JSOUT $json_content;
+	    close(JSOUT);
+	}
+	else {
+	    print STDERR "Error: Failed to open $ofilename for output\n";
+	    print STDERR "       $!\n";
+	}
+	
+    }
+    else {
+	print STDERR "Skipping Structure Data API request\n";
+	print STDERR "=> Using cached version of JSON structure file:\n    $ofilename\n";
+
+	if (open(JSIN,"<$ofilename")) {
+	    binmode(JSIN,":utf8");
+
+	    my $line;
+	    while (defined ($line=<JSIN>)) {
+		$json_content .= $line;
+	    }
+	    close(JSIN);
+	}
+	else {
+	    print STDERR "Error: Failed to open cached JSON file $ofilename for input\n";
+	    print STDERR "       $!\n";
+	}
+    }
+
+##    print "**** $json_content\n";
+
+    my $json_content_utf8 = Encode::encode("utf8",$json_content);
+    my $json_data = decode_json $json_content_utf8;
+
+    return $json_data;
+
+
+}
+
+
+# Example file
+
+#<PagedDocument>
+#  <Metadata name="Title">Matariki 1881</Metadata>
+#  <Metadata name="Date">18810423</Metadata>
+#  <Metadata name="Number">1</Metadata>
+#  <PageGroup>
+#    <Metadata name="Title">Supplementary Material</Metadata>
+#    <Page txtfile="abstracts/23__1abstract.txt">
+#      <Metadata name="Title">Abstract</Metadata>
+#    </Page>
+#  </PageGroup>
+#  <PageGroup>
+#    <Metadata name="Title">Newspaper pages</Metadata>
+#    <Page pagenum="1" imgfile="images/23__1_1.gif" txtfile="text/23__1_1.txt"/>
+#    <Page pagenum="2" imgfile="images/23__1_2.gif" txtfile="text/23__1_2.txt"/>
+#    <Page pagenum="3" imgfile="images/23__1_3.gif" txtfile="text/23__1_3.txt"/>
+#  </PageGroup>
+#</PagedDocument>
+
+sub rec_paged_image_structure
+{
+    my ($this_div,$pagenum,$elem_name,$depth,$htid,$file_id_map,$resource_output_dir) = @_;
+
+    my ($local_output_dir) = ($resource_output_dir =~ m/^.*\/(.*?)$/);
+
+    print PIOUT "  " x $depth, "<$elem_name>\n";
+
+    my $fptr_entry = $this_div->{'METS:fptr'};
+    
+    if (defined $fptr_entry) {
+	# hit a leaf node
+
+	my $fptr_array = undef;
+
+	if (ref $fptr_entry eq "HASH") {
+	    $fptr_array = [ $fptr_entry ];
+	}
+	else  {
+	    $fptr_array = $fptr_entry;
+	}
+
+	my $imgfile = undef;
+	my $txtfile = undef;
+
+	foreach my $fptr_hash (@$fptr_array) {
+	    my $fileid = $fptr_hash->{'FILEID'};
+
+##	    print STDERR "Looking up fileid = $fileid\n";
+
+	    my $file = $file_id_map->{$fileid};
+	    my $seq  = $file->{'SEQ'};
+	    my $href = $file->{'METS:FLocat'}->{'xlink:href'};
+
+	    if ($file->{'USE'} =~ m/\bimage\b/i) {		
+		$imgfile = "$local_output_dir/$href";
+		my $full_imgfile = "$resource_output_dir/$href";
+		pageimage_data_api($htid,$seq,$full_imgfile);
+	    }
+	    elsif ($file->{'USE'} =~ m/\bocr\b/i) {
+		$txtfile = "$local_output_dir/$href";
+		my $full_txtfile = "$resource_output_dir/$href";
+		pageocr_data_api($htid,$seq,$full_txtfile);
+	    }
+	}
+	# Generate line along the following lines
+
+	#  <Page pagenum="1" imgfile="images/23__1_1.gif" txtfile="text/23__1_1.txt"/>
+	print PIOUT "  " x ($depth+1), "<Page ";
+	print PIOUT "pagenum=\"$pagenum\" " if defined $pagenum;
+	print PIOUT "imgfile=\"$imgfile\" " if defined $imgfile;
+	print PIOUT "txtfile=\"$txtfile\" " if defined $txtfile;
+	print PIOUT "/>\n";
+	
+    }
+        
+    # Now process any child divs
+
+    my $div_entry = $this_div->{'METS:div'};
+
+    if (defined $div_entry) {
+
+	my $div_array = undef;
+
+	if (ref $div_entry eq "HASH") {
+	    # upgrade single entry to array
+	    $div_array = [ $div_entry ];
+	}
+	else {
+	    $div_array = $div_entry;
+	}
+
+	foreach my $div_hash (@$div_array) {
+
+	    my $pagenum = $div_hash->{'ORDER'};
+	    
+	    rec_paged_image_structure($div_hash,$pagenum,"PageGroup",$depth+1,$htid,$file_id_map,$resource_output_dir);
+	}
+    }
+
+
+    print PIOUT "  " x $depth, "</$elem_name>\n";
+
+}
+
+sub generate_paged_image_structure
+{
+    my ($toplevel_div,$htid,$file_id_map,$ofilename) = @_;
+    
+    print STDERR "Generating PageImage file: $ofilename\n";
+
+    my ($resource_output_dir) = ($ofilename =~ m/^(.*)\..+?$/);
+    if (!-d $resource_output_dir) {
+	mkdir $resource_output_dir;
+    }
+    
+    if (open(PIOUT,">$ofilename")) {
+	binmode(PIOUT,":utf8");
+
+	rec_paged_image_structure($toplevel_div,1,"PageDocument",0,$htid,$file_id_map,$resource_output_dir);
+
+	close(PIOUT);
+    }
+    else {
+	print STDERR "Error: Failed to open $ofilename for output\n";
+	print STDERR "       $!\n";
+    }
+
+
+
+}
+
+
+sub download_ht_doc
+{
+    my ($cat_key,$htid,$ofilename) = @_;
+
+    my $json_data = json_structure_data_api($htid,$ofilename);
+
+    # Map in the IDs from:
+    # METS:mets->METS:fileSec->METS:fileGrp
+
+    my $file_sec_ids = {};
+    
+    my $file_grp_array = $json_data->{'METS:mets'}->{'METS:fileSec'}->{'METS:fileGrp'};
+
+#    print "**** num file grps = ", scalar(@$file_grp_array), "\n";
+
+    foreach my $file_grp (@$file_grp_array) {
+
+	my $use = $file_grp->{'USE'};
+
+	my $file_entry = $file_grp->{'METS:file'};
+
+	my $file_array = undef;
+
+	if (ref $file_entry eq "HASH") {
+	    # upgrade single entry into array
+	    $file_array = [ $file_entry ];
+	}
+	else {
+	    $file_array = $file_entry;
+	}
+
+#	    print "**** num files = ", scalar(@$file_array), "\n";
+
+	foreach my $file_hash (@$file_array) {
+	    # push file_grp USE attribute down into each file entry (to make file easier later on)
+	    $file_hash->{'USE'} = $use;
+
+	    my $file_id = $file_hash->{'ID'};
+	    $file_sec_ids->{$file_id} = $file_hash;
+	    
+#	    print "file id = $file_id\n";
+	}
+
+    }
+
+    # METS:mets->METS:structMap->{nested METS:div}+
+
+    my $struct_map_array = $json_data->{'METS:mets'}->{'METS:structMap'};
+    my $toplevel_div = $struct_map_array->{'METS:div'};
+
+    my $pi_filename = $ofilename;
+    $pi_filename =~ s/_structure\.json$/_item.xml/;
+
+    generate_paged_image_structure($toplevel_div,$htid,$file_sec_ids,$pi_filename);
+
+
+##    print "**** json_content = $json_content_utf8\n\n";
+
+    exit 0;
+
+}
+
+sub read_json_file
+{
+    my ($filename) = @_;
+
+    print STDERR "+ Proccessing file: $filename\n";
+
+    my $json_file_content = "";
+    open(JSON_FILE, "<$filename");
+    binmode(JSON_FILE,":utf8");
+
+    my $line;
+    while (defined ($line=<JSON_FILE>)) {
+	$json_file_content .= $line;
+    }
+
+    close(JSON_FILE);
+
+    my $json_file_content_utf8 = Encode::encode("utf8",$json_file_content);
+    my $json_data = decode_json $json_file_content_utf8;
+    
+    my $record_hash = $json_data->{'records'};
+    my @record_keys = keys %$record_hash;
+    my $primary_cat_key = shift @record_keys;
+
+    my $items_array = $json_data->{'items'};
+    my $num_items = scalar(@$items_array);
+
+    my $num_pd = 0;
+
+    foreach my $item (@$items_array) {
+	
+	my $htid = $item->{'htid'};
+	my $rights_code = $item->{'rightsCode'};
+
+#	print "htid = $htid\n";
+#	print "Rights code = $rights_code\n" if defined $rights_code;
+
+	if (defined($rights_code) && ($rights_code eq "pd")) {
+	    # in the public domain
+	    $num_pd++;
+
+	    my $htid_safe = uri_escape($htid);
+
+	    my $ofilename = $filename;
+	    $ofilename =~ s/\.json/_structure.json/;
+
+	    download_ht_doc($primary_cat_key,$htid,$ofilename);
+
+	    # bail out at first public domain version of document
+	    last;
+	}
+    }
+
+#    if ($num_pd==0) {
+#	print "++ $num_items item(s)\n";
+#    }
+#    else {
+#	print "++ $num_items item(s) *of* *which* $num_pd is/are in the public domain\n";
+#    }
+
+}
+
+
+sub process_dir
+{
+    my ($full_dir) = @_;
+
+#    print "Processing directory: $full_dir\n";
+    
+    if (opendir(DIN, $full_dir)) {
+	my @dir_content = grep { $_ !~ m/^\./ }  readdir(DIN);
+	closedir DIN;
+
+	foreach my $df (@dir_content) {
+	    my $full_df = "$full_dir/$df";
+	    if (-d $full_df) {
+		my $full_sub_dir = $full_df;
+		process_dir($full_sub_dir);
+	    }
+	    else {
+		# file
+		my $full_file = $full_df;
+		if ($full_file =~ m/\.json$/) {
+		    read_json_file($full_file);
+		}
+	    }
+	}
+
+    }
+    else {
+	
+	print STDERR "Error: Failed to open directory: $full_dir\n";
+	print STDERR "       $!\n";
+    }
+
+}
+
+
+sub main
+{
+    my ($argv_ref) = @_;
+
+    my $toplevel_dir = shift @$argv_ref || "output";
+    
+
+    $toplevel_dir =~ s/\/$//; # remove any trailing /
+
+    process_dir($toplevel_dir);
+
+}
+
+main(\@ARGV);
Index: /gs3-extensions/hathitrust-downloadfrom/trunk/signed-htc-get-data-api.pl
===================================================================
--- /gs3-extensions/hathitrust-downloadfrom/trunk/signed-htc-get-data-api.pl	(revision 26436)
+++ /gs3-extensions/hathitrust-downloadfrom/trunk/signed-htc-get-data-api.pl	(revision 26436)
@@ -0,0 +1,48 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+
+use CGI;
+use OAuth::Lite::Consumer;
+use OAuth::Lite::AuthMethod;
+
+#my $access_key = 'PUBLIC_OAUTH_CONSUMER_KEY';
+#my $secret_key = 'PUBLIC_OAUTH_CONSUMER_SECRET';
+
+my $access_key = '7e6ee38bae';                   # PUBLIC_OAUTH_CONSUMER_KEY
+my $secret_key = 'e0429c0394385486249b4a230702'; # PUBLIC_OAUTH_CONSUMER_SECRET
+
+#my $request_url = 'http://babel.hathitrust.org/cgi/htd/dapiserver';
+#my $request_url = "http://babel.hathitrust.org/cgi/htd/meta/mdp.39015019203879";
+my $request_url = "http://babel.hathitrust.org/cgi/htd/pagemeta/mdp.39015000000128/12";
+
+
+my $consumer = OAuth::Lite::Consumer->new( 'consumer_key' => $access_key,
+					   'consumer_secret' => $secret_key,
+					   'auth_method' => OAuth::Lite::AuthMethod::URL_QUERY );
+
+my $response = $consumer->request( 'method' => 'GET',
+				   'url' => $request_url,
+#				   'params' => { 'hello' => 'world' } 
+);
+
+print CGI::header();
+
+print "<p><b>[CLIENT] sent this URL to server:</b><br/>";
+print $consumer->oauth_request->uri;
+
+print "<p><b>[CLIENT] received this HTTP response from server:</b><br/>";
+print $response->status_line;
+
+if ($response->is_success) {
+    print "<br/><b>[CLIENT] received this content response from server:</b><blockquote>" .
+	$response->content . "</blockquote>";
+}
+
+print STDERR "*****\n ", $consumer->oauth_request->uri, "\n";
+
+
+exit 0;
+
+
