Implementing a HyperBook interface
Implementing a HyperBook interface to a data collection
that satisfies the two HyperBook conventions, the following steps are required:
-
Define a subclass of
for your hyperbook type.
-
Define a subclass of
for pages in your hyperbook.
-
Implement the generic function
for your hyperbook class.
Additional generic functions can be implemented for optional functionality:
-
is called to
obtain a human-friendly title for a HyperBook or one of its pages.
The default implementation returns the id.
-
is called
to retrieve the id of the main page (home page, entry page) of a HyperBook
for display. The default implementation returns nil, indicating the
absence of a main page.
-
is called on a
page object to retrieve the links contained in the page. See
and its subclasses
and related functions to see how links are constructed.
-
If returns
a tree of when called
on a page object, HTML rendering is automatically provided and
takes care of retrieving the links in the page.
-
is used
by the to resolve a path extracted from a URL.
The default implementation accepts only one-element paths and interprets
the path item as a page id.
-
is used
by the to display the URL for a page.
The default implementation returns the page id.
Examples
There are a few example implementations that you can study:
-
Class
implements a hyperbook whose pages are the HTML files in a
directory. The hyperbook you are currently reading is written
this way. Most of the actual implementation is in the
system
to keep dependencies of the basic HyperBook code to a minimum.
Look at
and the surrounding code.
-
The three special hyperbooks
are implemented in the classes
, and
.
-
The interface is implemented in
a separate system, .
See class
and surrounding code.
-
The interface to Federated Wiki
is implemented in a separate system as well,
.
See class
and surrounding code.