Modul:PageTree: Unterschied zwischen den Versionen
update
w>PerfektesChaos (Setup) |
w>PerfektesChaos (update) |
||
| Zeile 1: | Zeile 1: | ||
--[=[ 2014-05- | --[=[ 2014-05-17 | ||
Module:pageTree | Module:pageTree | ||
]=] | ]=] | ||
| Zeile 8: | Zeile 8: | ||
local Current = { } | local Current = { } | ||
local Sort = false | local Sort = false | ||
local Toggles = { "lazy", "level", "lineup", "light", "linked", "list" } | |||
| Zeile 76: | Zeile 77: | ||
table.insert( unknown, s ) | table.insert( unknown, s ) | ||
elseif title.exists then | elseif title.exists then | ||
if Current.linked and | if v.shift then | ||
if not title.isRedirect then | |||
table.insert( redirect, | |||
table.insert( redirect, s ) | "(-)" .. s ) | ||
end | |||
elseif Current.linked and | |||
title.isRedirect then | |||
table.insert( redirect, | |||
"(+)" .. s ) | |||
end | end | ||
else | else | ||
| Zeile 298: | Zeile 304: | ||
r = string.format( "[[%s|%s]]", about.seed, about.show ) | r = string.format( "[[%s|%s]]", about.seed, about.show ) | ||
end | end | ||
end | |||
if type( about.suffix ) == "string" then | |||
r = string.format( "%s %s", r, about.suffix ) | |||
end | end | ||
if Current.linked and type( about.shift ) == "string" then | if Current.linked and type( about.shift ) == "string" then | ||
r = string.format( "%s <small>→[[%s]]</small>", | r = string.format( "%s <small>→[[%s]]</small>", | ||
r, fair ( about.shift ) ) | r, fair( about.shift ) ) | ||
end | end | ||
return r | return r | ||
| Zeile 376: | Zeile 385: | ||
local function flag( | local function flag( ahead ) | ||
-- Returns string with leading list syntax, either "#" or "*" or ":" | -- Returns string with leading list syntax, either "#" or "*" or ":" | ||
-- | -- ahead -- string, with syntax in case of .lazy | ||
local r | local r | ||
if Current.lazy then | if Current.lazy then | ||
r = | r = ":" | ||
else | else | ||
r = | r = ahead | ||
end | end | ||
return r | return r | ||
| Zeile 498: | Zeile 507: | ||
if v.show then | if v.show then | ||
v.show = nil | v.show = nil | ||
end | |||
if Current.light then | |||
local j, k = v.seed:find( Current.start ) | |||
if j == 1 then | |||
v.show = v.seed:sub( k + 1 ) | |||
end | |||
end | end | ||
n = n + 1 | n = n + 1 | ||
| Zeile 504: | Zeile 519: | ||
end -- for k, v | end -- for k, v | ||
if n > 0 then | if n > 0 then | ||
local start = "\n" .. flag( " | local start | ||
local long = ( not Current.light ) | |||
if Current.lineup then | |||
start = " * " | |||
else | |||
start = "\n" .. flag( "#" ) | |||
end | |||
table.sort( collect, first ) | table.sort( collect, first ) | ||
r = "" | r = "" | ||
| Zeile 511: | Zeile 532: | ||
r, | r, | ||
start, | start, | ||
field( v, | field( v, long ) ) | ||
end -- for k, v | end -- for k, v | ||
else | else | ||
| Zeile 521: | Zeile 542: | ||
local function formatPath() | local function formatPath( ancestor ) | ||
-- Render tree as partially opened list | -- Render tree as partially opened list | ||
-- ancestor -- string, with name of root element, or false | |||
-- Returns string with story | -- Returns string with story | ||
local higher | local higher | ||
local sup = Current.self | local sup = Current.self | ||
local r | local r | ||
if ancestor then | |||
higher = Current.pages[ ancestor ] | |||
if type( higher ) == "table" then | |||
higher.super = false | |||
end | |||
end | |||
while true do | while true do | ||
higher = Current.pages[ sup ] | higher = Current.pages[ sup ] | ||
| Zeile 541: | Zeile 569: | ||
end -- while true | end -- while true | ||
if higher then | if higher then | ||
r = follow( "*", 1, higher, false ) | r = follow( flag( "*" ), 1, higher, false ) | ||
else | else | ||
r = false | r = false | ||
| Zeile 613: | Zeile 641: | ||
local r = Current.pages[ true ] | local r = Current.pages[ true ] | ||
if r then | if r then | ||
r = follow( flag( " | r = follow( flag( "#" ), 1, r, true ) | ||
else | else | ||
r = false | r = false | ||
| Zeile 660: | Zeile 688: | ||
r = failures() | r = failures() | ||
else | else | ||
for k, v in pairs( Toggles ) do | |||
Current[ v ] = args[ v ] | |||
end -- for k, v | |||
if Current.service == "all" then | if Current.service == "all" then | ||
r = formatAll() | r = formatAll() | ||
| Zeile 669: | Zeile 696: | ||
fluent() | fluent() | ||
if Current.service == "path" then | if Current.service == "path" then | ||
r = formatPath() | local select | ||
if type( args.select ) == "string" then | |||
select = fair( args.select ) | |||
end | |||
r = formatPath( select ) | |||
else | else | ||
r = formatTree() | r = formatTree() | ||
| Zeile 694: | Zeile 725: | ||
-- #invoke call | -- #invoke call | ||
-- action -- string, with keyword | -- action -- string, with keyword | ||
local params = { service = action, | local params = { service = action, | ||
suite = frame:getTitle() } | suite = frame:getTitle() } | ||
| Zeile 708: | Zeile 738: | ||
if r then | if r then | ||
params.frame = frame | params.frame = frame | ||
for k, v in pairs( | for k, v in pairs( Toggles ) do | ||
if pars[ v ] then | if pars[ v ] then | ||
params[ v ] = ( pars[ v ] == "1" ) | params[ v ] = ( pars[ v ] == "1" ) | ||
end | end | ||
end -- for k, v | end -- for k, v | ||
params.select = pars.select | |||
params.stamped = pars.stamped | params.stamped = pars.stamped | ||
if pars.template then | if pars.template then | ||
| Zeile 767: | Zeile 798: | ||
-- #invoke|tree|Hilfe:|list=1 + hidden | -- #invoke|tree|Hilfe:|list=1 + hidden | ||
return framed( frame, "tree" ) | return framed( frame, "tree" ) | ||
end -- p. | end -- p.tree | ||
function p.test( args ) | function p.test( args ) | ||