Merge Internet Archive petabox-related changes
authorMichael Ang <mang@archive.org>
Thu, 28 Jan 2010 01:35:03 +0000 (01:35 +0000)
committerMichael Ang <mang@archive.org>
Thu, 28 Jan 2010 01:35:03 +0000 (01:35 +0000)
Merge branch 'traceychanges' into 0.9.20

Conflicts:
BookReaderIA/inc/BookReader.inc
BookReaderIA/www/BookReaderJSLocate.php

1  2 
BookReaderIA/datanode/BookReaderJSIA.php
BookReaderIA/inc/BookReader.inc
BookReaderIA/www/BookReaderJSLocate.php

@@@ -173,12 -173,19 +173,19 @@@ class BookReade
        // $$$ 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)) {
 -        return $server . ":81/~" . $match[1]; //xxxx
 +        $serverBaseURL = $serverBaseURL . "/~" . $match[1];
        }
      }
-     
+     return $server;
+   }
+   
+   
+   public static function jsMetadataURL($server, $identifier, $mainDir, $subPrefix = '')
+   {
+     $serverBaseURL = BookReader::adjustToHome($server);
      $params = array( 'id' => $identifier, 'itemPath' => $mainDir, 'server' => $server );
      if ($subPrefix) {
          $params['subPrefix'] = $subPrefix;
@@@ -32,24 -31,9 +32,12 @@@ $locator      = new Locator()
  
  $results = $locator->locateUDP($id, 1, false);
  
- $server = $results[0][0];
- $vhost = $server;
- // 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', 'rkumar');
-     if (in_array($match[1], $devhosts)) {
-         $vhost = $server . ":81/~" . $match[1];
-     }
- }
+ $serverBaseURL = BookReader::adjustToHome($results[0][0]);
  
 -$url = "http://{$serverBaseURL}/BookReader/BookReaderJSIA.php?id={$id}&itemPath={$results[0][1]}&server={$serverBaseURL}";
 +$url = "http://{$vhost}/BookReader/BookReaderJSIA.php?id=" . urlencode($id) . "&itemPath={$results[0][1]}&server={$server}";
 +if ($book) {
 +    $url .= "&subPrefix=" . urlencode($book);
 +}
  
  
  if (("" != $results[0][0]) && ("" != $results[0][1])) {