Skip to content

Commit

Permalink
"preview" uses marked cover for books >= 1923. "cover0" returns first…
Browse files Browse the repository at this point in the history
… marked cover or 404
  • Loading branch information
mangtronix committed Dec 5, 2011
1 parent 3cd69e1 commit 4ce97e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions BookReaderIA/datanode/BookReaderImages.inc.php
Expand Up @@ -120,26 +120,24 @@ function serveLookupRequest($requestEnv) {
$imageIndex = $metadata['titleIndex'];
break;

/* Old 'cover' behaviour where it would show cover 0 if it exists or return 404.
Could be re-added as cover0, cover1, etc
case 'cover':
/* Old 'cover' behaviour where it would show cover 0 if it exists or return 404. */
case 'cover0':
if (! array_key_exists('coverIndices', $metadata)) {
$this->BRfatal("No cover asserted in book");
}
$imageIndex = $metadata['coverIndices'][0]; // $$$ TODO add support for other covers
break;
*/

case 'preview':
case 'cover': // Show our best guess if cover is requested
// Preference is:
// Cover page if book was published >= 1950
// Cover page if book was published >= 1923
// Title page
// Cover page
// Page 0

if ( array_key_exists('date', $metadata) && array_key_exists('coverIndices', $metadata) ) {
if ($brm->parseYear($metadata['date']) >= 1950) {
if ($brm->parseYear($metadata['date']) >= 1923) {
$imageIndex = $metadata['coverIndices'][0];
break;
}
Expand Down
2 changes: 1 addition & 1 deletion BookReaderIA/datanode/BookReaderPreview.php
Expand Up @@ -33,7 +33,7 @@ function BRfatal($message) {
die(-1);
}

$allowedPages = array('title','cover','preview');
$allowedPages = array('title','cover','cover0','preview');
$allowedPattern = '#^(' . join('|', $allowedPages) . ')#';

$page = $_REQUEST['page'];
Expand Down

0 comments on commit 4ce97e0

Please sign in to comment.