Modulo:Categorie bozza: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
correggo |
m modulo no globals obsoleto |
||
(5 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 1:
require('
local p = {}
Riga 5:
function p.main(frame)
local args = frame:getParent().args
local namespace = mw.title.getCurrentTitle().namespace
if not args[1] or namespace == 0 then return args[1] end
local ret = args[1]
local catlinks = {}
local pattern = "%[%[
for catlink in string.gmatch(args[1], pattern) do
Riga 20 ⟶ 21:
ret = ret:sub(0, i - 1) .. ret:sub(j + 1)
catlink = catlink
:gsub('^%[%[ *[Cc].-: *', '
:gsub('^%l', string.upper)
:gsub('^', '[[:Categoria:')
:gsub('%|.+$', ']]')
:gsub('^%[%[(
table.insert(catlinks, '<li>' .. catlink .. '</li>')
end
Riga 28 ⟶ 31:
if #catlinks > 0 then
local label
if #catlinks == 1 then
label = 'Categoria'
text = string.format(text, 'nella seguente categoria')
else
label = 'Categorie'
text = string.format(text, 'nelle seguenti categorie')
end
local div = mw.html.create('div')
:css('font-size', 'small')
:wikitext(text)
▲ :wikitext('Questa pagina sarà elencata nelle seguenti categorie una volta spostata nel [[Aiuto:Namespace|namespace]] principale.')
local ul = mw.html.create('ul')
Riga 38 ⟶ 52:
local container = mw.html.create('div')
:addClass('catlinks')
:node(
:wikitext('[[Aiuto:Categorie|
:node(ul)
ret =
end
return mw.text.trim(ret)
end
|