// $$$ 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;
$foundImageStack = $filename;
}
}
-
+
if ($foundScandata && $foundImageStack) {
return true;
}
{
// Set title to default if not set
if (!$title) {
- $title = 'Bookreader';
+ $title = 'BookReader';
}
$id = $identifier;
// 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.17";
+ $version = "r25";
+
+ if (BookReader::getDevHost($server)) {
+ // on dev host - add time to force reload
+ $version .= '_' . time();
+ }
if ("" == $id) {
echo "No identifier specified!";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
+ <meta name="viewport" content="width=device-width, maximum-scale=1.0" />
<title><? echo $title; ?></title>
<!--[if lte IE 6]>
<meta http-equiv="refresh" content="2; URL=/bookreader/browserunsupported.php?id=<? echo($id); ?>">
<link rel="stylesheet" type="text/css" href="/bookreader/BookReader.css?v=<? echo($version); ?>">
<? if ($uiMode == "embed") { ?>
<link rel="stylesheet" type="text/css" href="/bookreader/BookReaderEmbed.css?v=<? echo($version); ?>">
+<? } elseif ($uiMode == "touch") { ?>
+ <link rel="stylesheet" type="text/css" href="/bookreader/touch/BookReaderTouch.css?v=<? echo($version); ?>">
<? } /* uiMode */ ?>
- <script src="/includes/jquery-1.3.2.min.js" type="text/javascript"></script>
- <script type="text/javascript" src="/bookreader/BookReader.js?v=<? echo($version); ?>"></script>
- <script type="text/javascript" src="/bookreader/jquery.easing.1.3.js"></script>
+ <script src="/includes/jquery-1.4.2.min.js" type="text/javascript"></script>
+ <script type="text/javascript" src="/bookreader/jquery-ui-1.8.1.custom.min.js"></script>
+ <script type="text/javascript" src="/bookreader/dragscrollable.js"></script>
+ <script type="text/javascript" src="/bookreader/BookReader.js?v=<? echo($version); ?>"></script>
</head>
<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">
brConfig["mode"] = 2;
<? } ?>
</script>
+<!-- The script included below is dynamically generated JavaScript that includes the book metadata and page image access functions -->
<script type="text/javascript" src="<? echo($metaURL); ?>"></script>
<? if ($uiMode == 'full') { ?>
<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>
exit;
}
- public static function jsMetadataURL($server, $identifier, $mainDir, $subPrefix = '')
+ // Returns the user part of dev host from URL, or null
+ public static function getDevHost($server)
{
- $serverBaseURL = $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)) {
+ if (preg_match("/^www-(\w+)/", $_SERVER["SERVER_NAME"], $match)) {
+ return $match[1];
+ }
+
+ return null;
+ }
+
+
+ public static function serverBaseURL($server)
+ {
+ // Check if we're on a dev vhost and point to JSIA in the user's public_html
+ // on the datanode
// $$$ 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');
- if (in_array($match[1], $devhosts)) {
- $serverBaseURL = $serverBaseURL . ":81/~" . $match[1];
+ $devhost = BookReader::getDevHost($server);
+ $devhosts = array('mang', 'testflip', 'rkumar');
+ if (in_array($devhost, $devhosts)) {
+ $server = $server . "/~" . $devhost;
}
- }
-
+ 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;
return $url;
}
+ // Return the URL for the requested /download/$path, or null
+ public static function getURL($path, $item) {
+ // $path should look like {itemId}/{operator}/{filename}
+ // Other operators may be added
+
+ $parts = preg_split('#/#', $path, 3);
+ if (count($parts) != 3) {
+ return null;
+ }
+ $identifier = $parts[0];
+ $operator = $parts[1];
+ $filename = $parts[2];
+
+ $serverBaseURL = BookReader::serverBaseURL($item->getServer());
+
+ switch ($operator) {
+ case 'page':
+ // Find bookId and which page was requested
+ $pathParts = pathinfo($filename);
+
+ // Look for preview request
+ if (preg_match('/^(.*)_(cover|title|preview)$/', $pathParts['filename'], $matches) === 0) {
+ return null;
+ }
+ $bookId = $matches[1];
+ $page = $matches[2];
+ $query = array(
+ 'id' => $identifier,
+ 'bookId' => $bookId,
+ 'itemPath' => $item->getMainDir(),
+ 'server' => $serverBaseURL,
+ 'page' => $page,
+ );
+ return 'http://' . $serverBaseURL . '/BookReader/BookReaderPreview.php?' . http_build_query($query, '', '&');
+
+ default:
+ return null;
+ }
+
+ return null; // was not handled
+ }
+
}
- ?>
+
+?>
\ No newline at end of file