Modul:Vorlage:LuaModuleDoc: Unterschied zwischen den Versionen
update
wp>PerfektesChaos (update) |
wp>PerfektesChaos (update) |
||
Zeile 1: | Zeile 1: | ||
--[=[ 2013-05- | --[=[ 2013-05-13 | ||
Support {{LuaModuleDoc}} | Support {{LuaModuleDoc}} | ||
* nav() | * nav() | ||
Zeile 21: | Zeile 21: | ||
-- LuaWiki.getArg() | -- LuaWiki.getArg() | ||
-- LuaWiki.transclude() | -- LuaWiki.transclude() | ||
-- LuaWiki.error() | |||
local show = LuaWiki.getArg( "pageErr" ) | local show = LuaWiki.getArg( "pageErr" ) | ||
local r | local r | ||
Zeile 30: | Zeile 31: | ||
r = LuaWiki.transclude( show, pars ) | r = LuaWiki.transclude( show, pars ) | ||
else | else | ||
r = " | r = LuaWiki.error( "arg 'pageErr' missing" ) | ||
end | end | ||
return r | return r | ||
Zeile 61: | Zeile 62: | ||
-- navError() | -- navError() | ||
local r = LuaWiki.transclude( swift, collect ) | local r = LuaWiki.transclude( swift, collect ) | ||
local s = | local s = false | ||
local t = currentTitle.talkPageTitle | local t = currentTitle.talkPageTitle | ||
if t then | if t then | ||
s = t.exists | s = t.exists | ||
end | end | ||
r = "<!-- LuaModuleDoc::b -->" .. r .. "<!-- LuaModuleDoc::e -->" | |||
if not s then | if not s then | ||
if super then | if super then | ||
Zeile 83: | Zeile 85: | ||
s = super .. collect[ i ] | s = super .. collect[ i ] | ||
if LuaWiki.isExisting( s ) then | if LuaWiki.isExisting( s ) then | ||
r | s = LuaWiki.transclude( s ) | ||
r = r .. s:gsub( "<!-- LuaModuleDoc::b -->.*<!-- LuaModuleDoc::e -->", "" ) | |||
break | break | ||
end | end | ||
Zeile 96: | Zeile 99: | ||
s = LuaWiki.getArg( "categoryDocs", "" ) | s = LuaWiki.getArg( "categoryDocs", "" ) | ||
if #s > 0 then | if #s > 0 then | ||
i = mw.title.makeTitle( "Category", s ) | |||
if | if i.exists then | ||
r = r .. "[[" .. | r = r .. "[[" .. i.prefixedText | ||
.. "|" .. collect[ 1 ] .. "]]" | |||
end | end | ||
end | end | ||
Zeile 142: | Zeile 146: | ||
local function navLangs( script | local function navLangs( space, start, script ) | ||
-- Analyze languages | -- Analyze languages | ||
-- Precondition: | -- Precondition: | ||
-- current page is supposed to transclude LuaModuleDoc | -- current page is supposed to transclude LuaModuleDoc | ||
-- space -- string; central documentation namespace | |||
-- start -- string; central documentation root | |||
-- script -- string; basic module name | -- script -- string; basic module name | ||
-- Return: | -- Return: | ||
-- table: args for navigation template | -- table: args for navigation template | ||
Zeile 158: | Zeile 163: | ||
-- LuaWiki.getArg() | -- LuaWiki.getArg() | ||
-- navLang() | -- navLang() | ||
-- navError() | -- navError() | ||
local e, i, s | local e, i, s, t | ||
local r = { } | local r = { } | ||
local specified = LuaWiki.getArg( "langsRequest", false ) | local specified = LuaWiki.getArg( "langsRequest", false ) | ||
local super = start .. "/" .. script .. "/" | |||
if type( specified ) == "string" then | if type( specified ) == "string" then | ||
if specified:match( "^%s*$" ) then | if specified:match( "^%s*$" ) then | ||
Zeile 168: | Zeile 173: | ||
end | end | ||
end | end | ||
navLang( LuaWiki.getArg( "langsDefault" ), | navLang( LuaWiki.getArg( "langsDefault" ), r, specified ) | ||
navLang( specified, r, false ) | navLang( specified, r, false ) | ||
if #r < 1 then | if #r < 1 then | ||
Zeile 179: | Zeile 182: | ||
s = e[ 1 ] | s = e[ 1 ] | ||
if e[ 2 ] then | if e[ 2 ] then | ||
t = mw.title.makeTitle( space, super .. s ) | |||
if not t.exists then | |||
s = false | s = false | ||
end | end | ||
Zeile 204: | Zeile 208: | ||
-- nsDocs -- number; namespace for doc | -- nsDocs -- number; namespace for doc | ||
-- Uses: | -- Uses: | ||
-- >< currentTitle | |||
-- LuaWiki.getArg() | -- LuaWiki.getArg() | ||
-- navError() | -- navError() | ||
Zeile 212: | Zeile 217: | ||
if type( start ) == "string" then | if type( start ) == "string" then | ||
local light = false | local light = false | ||
local story = currentTitle.text .. "/" | |||
local script | local script | ||
if lead then | if lead then | ||
script = currentTitle.baseText | |||
script = | |||
else | else | ||
local sub = "/([^/]+)/(.*)$" | local sub = "/([^/]+)/(.*)$" | ||
script, sub = mw.ustring.match( story, | script, sub = mw.ustring.match( story, | ||
"^" .. start .. sub ) | |||
if type( script ) == "string" then | if type( script ) == "string" then | ||
light = ( #sub > 0 ) | light = ( #sub > 0 ) | ||
Zeile 231: | Zeile 236: | ||
if type( swift ) == "string" then | if type( swift ) == "string" then | ||
-- nsDocs is valid, since it equals ns | -- nsDocs is valid, since it equals ns | ||
local | local space = mw.site.namespaces[ nsDocs ].name | ||
super | local super | ||
local collect = navLangs( script | local collect = navLangs( space, start, script ) | ||
if ns == nsDocs and | if ns == nsDocs and | ||
story == start .. "/" .. script .. "/" then | story == start .. "/" .. script .. "/" then | ||
super = | super = space .. ":" .. start .. "/" .. script .. "/" | ||
else | else | ||
super = false | super = false |