Modulo:Vedi anche/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
aggiunta funzione "sezione" per il template "Vedi anche sezione" |
m Bot: rimuovo no globals obsoleto |
||
(14 versioni intermedie di 3 utenti non mostrate) | |||
Riga 1:
--[[
* Modulo che implementa
]]
require('
-- Parsifica un argomento del template (rappresenta il titolo di una pagina) e ne
local p = {}▼
--
-- @param {string} arg
▲-- Parsifica un argomento del template (rappresenta il titolo di una pagina) e ne ritorna il wikilink.
-- @return {string}
local function parseArg(arg)
local dest, count
-- restituisce errore con wikilink a categorie
if arg:match('^%s*:%s*[Cc][Aa][Tt]') then
return '<span class="error">(usare il [[Template:Vedi categoria]])</span>'
end▼
-- rimuove eventuali pipe inserite tramite {{!}}
arg = arg:match('(.*)|') or arg
Line 20 ⟶ 26:
dest = count == 1 and (dest .. '|') or ''
return string.format("'''[[
end
-- Costruisce l'HTML per contenere i wikilink alle pagine.
--
local function buildHTML(wikitext, with_noprint)▼
-- @param {string} wikitext
-- @return {string}
local tableNode = mw.html.create('table')
tableNode
:addClass(
:tag('tr')
:tag('td')
▲ :wikitext('[[File:Exquisite-kfind.png|20px|class=noviewer]]')
:done()
:tag('td')
▲ :wikitext("''Lo stesso argomento in dettaglio: " .. wikitext .. "''.")
:done()
return tostring(tableNode)
end
-- =============================================================================
-- Entry-point per {{Vedi anche sezione}}▼
-- Funzioni esportate
-- =============================================================================
▲end
▲local p = {}
function p.main(frame)
local lastArg, conjunction
local styles = 'Modulo:Vedi anche/sandbox/styles.css'
local args = {}
for _, val in ipairs(frame:getParent().args) do
if mw.text.trim(val) ~= '' then
table.insert(args, parseArg(val))
lastArg = val
end
end
if #args > 1 and lastArg then
conjunction = mw.ustring.lower(lastArg:sub(1, 1)) == 'e' and 'ed' or 'e'
conjunction = ' ' .. conjunction .. ' '
end
return frame:extensionTag{
return buildHTML(mw.text.listToText(args, ', ', ' e '), true)▼
name = 'templatestyles',
args = {src = styles}
end
|