Wikipedia:Lua/Modul/PageTree/en
Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
PageTree
– Module for presentation and administration of wiki pages within a hierarchical structure.
From one unique page definition varoious consistent presentations may be retrieved:
- Uncollapsed path to a certain page, as might be shown in linkboxes, together with neighbouring entries
- List of all pages
- „Sitemap“ with complete tree structure
Page structure is defined by a sub module.
Functions for templates
[Am Gwëntext werkeln]All functions (except failsafe) have one mandatory parameter with the identifier of structure. More named parameters may be applied.
The return value is a string according to the request and current page name; even empty or error message.
- all
- List all entries as (non hierarchical) list in alphabetical order.
- Parameters:
light lineup list lazy stamped suppress
- check
- Check all entries (for existence of page) if link target.
- Parameters:
linked
– Is every redirect declared asshift
? - path
- Show path to current page, also related sister entries in given order.
- Parameters:
lazy segment
- subpages
- Show sequence of subpages.
- Parameters:
subpager
– Pass sequence to that template. - tree
- Show all entries as tree structure in given order.
- Parameters:
list lazy segment stamped suppress
- failsafe
- Version identifier (local):
2018-09-13
- Optional parameter:
1
– required version, or keywordwikidata
- Returns:
- (empty), if minimal version condition not matched
- local version otherwise, or registered on Wikidata (
2018-09-13
) whenwikidata
or local if not found there
Parameters on function call
[Am Gwëntext werkeln]- 1
- Identifier of structure
- mandatory parameter
- lazy
- Use more neutral list bullet.
- Default:
#
in total view,*
onpath
- Neutral:
*
or:
- level
- Do not show sub pages.
- Default: show sub pages.
- light
- Show complete view
all
without prefix. - Default: Preced with prefix.
- lineup
- Show complete view
all
continously without list bullet. - Default: List, one line per entry.
- linked
- Show redirects (
shift
). - Default: No redirects included.
- list
- List all.
- Default: Entries marked by
list=false
in structures omitted. - segment
- Begin
path
at alternative root element. - If beginning with
/
then evaluated relative tostart
. - stamped
- Date/time format, for parser function
#time
etc. - suppress
- Omit page names matching this pattern.
- subpager
- Name of a template for subpages.
subpager=Subpage
Parameter names beginning with l
are regarded as true if set to 1
.
Definition of a structure
[Am Gwëntext werkeln]The definition is expected by a sub module, where the identifier has been appended to Module:PageTree/
root.
Format of sub module
[Am Gwëntext werkeln]- The sub module has to match the mw.loadData() conditions.
- A table is to be returned.
The following components might be delivered in that table:
- stamp
- Date/time according to ISO 8601
- start
- Prefix; replace leading
/
in page names - sub
- Identifier of a sub-sub module relative to current sub module; without leading
/
- The sub-sub module will be imported consecutively by exacly the same rules.
- Repeated declarations by sub-sub module will be resolved as follows:
- pages
- List of page entries as table – each according to page entry format
Format or a page entry
[Am Gwëntext werkeln]A page entry may be contained in the table pages
by one of three modes:
- string
"pagename"
- Named element with further details
["pagename"] = { detailA= ... }
- A named element is required to contain a
true
value instead of the string with page name. That is the root element.
- table with details; page name is
seed
element.{ seed="Seitenname", detailA= ... }
Every page name must not occur more than once in a pages
table.
Every entry may contain the following properties:
- seed
- Page name as string; or
true
on root element. - mandatory parameter
- If missing but named element the element identifier will be used.
- If element not a table but string that one will be used as page name.
- If beginning with
/
then linked relative tostart
. - shift
- Target of a redirect
- If beginning with
/
then linked relative tostart
. - show
- Displayed link title
- Default: Last sub page segment; else page title without namespace.
- suffix
- Additional text after linked page
- super
- Higher page in hierachy; string or
true
. - If beginning with
/
then linked relative tostart
. - Default: next higher page before
/
. - less
path
– do not show deeper levels.- Default: show.
- list
- Suppress presentation by default if not requested explicitly by
list=true
. - Default: show.
- Assignment:
list=false
- loose
- Mark orphaned root element.
all
– if also marked bylist=false
then ignorepath
– show for current page, even if otherwise marked bylist=false
.subpages
– do not show for current page, if not recurring to a deklared root element.
- Default: show element.
- Assignment:
loose=true
- index
- Numerical sort order.
- Default: alphabetical by page name or link title, respectively.
Functions for Lua modules (API)
[Am Gwëntext werkeln]There are two functions for test and management purpose:
- p.test(args)
args
are the arguments passed by#invoke
otherwise in template syntax. Moreover can (must) be provided:args.self
– use as current page nameargs.series
– identifier of structure in place of 1.args.service
– type of action; name of functionargs.suite
– path to module; here:Modul:PageTree
Parameter names beginning with l
are expecting boolean values.
args.hide
is a table, whose entries aresuppress
.
- p.failsafe(atleast)
-
- atleast
optional
nil or required version or"wikidata"
- atleast
- returns: string or false
Usage
[Am Gwëntext werkeln]General library; no limitations.