From b845ac259f02afd3a457cc61e4f07e30d64622c3 Mon Sep 17 00:00:00 2001 From: Michael Ang Date: Fri, 12 Jun 2009 21:36:24 +0000 Subject: [PATCH] Move Archive-specific files into different directories. --- GnuBookIA/GnuBookJP2.php | 77 --------- GnuBookIA/GnuBookJSLocate.php | 54 ------- GnuBookIA/{ => datanode}/GnuBookImages.php | 0 GnuBookIA/{ => datanode}/GnuBookJSIA.php | 0 .../{ => datanode}/flipbook_search_gb.php | 0 GnuBookIA/inc/GnuBook.inc | 149 ++++++++++++++++++ GnuBookIA/index.php | 89 ----------- GnuBookIA/{ => www}/GnuBookEmbed.php | 0 GnuBookIA/{ => www}/browserunsupported.php | 0 9 files changed, 149 insertions(+), 220 deletions(-) delete mode 100644 GnuBookIA/GnuBookJP2.php delete mode 100644 GnuBookIA/GnuBookJSLocate.php rename GnuBookIA/{ => datanode}/GnuBookImages.php (100%) rename GnuBookIA/{ => datanode}/GnuBookJSIA.php (100%) rename GnuBookIA/{ => datanode}/flipbook_search_gb.php (100%) create mode 100644 GnuBookIA/inc/GnuBook.inc delete mode 100644 GnuBookIA/index.php rename GnuBookIA/{ => www}/GnuBookEmbed.php (100%) rename GnuBookIA/{ => www}/browserunsupported.php (100%) diff --git a/GnuBookIA/GnuBookJP2.php b/GnuBookIA/GnuBookJP2.php deleted file mode 100644 index 5ac812a..0000000 --- a/GnuBookIA/GnuBookJP2.php +++ /dev/null @@ -1,77 +0,0 @@ -. -*/ - -header('Content-type: image/jpeg'); -header('Cache-Control: max-age=15552000'); - -$zipPath = $_REQUEST['zip']; -$file = $_REQUEST['file']; - - -if (isset($_REQUEST['height'])) { - $ratio = floatval($_REQUEST['origHeight']) / floatval($_REQUEST['height']); - if ($ratio <= 2) { - $reduce = 1; - } else if ($ratio <= 4) { - $reduce = 2; - } else { - //$reduce = 3; //too blurry! - $reduce = 1; - } - -} else { - $scale = $_REQUEST['scale']; - if (1 >= $scale) { - $reduce = 0; - } else if (2 == $scale) { - $reduce = 1; - } else if (4 == $scale) { - $reduce = 2; - } else { - $reduce = 3; - } -} - -if (!file_exists('/tmp/stdout.ppm')) -{ - system('ln -s /dev/stdout /tmp/stdout.ppm'); -} - - -putenv('LD_LIBRARY_PATH=/petabox/sw/lib/kakadu'); - - -$cmd = 'unzip -p ' . - escapeshellarg($zipPath) . - ' ' . - escapeshellarg($file) . - " | /petabox/sw/bin/kdu_expand -no_seek -quiet -reduce $reduce -i /dev/stdin -o /tmp/stdout.ppm "; - -if (isset($_REQUEST['height'])) { - $cmd .= " | pnmscale -height {$_REQUEST['height']} "; -} - -$cmd .= ' | pnmtojpeg -quality 90'; - - -passthru ($cmd); -#print $cmd; -?> - diff --git a/GnuBookIA/GnuBookJSLocate.php b/GnuBookIA/GnuBookJSLocate.php deleted file mode 100644 index 5ec166f..0000000 --- a/GnuBookIA/GnuBookJSLocate.php +++ /dev/null @@ -1,54 +0,0 @@ -. -*/ - -require_once '/petabox/setup.inc'; - -$id = $_REQUEST['id']; - -if ("" == $id) { - echo "No identifier specified!"; - die(-1); -} - -$locator = new Locator(); - -$results = $locator->locateUDP($id, 1, false); - -$serverBaseURL = $results[0][0]; - -// 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)) { - // $$$ the remapping isn't totally automatic yet and requires user to - // ln -s ~/petabox/www/datanode/GnuBook ~/public_html/GnuBook - // so we enable it only for known hosts - $devhosts = array('mang', 'testflip'); - if (in_array($match[1], $devhosts)) { - $serverBaseURL = $serverBaseURL . ":81/~" . $match[1]; - } -} - -$url = "http://{$serverBaseURL}/GnuBook/GnuBookJSIA.php?id={$id}&itemPath={$results[0][1]}&server={$serverBaseURL}"; - - -if (("" != $results[0][0]) && ("" != $results[0][1])) { - header("Location: $url"); -} - -?> \ No newline at end of file diff --git a/GnuBookIA/GnuBookImages.php b/GnuBookIA/datanode/GnuBookImages.php similarity index 100% rename from GnuBookIA/GnuBookImages.php rename to GnuBookIA/datanode/GnuBookImages.php diff --git a/GnuBookIA/GnuBookJSIA.php b/GnuBookIA/datanode/GnuBookJSIA.php similarity index 100% rename from GnuBookIA/GnuBookJSIA.php rename to GnuBookIA/datanode/GnuBookJSIA.php diff --git a/GnuBookIA/flipbook_search_gb.php b/GnuBookIA/datanode/flipbook_search_gb.php similarity index 100% rename from GnuBookIA/flipbook_search_gb.php rename to GnuBookIA/datanode/flipbook_search_gb.php diff --git a/GnuBookIA/inc/GnuBook.inc b/GnuBookIA/inc/GnuBook.inc new file mode 100644 index 0000000..cb8ba40 --- /dev/null +++ b/GnuBookIA/inc/GnuBook.inc @@ -0,0 +1,149 @@ +metadataGrabber->mainDir . '/'); + foreach ($item->getFiles() as $location => $fileInfo) { + $filename = substr($location, $baseLength); + + if ($checkOldScandata) { + if ($filename == 'scandata.xml' || $filename == 'scandata.zip') { + $foundScandata = $filename; + } + } + + if ($filename == $targetScandata) { + $foundScandata = $filename; + } + + if (preg_match($imageFormatRegex, $filename)) { + $foundImageStack = $filename; + } + } + + if ($foundScandata && $foundImageStack) { + return true; + } + + return false; + } + + public static function draw($server, $mainDir, $identifier, $title, + $coverleaf=null, $titlestart='Internet Archive') + { + // Set title to default if not set + if (!$title) { + $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.7"; + + if ("" == $id) { + echo "No identifier specified!"; + die(-1); + } + + $metaURL = GnuBook::jsMetadataURL($server, $identifier, $mainDir); +?> + + + + <? echo $title; ?> + + + + + + + + +
x
+ + + + +
+
+

+ +

+
+
+ Search results +
+
+ + +
+ + +
+ + + diff --git a/GnuBookIA/index.php b/GnuBookIA/index.php deleted file mode 100644 index 8c139dd..0000000 --- a/GnuBookIA/index.php +++ /dev/null @@ -1,89 +0,0 @@ -. -*/ - -$id = $_REQUEST['id']; - -// 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.5"; - -if ("" == $id) { - echo "No identifier specified!"; - die(-1); -} -?> - - - - bookreader demo - - - - - - - - - -
x
- - - - -
-
-

- -

-
-
- Search results -
-
- - -
- - -
- - - - - diff --git a/GnuBookIA/GnuBookEmbed.php b/GnuBookIA/www/GnuBookEmbed.php similarity index 100% rename from GnuBookIA/GnuBookEmbed.php rename to GnuBookIA/www/GnuBookEmbed.php diff --git a/GnuBookIA/browserunsupported.php b/GnuBookIA/www/browserunsupported.php similarity index 100% rename from GnuBookIA/browserunsupported.php rename to GnuBookIA/www/browserunsupported.php -- 2.20.1