From 58cceebf12bef2963f1da327d4e8344359add18e Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 24 Jun 2012 00:56:29 +0200 Subject: [PATCH] tweaks for missing pages --- plack/lib/Plack/App/BookReader.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plack/lib/Plack/App/BookReader.pm b/plack/lib/Plack/App/BookReader.pm index 8cc9422..f3f26f3 100644 --- a/plack/lib/Plack/App/BookReader.pm +++ b/plack/lib/Plack/App/BookReader.pm @@ -108,6 +108,7 @@ br.getPageHeight = function(index) { // We load the images from archive.org -- you can modify this function to retrieve images // using a different URL structure br.getPageURI = function(index, reduce, rotate) { + if ( ! pages[index] ) return; // reduce and rotate are ignored in this simple implementation, but we // could e.g. look at reduce and load images from a different directory // or pass the information to an image server @@ -167,7 +168,7 @@ br.getPageNum = function(index) { br.numLeafs = pages.length; // Book title and the URL used for the book title link -br.bookTitle= 'Open Library BookReader Presentation'; +br.bookTitle= '%s'; br.bookUrl = 'http://openlibrary.org'; // Override the path used to find UI images @@ -306,9 +307,10 @@ sub serve_path { $pages = decode_json read_file $pages_path; } else { $pages = [ + grep { defined $_ } map { my ( $w, $h ) = imgsize("$path/$_"); - $w && $h ? [ "$dir_url/$_", $w, $h ] : [] + $w && $h ? [ "$dir_url/$_", $w, $h ] : undef } sort { $a <=> $b } @page_files ]; make_basedir $pages_path; @@ -316,7 +318,7 @@ sub serve_path { warn "# created $pages_path ", -s $pages_path, " bytes\n"; } warn "# pages = ",dump($pages); - $page = sprintf $reader_page, $dir, encode_json( $pages ); + $page = sprintf $reader_page, $dir, encode_json( $pages ), $dir; # FIXME: title } else { -- 2.20.1