Modulo:Controllo Wikidata/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
allineo a ultima versione |
m Bot: rimuovo no globals obsoleto |
||
(7 versioni intermedie di un altro utente non mostrate) | |||
Riga 1:
--[[▼
]]--▼
require('strict')
-- require('Modulo:No globals')▼
local p = {}
Riga 26 ⟶ 29:
end
▲--[[
▲]]--
▲function p._category(wdprop, userval, catprefix, args)
if args.id == 'no' then▼
wdval = wdprop▼
wdval = mWikidata._getProperty( {▼
showunit = args['unità'] ~= 'no',▼
from = args.from▼
local comparefunc = function(v1, v2) return v1 == v2 end
local cat
Riga 53 ⟶ 35:
-- consente di definire funzioni di confronto per proprietà specifiche
-- (oppure tramite eventuali parametri)
▲ if mWikidata._getDatatype({ args[1] }) == 'file multimediale su Commons' then
▲ comparefunc = compareCommonsMediaFile
▲ comparefunc = compareURL
end
if userval then
if not wdval then
cat = string.format('%s assente su Wikidata',
elseif args.uguale ~= 'no' and comparefunc(wdval, userval) then
cat = string.format('%s uguale
elseif args.diff ~= 'no' then
cat = string.format('%s differente
end
elseif wdval then
cat = string.format('%s
end
return
end
▲* Per l'utilizzo da altro modulo.
function p._main(args)
local wdprop, userval
-- namespace 0
if (mw.title.getCurrentTitle().namespace ~= 0 and args.everyNS ~= 'sì') or not wdprop then
return
end
unit = args.unit,
})
▲ return category and string.format('[[Categoria:%s]]', category) or ''
end
▲* Entry-point di _main per il template {{Controllo Wikidata}}
function p.main(frame)
return p._main(getArgs(frame, { parentOnly = true }))▼
▲ local getArgs = require('Modulo:Arguments').getArgs
▲ return p._main(getArgs(frame, {parentOnly = true}))
end
|