Importer, Bürokraten, Moderatoren (CommentStreams), Strukturierte-Diskussionen-Bots, Oberflächenadministratoren, Push-Abonnementverwalter, Oversighter, Administratoren, Kampagnenbearbeiter (Hochladeassistent)
855
Bearbeitungen
(2023-01-07) |
K (73 Versionen von wikivoyage:Modul:TemplateData importiert) |
||
| (2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
local TemplateData = { suite = "TemplateData", | local TemplateData = { suite = "TemplateData", | ||
serial = " | serial = "2021-07-05", | ||
item = 46997995 } | item = 46997995 } | ||
--[==[ | --[==[ | ||
| Zeile 11: | Zeile 11: | ||
local Config = { | local Config = { | ||
-- multiple option names mapped into unique internal fields | -- multiple option names mapped into unique internal fields | ||
basicCnf = { catProblem | basicCnf = { catProblem = "strange", | ||
classNoNumTOC = "suppressTOCnum", | |||
classNoNumTOC | classTable = "classTable", | ||
classTable | cssParWrap = "cssTabWrap", | ||
cssParWrap | cssParams = "cssTable", | ||
cssParams | docpageCreate = "suffix", | ||
docpageCreate | docpageDetect = "subpage", | ||
docpageDetect | helpBoolean = "support4boolean", | ||
helpContent = "support4content", | |||
helpBoolean | helpDate = "support4date", | ||
helpContent | helpFile = "support4wiki-file-name", | ||
helpDate | helpFormat = "supportFormat", | ||
helpFile | helpLine = "support4line", | ||
helpFormat | helpNumber = "support4number", | ||
helpLine | helpPage = "support4wiki-page-name", | ||
helpNumber | helpString = "support4string", | ||
helpPage | helpTemplate = "support4wiki-template-name", | ||
helpString | helpURL = "support4url", | ||
helpTemplate | helpUser = "support4wiki-user-name", | ||
helpURL | msgDescMiss = "solo", | ||
helpUser | tStylesTOCnum = "stylesTOCnum" }, | ||
msgDescMiss | |||
tStylesTOCnum | |||
classTable = { "wikitable" }, -- classes for params table | classTable = { "wikitable" }, -- classes for params table | ||
debugmultilang = "C0C0C0", | debugmultilang = "C0C0C0", | ||
| Zeile 71: | Zeile 68: | ||
} | } | ||
local Permit = { | local Permit = { | ||
builder = { after | builder = { after = "block", | ||
align | align = "block", | ||
block | block = "block", | ||
compressed = "block", | compressed = "block", | ||
dense | dense = "block", | ||
grouped | grouped = "inline", | ||
half | half = "inline", | ||
indent | indent = "block", | ||
inline | inline = "inline", | ||
last | last = "block", | ||
lead | lead = "block", | ||
newlines | newlines = "*", | ||
spaced | spaced = "inline" }, | ||
colors = { | colors = { tableheadbg = "B3B7FF", | ||
required = "EAF3FF", | required = "EAF3FF", | ||
suggested = "FFFFFF", | suggested = "FFFFFF", | ||
| Zeile 102: | Zeile 97: | ||
style = "string table", | style = "string table", | ||
suggested = "boolean", | suggested = "boolean", | ||
suggestedvalues = "string table number | suggestedvalues = "string table number", | ||
type = "string" }, | type = "string" }, | ||
root = { description = "string table I18N", | root = { description = "string table I18N", | ||
| Zeile 244: | Zeile 239: | ||
return r | return r | ||
end -- facet() | end -- facet() | ||
| Zeile 678: | Zeile 609: | ||
local l, cx = pcall( mw.loadData, | local l, cx = pcall( mw.loadData, | ||
TemplateData.frame:getTitle() .. "/config" ) | TemplateData.frame:getTitle() .. "/config" ) | ||
local scripting | local scripting | ||
TemplateData.ltr = not mw.language.getContentLanguage():isRTL() | TemplateData.ltr = not mw.language.getContentLanguage():isRTL() | ||
if TemplateData.ltr then | if TemplateData.ltr then | ||
| Zeile 697: | Zeile 628: | ||
k = "tablehead" | k = "tablehead" | ||
end | end | ||
Permit.css[ k ] = { ["background-color"] = "#" .. v } | |||
Permit.css[ k ] = { | |||
end -- for k, v | end -- for k, v | ||
if type( cx ) == "table" then | if type( cx ) == "table" then | ||
| Zeile 726: | Zeile 651: | ||
for k, v in pairs( Config.basicCnf ) do | for k, v in pairs( Config.basicCnf ) do | ||
s = type( cx[ k ] ) | s = type( cx[ k ] ) | ||
if s == "string" or s == "table" then | if s == "string" or s == "table" then | ||
Config[ v ] = cx[ k ] | Config[ v ] = cx[ k ] | ||
| Zeile 752: | Zeile 676: | ||
local function feasible( | local function feasible( about, at ) | ||
-- Deal with suggestedvalues within parameter | -- Deal with suggestedvalues within parameter | ||
-- Parameter: | -- Parameter: | ||
-- | -- about -- parameter details | ||
-- . | -- .suggestedvalues -- table|string|number, | ||
-- value and possibly description | |||
-- .code -- mandatory | |||
-- .label -- table|string | |||
-- .icon -- string | |||
-- .class -- table|string | |||
-- .css -- table | |||
-- .style -- string | |||
-- .less -- true: suppress code | |||
-- .type | -- .type | ||
-- at -- string, with parameter name | -- at -- string, with parameter name | ||
-- Returns | -- Returns | ||
-- 1: mw.html object | -- 1: mw.html object | ||
-- 2: sequence table with values, or nil | -- 2: sequence table with values, or nil | ||
local | local p = about.suggestedvalues | ||
local e, r1, r2 | local s = type( p ) | ||
if # | local e, r1, r2, v | ||
if s == "table" then | |||
if #p > 0 then | |||
for i = 1, #p do | |||
e = p[ i ] | |||
s = type( e ) | |||
if s == "table" then | |||
if type( e.code ) == "string" then | |||
s = mw.text.trim( e.code ) | |||
if s == "" then | |||
e = nil | |||
else | |||
e.code = s | |||
end | |||
else | |||
e = nil | |||
s = string.format( "params.%s.%s[%d] %s", | |||
at, | |||
"suggestedvalues", | |||
i, | |||
"MISSING 'code:'" ) | |||
end | |||
elseif s == "string" then | |||
s = mw.text.trim( e ) | |||
if s == "" then | if s == "" then | ||
e = nil | e = nil | ||
s = string.format( "params.%s.%s[%d] EMPTY", | |||
at, "suggestedvalues", i ) | |||
Fault( s ) | |||
else | else | ||
e | e = { code = s } | ||
end | end | ||
elseif s == "number" then | |||
e = { code = tostring( e ) } | |||
else | else | ||
s = string.format( "params.%s.%s[%d] INVALID", | |||
s = string.format( "params.%s.%s[%d] | |||
at, "suggestedvalues", i ) | at, "suggestedvalues", i ) | ||
Fault( s ) | Fault( s ) | ||
e = false | |||
e = | |||
end | end | ||
if e then | |||
v = v or { } | |||
table.insert( v, e ) | |||
end | end | ||
end -- for i | |||
else | |||
Fault( string.format( "params.%s.suggestedvalues %s", | |||
at, "NOT AN ARRAY" ) ) | |||
end | |||
elseif s == "string" then | |||
s = mw.text.trim( p ) | |||
if s ~= "" then | |||
v = { } | |||
table.insert( v, | |||
{ code = s } ) | |||
end | |||
elseif s == "number" then | |||
v = { } | |||
table.insert( v, | |||
{ code = tostring( p ) } ) | |||
end | end | ||
if v then | if v then | ||
local | local d, less, story, swift, t, u | ||
r1 = mw.html.create( "ul" ) | r1 = mw.html.create( "ul" ) | ||
r2 = { } | r2 = { } | ||
| Zeile 875: | Zeile 801: | ||
end | end | ||
end | end | ||
if | if about.type:sub( 1, 5 ) == "wiki-" and | ||
swift == e.code then | swift == e.code then | ||
local rooms = { file = 6, | local rooms = { file = 6, | ||
temp = 10, | temp = 10, | ||
user = 2 } | user = 2 } | ||
local ns = rooms[ | local ns = rooms[ about.type:sub( 6, 9 ) ] or 0 | ||
t = mw.title.makeTitle( ns, swift ) | t = mw.title.makeTitle( ns, swift ) | ||
if t and t.exists then | if t and t.exists then | ||
| Zeile 887: | Zeile 813: | ||
end | end | ||
end | end | ||
u:node( mw.html.create( "code" ) | |||
:css( "white-space", "nowrap" ) | |||
:wikitext( swift ) ) | |||
end | end | ||
if e.class then | if e.class then | ||
| Zeile 930: | Zeile 849: | ||
end | end | ||
end | end | ||
if | if about.type == "wiki-file-name" and not e.icon then | ||
e.icon = e.code | e.icon = e.code | ||
end | end | ||
| Zeile 996: | Zeile 915: | ||
end -- for i | end -- for i | ||
end | end | ||
if not r1 | if not r1 then | ||
Fault( string.format( "params.%s.suggestedvalues INVALID", at ) ) | Fault( string.format( "params.%s.suggestedvalues INVALID", at ) ) | ||
r1 = mw.html.create( "code" ) | r1 = mw.html.create( "code" ) | ||
| Zeile 1.141: | Zeile 1.060: | ||
:wikitext( s ) | :wikitext( s ) | ||
else | else | ||
syn = mw.html.create( "span" ) | syn = mw.html.create( "span" ) | ||
:addClass( styles .. "alias" ) | :addClass( styles .. "alias" ) | ||
| Zeile 1.221: | Zeile 1.135: | ||
end | end | ||
elseif s == "suggestedvalues" then | elseif s == "suggestedvalues" then | ||
local | local html, values = feasible( param, access ) | ||
dd:newline() | |||
:node( html ) | |||
Data.params[ access ].suggestedvalues = values | |||
else | else | ||
dd:wikitext( show ) | dd:wikitext( show ) | ||
| Zeile 1.298: | Zeile 1.196: | ||
end | end | ||
end | end | ||
-- status | -- status | ||
if param.required then | if param.required then | ||
| Zeile 1.343: | Zeile 1.240: | ||
eager:attr( "data-sort-value", tostring( mode ) ) | eager:attr( "data-sort-value", tostring( mode ) ) | ||
:node( ranking ) | :node( ranking ) | ||
:addClass( string.format( "%sstatus- | :addClass( string.format( "%sstatus-%s", | ||
styles, status | styles, status ) ) | ||
-- <tr> | -- <tr> | ||
| Zeile 1.384: | Zeile 1.280: | ||
tbl:css( Config.cssTable ) | tbl:css( Config.cssTable ) | ||
end | end | ||
tr | tr:node( mw.html.create( "th" ) | ||
:attr( "colspan", "2" ) | :attr( "colspan", "2" ) | ||
:css( Permit.css.tablehead ) | :css( Permit.css.tablehead ) | ||
| Zeile 1.592: | Zeile 1.487: | ||
if r:find( "<", 1, true ) then | if r:find( "<", 1, true ) then | ||
local Text = Fetch( "Text" ) | local Text = Fetch( "Text" ) | ||
r = r:gsub( "<br */?>", "\r\n" ) | r = Text.getPlain( r:gsub( "<br */?>", "\r\n" ) ) | ||
end | end | ||
if r:find( "[", 1, true ) then | if r:find( "[", 1, true ) then | ||
| Zeile 2.011: | Zeile 1.903: | ||
end | end | ||
end | end | ||
toc | toc:css( "margin-top", "0.5em" ) | ||
:wikitext( "__TOC__" ) | :wikitext( "__TOC__" ) | ||
if Data.sibling then | if Data.sibling then | ||
| Zeile 2.069: | Zeile 1.960: | ||
end | end | ||
r:node( mw.html.create( "p" ) | r:node( mw.html.create( "p" ) | ||
:wikitext( show .. ": " ) | :wikitext( show .. ": " ) | ||
:node( e ) ) | :node( e ) ) | ||
| Zeile 2.093: | Zeile 1.983: | ||
Data.div = mw.html.create( "div" ) | Data.div = mw.html.create( "div" ) | ||
:addClass( "mw-templatedata-doc-wrap" ) | :addClass( "mw-templatedata-doc-wrap" ) | ||
focus() | focus() | ||
if Data.tag then | if Data.tag then | ||
| Zeile 2.382: | Zeile 2.266: | ||
return TemplateData | return TemplateData | ||
end | end | ||
return p | return p | ||