Modul:Vorlage:LuaModuleDoc: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
2017-11-05
wp>PerfektesChaos (2017-01-25) |
wp>PerfektesChaos (2017-11-05) |
||
Zeile 1: | Zeile 1: | ||
local Serial = "2017- | local Serial = "2017-11-05" | ||
--[=[ | --[=[ | ||
Support {{LuaModuleDoc}} | Support {{LuaModuleDoc}} | ||
Zeile 49: | Zeile 49: | ||
return r | return r | ||
end -- catIfDefined() | end -- catIfDefined() | ||
local function createPage( swift, sub, start, ns, script ) | |||
-- Create button for page creation | |||
-- swift -- string; | |||
-- "NoPageCentral", "NoTalkCentral", "NoTalkRedir" | |||
-- sub -- string; page name to be created | |||
-- start -- string; defined pageDocRoot argument | |||
-- ns -- number; namespace | |||
-- script -- string; module name (main) | |||
-- Return: | |||
-- string | |||
-- Uses: | |||
-- fetch() | |||
-- MediaWiki:Move-leave-redirect Weiterleitung erstellen | |||
-- MediaWiki:autosumm-new Seite wurde neu angelegt: „$1“ | |||
local setup = "preload" .. swift:sub( 7 ) | |||
local r | |||
setup = fetch( setup ) | |||
if setup then | |||
local create = { action = "edit", | |||
preload = setup, | |||
redlink = "1" } | |||
local button, path, show, story, summary | |||
if swift == "NoTalkRedir" then | |||
show = "move-leave-redirect" | |||
story = string.format( "%s/%s", start, script ) | |||
story = mw.title.makeTitle( ns, story ).prefixedText | |||
story = string.format( "[[%s]]", story ) | |||
summary = "#redirect " .. story | |||
else | |||
local s = fetch( "langsRequest", false ) | |||
show = "recreate" | |||
if s then | |||
s = mw.text.trim( s ) | |||
if s ~= "" then | |||
story = "|" .. s | |||
end | |||
end | |||
story = ( s or "" ) | |||
summary = "{{LuaModuleDoc}}" | |||
end | |||
-- summary = mw.message.new( "autosumm-new" ):params( summary ) | |||
create.summary = summary | |||
create.preloadtitle = summary | |||
if story then | |||
create[ "preloadparams[]" ] = story | |||
end | |||
path = { sub, mw.uri.buildQueryString( create ) } | |||
r = Frame:callParserFunction( "fullurl", path ) | |||
show = mw.message.new( show ):plain() | |||
button = mw.title.makeTitle( mw.site.namespaces.Template.id, | |||
"MediaWiki-Button" ) | |||
if button.exists then | |||
button = { template = button.text, | |||
Typ = "progressive", | |||
["Groß"] = "1", | |||
Link = r, | |||
Text = show } | |||
r = Frame:expandTemplate{ title = button.template, | |||
args = button } | |||
else | |||
r = string.format( "<br>[%s '''%s''']", r, show ) | |||
end | |||
end | |||
return r or "" | |||
end -- createPage() | |||
Zeile 65: | Zeile 133: | ||
local entity = mw.wikibase.getEntity() | local entity = mw.wikibase.getEntity() | ||
local r | local r | ||
if entity then | if type( entity ) == "table" then | ||
local mode = 0 | local mode = 0 | ||
local repo = entity:formatPropertyValues( "P1324" ) | local repo = entity:formatPropertyValues( "P1324" ) | ||
local params, s, t | local params, s, t | ||
if repo and | if type( repo ) == "table" and | ||
type( repo.value) == "string" and | |||
repo.value:find( "//" ) then | |||
repo = mw.uri.new( repo.value ) | repo = mw.uri.new( repo.value ) | ||
if repo and | if type( repo.path ) == "string" and | ||
repo.path:match( "^/wiki/" ) then | |||
local space | local space | ||
space, s = repo.path:sub( 7 ):match( "^([^:]+):(.+)$" ) | space, s = repo.path:sub( 7 ):match( "^([^:]+):(.+)$" ) | ||
Zeile 87: | Zeile 158: | ||
s = fetch( "templateGlobal", "" ) | s = fetch( "templateGlobal", "" ) | ||
if #s > 0 then | if #s > 0 then | ||
local lucky, | local lucky, bib = pcall( require, | ||
CurrentTitle.prefixedText ) | |||
local vsn = entity:formatPropertyValues( "P348" ) | local vsn = entity:formatPropertyValues( "P348" ) | ||
params = { } | params = { } | ||
Zeile 96: | Zeile 167: | ||
repo.host ) | repo.host ) | ||
end | end | ||
if vsn and | if type( vsn ) == "table" and | ||
type( vsn.value) == "string" and | |||
vsn.value ~= "" then | |||
params.version = vsn.value | params.version = vsn.value | ||
end | end | ||
if type( | if type( bib ) == "table" and bib.failsafe then | ||
t = type( | t = type( bib.failsafe ) | ||
if t == "function" then | if t == "function" then | ||
bib = bib.failsafe( { args = { } } ) | |||
t = type( | t = type( bib ) | ||
else | else | ||
bib = bib.failsafe | |||
end | end | ||
if t == "number" then | if t == "number" then | ||
bib = string.format( "%d", bib ) | |||
t = "string" | t = "string" | ||
end | end | ||
if t == "string" then | if t == "string" then | ||
params.here = | params.here = bib | ||
end | end | ||
end | end | ||
Zeile 328: | Zeile 401: | ||
-- navError() | -- navError() | ||
-- mw.title.makeTitle() | -- mw.title.makeTitle() | ||
-- createPage() | |||
-- fetch() | -- fetch() | ||
local server = mw.site.server | local server = mw.site.server | ||
Zeile 372: | Zeile 446: | ||
if not low then | if not low then | ||
t = CurrentTitle.talkPageTitle | t = CurrentTitle.talkPageTitle | ||
if | if ns == mw.site.namespaces.Module.id then | ||
s = | local doc | ||
s = string.format( "%s/%s", start, script ) | |||
doc = mw.title.makeTitle( nsDocs, s ) | |||
if not doc.exists then | |||
r = r .. createPage( "NoPageCentral", | |||
doc.text, | |||
start, | |||
nsDocs, | |||
script ) | |||
t = false | |||
end | |||
end | end | ||
if not | if t and not t.exists then | ||
if super then | if super then | ||
s = "NoTalkCentral" | s = "NoTalkCentral" | ||
Zeile 386: | Zeile 468: | ||
end | end | ||
if s then | if s then | ||
r = r | r = string.format( "%s%s%s", | ||
r, | |||
navError( s ), | |||
createPage( s, | |||
t.prefixedText, | |||
start, | |||
nsDocs + 1, | |||
script ) ) | |||
end | end | ||
end | end |