NAME
Template::Plugin::FileWiki - FileWiki plugin for Template Toolkit
SYNOPSIS
Usage in Template:
[% USE FileWiki %]
[% FileWiki.PageTree( <arguments...> ) %]
[% FileWiki.PageList( <arguments...> ) %]
[% FileWiki.Sitemap %]
[% FileWiki.DumpVars %]
[% FileWiki.Log %]
DESCRIPTION
FileWiki plugin for Template Toolkit.
Provides functions for displaying information from a FileWiki site structure from within a template.
METHODS
PageTree
Generate a HTML list (with sublists) of all pages, starting at ROOT node. Provides a flexible way to recurse into all pages.
See "Generic Function Arguments" below for the arguments taken.
Example:
[% FileWiki.PageTree( text_key => "menu",
title_key => "menu_title",
depth => 2,
collapse => 1 )
%]
This displays a collapsed menu with a depth of 2, showing the page-var "menu" as link text and "menu_title" as link title.
PageList
Generate a flat HTML list of all pages, starting at ROOT node.
See "Generic Function Arguments" below for the arguments taken.
Example:
[% FileWiki.PageList(
match => { IS_DIR => '0',
SRC_FILE => "^$libdir/.*\.pm$" },
text_key => 'SRC_FILE',
regexp => [ { match => "^$libdir/", replace => '' },
{ match => '\.pm$', replace => '' },
{ match => '/', replace => '::' } ],
)
%]
This shows a list of all perl modules in "libdir" (page-var), reformatted in perl notation (Example::TestModule).
PageArray
Returns an array of pointers to page hash See "Generic Function Arguments" below for the arguments taken.
Example:
[% FileWiki.PageArray(
match => { IS_DIR => '0',
SRC_FILE => "^$libdir/.*\.pm$" },
text_key => 'SRC_FILE',
regexp => [ { match => "^$libdir/", replace => '' },
{ match => '\.pm$', replace => '' },
{ match => '/', replace => '::' } ],
)
%]
This shows a list of all perl modules in "libdir" (page-var), reformatted in perl notation (Example::TestModule).
PageTrail
Generate a HTML list (backwards list of PARENT_DIR chain).
See "Generic Function Arguments" below for the arguments taken.
Sitemap
Displays a Sitemap of all pages, with useful information such as source file and source file type. Useful when creating a site.
Takes only the "ROOT" argument from "Generic Function Arguments".
DumpVars
Displays all vars of a page. Takes a page as argument. Useful when creating a site.
Log
Displays the FileWiki log.
Generic Function Arguments
Arguments for the "PageTree" and "PageList" functions.
- ROOT
-
The root node, must be a directory node. Defaults to site root.
- page_current
-
The page to be considered as currently displayed. Affects the highlight and collapse behaviour. Defaults to current page.
- depth
-
If set, stops traversing directories at deeper levels.
- collapse
-
If set, displays only top-level directories and the pages which are on the same level as the current page (see page_current above). Useful for menu. Defaults to false.
- text_key
-
The page-var key (scalar or arrayref) to be displayed in the link. Unless the "list_empty_text_key" argument is set, pages with an empty text_key are not displayed. Defaults to "NAME" in PageTree, and "URI" in PageList.
- list_empty_text_key
-
If set, also list pages with text_key unset (and print a warning).
- uri_key
-
The page-var key to be set as "href" attribute in the link. Note that if the page-var is not set, the default value is used. Defaults to "URI" (or {INDEX_PAGE}->{URI} for dir pages).
- title_key
-
The page-var key to be set as "title" attribute in the link. Defaults to undef.
- highlight_link
-
If set, tag the link of the current page with class "highlight". Defaults to false.
- highlight_list_item
-
If set, tag the list item of the current page with class "highlight". Defaults to false.
- highlight_parents
-
If set, also tag all parents of the current page with class "highlight". Defaults to false.
- list_id_key
-
The dir-var (sic!) key to be set as "id" attribute in the "ul" list element. Defaults to undef.
- list_item_onclick_handler
-
Function name of the onclick handler called on list_item_element (only set if list_id_key is valid!). The handler is called with arguments: "<list_id>, event". Defaults to undef.
- list_onclick_class, list_item_onclick_button_class
-
Class to be set on elements "ul" (list_onclick_class) or list_item_element (list_item_onclick_button_class) if list_id_key is valid. Defaults to undef.
- list_item_element
-
The html element to use. Defaults to "a" or "span" (if no uri).
- list_item_id_key
-
The page-var key to be set as "id" attribute in the list item element. Defaults to undef.
- list_item_class_key
-
The page-var key to be set as "class" attribute in the list item element. Defaults to undef.
- match
-
Hash reference to match expressions: the key defines the page-var, the value defines the match expression. A page is only displayed in the list if ALL the matches succeed. If not set, all pages are displayed.
Example (display pages from authors from "tty0.ch", no directories):
match => { IS_DIR => '0', author => "<.*@tty0.ch>" },
- regexp
-
Reference a hash reference, or array reference to array of hash references. Perform replace regexp on displayed text (given by text_key).
Example (display perl modules in perl-style):
regexp => [ { match => "^$libdir/", replace => '' }, { match => '\.pm$', replace => '' }, { match => '/', replace => '::' } ],
AUTHOR
Axel Burri <axel@tty0.ch>
COPYRIGHT AND LICENSE
Copyright (c) 2011-2019 Axel Burri. All rights reserved.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
SEE ALSO
Template Toolkit Plugin Documentation:
http://www.template-toolkit.org/docs/modules/Template/Plugin.html