Wikipedia:Lua/Modul/PageTree/en

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen
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

[Quelltext bearbeiten]

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 as shift?
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): 2024-04-02
Optional parameter:
  • 1 – required version, or keyword wikidata
Returns:
  • (empty), if minimal version condition not matched
  • local version otherwise, or registered on Wikidata (2024-04-02) when wikidata or local if not found there

Parameters on function call

[Quelltext bearbeiten]
1
Identifier of structure
mandatory parameter
lazy
Use more neutral list bullet.
Default: # in total view, * on path
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 to start.
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

[Quelltext bearbeiten]

The definition is expected by a sub module, where the identifier has been appended to Module:PageTree/ root.

Format of sub module

[Quelltext bearbeiten]
  • 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:
  • A younger stamp is overwriting the older one.
  • start is assigned to the new value.
  • A deeper sub may be gestarted again.
  • Entries in pages with exisiting definition will be ignored.
pages
List of page entries as table – each according to page entry format

Format or a page entry

[Quelltext bearbeiten]

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 to start.
shift
Target of a redirect
If beginning with / then linked relative to start.
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 to start.
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 by list=false then ignore
  • path – show for current page, even if otherwise marked by list=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)

[Quelltext bearbeiten]

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 name
  • args.series – identifier of structure in place of 1.
  • args.service – type of action; name of function
  • args.suite – path to module; here: Modul:PageTree

Parameter names beginning with l are expecting boolean values.

  • args.hide is a table, whose entries are suppress.
p.failsafe(atleast)
  1. atleast
    optional
    nil or required version or "wikidata"
returns: string or false

General library; no limitations.

Dependencies

[Quelltext bearbeiten]