Zim::Store::Gjots.3pm

Langue: en

Autres versions - même langue

Version: 2009-02-23 (debian - 07/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Zim::Store::Gjots - Class for opening .gjots files

DESCRIPTION

This module read .gjots files. The format is the format used by the gjots2(1) program. Acording to the man page of this program the format is also the same as used for the (old) kjots(1) and jots(1) programs.

The format is very simple, there are just 3 directives:

         \NewEntry       start a new page
         \NewFolder      start a new namespace
         \EndFolder      end of the namespace
 
 

Pages do not have any formatting and the first line, which may be empty, is used as the page title. Titles do not have to be unique.

We read the whole file to memory, which puts certain limits on scalebility, however the gjots format seems to be mainly used for large numbers of very short entries, which may take a lot of overhead when saved as individual files.

This Store only implements reading gjots files for now. Adding write support is left as an exercise for the reader.

METHODS

"list_pages(NAMESPACE)"
This method should return a list of pages in NAMESPACE. The list is used by the gui to produce a hierarchical index, it does not tell anything about the actual existence of the pages.

The default returns an empty list.

"get_page(NAME)"
Returns a Zim::Page object or "undef".
"resolve_case(\@NAME, \@REF)"
Private method called by "resolve_name()". To be overloaded by child classes.

NAME contains the parts of the pagename we are looking for. REF contains parts of the pagename we use as base for a relative lookup. Try to match the first part of NAME in the path defined by REF. If REF is undefined, just start from ``:''.

"document_dir(PAGE)"
Returns the dir where the gjots file is. Just in case anyone tries to atach files etc.

Private Methods

"parse_gjots(FILE)"
Reads a gjots file and returns a data structure like:
         [ title, body,
                 [title, body],
                 [title, body,
                         [title, body],
                         ...
                 ],
                 ...
         ]
 
 

Title is simply the first line of the body, but can have a number attached to make it unique. The file name is used as title for the top level node.

"get_entry(TREE, NAME)"
Returns the node in the tree that maps to a page name.

BUGS

Please mail the author if you find any bugs.

AUTHOR

Jaap Karssenberg || Pardus [Larus] <pardus@cpan.org>

Copyright (c) 2008 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Zim, Zim::Store, gjots2(1)