Modul:Vorlage:LuaModuleDoc: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
update
wp>PerfektesChaos (update) |
wp>PerfektesChaos (update) |
||
Zeile 1: | Zeile 1: | ||
--[=[ 2013-05- | --[=[ 2013-05-14 | ||
Support {{LuaModuleDoc}} | Support {{LuaModuleDoc}} | ||
* nav() | * nav() | ||
Zeile 35: | Zeile 35: | ||
return r | return r | ||
end -- navError() | end -- navError() | ||
Zeile 146: | Zeile 72: | ||
local function navLangs( | local function navLangs( nsDocs, start, script ) | ||
-- Analyze languages | -- Analyze languages | ||
-- Precondition: | -- Precondition: | ||
-- current page is supposed to transclude LuaModuleDoc | -- current page is supposed to transclude LuaModuleDoc | ||
-- | -- nsDocs -- number; central documentation namespace | ||
-- start -- string; central documentation root | -- start -- string; central documentation root | ||
-- script -- string; basic module name | -- script -- string; basic module name | ||
Zeile 163: | Zeile 89: | ||
-- LuaWiki.getArg() | -- LuaWiki.getArg() | ||
-- navLang() | -- navLang() | ||
-- | -- mw.title.makeTitle() | ||
local e, i, s, t | local e, i, s, t | ||
local r = { } | local r = { } | ||
Zeile 182: | Zeile 108: | ||
s = e[ 1 ] | s = e[ 1 ] | ||
if e[ 2 ] then | if e[ 2 ] then | ||
t = mw.title.makeTitle( | t = mw.title.makeTitle( nsDocs, super .. s ) | ||
if not t.exists then | if not t.exists then | ||
s = false | s = false | ||
Zeile 197: | Zeile 123: | ||
return r | return r | ||
end -- navLangs() | end -- navLangs() | ||
local function navMerge( start, swift, ns, nsDocs, script ) | |||
-- Include various external content into page | |||
-- Precondition: | |||
-- start -- string; defined pageDocRoot argument | |||
-- swift -- string; defined pageNav argument | |||
-- nsDocs -- number; central documentation namespace | |||
-- ns -- number; current namespace | |||
-- script -- string; modul name | |||
-- Uses: | |||
-- >< currentTitle | |||
-- navLangs() | |||
-- LuaWiki.transclude() | |||
-- navError() | |||
-- mw.title.makeTitle() | |||
-- LuaWiki.getArg() | |||
-- LuaWiki.isExisting() | |||
local r | |||
local s | |||
local super | |||
local t = currentTitle.talkPageTitle | |||
local collect = navLangs( nsDocs, start, script ) | |||
if ns == nsDocs and | |||
currentTitle.text == start .. "/" .. script then | |||
super = currentTitle.text .. "/" | |||
else | |||
super = false | |||
end | |||
r = LuaWiki.transclude( swift, collect ) | |||
if t then | |||
s = t.exists | |||
else | |||
s = false | |||
end | |||
if not s then | |||
if super then | |||
s = "NoTalkCentral" | |||
elseif ns == nsDocs + 1 then | |||
s = false | |||
else | |||
s = "NoTalkRedir" | |||
end | |||
if s then | |||
r = r .. navError( s ) | |||
end | |||
end | |||
if super then | |||
local i | |||
local d = "{{%s*[lL]uaModuleDoc[^}]*}}%s*" | |||
local p1 = "^%s*" .. d .. "<onlyinclude>" | |||
local p2 = "%s*<noinclude>" .. d .. "</noinclude>" | |||
for i = 3, #collect do | |||
t = mw.title.makeTitle( nsDocs, super .. collect[ i ] ) | |||
s = t:getContent() | |||
if s then | |||
s = s:gsub( p1, "" ):gsub( p2, "" ) | |||
if s:match( d ) then | |||
r = r .. "<br />" | |||
.. navError( "BadInclude", t.prefixedText ) | |||
.. "<br />" | |||
else | |||
r = r .. LuaWiki.transclude( t.prefixedText ) | |||
break | |||
end | |||
end | |||
end -- for i | |||
s = LuaWiki.getArg( "pageTemplateInsert", "" ) | |||
if LuaWiki.isExisting( s ) then | |||
local suppress = LuaWiki.getArg( "noHint", "" ) | |||
if #suppress == 0 then | |||
r = r .. LuaWiki.transclude( s, { collect[ 1 ] } ) | |||
end | |||
end | |||
s = LuaWiki.getArg( "categoryDocs", "" ) | |||
if #s > 0 then | |||
i = mw.title.makeTitle( "Category", s ) | |||
if i.exists then | |||
r = r .. "[[" .. i.prefixedText | |||
.. "|" .. collect[ 1 ] .. "]]" | |||
end | |||
end | |||
r = r .. "__NOEDITSECTION__" | |||
end | |||
return r | |||
end -- navMerge() | |||
Zeile 211: | Zeile 224: | ||
-- LuaWiki.getArg() | -- LuaWiki.getArg() | ||
-- navError() | -- navError() | ||
-- | -- navMerge() | ||
local r | local r | ||
local start = LuaWiki.getArg( "pageDocRoot" ) | local start = LuaWiki.getArg( "pageDocRoot" ) | ||
if type( start ) == "string" then | if type( start ) == "string" then | ||
local light = false | local light = false | ||
local script | local script | ||
if lead then | if lead then | ||
Zeile 223: | Zeile 234: | ||
else | else | ||
local sub = "/([^/]+)/(.*)$" | local sub = "/([^/]+)/(.*)$" | ||
script, sub = mw.ustring.match( | script, sub = mw.ustring.match( currentTitle.text .. "/", | ||
"^" .. start .. sub ) | "^" .. start .. sub ) | ||
if type( script ) == "string" then | if type( script ) == "string" then | ||
light = ( #sub > 0 ) | light = ( #sub > 0 ) | ||
else | else | ||
r = navError( "BadPage" ) .. | r = navError( "BadPage" ) .. currentTitle.text | ||
script = false | script = false | ||
end | end | ||
Zeile 235: | Zeile 246: | ||
local swift = LuaWiki.getArg( "pageNav" ) | local swift = LuaWiki.getArg( "pageNav" ) | ||
if type( swift ) == "string" then | if type( swift ) == "string" then | ||
r = navMerge( start, swift, nsDocs, ns, script ) | |||
else | else | ||
r = navError( "configMissing", "pageNav" ) | r = navError( "configMissing", "pageNav" ) |