Add GnuBookDemo directory which contains a simple example of how to use the bookreader.
authorMichael Ang <gtronix@gmail.com>
Wed, 25 Feb 2009 23:36:41 +0000 (23:36 +0000)
committerMichael Ang <gtronix@gmail.com>
Wed, 25 Feb 2009 23:36:41 +0000 (23:36 +0000)
The demo pulls images from archive.org and requires an Internet connection.

GnuBook/GnuBookJSSimple.js [deleted file]
GnuBookDemo/GnuBookJSSimple.js [new file with mode: 0644]
GnuBookDemo/index.html [new file with mode: 0644]

diff --git a/GnuBook/GnuBookJSSimple.js b/GnuBook/GnuBookJSSimple.js
deleted file mode 100644 (file)
index 41b78b3..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//Copyright(c)2008 Internet Archive. Software license AGPL version 3.
-
-gb = new GnuBook();
-
-gb.getPageWidth = function(index) {
-    return 800;
-}
-
-gb.getPageHeight = function(index) {
-    return 1200;
-}
-
-gb.getPageURI = function(index) {
-    var leafStr = '000';            
-    var imgStr = (index+1).toString();
-    var re = new RegExp("0{"+imgStr.length+"}$");
-    var url = 'StandAloneImages/page'+leafStr.replace(re, imgStr) + '.jpg';
-    return url;
-}
-
-gb.getPageSide = function(index) {
-    if (0 == (index & 0x1)) {
-        return 'R';
-    } else {
-        return 'L';
-    }
-}
-
-gb.getPageNum = function(index) {
-    return index+1;
-}
-
-gb.numLeafs = 15;
-
-gb.bookTitle= 'Open Library Bookreader Presentation';
-gb.bookUrl  = 'http://openlibrary.org';
-gb.init();
diff --git a/GnuBookDemo/GnuBookJSSimple.js b/GnuBookDemo/GnuBookJSSimple.js
new file mode 100644 (file)
index 0000000..8d91879
--- /dev/null
@@ -0,0 +1,54 @@
+// 
+// This file shows the minimum you need to provide to GnuBook to display a book
+//
+// Copyright(c)2008-2009 Internet Archive. Software license AGPL version 3.
+
+// Create the GnuBook object
+gb = new GnuBook();
+
+// Return the width of a given page.  Here we assume all images are 800 pixels wide
+gb.getPageWidth = function(index) {
+    return 800;
+}
+
+// Return the height of a given page.  Here we assume all images are 1200 pixels high
+gb.getPageHeight = function(index) {
+    return 1200;
+}
+
+// We load the images from archive.org -- you can modify this function to retrieve images
+// using a different URL structure
+gb.getPageURI = function(index) {
+    var leafStr = '000';            
+    var imgStr = (index+1).toString();
+    var re = new RegExp("0{"+imgStr.length+"}$");
+    var url = 'http://www.archive.org/download/GnuBook/img/page'+leafStr.replace(re, imgStr) + '.jpg';
+    return url;
+}
+
+// Return which side, left or right, that a given page should be displayed on
+gb.getPageSide = function(index) {
+    if (0 == (index & 0x1)) {
+        return 'R';
+    } else {
+        return 'L';
+    }
+}
+
+// For a given "accessible page index" return the page number in the book.
+//
+// For example, index 5 might correspond to "Page 1" if there is front matter such
+// as a title page and table of contents.
+gb.getPageNum = function(index) {
+    return index+1;
+}
+
+// Total number of leafs
+gb.numLeafs = 15;
+
+// Book title and the URL used for the book title link
+gb.bookTitle= 'Open Library Bookreader Presentation';
+gb.bookUrl  = 'http://openlibrary.org';
+
+// Let's go!
+gb.init();
diff --git a/GnuBookDemo/index.html b/GnuBookDemo/index.html
new file mode 100644 (file)
index 0000000..48e5e35
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+
+<html>
+<head>
+    <title>bookreader demo</title>
+    <link rel="stylesheet" type="text/css" href="../GnuBook/GnuBook.css">    
+    <script type="text/javascript" src="http://www.archive.org/download/GnuBook/lib/jquery-1.2.6.min.js"></script>
+    <script type="text/javascript" src="http://www.archive.org/download/GnuBook/lib/jquery.easing.1.3.js"></script>
+    <script type="text/javascript" src="../GnuBook/GnuBook.js"></script>    
+</head>
+<body style="background-color: rgb(249, 248, 208);">
+
+<div id="GnuBook" style="left:10px; right:10px; top:10px; bottom:2em;">x</div>
+<script type="text/javascript" src="GnuBookJSSimple.js"></script>
+
+<div id="GBfooter">
+    <div class="GBlogotype">
+        <a href="http://openlibrary.org/" class="GBwhite">Open Library</a>
+        <a href="http://openlibrary.org/beta" class="GBwhite" style="font-size: 0.8em; text-decoration: underline;">beta</a>
+    </div>
+    <div class="GBnavlinks">
+        <a class="GBwhite" href="http://openlibrary.org/dev/docs/bookreader">About the Bookreader</a> |
+        <a class="GBwhite" href="https://bugs.launchpad.net/gnubook/+filebug-advanced">Report Errors</a> |
+        <a class="GBwhite" href="http://openlibrary.org/about">About Us</a> |
+        <a class="GBwhite" href="http://openlibrary.org/index/index.html">Index</a> |
+        <a class="GBwhite" href="http://www.archive.org/">IA</a> |
+        <a class="GBwhite" href="http://www.opencontentalliance.org/">OCA</a> |
+        <a class="GBwhite" href="http://wikimediafoundation.org/">WMF</a> |
+        <a class="GBwhite" href="http://openlibrary.org/about/contact">Contact Us</a>
+    </div>
+</div>
+
+</body>
+</html>