Zim.3pm

Langue: en

Autres versions - même langue

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

Section: 3 (Bibliothèques de fonctions)

NAME

Zim - Application object for the zim desktop wiki

SYNOPSIS

         use Zim;
 
         my $repo = Zim->new( dir => $dir );
         my $page = $repo->get_page('Home');
 
 

DESCRIPTION

This class defines the public interface to the document repository as used by zim(1). It acts as a dispatcher that manages one or more store objects to handle page requests. It also adds some tests and thus tries to isolate the stores from errors in the GUI. These repositories are called ``notebooks'' in the UI

The interface which child objects should support is defined in Zim::Store.

SIGNALS

This following signals are emitted by this object:
"config_changed"
Any othe object changing our config should call "signal_emit" for this signal in order to notify all other objects.

METHODS

Public Methods

The following methods can be used by the GUI.
new(%PARAM)
Constructor. Parameters can be:
         dir - top leve ldirectory for the notebook
         type - type of the (default) top level store object
         parent - parent object in case we are nested
         namespace - namespace in case we are nested
 
 
"add_child(NAMESPACE, CHILD, ...)"
This will connect a new child object to this repository under a certain namespace. CHILD is a class name implementing the store interface. The class will be looked for in "Zim::Store::". All remaining arguments will be passed on to the constructor of the object.
"init_history()"
Open or initialize the history for this notebook. Returns an object of class Zim::History.
"init_vcs(VCS, \%ARGS)"
Initializes a Version Control System for the top level notebook dir. VCS is the system you want to use, e.g. 'Bazaar'. Only needs to be called for notebooks that are not yet under version control.
"save()"
Save config, history, etc. to disk.
"root()"
Returns self.
"list_pages(NAMESPACE)"
Lists pages in NAMESPACE. Sub-namespaces have a trailing ':' in the listing.

If a page is not present in this list that does not mean that it doesn't exists. This list is used for hierarchical views of the page structure; not all stores need to support a hierarchical order.

get_page(NAME)
Returns an object of a class inheriting from Zim::Page. When you ask for a page that doesn't exists yet, you should get a new object. In case it is not possible to create the page in question "undef" is returned.
"resolve_page(LINK, PAGE, REFERENCE, NO_DEFAULT)"
Convenience function combining "resolve_name()" and "get_page()".
"resolve_name(LINK, PAGE, REFERENCE, NO_DEFAULT)"
Cleans up NAME but does not actually fetch a page object.
"resolve_namespace(NAME)"
Returns a namespace string. Used to sanitize user input.
copy_page(SOURCE, TARGET, UPDATE_LINKS)
Copy page SOURCE to TARGET. Both arguments can be either page names or objects. Returns the (new) TARGET object. The UPDATE_LINKS argument is a boolean that tells whether links to this page should be updated to point to this new name.
move_page(SOURCE, TARGET, UPDATE_LINKS)
Move page SOURCE to TARGET. Both arguments can be either page names or objects. Returns the (new) TARGET object.The UPDATE_LINKS argument is a boolean that tells whether links to this page should be updated to point to this new name.
delete_page(PAGE)
Delete PAGE. PAGE can be either a page name or a page object.
"list_backlinks(PAGE)"
Returns a list of links to this page.
"search(QUERY, CALLBACK)"
TODO stable api for this using Zim::Selection

Results are given as arguments to CALLBACK in the form "[PAGE, SCORE]".

"interwiki_lookup(KEY, PAGE)"
Returns an url for an interwiki link with interwiki name KEY and page PAGE. Lookup for names is case in-sensitive.

Document Interface

This interface is used to deal with external documents that belong to the notebook. Think of these documents as attachments.

See detailed docs in Zim::Store.

"document_dir(PAGE)"
Returns the document dir for PAGE or undef. Returns top level dir if PAGE is undefined.
"document_root()"
Returns the document root or undef.
"store_file(FILE, PAGE)"
Stores FILE in the document dir.
"resolve_file(PATH, PAGE)"
Resolve a linked file.
"relative_path(PATH, PAGE)"
Returns a relative path for creating links.

Class Methods

These methods can be called as "Zim->method(...)".
"get_notebook_config(DIR)"
Return a config file for the notebook at DIR or undef.

Also can be called as object method on the main notebook object.

"get_notebook_cache(DIR)"
Returns a dir to store e.g. history and other state files. By default this is either ``.zim/'' in the notebook directory or a directory under XDG_CACHE.

Also can be called as object method on the main notebook object.

"is_notebook(DIR)"
Returns true if DIR is the root of a notebook.
"get_notebook(NAME)"
Returns a path for notebook NAME. Special names are:
         _default_       default notebook
         _doc_           help manual
 
 
"get_notebook_list()"
Returns a list of array references containing name and path for known notebooks.
"set_notebook_list()"
Save a list of array references containing name and path for known notebooks.
"check_version_control(DIR)"
Checks if DIR is under one of the supported version control systems and returns an object for the root dir of the version control repository or undef.

BUGS

Please mail the author if you find any bugs.

AUTHOR

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

Copyright (c) 2005 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(1), Zim::Store