Modulo:Collegamenti esterni: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m messaggio più preciso
ottimizzo e riduco possibilità errori se si compila male il parametro template nella configurazione
Riga 367:
local cfg = readConfig()
local lang = mw.language.getContentLanguage()
local pageContent, =isPreview, mw.title.getCurrentTitle():getContent()isSection
: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 ⟶ 373:
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 423 ⟶ 418:
-- controlla che il link non sia generato da altri template in voce
if valido and linkConf.template then
forlocal templatetemplateList in= mw.text.gsplit(linkConf.template, ',') do
template = mw.text.trim:gsub(template'%s*,%s*', ','):gsub(' ,+', ','):gsub('^,', +''):gsub(',$', '')
localif first_chartemplateList ~= template:match('^.') then
if previewnot pageContent then
first_char = string.format('[%s%s]', first_char:upper(), first_char:lower())
if pageContent:match('{{%s*' = mw.title. templategetCurrentTitle():gsubgetContent('^.', first_char) .. '%s*[|}]') then
: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()
local preview isPreview = mw.getCurrentFrame():preprocess('{{REVISIONID}}') == ''
end
for template in mw.text.gsplit(templateList, ',') do
template = template:gsub(' +', ' +')
local firstChar = template:match('^.')
first_char firstChar = string.format('[%s%s]', first_charfirstChar:upper(), first_charfirstChar:lower())
if pageContent:match('{{%s*' .. template:gsub('^.', firstChar) .. '%s*[|}]') then
valido, duplicates = previewisPreview, true
if isPreview then
previewMsg = mw.message.newRawMessage(tmpFound, template):plain()
break end
break
end
end
if sectionisPreview and not previewMsg then
if isSection == nil then
local section isSection = pageContent:match('^=+[^=\n]+=+ *\n') and true or false
end
if isSection then
templateList = templateList:gsub(',', ', ')
previewMsg = mw.message.newRawMessage(tmpSection, linkConf.templatetemplateList):plain()
end
break
end
end
if section and not previewMsg then
previewMsg = mw.message.newRawMessage(tmpSection, linkConf.template):plain()
end
end