Modulo:Collegamenti esterni: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
mostro spiegazione doppioni nell'anteprima per fare chiarezza, vedi discussione |
aggiungo gruppo "Gastronomia" |
||
(6 versioni intermedie di 2 utenti non mostrate) | |||
Riga 3:
]]--
require('
local getArgs = require('Modulo:Arguments').getArgs
Riga 14:
'Letteratura', 'Politica', 'Religione', 'Architettura',
'Astronomia', 'Biologia', 'Editoria', 'Geografia',
'Linguistica', 'MAB', 'Matematica', 'Software', 'Calcio', 'Sci',
'Sport', 'Videogiochi', 'Musica', 'Fumetti', 'Cinema', 'Gastronomia'
}
-- Soglie di attenzione sul numero elevato di collegamenti, per categorie di controllo
Riga 31:
-- Avvisi per i link omessi
local tmpFound = 'Link visibile solo nell\'anteprima della pagina. È già presente il template $1'
local tmpSection = '
-- Tabella dei qualificatori riconosciuti
-- Qui vanno elencati solo quelli generali, validi per tutte le dichiarazioni
Riga 221:
return self.linkConf.cid
end
function ExtLink:_formatPreviewMsg()
local ret = ''
ret = tostring(ret) .. ' '
end
return ret
end
Riga 247 ⟶ 260:
urlmorto = self.extraConf.urlmorto[idx] and 'sì' or (self.extraConf.archivio[idx] and 'no')
})
table.insert(formattedLinks, '* ' .. self:_formatPreviewMsg() .. formattedLink ..
mEditAtWikidata._showMessage({ pid = self.linkConf.pid, qid = self.from }))
end
Riga 257 ⟶ 270:
-- @return {string}
function ExtLink:getListItem()
-- restituisce il link se è già stato formattato
-- se è specificato l'URL di formattazione è una▼
if self.extraConf.formattedLink then
return '* ' .. self:_formatPreviewMsg() .. self.extraConf.formattedLink
if not self.linkConf.url then▼
-- proprietà di tipo URL e non di tipo "identificativo esterno"
return self:_formatPropertyURL()
end
Riga 281 ⟶ 297:
tipo = self.linkConf.tipo or self.sitodis
})
table.insert(formattedLinks, '* ' .. self:_formatPreviewMsg() .. formattedLink ..▼
▲ if self.extraConf.previewMsg then
▲ local warning = mw.html.create('abbr')
▲ :css('color', 'red')
▲ :css('font-weight', 'bold')
▲ :attr('title', self.extraConf.previewMsg)
▲ :wikitext('!')
▲ end
▲ table.insert(formattedLinks, '* ' .. formattedLink ..
mEditAtWikidata._showMessage({ pid = self.linkConf.pid, qid = self.from }))
end
Riga 367 ⟶ 375:
local cfg = readConfig()
local lang = mw.language.getContentLanguage()
local pageContent,
:gsub('<!%-%-.-%-%->', '')▼
:gsub('<[Rr][Ee][Ff]%s.-/>', '') -- facilita la ricerca successiva▼
:gsub('<[Rr][Ee][Ff].->.-</[Rr][Ee][Ff]%s*>', '')▼
local loadedEntities = setmetatable({}, {
__newindex = function(t1, key, t2)
Riga 376 ⟶ 381:
for k, v in pairs(t2) do rawset(t1, k, v) end
end })
local preview = mw.getCurrentFrame():preprocess('{{REVISIONID}}') == ''▼
local section = pageContent:match('^=+[^=\n]+=+ *\n')▼
local duplicates = false -- per categoria temporanea
for _, groupName in ipairs(orderedGroupNames) do -- per ogni gruppo tematico
Riga 387 ⟶ 390:
end
for _, linkConf in ipairs(cfg[groupName]) do -- per ogni sito configurato
local claims, valido,
-- se il sito non è escluso manualmente dall'utente, avviene la lettura da Wikidata
if not (self:_Escluso(linkConf.pid, self.soloprop) or
Riga 395 ⟶ 398:
-- controlla se ci sono valori
if claims and #claims > 0 then
-- controlla se è un sito da escludere per soggetto non pertinente
if type(linkConf.vincolo) == 'table' then
Riga 423 ⟶ 427:
-- controlla che il link non sia generato da altri template in voce
if valido and linkConf.template then
first_char = string.format('[%s%s]', first_char:upper(), first_char:lower())▼
▲ :gsub('<!%-%-.-%-%->', '')
valido, duplicates = preview, true▼
▲ :gsub('<[Rr][Ee][Ff]%s.-/>', '') -- facilita la ricerca successiva
▲ if preview then
▲ :gsub('<[Rr][Ee][Ff].->.-</[Rr][Ee][Ff]%s*>', '')
previewMsg = mw.message.newRawMessage(tmpFound, template):plain()▼
end▼
for template in mw.text.gsplit(templateList, ',') do
template = template:gsub(' +', ' +')
local firstChar = template:match('^.')
▲
if pageContent:match('{{%s*' .. template:gsub('^.', firstChar) .. '%s*[|}]') then
if isPreview then
▲ extraConf.previewMsg = mw.message.newRawMessage(tmpFound, template):plain()
break
end
end
if isSection == nil then
end
if isSection then
templateList = templateList:gsub(',', ', ')
end
▲ break
end
end
end
▲ if section and not previewMsg then
end
▲ previewMsg = mw.message.newRawMessage(tmpSection, linkConf.template):plain()
-- verifica se deve generare il link con un sottomodulo
▲ end
-- che può fare a sua volta altri controlli
if valido and linkConf.sottomodulo then
local success, metamodule = pcall(require, 'Modulo:' .. linkConf.sottomodulo)
if success and type(metamodule._main) == 'function' then
extraConf.formattedLink = metamodule._main({
from = self.from,
['mostra errori'] = 'no'
})
end
if extraConf.formattedLink then
claims = {}
else
valido = false
end
end
Riga 443 ⟶ 480:
if valido then
local url = {}
▲ local extraConf = { cid = {}, titolodis = { count = 0 }, previewMsg = previewMsg }
-- per ogni dichiarazione
for i, claim in ipairs(claims) do
Riga 512 ⟶ 548:
catMultiSenzaQual or catLetta
self:_addCategory(linkConf.pid .. tail)
-- per verificare se un sito è ripetuto nel gruppo e necessita di disambiguazione
groupSites[groupName][extraConf.sito] = (groupSites[groupName][extraConf.sito] or 0) + 1
-- conteggio complessivo dei collegamenti
Riga 590 ⟶ 626:
local wdLinks = {}
for _, linkConf in ipairs(cfg[groupName]) do
assert(label, string.format(
'Impossibile trovare l\'etichetta della proprietà %s del gruppo %s',
linkConf.pid, groupName))
local templates = {}
for template in string.gmatch(linkConf.template or '', '[^,]+') do
Riga 596 ⟶ 636:
local wdLink = string.format(formatString,
linkConf.pid,
label,
▲ mWikidata._getLabel({ linkConf.pid }),
linkConf.pid,
linkConf.url or '',
|