Importer, Bürokraten, Moderatoren (CommentStreams), Strukturierte-Diskussionen-Bots, Oberflächenadministratoren, Push-Abonnementverwalter, Oversighter, Administratoren, Kampagnenbearbeiter (Hochladeassistent)
855
Bearbeitungen
(2018-08-01) |
K (36 Versionen von wikipedia:Modul:Vorlage:LuaModuleDoc importiert) |
||
| (5 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
local LuaModuleDoc = { suite = "LuaModuleDoc", | local LuaModuleDoc = { suite = "LuaModuleDoc", | ||
serial = " | serial = "2022-04-22", | ||
item = 12981914, | item = 12981914, | ||
frame = false, | frame = false, | ||
| Zeile 15: | Zeile 15: | ||
* failsafe() | * failsafe() | ||
]=] | ]=] | ||
local Failsafe = LuaModuleDoc | |||
| Zeile 144: | Zeile 145: | ||
local mode = 0 | local mode = 0 | ||
local repo = entity:formatPropertyValues( "P1324" ) | local repo = entity:formatPropertyValues( "P1324" ) | ||
local params, s | local params, s | ||
if type( repo ) == "table" and | if type( repo ) == "table" and | ||
type( repo.value) == "string" and | type( repo.value ) == "string" and | ||
repo.value:find( "//" ) then | repo.value:find( "//" ) then | ||
repo = mw.uri.new( | local t = mw.text.split( repo.value, ",%s+" ) | ||
if #t > 1 then | |||
for i = 1, #t do | |||
if t[ i ]:find( mw.site.server, 1, true ) then | |||
s = t[ i ] | |||
break -- for i | |||
end | |||
end -- for i | |||
if not s then | |||
s = t[ 1 ] | |||
end | |||
else | |||
s = repo.value | |||
end | |||
repo = mw.uri.new( s ) | |||
if type( repo.path ) == "string" and | if type( repo.path ) == "string" and | ||
repo.path:match( "^/wiki/" ) then | repo.path:match( "^/wiki/" ) then | ||
local space | local space | ||
space, s = repo.path:sub( 7 ):match( "^([^:]+):(.+)$" ) | space, s = repo.path:sub( 7 ):match( "^([^:]+):(.+)$" ) | ||
if space and | if space and | ||
mw.site.namespaces[ space ] then | |||
t = mw.title.makeTitle( space, s ) | t = mw.title.makeTitle( space, s ) | ||
s = "//" .. repo.host | s = "//" .. repo.host | ||
| Zeile 180: | Zeile 196: | ||
params.version = vsn.value | params.version = vsn.value | ||
end | end | ||
if type( bib ) == "table" | if type( bib ) == "table" then | ||
local serial | |||
if bib.failsafe then | |||
if type( bib.failsafe ) == "function" then | |||
serial = bib.failsafe( { args = { } } ) | |||
else | |||
serial = bib.failsafe | |||
end | |||
elseif bib[ "#serial"] then | |||
serial = bib[ "#serial"] | |||
end | end | ||
if | if type( serial ) == "number" then | ||
serial = string.format( "%d", serial ) | |||
end | end | ||
if | if type( serial ) == "string" then | ||
params.here = | params.here = serial | ||
end | end | ||
end | end | ||
if fetch( "forkedGlobal", "0" ) ~= "1" and | if fetch( "forkedGlobal", "0" ) ~= "1" and | ||
params.version and params.here and | params.version and params.here and | ||
params.version ~= params.here | params.version ~= params.here then | ||
params.update = "1" | params.update = "1" | ||
end | end | ||
| Zeile 273: | Zeile 291: | ||
end | end | ||
if t then | if t then | ||
r = | r = string.format( "%s:%s", | ||
mw.site.namespaces[ n ].name, s ) | |||
end | end | ||
return r | return r | ||
| Zeile 650: | Zeile 669: | ||
Failsafe.failsafe = function ( atleast ) | |||
-- Retrieve versioning and check for compliance | -- Retrieve versioning and check for compliance | ||
-- Precondition: | -- Precondition: | ||
-- | -- atleast -- string, with required version | ||
-- | -- or wikidata|item|~|@ or false | ||
-- Postcondition: | -- Postcondition: | ||
-- Returns string with | -- Returns string -- with queried version/item, also if problem | ||
-- false -- if appropriate | |||
-- 2020-08-17 | |||
local since = atleast | |||
local last = ( since == "~" ) | |||
local linked = ( since == "@" ) | |||
local link = ( since == "item" ) | |||
local r | local r | ||
if since == "wikidata" then | if last or link or linked or since == "wikidata" then | ||
local item = | local item = Failsafe.item | ||
since = false | since = false | ||
if type( item ) == "number" and item > 0 then | if type( item ) == "number" and item > 0 then | ||
local | local suited = string.format( "Q%d", item ) | ||
if link then | |||
r = suited | |||
else | |||
local entity = mw.wikibase.getEntity( suited ) | |||
if type( entity ) == "table" then | |||
local seek = Failsafe.serialProperty or "P348" | |||
local vsn = entity:formatPropertyValues( seek ) | |||
if type( vsn ) == "table" and | |||
type( vsn.value ) == "string" and | |||
vsn.value ~= "" then | |||
if last and vsn.value == Failsafe.serial then | |||
r = false | |||
elseif linked then | |||
if mw.title.getCurrentTitle().prefixedText | |||
== mw.wikibase.getSitelink( suited ) then | |||
r = false | |||
else | |||
r = suited | |||
end | |||
else | |||
r = vsn.value | |||
end | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
if | if type( r ) == "nil" then | ||
if not since or since <= | if not since or since <= Failsafe.serial then | ||
r = | r = Failsafe.serial | ||
else | else | ||
r = false | r = false | ||
| Zeile 682: | Zeile 723: | ||
end | end | ||
return r | return r | ||
end -- | end -- Failsafe.failsafe() | ||
| Zeile 728: | Zeile 769: | ||
end | end | ||
end | end | ||
return | return Failsafe.failsafe( since ) or "" | ||
end -- p.failsafe() | end -- p.failsafe() | ||
return p | return p | ||