Modul:PageTree: Unterschied zwischen den Versionen
+ limit (restrictions)
w>PerfektesChaos (update) |
w>PerfektesChaos (+ limit (restrictions)) |
||
| Zeile 1: | Zeile 1: | ||
--[=[ 2014-12- | --[=[ 2014-12-28 | ||
Module:pageTree | Module:pageTree | ||
]=] | ]=] | ||
| Zeile 9: | Zeile 9: | ||
local Sort = false | local Sort = false | ||
local Strings = { "segment", "self", "stamped", "subpager", "suppress" } | local Strings = { "segment", "self", "stamped", "subpager", "suppress" } | ||
local Toggles = { "lazy", "level", "lineup", "light", "linked", "list" } | local Toggles = { "lazy", "level", "lineup", "light", "linked", "limit", | ||
"list" } | |||
| Zeile 148: | Zeile 149: | ||
return r | return r | ||
end -- fair() | end -- fair() | ||
local function fasten( adopt ) | |||
-- Format restrictions | |||
-- adopt -- string, with restriction entry | |||
-- Returns absolute page name, or false | |||
local designs = { | |||
autoconfirmed = "background:#FFFF00", | |||
superprotect = "background:#FF0000;border:#FFFF00 9px solid", | |||
sysop = "background:#FFFF00;border:#FF0000 2px solid", | |||
["?????????"] = "border:#FF0000 5px solid;color:#FF0000" } | |||
local restrictions = mw.text.split( adopt, ":" ) | |||
local r = "" | |||
local start = "margin-left:2em;" | |||
local staff, strict, style | |||
for i = 1, #restrictions do | |||
strict, staff = restrictions[ i ]:match( "^(.*)=(.+)$" ) | |||
strict = mw.text.trim( strict ) | |||
if strict == "" then | |||
strict = "?????????" | |||
end | |||
style = designs[ staff ] | |||
if not style then | |||
style = designs[ "?????????" ] | |||
strict = strict .. "?????????" | |||
end | |||
if start then | |||
style = start .. style | |||
start = false | |||
end | |||
style = style .. ";padding-left:3px;padding-right:3px;" | |||
r = string.format( "%s<span style='%s'>%s</span>", | |||
r, style, strict ) | |||
end -- for i | |||
return r | |||
end -- fasten() | |||
| Zeile 335: | Zeile 373: | ||
-- Format entry as link | -- Format entry as link | ||
-- about -- table, with entry | -- about -- table, with entry | ||
-- .show | -- .show -- link title | ||
-- .seed | -- .seed -- page name | ||
-- .shift | -- .shift -- redirect target | ||
-- .protection -- restrictions | |||
-- absolute -- true, if real page name to be shown | -- absolute -- true, if real page name to be shown | ||
-- Returns string | -- Returns string | ||
| Zeile 357: | Zeile 396: | ||
r = string.format( "%s <small>→[[%s]]</small>", | r = string.format( "%s <small>→[[%s]]</small>", | ||
r, fair( about.shift ) ) | r, fair( about.shift ) ) | ||
end | |||
if Current.limit and type( about.protection ) == "string" then | |||
r = string.format( "%s %s", | |||
r, fasten( about.protection ) ) | |||
end | end | ||
return r | return r | ||
| Zeile 806: | Zeile 849: | ||
r = formatPath( segment ) | r = formatPath( segment ) | ||
else | else | ||
if args.limit == "1" or | |||
args.limit == true then | |||
Current.limit = true | |||
end | |||
r = formatTree( segment ) | r = formatTree( segment ) | ||
end | end | ||
| Zeile 903: | Zeile 950: | ||
-- .suite -- Module path | -- .suite -- Module path | ||
-- .self -- page name, in service="path" | -- .self -- page name, in service="path" | ||
-- .limit -- show restrictions | |||
local lucky, r = pcall( forward, args ) | local lucky, r = pcall( forward, args ) | ||
return r or Current | return r or Current | ||