On 07/30/2016 11:40 AM, Gavin Smith wrote:
On 21 July 2016 at 08:11, Per Bothner <[email protected]> wrote:
I've mentioned earlier using JavaScript to generate a table-of-contents
side-bar using Javascript, similar to the Kawa homepage (which is
https://www.gnu.org/software/kawa/ and is currently generated ahead-of-time,
without using JavaScript).
I went ahead and implemented this for the Kawa epub version.
I wrote some JavaScript that loads the epub table-of-contents
page (in Kawa's case bk01-toc.xhtml) and loads it into a
either an iframe or a frameset, depending on the URL used.
Furthermore, it hides and unhides nodes in the ToC so it
only shows the most interesting links (basically children,
ancestors, and siblings).
I downloaded and tried opening a few of the files included, but I
didn't get any of the "smart" behaviour. I tried opening
bk01-toc.xhtml, index.xhtml and a couple of others. Is this supposed
to work in a regular web browser?
Sorry; my instructions were incomplete. I can suggest 3 ways to try it:
(1) Unzip kawa-manual.epub.
(I assume you tried this, but I failed to specify the URLs to use.)
Then point Firefox at either (appropriately adjusted):
file:///tmp/kawa-2.1.9/doc/OEBPS/index.xhtml?sidebar
or:
file:///tmp/kawa-2.1.9/doc/OEBPS/with-frames.html
The former uses an iframe; the latter old-fashioned framesets.
NOTE: Neither of these work with Chrome (you get a scrambled sidebar).
I believe this has to do with a security restriction on file: URLs,
but I haven't investigated. I should do that.
(2) Use a web-server to serve the pages - avoiding the problems
with file: URLs.
Kawa has a convenient web-server. You don't need Kawa installed, since
it's in the zip file. For example:
/tmp/kawa-2.1.9/bin/kawa --http-auto-handler / /tmp/kawa-2.1.9/doc/
--http-start 8888
and then browse http://127.0.0.1:8888/.
This assumes 'java' is in your path. For example on Fedora the installed
/usr/bin/java does fine.
This gets you the sidebar/iframes by default. To get the frameset version,
requires a patch (attached). Then you can browse to:
http://127.0.0.1:8888/with-frames.html
(3) Use the JavaFX builtin-web browser. To do that you just need to:
/tmp/kawa-2.1.9/bin/browse-kawa-manual
This also requires 'java' to be in your path, but it has to be a version
of java that includes JavaFX. Java SE 8 downloaded from Oracle has it.
/usr/bin/java on Fedora doesn't.
--
--Per Bothner
[email protected] http://per.bothner.com/
Index: doc/+default+
===================================================================
--- doc/+default+ (revision 8895)
+++ doc/+default+ (working copy)
@@ -24,6 +24,8 @@
(define response-type
(cond
((local-path:endsWith ".css") 'text/css)
+ ((local-path:endsWith ".html") 'text/html)
+ ((local-path:endsWith ".png") 'image/png)
((local-path:endsWith ".js") 'application/javascript)
(else 'application/xhtml+xml)))