Modul:Vorlage:Auflistung: Unterschied zwischen den Versionen
Modul:Vorlage:Auflistung (Quelltext anzeigen)
Version vom 2. November 2020, 17:49 Uhr
, vor 5 Jahren2020-11-02
K (Schützte „Modul:Vorlage:Auflistung“: https://de.wikipedia.org/w/index.php?title=Wikipedia:Administratoren/Anfragen&curid=6974524&diff=204979448&oldid=204979229 ([Bearbeiten=Nur Sichter] (unbeschränkt) [Verschieben=Nur Administratoren] (unbeschränkt))) |
(2020-11-02) |
||
| Zeile 1: | Zeile 1: | ||
local HorizontalList = { suite = "HorizontalList", | local HorizontalList = { suite = "HorizontalList", | ||
serial = "2020- | serial = "2020-11-02", | ||
item = 100938243 } | item = 100938243 } | ||
-- Horizontal list of items by HTML/CSS list | --[=[ | ||
Horizontal list of items by HTML/CSS list | |||
]=] | |||
local CSS = { classesBlock = { }, | local CSS = { classesBlock = { }, | ||
classesSep | classesPrefix = { }, | ||
classesSep = { } } | |||
local Failsafe = HorizontalList | local Failsafe = HorizontalList | ||
HorizontalList.f = function ( all, altogether, apart, frame ) | HorizontalList.f = function ( all, ahead, altogether, apart, frame ) | ||
-- Generate horizontal list from wikitext | -- Generate horizontal list from wikitext | ||
-- Parameter: | -- Parameter: | ||
-- all -- string, with wikitext | -- all -- string, with wikitext | ||
-- each line starting with one of * or # | -- each line starting with one of * or # | ||
-- ahead -- string, to prefix if desired | |||
-- altogether -- true, if nowrap around each regular item | -- altogether -- true, if nowrap around each regular item | ||
-- apart -- string, with separator, if desired | -- apart -- string, with separator, if desired | ||
| Zeile 42: | Zeile 46: | ||
end -- for i | end -- for i | ||
if got then | if got then | ||
local start | |||
if type( ahead ) == "string" and ahead ~= "" then | |||
start = ahead | |||
end | |||
r = HorizontalList.fiat( got, | r = HorizontalList.fiat( got, | ||
list, | list, | ||
start, | |||
altogether, | altogether, | ||
apart, | apart, | ||
| Zeile 63: | Zeile 72: | ||
HorizontalList.fiat = function ( all, advance, altogether, apart, frame ) | HorizontalList.fiat = function ( all, advance, ahead, | ||
altogether, apart, frame ) | |||
-- Generate horizontal list from item sequence | -- Generate horizontal list from item sequence | ||
-- Parameter: | -- Parameter: | ||
-- all -- table, with sequence of items | -- all -- table, with sequence of items | ||
-- each item is a string or a mw.html object | -- each item is a string or a mw.html object | ||
-- ahead -- string, to prefix if desired | |||
-- advance -- true, if ordered list requested | -- advance -- true, if ordered list requested | ||
-- altogether -- true, if nowrap around each item | -- altogether -- true, if nowrap around each item | ||
| Zeile 95: | Zeile 106: | ||
es:addClass( v ) | es:addClass( v ) | ||
end -- for k, v | end -- for k, v | ||
end | |||
if type( ahead ) == "string" then | |||
e = mw.html.create( "li" ) | |||
:wikitext( ahead ) | |||
for k, v in pairs( CSS.classesPrefix ) do | |||
e:addClass( v ) | |||
end -- for k, v | |||
ou:newline() | |||
:node( e ) | |||
end | end | ||
for i = 1, #all do | for i = 1, #all do | ||
| Zeile 151: | Zeile 171: | ||
-- -- table, with title object | -- -- table, with title object | ||
-- classesBlock -- class(es) for block element | -- classesBlock -- class(es) for block element | ||
-- -- string, with class(es) | |||
-- -- table, with particular mapping | |||
-- classesPrefix -- class(es) for prefix element | |||
-- -- string, with class(es) | -- -- string, with class(es) | ||
-- -- table, with particular mapping | -- -- table, with particular mapping | ||
| Zeile 265: | Zeile 288: | ||
p.f = function ( frame ) | p.f = function ( frame ) | ||
-- Template call | -- Template call | ||
HorizontalList.first( { styles | HorizontalList.first( { styles = frame.args.styles, | ||
classesBlock = frame.args.classesBlock, | classesBlock = frame.args.classesBlock, | ||
classesSep | classesPrefix = frame.args.classesPrefix, | ||
classesSep = frame.args.classesSep } ) | |||
return HorizontalList.f( frame.args[ 1 ], | return HorizontalList.f( frame.args[ 1 ], | ||
frame.args.prefix, | |||
frame.args.nowrap == "1", | frame.args.nowrap == "1", | ||
frame.args.sep, | frame.args.sep, | ||