X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=BookReaderIA%2Finc%2FBookReader.inc;h=68eff3c2a7e6b62b3caf9ce8dd5f3d5ae5476d2f;hb=e08b87d9dd895da41cb728db29ea8bf33e0bdbfd;hp=585ee1d0368cf77bf20e87e41452a14d3c82b571;hpb=22e65b2d601696ad0ae34d27367887bd5251a308;p=bookreader.git diff --git a/BookReaderIA/inc/BookReader.inc b/BookReaderIA/inc/BookReader.inc index 585ee1d..68eff3c 100644 --- a/BookReaderIA/inc/BookReader.inc +++ b/BookReaderIA/inc/BookReader.inc @@ -1,8 +1,23 @@ "> - + + + + + - + - -
Internet Archive BookReader
- -
Internet Archive Bookreader
- + +//
Internet Archive BookReader
+// +//
Internet Archive Bookreader
+// +*/ +?> + +
Internet Archive BookReader
+ + +
+
+
+
+ + + + + + + +
+
I. The Minotaur | Page 1
+
+ +
+
II. The Griffon | Page 44
+
+ +
+
III. The Firedrake | Page 129
+
+ +
+
V. The Pegasus | Page 201
+
+ +
+
VI. The Goblin | Page 255
+
+ +
+
+ A related distinction is between the emotion and the results of the emotion, principally behaviors and emotional expressions. People often behave in certain ways as a direct result of their emotional state, such as crying, fighting or fleeing. Page 163 +
IV. The Witch | Page 163
+
+
+ +
+
- +

@@ -170,6 +383,29 @@ class BookReader $(document).ready(function() { $(window).trigger('resize'); }); + + //XXXmang + function hideFace() { + $('#BookReader').die('mousemove').live('mousemove',function(event) { + var toolpos = $('#BRtoolbar').offset(); + var tooltop = toolpos.top; + var navkey = $(document).height() - 75; + if ((event.pageY < 76) || (event.pageY > navkey)) { + if (tooltop == -60) { + $('#BRtoolbar').animate({top:'0'}); + $('#BRnav').animate({bottom:'0'}); + }; + } else if ($('.bt-wrapper').size() == 0) { + if (tooltop == 0) { + $('#BRtoolbar').animate({top:'-60'}); + $('#BRnav').animate({bottom:'-60'}); + } + }; + }); + }; + window.onload = function() { + window.setTimeout(hideFace, 3000); + }; getServer()); - + + // Baseline query params + $query = array( + 'id' => $identifier, + 'itemPath' => $item->getMainDir(), + 'server' => $serverBaseURL + ); + if ($subPrefix) { + $query['subPrefix'] = $subPrefix; + } + 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; + // 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, '', '&'); + } + + // 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, '', '&'); } - $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, '', '&'); + + // Asking for a non-preview page + $query['page'] = $filename; + return 'http://' . $serverBaseURL . '/BookReader/BookReaderImages.php?' . http_build_query($query, '', '&'); default: + // Unknown operator return null; } @@ -297,6 +552,42 @@ class BookReader } return array(); } + + public static function parsePath($path) { + // Parse the BookReader path and return the parts + // e.g. itemid/some/sub/dir/page/cover.jpg -> array( 'identifier' => 'itemid', 'subPrefix' => 'some/sub/dir', + // 'operator' => 'page', 'filename' => 'cover.jpg') + + $parts = array(); + + // Pull off query, e.g. ?foo=bar + if (preg_match('#(.*?)(\?.*)#', $path, $matches) === 1) { + $parts['query'] = $matches[2]; + $path = $matches[1]; + } + + // Pull off identifier + if (preg_match('#[^/&?]+#', $path, $matches) === 0) { + // no match + return $parts; + } + $parts['identifier'] = $matches[0]; + $path = substr($path, strlen($matches[0])); + + // Look for operators + // The sub-prefix can be arbitrary, so we match up until the first operator + $operators = '(' . join('|', self::$downloadOperators) . ')'; + $pattern = '#(?P.*?)/(?P' . $operators . ')/(?P.*)#'; + if (preg_match($pattern, $path, $matches) === 1) { + $parts['subPrefix'] = substr($matches['subPrefix'], 1); // remove leading '/' + $parts['operator'] = $matches['operator']; + $parts['operand'] = $matches['operand']; + } else { + $parts['subPrefix'] = $path; + } + + return $parts; + } }