Modul:Vorlage:LuaModuleDoc: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Modul:Vorlage:LuaModuleDoc (bearbeiten)
Version vom 26. November 2016, 20:21 Uhr
, 26. November 20162016-11-25
wp>PerfektesChaos (2016-11-24) |
wp>PerfektesChaos (2016-11-25) |
||
Zeile 1: | Zeile 1: | ||
local Serial = "2016-11- | local Serial = "2016-11-25" | ||
--[=[ | --[=[ | ||
Support {{LuaModuleDoc}} | Support {{LuaModuleDoc}} | ||
Zeile 13: | Zeile 13: | ||
local CurrentTitle | local CurrentTitle | ||
local Frame | local Frame | ||
local function catIfDefined( slot ) | |||
-- Categorize if category defined | |||
-- slot -- string; Config entry | |||
-- Return: | |||
-- string or false: categorization, if any | |||
-- Uses: | |||
-- mw.title.makeTitle() | |||
local s = LuaWiki.getArg( slot, "" ) | |||
local r | |||
if #s > 0 then | |||
local t = mw.title.makeTitle( "Category", s ) | |||
if t.exists then | |||
r = string.format( "[[%s]]", t.prefixedText ) | |||
end | |||
end | |||
return r | |||
end -- catIfDefined() | |||
Zeile 22: | Zeile 42: | ||
-- LuaWiki.getArg() | -- LuaWiki.getArg() | ||
-- >< CurrentTitle | -- >< CurrentTitle | ||
-- Return: | |||
-- string | |||
-- Uses: | |||
-- mw.wikibase.getEntity() | |||
-- mw.title.makeTitle() | |||
local entity = mw.wikibase.getEntity() | local entity = mw.wikibase.getEntity() | ||
local r | local r | ||
Zeile 27: | Zeile 52: | ||
local mode = 0 | local mode = 0 | ||
local repo = entity:formatPropertyValues( "P1324" ) | local repo = entity:formatPropertyValues( "P1324" ) | ||
local s, t | local params, s, t | ||
if repo and repo.value and repo.value:find( "//" ) then | if repo and repo.value and repo.value:find( "//" ) then | ||
repo = mw.uri.new( repo.value ) | repo = mw.uri.new( repo.value ) | ||
Zeile 47: | Zeile 72: | ||
s = LuaWiki.getArg( "templateGlobal", "" ) | s = LuaWiki.getArg( "templateGlobal", "" ) | ||
if #s > 0 then | if #s > 0 then | ||
local | local lucky, code = pcall( require, | ||
local vsn | CurrentTitle.prefixedText ) | ||
local vsn = entity:formatPropertyValues( "P348" ) | |||
params = { } | |||
if mode < 2 then | if mode < 2 then | ||
params[ 1 ] = string.format( "[%s %s]", | params[ 1 ] = string.format( "[%s %s]", | ||
Zeile 56: | Zeile 83: | ||
if vsn and vsn.value and vsn.value ~= "" then | if vsn and vsn.value and vsn.value ~= "" then | ||
params.version = vsn.value | params.version = vsn.value | ||
end | |||
if type( code ) == "table" and code.failsafe then | |||
t = type( code.failsafe ) | |||
if t == "function" then | |||
code = code.failsafe( { args = { } } ) | |||
t = type( code ) | |||
else | |||
code = code.failsafe | |||
end | |||
if t == "number" then | |||
code = string.format( "%d", code ) | |||
t = "string" | |||
end | |||
if t == "string" then | |||
params.here = code | |||
end | |||
end | |||
if params.version and params.here and | |||
params.version ~= params.here then | |||
params.update = "1" | |||
end | end | ||
r = Frame:expandTemplate{ title=s, | r = Frame:expandTemplate{ title=s, | ||
Zeile 63: | Zeile 110: | ||
s = LuaWiki.getArg( "categoryWikiData", "" ) | s = LuaWiki.getArg( "categoryWikiData", "" ) | ||
if #s > 0 then | if #s > 0 then | ||
local slot | |||
if mode > 0 then | if mode > 0 then | ||
if mode == 2 then | if mode == 2 then | ||
slot = catIfDefined( "categoryWikiDataParent" ) | |||
else | |||
slot = catIfDefined( "categoryWikiDataChild" ) | |||
end | |||
end | |||
if not slot then | |||
slot = catIfDefined( s ) | |||
end | |||
if slot then | |||
if r then | |||
r = r .. slot | |||
else | else | ||
r = slot | |||
end | end | ||
if params and params.update then | |||
slot = catIfDefined( "categoryWikiDataObsolete" ) | |||
if slot then | |||
if | r = r .. slot | ||
end | end | ||
end | end | ||
end | end | ||
end | end |