Modul:Vorlage:LuaModuleDoc: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Modul:Vorlage:LuaModuleDoc (bearbeiten)
Version vom 16. November 2016, 19:18 Uhr
, 16. November 20162016-11-15
wp>PerfektesChaos (2016-11-12) |
wp>PerfektesChaos (2016-11-15) |
||
Zeile 1: | Zeile 1: | ||
local Serial = "2016-11- | local Serial = "2016-11-15" | ||
--[=[ | --[=[ | ||
Support {{LuaModuleDoc}} | Support {{LuaModuleDoc}} | ||
Zeile 10: | Zeile 10: | ||
-- Module globals | -- Module globals | ||
local | local Lucky, LuaWiki = pcall( require, "Module:LuaWiki" ) | ||
local | local CurrentTitle | ||
local Frame | |||
local function globalRepos( script ) | |||
-- Check for global dissemination | |||
-- script -- string; module name (main) | |||
-- Uses: | |||
-- LuaWiki.getArg() | |||
-- >< CurrentTitle | |||
local entity = mw.wikibase.getEntity() | |||
local r | |||
if entity then | |||
local repo = entity:formatPropertyValues( "P1324" ) | |||
local s = LuaWiki.getArg( "categoryWikiData", "" ) | |||
local t | |||
if #s > 0 then | |||
t = mw.title.makeTitle( "Category", s ) | |||
if t.exists then | |||
r = string.format( "[[%s|%s]]", | |||
t.prefixedText, script ) | |||
end | |||
end | |||
if repo and repo.value then | |||
local leader | |||
repo = mw.uri.new( repo.value ) | |||
if repo and repo.path:match( "^/wiki/" ) then | |||
local space | |||
space, s = mw.ustring.match( repo.path:sub( 7 ), | |||
"^([^:]+):(.+)$" ) | |||
if space and source then | |||
t = mw.title.makeTitle( space, source ) | |||
leader = ( mw.title.equals( CurrentTitle, t ) | |||
and | |||
mw.site.server == "//" .. repo.host ) | |||
end | |||
end | |||
s = LuaWiki.getArg( "templateGlobal", "" ) | |||
if #s > 0 then | |||
local params | |||
if not leader then | |||
params = { [1] = string.format( "[%s %s]", | |||
tostring( repo ), | |||
repo.host ) } | |||
end | |||
r = r or "" | |||
r = r .. Frame:expandTemplate{ title=s, | |||
args=params } | |||
end | |||
end | |||
end | |||
return r or "" | |||
end -- globalRepos() | |||
Zeile 182: | Zeile 235: | ||
-- lead -- true: Module: namespace; false: text namespace | -- lead -- true: Module: namespace; false: text namespace | ||
-- Uses: | -- Uses: | ||
-- >< | -- >< CurrentTitle | ||
-- navLangs() | -- navLangs() | ||
-- LuaWiki.transclude() | -- LuaWiki.transclude() | ||
Zeile 199: | Zeile 252: | ||
if ns == nsDocs then | if ns == nsDocs then | ||
s = string.format( "%s/%s", start, script ) | s = string.format( "%s/%s", start, script ) | ||
if | if CurrentTitle.text == s then | ||
super = | super = CurrentTitle.text .. "/" | ||
elseif sub then | elseif sub then | ||
collect.subDoc = sub | collect.subDoc = sub | ||
collect.subModule = sub | collect.subModule = sub | ||
s = string.format( "%s/%s/%s", start, script, sub ) | s = string.format( "%s/%s/%s", start, script, sub ) | ||
if | if CurrentTitle.text == s then | ||
s = string.format( "%s/%s", s, collect[ 3 ] ) | s = string.format( "%s/%s", s, collect[ 3 ] ) | ||
t = mw.title.makeTitle( nsDocs, s ) | t = mw.title.makeTitle( nsDocs, s ) | ||
if t.exists then | if t.exists then | ||
super = | super = CurrentTitle.text .. "/" | ||
end | end | ||
end | end | ||
Zeile 221: | Zeile 274: | ||
end | end | ||
r = LuaWiki.transclude( swift, collect ) | r = LuaWiki.transclude( swift, collect ) | ||
t = | t = CurrentTitle.talkPageTitle | ||
if t then | if t then | ||
s = t.exists | s = t.exists | ||
Zeile 240: | Zeile 293: | ||
end | end | ||
if super then | if super then | ||
local d = "{{%s*[lL]uaModuleDoc[^}]*}}%s*" | local d = "{{%s*[lL]uaModuleDoc[^}]*}}%s*" | ||
local p1 = "^%s*" .. d .. "<onlyinclude>" | local p1 = "^%s*" .. d .. "<onlyinclude>" | ||
Zeile 282: | Zeile 334: | ||
end | end | ||
if lead then | if lead then | ||
r = r .. globalRepos( script ) | |||
end | end | ||
return r | return r | ||
Zeile 307: | Zeile 349: | ||
-- nsDocs -- number; namespace for doc | -- nsDocs -- number; namespace for doc | ||
-- Uses: | -- Uses: | ||
-- >< | -- >< CurrentTitle | ||
-- LuaWiki.getArg() | -- LuaWiki.getArg() | ||
-- navError() | -- navError() | ||
Zeile 320: | Zeile 362: | ||
end | end | ||
s = s .. "([^/]+)/(.*/?)$" | s = s .. "([^/]+)/(.*/?)$" | ||
script, s = mw.ustring.match( | script, s = mw.ustring.match( CurrentTitle.text .. "/", s ) | ||
if type( script ) == "string" then | if type( script ) == "string" then | ||
local sub = false | local sub = false | ||
Zeile 341: | Zeile 383: | ||
end | end | ||
else | else | ||
r = navError( "BadPage" ) .. | r = navError( "BadPage" ) .. CurrentTitle.text | ||
end | end | ||
else | else | ||
Zeile 354: | Zeile 396: | ||
-- Start execution; return navigation text; analyze namespace | -- Start execution; return navigation text; analyze namespace | ||
-- Uses: | -- Uses: | ||
-- >< | -- >< CurrentTitle | ||
-- LuaWiki.getArg() | -- LuaWiki.getArg() | ||
-- mw.title.getCurrentTitle() | -- mw.title.getCurrentTitle() | ||
Zeile 362: | Zeile 404: | ||
local nsDocs = LuaWiki.getArg( "nsDocs" ) | local nsDocs = LuaWiki.getArg( "nsDocs" ) | ||
if nsDocs then | if nsDocs then | ||
CurrentTitle = mw.title.getCurrentTitle() | |||
local ns = | local ns = CurrentTitle.namespace | ||
local lead = ( ns == mw.site.namespaces.Module.id ) | local lead = ( ns == mw.site.namespaces.Module.id ) | ||
nsDocs = tonumber( nsDocs ) | nsDocs = tonumber( nsDocs ) | ||
Zeile 389: | Zeile 431: | ||
local r | local r | ||
if type( LuaWiki ) == "table" then | if type( LuaWiki ) == "table" then | ||
Frame = frame | |||
Lucky, r = pcall( navigation ) | |||
r = r or "" | r = r or "" | ||
else | else |