<?
+/*
+ *
+
+/*
+ * Note: Edits to this file must pass through github. To submit a patch to this
+ * file please contact mang at archive dot org or http://github.com/mangtronix
+ * Direct changes to this file may get clobbered when the code is synchronized
+ * from github.
+ */
+
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 = "r26a";
+ $version = "imageurls";
if (BookReader::getDevHost($server)) {
// on dev host - add time to force reload
<script type="text/javascript" src="/bookreader/jquery-ui-1.8.1.custom.min.js?v=<? echo($version); ?>"></script>
<script type="text/javascript" src="/bookreader/dragscrollable.js?v=<? echo($version); ?>"></script>
<script type="text/javascript" src="/bookreader/BookReader.js?v=<? echo($version); ?>"></script>
+ <script type="text/javascript" src="/bookreader/soundmanager/soundmanager2.js?v=<? echo($version); ?>"></script>
+ <script>
+ soundManager.debugMode = false;
+ soundManager.url = '/bookreader/soundmanager/swf/';
+ soundManager.useHTML5Audio = true;
+ </script>
</head>
<body style="background-color: #FFFFFF;">
// ln -s ~/petabox/www/datanode/BookReader ~/public_html/BookReader
// so we enable it only for known hosts
$devhost = BookReader::getDevHost($server);
- $devhosts = array('mang', 'testflip', 'rkumar');
+ $devhosts = array('mang', 'testflip', 'rkumar', 'mccabe');
if (in_array($devhost, $devhosts)) {
$server = $server . "/~" . $devhost;
}
switch ($operator) {
case 'page':
- // Find bookId and which page was requested
- $pathParts = pathinfo($filename);
- // Look for old-style preview request
- // $$$ currently ignoring file extension
- if (preg_match('/^(.*)_(cover|title|preview)/', $filename, $matches) === 0) {
- return null;
+ // Look for old-style preview request - e.g. {identifier}_cover.jpg
+ if (preg_match('/^(.*)_((cover|title|preview).*)/', $filename, $matches) === 1) {
+ // Serve preview image
+ $page = $matches[2];
+ $query['page'] = $page;
+ return 'http://' . $serverBaseURL . '/BookReader/BookReaderPreview.php?' . http_build_query($query, '', '&');
}
- $page = $matches[2];
- $query['page'] = $page;
+ // New-style preview request - e.g. cover_thumb.jpg
+ if (preg_match('/^(cover|title|preview)/', $filename, $matches) === 1) {
+ $query['page'] = $filename;
+ return 'http://' . $serverBaseURL . '/BookReader/BookReaderPreview.php?' . http_build_query($query, '', '&');
+ }
- return 'http://' . $serverBaseURL . '/BookReader/BookReaderPreview.php?' . http_build_query($query, '', '&');
+ // Asking for a non-preview page
+ $query['page'] = $filename;
+ return 'http://' . $serverBaseURL . '/BookReader/BookReaderImages.php?' . http_build_query($query, '', '&');
default:
// Unknown operator
$parts = array();
- // Pull off query
+ // Pull off query, e.g. ?foo=bar
if (preg_match('#(.*?)(\?.*)#', $path, $matches) === 1) {
$parts['query'] = $matches[2];
$path = $matches[1];
// Look for operators
// The sub-prefix can be arbitrary, so we match up until the first operator
$operators = '(' . join('|', self::$downloadOperators) . ')';
- $pattern = '#/(?P<subPrefix>.*?)/(?P<operator>' . $operators . ')/(?P<operand>.*)#';
+ $pattern = '#(?P<subPrefix>.*?)/(?P<operator>' . $operators . ')/(?P<operand>.*)#';
if (preg_match($pattern, $path, $matches) === 1) {
- $parts['subPrefix'] = $matches['subPrefix'];
+ $parts['subPrefix'] = substr($matches['subPrefix'], 1); // remove leading '/'
$parts['operator'] = $matches['operator'];
$parts['operand'] = $matches['operand'];
} else {