Nicht angemeldeter Benutzer - Bearbeiten von Seiten ist nur als angemeldeter Benutzer möglich.
Änderungen
Zur Navigation springen
Zur Suche springen
Zeile 1:
Zeile 1:
− +
Zeile 16:
Zeile 16:
− +
− +
− l10nDef.en = {+
Zeile 26:
Zeile 26:
+
+
Zeile 35:
Zeile 37:
− l10nDef.de = {+
Zeile 46:
Zeile 48:
+
Zeile 80:
Zeile 83:
+
+
Zeile 113:
Zeile 118:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Zeile 123:
Zeile 180:
− +
− +
− +
− +
− +
Zeile 229:
Zeile 286:
+
Zeile 293:
Zeile 351:
+
+
+
+
+
+
+
+
Zeile 464:
Zeile 530:
− +
+
Zeile 472:
Zeile 539:
+
+
+
+
+
+
+
+
+
+
+
− +
− +
− +
− r = "<span class='error'>" .. r .. "</span>" +
+
+
+
Zeile 499:
Zeile 580:
− +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Zeile 809:
Zeile 906:
− +
+
Zeile 818:
Zeile 916:
− +
+
Zeile 1.053:
Zeile 1.152:
− +
+
Zeile 1.063:
Zeile 1.163:
− +
+
Zeile 1.110:
Zeile 1.211:
− +
− +
− +
− +
+
Modul:TemplatePar (Quelltext anzeigen)
Version vom 22. Dezember 2014, 23:47 Uhr
, 23:47, 22. Dez. 2014gem. Spezial:Diff/137026344/137027480
--[=[ TemplatePar 2013-09-06
--[=[ TemplatePar 2014-12-22
Template parameter utility
Template parameter utility
* assert
* assert
-- Module globals
-- Module globals
local TemplatePar = { }
local TemplatePar = { }
local messagePrefix = "lua-module-TemplatePar-"
local MessagePrefix = "lua-module-TemplatePar-"
local l10nDef = {}
local L10nDef = {}
L10nDef.en = {
badPattern = "#invoke:TemplatePar pattern syntax error",
badPattern = "#invoke:TemplatePar pattern syntax error",
dupOpt = "#invoke:TemplatePar repeated optional parameter",
dupOpt = "#invoke:TemplatePar repeated optional parameter",
invalidPar = "#invoke:TemplatePar invalid parameter",
invalidPar = "#invoke:TemplatePar invalid parameter",
minmax = "#invoke:TemplatePar min > max",
minmax = "#invoke:TemplatePar min > max",
missing = "#invoke:TemplatePar missing library",
multiSpell = "Error in template * multiple spelling of parameter",
multiSpell = "Error in template * multiple spelling of parameter",
noErrorCat = "#invoke:TemplatePar noError and missing category",
noErrorCat = "#invoke:TemplatePar noError and missing category",
noname = "#invoke:TemplatePar missing parameter name",
noname = "#invoke:TemplatePar missing parameter name",
notFound = "Error in template * missing page",
tooLong = "Error in template * parameter too long",
tooLong = "Error in template * parameter too long",
tooShort = "Error in template * parameter too short",
tooShort = "Error in template * parameter too short",
unknownRule = "#invoke:TemplatePar unknown rule"
unknownRule = "#invoke:TemplatePar unknown rule"
}
}
L10nDef.de = {
badPattern = "#invoke:TemplatePar Syntaxfehler des pattern",
badPattern = "#invoke:TemplatePar Syntaxfehler des pattern",
dupOpt = "#invoke:TemplatePar Optionsparameter wiederholt",
dupOpt = "#invoke:TemplatePar Optionsparameter wiederholt",
noErrorCat = "#invoke:TemplatePar noError und keine Kategorie",
noErrorCat = "#invoke:TemplatePar noError und keine Kategorie",
noname = "#invoke:TemplatePar Parameter nicht angegeben",
noname = "#invoke:TemplatePar Parameter nicht angegeben",
notFound = "Fehler bei Vorlage * Seite fehlt",
tooLong = "Fehler bei Vorlage * Parameter zu lang",
tooLong = "Fehler bei Vorlage * Parameter zu lang",
tooShort = "Fehler bei Vorlage * Parameter zu kurz",
tooShort = "Fehler bei Vorlage * Parameter zu kurz",
[ "abc+" ] = "^[a-z]+$",
[ "abc+" ] = "^[a-z]+$",
[ "aBc+" ] = "^[a-z]+[A-Z][A-Za-z]*$",
[ "aBc+" ] = "^[a-z]+[A-Z][A-Za-z]*$",
[ "w" ] = "^%S*$",
[ "w+" ] = "^%S+$",
[ "base64" ] = "^[A-Za-z0-9%+/]*$",
[ "base64" ] = "^[A-Za-z0-9%+/]*$",
[ "base64+" ] = "^[A-Za-z0-9%+/]+$",
[ "base64+" ] = "^[A-Za-z0-9%+/]+$",
return r
return r
end -- containsCJK()
end -- containsCJK()
local function facility( accept, attempt )
-- Check string as possible file name or other source page
-- Precondition:
-- accept -- string; requirement
-- file
-- file+
-- file:
-- file:+
-- image
-- image+
-- image:
-- image:+
-- attempt -- string; to be tested
-- Postcondition:
-- Return error keyword, or false
-- Uses:
-- Module:FileMedia
-- FileMedia.isType()
local r
if attempt and attempt ~= "" then
local lucky, FileMedia = pcall( require, "Module:FileMedia" )
if type( FileMedia ) == "table" then
FileMedia = FileMedia.FileMedia()
local s, live = accept:match( "^([a-z]+)(:?)%+?$" )
if live then
if FileMedia.isType( attempt, s ) then
if FileMedia.isFile( attempt ) then
r = false
else
r = "notFound"
end
else
r = "invalid"
end
elseif FileMedia.isType( attempt, s ) then
r = false
else
r = "invalid"
end
else
r = "missing"
end
elseif accept:match( "%+$" ) then
r = "empty"
else
r = false
end
return r
end -- facility()
-- Return some message string
-- Return some message string
-- Uses:
-- Uses:
-- > messagePrefix
-- > MessagePrefix
-- > l10nDef
-- > L10nDef
-- mw.language.getContentLanguage()
-- mw.language.getContentLanguage()
-- mw.message.new()
-- mw.message.new()
local c = mw.language.getContentLanguage():getCode()
local c = mw.language.getContentLanguage():getCode()
local m = mw.message.new( messagePrefix .. say )
local m = mw.message.new( MessagePrefix .. say )
local r = false
local r = false
if m:isBlank() then
if m:isBlank() then
local l10n = l10nDef[ c ]
local l10n = L10nDef[ c ]
if not l10n then
if not l10n then
l10n = l10nDef[ "en" ]
l10n = L10nDef[ "en" ]
end
end
r = l10n[ say ]
r = l10n[ say ]
-- failure()
-- failure()
-- mw.text.trim()
-- mw.text.trim()
-- facility()
-- failsafe()
-- failsafe()
-- containsCJK()
-- containsCJK()
r = "undefined"
r = "undefined"
end
end
elseif s:match( "^image%+?:?$" ) or
s:match( "^file%+?:?$" ) then
r = facility( s, analyze )
n = true
elseif s:match( "langW?%+?" ) then
n = "lang"
-- lang lang+
-- langW langW+
end
end
if not n and not r then
if not n and not r then
-- submit -- string or false or nil; non-empty error message
-- submit -- string or false or nil; non-empty error message
-- options -- table or nil; optional details
-- options -- table or nil; optional details
-- options.noError
-- options.noError -- OBSOLETE
-- options.format
-- options.cat
-- options.cat
-- options.template
-- options.template
-- factory()
-- factory()
local r = false
local r = false
local lapsus -- OBSOLETE
if submit then
if submit then
local opt, s
local opt, s
local lazy = false
local show = false
lapsus = false -- OBSOLETE
if type( options ) == "table" then
if type( options ) == "table" then
opt = options
opt = options
if opt.noError then -- OBSOLETE
lazy = true
lapsus = true
end
show = opt.format
lazy = lazy or
( show == "" or show == "0" or show == "-" )
else
else
opt = { }
opt = { }
end
end
if opt.noError then
if lazy then
if not opt.cat then
if not opt.cat then
r = submit .. " " .. factory( "noErrorCat" )
r = submit .. " " .. factory( "noErrorCat" ) -- OBSOLETE
end
end
else
else
r = submit
r = submit
end
end
if r then
if r and not lazy then
if not show or show == "*" then
show = "<span class=\"error\">@@@</span>"
end
r = mw.ustring.gsub( show, "@@@", r )
end
end
s = opt.cat
s = opt.cat
end
end
end
end
r = r .. "[[Category:" .. s .. "]]"
local i
local cats = mw.text.split( s, "%s*#%s*" )
for i = 1, #cats do
s = mw.text.trim( cats[ i ] )
if #s > 0 then
r = string.format( "%s[[Category:%s]]", r, s )
end
end -- for i
end
elseif type( options ) == "table" then
lapsus = options.noError -- OBSOLETE
end
if lapsus then -- OBSOLETE
if not r then
r = ""
end
end
r = r ..
"[[Category:Wikipedia:Wartung Modul:TemplatePar noError]]"
end
end
return r
return r
"max",
"max",
"min",
"min",
"noError",
"noError", -- OBSOLETE
"format",
"template" },
"template" },
template = "#invoke:TemplatePar|".. action .. "|"
template = "#invoke:TemplatePar|".. action .. "|"
options = { cat = frame.args.cat,
options = { cat = frame.args.cat,
low = frame.args.low,
low = frame.args.low,
noError = frame.args.noError,
noError = frame.args.noError, -- OBSOLETE
format = frame.args.format,
template = frame.args.template
template = frame.args.template
}
}
"cat",
"cat",
"low",
"low",
"noError",
"noError", -- OBSOLETE
"format",
"template" },
"template" },
template = "#invoke:TemplatePar|check|"
template = "#invoke:TemplatePar|check|"
cat = frame.args.cat,
cat = frame.args.cat,
low = frame.args.low,
low = frame.args.low,
noError = frame.args.noError,
noError = frame.args.noError, -- OBSOLETE
format = frame.args.format,
template = frame.args.template
template = frame.args.template
}
}
-- finalize()
-- finalize()
local r = false
local r = false
local options = { cat = frame.args.cat,
local options = { cat = frame.args.cat,
low = frame.args.low,
low = frame.args.low,
noError = frame.args.noError,
noError = frame.args.noError, -- OBSOLETE
template = frame.args.template
format = frame.args.format,
template = frame.args.template
}
}
local k, v, s
local k, v, s