Modulo:Infobox/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
passati a RemexHTML dovrebbe essere sufficiente spostare il testo su una riga a sé
Test parametro posizione
 
(14 versioni intermedie di 2 utenti non mostrate)
Riga 6:
local root -- radice del markup html
local dump = {}
 
local function checkList(valore)
-- Permette al software Mediawiki di gestire le liste # o *
local c = mw.ustring.sub(valore, 1, 1)
if c == '#' or c == '*' then
valore = '<div>\n' .. valore .. '\n</div>'
end
return valore .. '\n'
end
 
local function getArgNums(...)
Riga 36 ⟶ 45:
:tag('th')
:attr('colspan', 2)
:cssText(rowArgs.stilestilegruppoN or args.StileGruppo or ''nil)
:wikitext(rowArgs.gruppo)
-- Altrimenti se rowArgs.valore non è nullo inserisce una riga dati, verificando
Riga 46 ⟶ 55:
row
:tag('th')
:cssText(rowArgs.stilenomeN or args.StileNome or ''nil)
:wikitext(rowArgs.nome)
dataCell = row:tag('td')
else
dataCell = row:tag('td')
:addClass('sinottico_testo_centrale')
:attr('colspan', 2)
:css('text-align', 'center')
end
dataCell
:addClass(rowArgs.classe or ''nil)
:cssText(rowArgs.stilevaloreN or args.StileValore or ''nil)
:wikitext(checkList(rowArgs.valore))
:newline()
:wikitext(rowArgs.valore)
end
end
Riga 68 ⟶ 76:
:tag('span')
:addClass('sinottico_sottotitolo')
:cssText(args.StileSopraTitolo or ''nil)
:wikitext(args.SopraTitolo)
:done()
Riga 79 ⟶ 87:
:tag('span')
:addClass('sinottico_sottotitolo')
:cssText(args.StileSottoTitolo or ''nil)
:wikitext(args.SottoTitolo)
end
Riga 86 ⟶ 94:
:tag('caption')
:addClass('sinottico_testata')
:cssText(args.StileTitoloEst or ''nil)
:css("font-weight", "bold")
:cssText(args.StileTitoloEst or '')
:node(suptitle)
:wikitext(args.TitoloEst)
Riga 98 ⟶ 105:
:attr('colspan', '2')
:node(suptitle)
:cssText(args.StileTitoloInt or ''nil)
:wikitext(args.TitoloInt)
:node(subtitle)
Riga 108 ⟶ 115:
local cell_immagine = mw.html.create('td')
cell_immagine
:addClass('sinottico_testo_centrale ' .. (args.ClasseImmagine or ''))
:attr('colspan', '2')
:cssText(args.StileImmagine or ''nil)
:css('text-align', 'center')
:cssText(args.StileImmagine or '')
:wikitext(args.Immagine)
if args.Didascalia then
Riga 118 ⟶ 124:
:done()
:tag('span')
:cssText(args.StileDidascalia or ''nil)
:wikitext(args.Didascalia)
end
Riga 126 ⟶ 132:
 
local function renderRows()
local rownums = getArgNums('Valore', 'GruppoOpzionale', 'Gruppo', 'Nodo')
for k, num in ipairs(rownums) do
local skip = false
Riga 133 ⟶ 139:
for j = k+1, #rownums do
if args['Gruppo' .. rownums[j]] ~= nil or args['GruppoOpzionale' .. rownums[j]]~=nil then break end
if args['Valore' .. rownums[j]] ~= nil or args['Nodo' .. rownums[j]] ~= nil then
skip = false
break
end
end
end
if args['Nodo' .. num] ~= nil then
root:wikitext(args['Nodo' .. num])
skip = true
end
if not skip and args['GruppoOpzionale' .. num] ~= '$fine' then
Riga 145 ⟶ 155:
valore = args['Valore' .. num],
classe = args['Classe' .. num],
stilestilegruppoN = args['GruppoStile' .. num],
stilenomeN = args['NomeStile' .. num],
stilevaloreN = args['ValoreStile' .. num]
})
end
Riga 158 ⟶ 170:
:attr('colspan', '2')
:addClass('sinottico_piede')
:cssText(args.StileUltima or ''nil)
:wikitext(args.Ultima)
:newline()
Riga 168 ⟶ 180:
:tag('tr')
:tag('td')
:addClass('sinottico_piede2 noprint nomobile metadata')
:attr('colspan', '2')
:wikitext(mw.getCurrentFrame():expandTemplate({
Riga 180 ⟶ 192:
local function _infobox()
-- Crea l'albero html che rappresenta la tabella del sinottico e restituisce il markup
if args.CreaTable == 'no' or args.Posizione == 'corpo' or args.Posizione == 'coda' then
root = mw.html.create('')
else
root = mw.html.create('table')
root
:addClass('infobox sinottico')
:cssText(args.StileTabella or ''nil)
:attr('summary', args.Summary or 'Tabella sinottica che riassume i principali dati del soggetto')
end
Riga 194 ⟶ 206:
renderLastRow()
renderNavBar()
returnlocal res = tostring(root)
if args.Posizione == 'coda' then
res = res .. '</table>';
elseif args.Posizione == 'testa' then
res = mw.ustring.gsub( res, '</table>$', '')
end
return res
end
 
Riga 299 ⟶ 318:
preprocessSingleArg('StileValore')
preprocessArgs({
{prefix = 'Nodo'},
{prefix = 'Gruppo', depend={'GruppoStile'}},
{prefix = 'GruppoOpzionale', depend={'GruppoStile'}},
{prefix = 'Valore', depend={'Nome', 'Classe', 'NomeStile', 'ValoreStile'}},
}, 50)
preprocessSingleArg('Ultima')
Riga 308 ⟶ 328:
preprocessSingleArg('LinkWikidata')
preprocessSingleArg('CreaTable')
preprocessSingleArg('Posizione')
preprocessSingleArg('Summary')
return _infobox()