Importer, Bürokraten, Moderatoren (CommentStreams), Strukturierte-Diskussionen-Bots, Oberflächenadministratoren, Push-Abonnementverwalter, Oversighter, Administratoren, Kampagnenbearbeiter (Hochladeassistent)
855
Bearbeitungen
(2020-10-23) |
K (9 Versionen von wikipedia:Modul:Vorlage:Auflistung importiert) |
||
| (6 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
local HorizontalList = { suite = "HorizontalList", | local HorizontalList = { suite = "HorizontalList", | ||
serial = " | serial = "2021-02-05", | ||
item = | 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 | classesNowrap = { }, | ||
classesPrefix = { }, | |||
classesSep = { } } | |||
local Failsafe = HorizontalList | local Failsafe = HorizontalList | ||
HorizontalList.f = function ( all, altogether, apart, frame ) | local fix = function ( at ) | ||
for k, v in pairs( CSS.classesNowrap ) do | |||
at:addClass( v ) | |||
end -- for k, v | |||
end -- fix() | |||
HorizontalList.f = function ( all, ahead, altogether, access, alien, | |||
apart, frame ) | |||
-- Generate horizontal list from wikitext | -- Generate horizontal list from wikitext | ||
-- Parameter: | -- Parameter: | ||
-- all | -- all -- string, with wikitext | ||
-- | -- each line starting with one of * or # | ||
-- altogether | -- ahead -- string, to prefix if desired | ||
-- apart | -- altogether -- true, if nowrap around each regular item | ||
-- frame | -- access -- string, with fragment, if desired | ||
-- alien -- string, with language code, if desired | |||
-- apart -- string, with separator, if desired | |||
-- frame -- object, if available | |||
-- Returns string | -- Returns string | ||
local r | local r | ||
| Zeile 42: | Zeile 58: | ||
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, | ||
access, | |||
alien, | |||
apart, | apart, | ||
frame ) | frame ) | ||
| Zeile 63: | Zeile 86: | ||
HorizontalList.fiat = function ( all, advance, altogether, apart, frame ) | HorizontalList.fiat = function ( all, advance, ahead, altogether, | ||
access, alien, apart, frame ) | |||
-- Generate horizontal list from item sequence | -- Generate horizontal list from item sequence | ||
-- Parameter: | -- Parameter: | ||
-- all | -- all -- table, with sequence of items | ||
-- | -- each item is a string or a mw.html object | ||
-- advance | -- ahead -- string, to prefix if desired | ||
-- altogether | -- advance -- true, if ordered list requested | ||
-- apart | -- altogether -- true, if nowrap around each item | ||
-- frame | -- access -- string, with fragment, if desired | ||
-- alien -- string, with language code, if desired | |||
-- apart -- string, with separator, if desired | |||
-- frame -- object, if available | |||
-- Returns string | -- Returns string | ||
local r | local r | ||
| Zeile 87: | Zeile 114: | ||
ou:addClass( v ) | ou:addClass( v ) | ||
end -- for k, v | end -- for k, v | ||
if CSS.style then | |||
ou:cssText( CSS.style ) | |||
end | |||
if CSS.css then | |||
ou:css( CSS.css ) | |||
end | |||
if type( access ) == "string" then | |||
s = mw.text.trim( access ) | |||
if s ~= "" then | |||
ou:attr( "id", s ) | |||
end | |||
end | |||
if alien then | |||
s = mw.text.trim( alien ) | |||
if s ~= "" then | |||
ou:attr( "lang", s ) | |||
end | |||
end | |||
if type( apart ) == "string" then | if type( apart ) == "string" then | ||
es = mw.html.create( "span" ) | es = mw.html.create( "span" ) | ||
:wikitext( apart ) | :node( mw.html.create( "span" ) | ||
:attr( "aria-hidden", "true" ) | |||
:wikitext( apart ) ) | |||
for k, v in pairs( CSS.classesSep ) do | for k, v in pairs( CSS.classesSep ) do | ||
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 101: | Zeile 157: | ||
else | else | ||
e:wikitext( tostring( s ) ) | e:wikitext( tostring( s ) ) | ||
end | |||
if CSS.styleItem then | |||
e:cssText( CSS.styleItem ) | |||
end | end | ||
if es and i < #all then | if es and i < #all then | ||
| Zeile 106: | Zeile 165: | ||
end | end | ||
if altogether then | if altogether then | ||
e | fix( e ) | ||
end | end | ||
ou:newline() | ou:newline() | ||
| Zeile 125: | Zeile 184: | ||
r = all[ 1 ] | r = all[ 1 ] | ||
if altogether then | if altogether then | ||
if type( r ) | if type( r ) ~= "table" then | ||
r = mw.html.create( "span" ) | r = mw.html.create( "span" ) | ||
:wikitext( tostring( r ) ) | :wikitext( tostring( r ) ) | ||
end | end | ||
fix( r ) | |||
end | end | ||
r = tostring( r ) | r = tostring( r ) | ||
| Zeile 145: | Zeile 203: | ||
-- Parameter: | -- Parameter: | ||
-- arglist -- table, with optional components | -- arglist -- table, with optional components | ||
-- styleItem -- style per item | |||
-- -- string | |||
-- styles -- templatestyles page | -- styles -- templatestyles page | ||
-- -- string, with name | -- -- string, with name | ||
-- -- 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 | |||
-- classesNowrap -- class(es) for nowrap 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 194: | Zeile 260: | ||
if s and s:match( ".+:.+%.css$") then | if s and s:match( ".+:.+%.css$") then | ||
CSS.styles = s | CSS.styles = s | ||
end | |||
val = arglist.style | |||
s = type( val ) | |||
if s == "string" then | |||
s = mw.text.trim( val ) | |||
if s ~= "" then | |||
CSS.style = s | |||
end | |||
elseif s == "table" then | |||
CSS.css = val | |||
end | |||
val = arglist.styleItem | |||
if type( val ) == "string" then | |||
s = mw.text.trim( val ) | |||
if s ~= "" then | |||
CSS.styleItem = s | |||
end | |||
end | end | ||
end | end | ||
| Zeile 263: | Zeile 346: | ||
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 | classesNowrap = frame.args.classesNowrap, | ||
classesPrefix = frame.args.classesPrefix, | |||
classesSep = frame.args.classesSep, | |||
style = frame.args.style, | |||
styleItem = frame.args.styleItem } ) | |||
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.id, | |||
frame.args.lang, | |||
frame.args.sep, | frame.args.sep, | ||
frame ) | frame ) | ||