added jstore path
[bookreader.git] / BookReaderIA / test / BookReaderTest.php
1 <?php
2
3 /*
4 Copyright(c) 2010 Internet Archive. Software license AGPL version 3.
5
6 This file is part of BookReader.  The full source code can be found at GitHub:
7 http://github.com/openlibrary/bookreader
8
9 Author:
10   Michael Ang <http://github.com/mangtronix>
11
12     BookReader is free software: you can redistribute it and/or modify
13     it under the terms of the GNU Affero General Public License as published by
14     the Free Software Foundation, either version 3 of the License, or
15     (at your option) any later version.
16
17     BookReader is distributed in the hope that it will be useful,
18     but WITHOUT ANY WARRANTY; without even the implied warranty of
19     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20     GNU Affero General Public License for more details.
21
22     You should have received a copy of the GNU Affero General Public License
23     along with BookReader.  If not, see <http://www.gnu.org/licenses/>.
24 */
25
26 require_once('../datanode/BookReaderImages.inc.php');
27
28 try {
29     switch ($_REQUEST['test']) {
30         case 'pageparse':
31             $bri = new BookReaderImages();
32             ok('text/javascript');
33             print( json_encode($bri->parsePageRequest($_REQUEST['value'], $_REQUEST['bookPrefix'])) );
34             break;
35             
36         default:
37             ok('text/html');
38             print "<html><head><title>BookReader Tests</title></head>";
39             print "<body>";
40             print "<h1>Available tests</h1>";
41             print "<pre>";
42             print "<a href='BookReaderTest.php?test=pageparse&value=cover_r4.jpg'>pageparse</a> value bookPrefix";
43             print "</body>";
44             print "</html>";
45             break;
46     }
47     
48 } catch (Exception $e) {
49     print "Error serving request:\n";
50     print "  " . $e->getMessage() . "\n\n";
51     print "Debugging information:\n";
52     echo $e->getTraceAsString();
53 }
54
55 function ok($type) {
56     header('HTTP/1.0 200 OK');
57     header('Content-type: ' . $type);
58 }
59
60 ?>