Merged changes upstream
[bookreader.git] / BookReaderIA / inc / BookReader.inc
index ac0c6c6..1b2606f 100644 (file)
@@ -19,12 +19,12 @@ class BookReader
     // $$$ TODO add support for jpg and tar stacks
     // https://bugs.edge.launchpad.net/gnubook/+bug/323003
     // https://bugs.edge.launchpad.net/gnubook/+bug/385397
-    $imageFormatRegex = '@' . preg_quote($prefix, '@') . '_(jp2|tif)\.zip$@';
+    $imageFormatRegex = '@' . preg_quote($prefix, '@') . '_(jp2|tif|jpg)\.(zip|tar)$@';
     
     $baseLength = strlen($item->metadataGrabber->mainDir . '/');
     foreach ($item->getFiles() as $location => $fileInfo) {
         $filename = substr($location, $baseLength);
-
+        
         if ($checkOldScandata) {
             if ($filename == 'scandata.xml' || $filename == 'scandata.zip') {
                 $foundScandata = $filename;
@@ -39,7 +39,7 @@ class BookReader
             $foundImageStack = $filename;
         }
     }
-        
+    
     if ($foundScandata && $foundImageStack) {
         return true;
     }
@@ -81,7 +81,7 @@ class BookReader
     // manually update with Launchpad version number at each checkin so that browsers
     // do not use old cached version
     // see https://bugs.launchpad.net/gnubook/+bug/330748
-    $version = "0.9.18";
+    $version = "0.9.21";
     
     if ("" == $id) {
         echo "No identifier specified!";
@@ -109,9 +109,9 @@ class BookReader
 <body style="background-color: #FFFFFF;">
 
 <? if ($uiMode == 'full') { ?>
-<div id="BookReader" style="left:10px; right:200px; top:10px; bottom:2em;">x</div>
+<div id="BookReader" style="left:10px; right:200px; top:10px; bottom:2em;">Internet Archive BookReader <noscript>requires JavaScript to be enabled.</noscript></div>
 <? } else { ?>
-<div id="BookReader" style="left:0; right:0; top:0; bottom:0; border:0">x</div>
+<div id="BookReader" style="left:0; right:0; top:0; bottom:0; border:0">Internet Archive Bookreader <noscript>requires JavaScript to be enabled.</noscript></div>
 <? } /* uiMode*/ ?>
 
 <script type="text/javascript">
@@ -147,7 +147,7 @@ class BookReader
     <div class="BRnavlinks">
         <!-- <a class="BRblack" href="http://openlibrary.org/dev/docs/bookreader">About the Bookreader</a> | -->
         <a class="BRblack" href="http://www.archive.org/about/faqs.php#Report_Item">Content Problems</a> |
-        <a class="BRblack" href="https://bugs.launchpad.net/bookserver/+filebug-advanced">Report Bugs</a> |
+        <a class="BRblack" href="https://bugs.launchpad.net/bookreader/+filebug">Report Bugs</a> |
         <a class="BRblack" href="http://www.archive.org/details/texts">Texts Collection</a> |
         <a class="BRblack" href="http://www.archive.org/about/contact.php">Contact Us</a>
     </div>
@@ -163,22 +163,29 @@ class BookReader
   <?
     exit;
   }
+
   
-  public static function jsMetadataURL($server, $identifier, $mainDir, $subPrefix = '')
+  public static function serverBaseURL($server)
   {
-    $serverBaseURL = $server;
-    
-    // Check if we're on a dev vhost and point to JSIA in the user's public_html on the datanode
+    // Check if we're on a dev vhost and point to JSIA in the user's public_html
+    // on the datanode
     if (preg_match("/^www-(\w+)/", $_SERVER["SERVER_NAME"], $match)) {
       // $$$ the remapping isn't totally automatic yet and requires user to
       //     ln -s ~/petabox/www/datanode/BookReader ~/public_html/BookReader
       //     so we enable it only for known hosts
-      $devhosts = array('mang', 'testflip');
+      $devhosts = array('mang', 'testflip', 'rkumar');
       if (in_array($match[1], $devhosts)) {
-        $serverBaseURL = $serverBaseURL . ":81/~" . $match[1];
+        $server = $server . "/~" . $match[1];
       }
     }
-    
+    return $server;
+  }
+  
+  
+  public static function jsMetadataURL($server, $identifier, $mainDir, $subPrefix = '')
+  {
+    $serverBaseURL = BookReader::serverBaseURL($server);
+
     $params = array( 'id' => $identifier, 'itemPath' => $mainDir, 'server' => $server );
     if ($subPrefix) {
         $params['subPrefix'] = $subPrefix;