Modul:Message box: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Modul:Message box (Quelltext anzeigen)
Version vom 1. September 2021, 20:01 Uhr
, 20:01, 1. Sep. 2021per request Special:Permalink/4730320
StadtbahnBI>Tacsipacsi |
StadtbahnBI>Majavah (per request Special:Permalink/4730320) |
||
Zeile 13: | Zeile 13: | ||
local CONFIG_MODULE = 'Module:Message box/configuration' | local CONFIG_MODULE = 'Module:Message box/configuration' | ||
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'} | local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'} | ||
local TEMPLATE_STYLES = 'Module:Message box/%s.css' | |||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
Zeile 66: | Zeile 67: | ||
args = args or {} | args = args or {} | ||
local obj = {} | local obj = {} | ||
obj.boxType = boxType | |||
-- Set the title object and the namespace. | -- Set the title object and the namespace. | ||
Zeile 81: | Zeile 84: | ||
-- use template from DEMOSPACES | -- use template from DEMOSPACES | ||
obj.cfg = cfg[DEMOSPACES[demospace]] | obj.cfg = cfg[DEMOSPACES[demospace]] | ||
obj.boxType = DEMOSPACES[demospace] | |||
elseif string.find( demospace, 'talk' ) then | elseif string.find( demospace, 'talk' ) then | ||
-- demo as a talk page | -- demo as a talk page | ||
obj.cfg = cfg.tmbox | obj.cfg = cfg.tmbox | ||
obj.boxType = 'tmbox' | |||
else | else | ||
-- default to ombox | -- default to ombox | ||
obj.cfg = cfg.ombox | obj.cfg = cfg.ombox | ||
obj.boxType = 'ombox' | |||
end | end | ||
elseif ns == 0 then | elseif ns == 0 then | ||
obj.cfg = cfg.ambox -- main namespace | obj.cfg = cfg.ambox -- main namespace | ||
obj.boxType = 'ambox' | |||
elseif ns == 6 then | elseif ns == 6 then | ||
obj.cfg = cfg.imbox -- file namespace | obj.cfg = cfg.imbox -- file namespace | ||
obj.boxType = 'imbox' | |||
elseif ns == 14 then | elseif ns == 14 then | ||
obj.cfg = cfg.cmbox -- category namespace | obj.cfg = cfg.cmbox -- category namespace | ||
obj.boxType = 'cmbox' | |||
else | else | ||
local nsTable = mw.site.namespaces[ns] | local nsTable = mw.site.namespaces[ns] | ||
if nsTable and nsTable.isTalk then | if nsTable and nsTable.isTalk then | ||
obj.cfg = cfg.tmbox -- any talk namespace | obj.cfg = cfg.tmbox -- any talk namespace | ||
obj.boxType = 'tmbox' | |||
else | else | ||
obj.cfg = cfg.ombox -- other namespaces or invalid input | obj.cfg = cfg.ombox -- other namespaces or invalid input | ||
obj.boxType = 'ombox' | |||
end | end | ||
end | end | ||
Zeile 190: | Zeile 201: | ||
self:addClass(args.class) | self:addClass(args.class) | ||
self.style = args.style | self.style = args.style | ||
self.attrs = args.attrs | self.attrs = args.attrs | ||
Zeile 479: | Zeile 488: | ||
)) | )) | ||
end | end | ||
-- Add TemplateStyles | |||
root:wikitext(mw.getCurrentFrame():extensionTag{ | |||
name = 'templatestyles', | |||
args = { src = TEMPLATE_STYLES:format(self.boxType) }, | |||
}) | |||
-- Create the box table. | -- Create the box table. | ||
Zeile 490: | Zeile 505: | ||
:attr('role', 'presentation') | :attr('role', 'presentation') | ||
if self.attrs then | if self.attrs then | ||
boxTable:attr(self.attrs) | boxTable:attr(self.attrs) |