Modul:TemplateData: Unterschied zwischen den Versionen
2018-03-01
w>PerfektesChaos (2018-02-16) |
w>PerfektesChaos (2018-03-01) |
||
Zeile 1: | Zeile 1: | ||
local TemplateData = { suite = "TemplateData", | local TemplateData = { suite = "TemplateData", | ||
serial = "2018- | serial = "2018-03-01", | ||
item = 46997995 } | item = 46997995 } | ||
--[=[ | --[=[ | ||
Zeile 31: | Zeile 31: | ||
-- classParams = "classTable", | -- classParams = "classTable", | ||
-- classTable = false, -- class for params table | -- classTable = false, -- class for params table | ||
debugmultilang = "C0C0C0", | |||
loudly = false, -- show exported element, etc. | loudly = false, -- show exported element, etc. | ||
solo = false, -- complaint on missing description | solo = false, -- complaint on missing description | ||
Zeile 39: | Zeile 40: | ||
subpage = false, -- pattern to identify subpage | subpage = false, -- pattern to identify subpage | ||
suffix = false, -- subpage creation scheme | suffix = false, -- subpage creation scheme | ||
suppressTOCnum = false | suppressTOCnum = false, -- class for TOC number suppression | ||
jsonDebug = "json-code-lint" -- class for jsonDebug tool | |||
} | } | ||
local Data = { | local Data = { | ||
Zeile 75: | Zeile 77: | ||
newlines = "block", | newlines = "block", | ||
spaced = "inline" }, | spaced = "inline" }, | ||
colors = { tableheadbg = "B3B7FF", | colors = { tableheadbg = "B3B7FF", | ||
required | required = "EAF3FF", | ||
suggested | suggested = "FFFFFF", | ||
optional | optional = "EAECF0", | ||
deprecated | deprecated = "FFCBCB" }, | ||
params = { aliases = "table", | params = { aliases = "table", | ||
autovalue = "string", | autovalue = "string", | ||
Zeile 195: | Zeile 197: | ||
-- adapt -- string, message ID after "templatedata-" | -- adapt -- string, message ID after "templatedata-" | ||
-- Returns string, with localized text | -- Returns string, with localized text | ||
return mw.message.new( "templatedata-" .. adapt ):plain() | return mw.message.new( "templatedata-" .. adapt ) | ||
:inLanguage( Data.slang ) | |||
:plain() | |||
end -- factory() | end -- factory() | ||
Zeile 275: | Zeile 279: | ||
return r | return r | ||
end -- fair() | end -- fair() | ||
local function fancy( advance, alert ) | |||
-- Present JSON source | |||
-- Parameter: | |||
-- advance -- true, for nice | |||
-- alert -- true, for visible | |||
-- Returns string | |||
local r | |||
if Data.source then | |||
local support = Config.jsonDebug | |||
local css | |||
if advance then | |||
css = { height = "6em", | |||
resize = "vertical" } | |||
r = { [ 1 ] = "syntaxhighlight", | |||
[ 2 ] = Data.source, | |||
lang = "json", | |||
style = table.concat( css, ";" ) } | |||
if alert then | |||
r.class( support ) | |||
end | |||
r = TemplateData.frame:callParserFunction( "#tag", r ) | |||
else | |||
css = { [ "font-size" ] = "77%", | |||
[ "line-height" ] = "1.35" } | |||
if alert then | |||
css.resize = "vertical" | |||
else | |||
css.display = "none" | |||
end | |||
r = mw.html.create( "pre" ) | |||
:addClass( support ) | |||
:css( css ) | |||
:wikitext( mw.text.encode( Data.source ) ) | |||
r = tostring( r ) | |||
end | |||
r = "\n".. r | |||
else | |||
r = "" | |||
end | |||
return r | |||
end -- fancy() | |||
Zeile 489: | Zeile 538: | ||
para:wikitext( about.description[ 1 ] ) | para:wikitext( about.description[ 1 ] ) | ||
plus = mw.html.create( "ul" ) | plus = mw.html.create( "ul" ) | ||
for k, v in pairs( about.description[ 2 ] ) do | for k, v in pairs( about.description[ 2 ] ) do | ||
plus:node( mw.html.create( "li" ) | plus:node( mw.html.create( "li" ) | ||
Zeile 500: | Zeile 545: | ||
:wikitext( fair( v ) ) ) | :wikitext( fair( v ) ) ) | ||
end -- for k, v | end -- for k, v | ||
if Config.loudly then | |||
plus = mw.html.create( "div" ) | |||
:css( "background-color", | |||
"#" .. Config.debugmultilang ) | |||
:node( plus ) | |||
else | |||
plus:addClass( "templatedata-maintain" ) | |||
:css( "display", "none" ) | |||
end | |||
end | end | ||
elseif Config.solo and asked then | elseif Config.solo and asked then | ||
Zeile 841: | Zeile 895: | ||
local function finalize() | local function finalize( advance ) | ||
-- Wrap presentation into frame | -- Wrap presentation into frame | ||
-- Parameter: | |||
-- advance -- true, for nice | |||
-- Returns string | -- Returns string | ||
local r | local r, lapsus | ||
if Data.div then | if Data.div then | ||
r = tostring( Data.div ) | r = tostring( Data.div ) | ||
Zeile 850: | Zeile 906: | ||
r = Data.strip | r = Data.strip | ||
else | else | ||
r = "" | lapsus = true | ||
r = "" | |||
end | |||
r = r .. failures() | |||
if Data.source then | |||
local live = ( advance or lapsus ) | |||
if not live then | |||
live = TemplateData.frame:preprocess( "{{REVISIONID}}" ) | |||
live = ( live == "" ) | |||
end | |||
if live then | |||
r = r .. fancy( advance, lapsus ) | |||
end | |||
end | end | ||
return r | return r | ||
end -- finalize() | end -- finalize() | ||
Zeile 1.352: | Zeile 1.420: | ||
Data.strip = s | Data.strip = s | ||
end | end | ||
end | |||
if arglist.lang then | |||
Data.slang = arglist.lang:lower() | |||
elseif adapt.lang then | |||
Data.slang = adapt.lang:lower() | |||
end | end | ||
if not source then | if not source then | ||
Zeile 1.380: | Zeile 1.453: | ||
end | end | ||
TemplateData.getPlainJSON( source ) | TemplateData.getPlainJSON( source ) | ||
return finalize() | return finalize( faculty( arglist.source ) ) | ||
--return spy .. finalize() | --return spy .. finalize() | ||
end -- furnish() | end -- furnish() |