Modulo:Categorie bozza: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
creazione modulo |
m modulo no globals obsoleto |
||
(8 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 1:
require('
local p = {}
function p.main(frame)
local namespace = mw.title.getCurrentTitle().namespace
if not args[1] or namespace == 0 then return args[1] end
local ret = frame.args[1]▼
local catlinks = {}
local pattern = "%[%[
for catlink in string.gmatch(
local namespaceprefix = catlink:match('[^%[ :]+')
local ns = mw.site.namespaces[namespaceprefix]
Riga 17 ⟶ 20:
local i, j = ret:find(catlink, 1, true)
ret = ret:sub(0, i - 1) .. ret:sub(j + 1)
catlink = catlink
:gsub('^%[%[ *[Cc].-: *', ' :gsub('^% :gsub('^', '[[:Categoria:')
:gsub('%|.+$', ']]')
:gsub('^%[%[(:.-):(.+)%]%]$', '[[%1:%2|%2]]')
table.insert(catlinks, '<li>' .. catlink .. '</li>')
end
Riga 23 ⟶ 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 33 ⟶ 52:
local container = mw.html.create('div')
:addClass('catlinks')
:node(
:wikitext('[[Aiuto:Categorie|
:node(ul)
Riga 40 ⟶ 59:
end
return mw.text.trim(ret)
end
|