Modulo:Interprogetto/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
rifiniture
use require('strict') instead of require('Module:No globals')
 
(6 versioni intermedie di un altro utente non mostrate)
Riga 1:
-- Modulo per implementare le funzionalità di template:Interprogetto
require('Module:No globalsstrict')
local p = {} -- per l'esportazione delle funzioni del modulo
 
Riga 124:
if self.entity.claims and
self.entity.claims[property_id] and
self.entity.claims[property_id][1].mainsnak.datavalue and
self.entity.claims[property_id][1].mainsnak.datavalue.type == 'string' then
return self.entity.claims[property_id][1].mainsnak.datavalue.value
Line 134 ⟶ 135:
local interwiki = { project }
if property_language and self.entity.claims and self.entity.claims[property_language] then
project = project:sub(3)
for i_, claim in ipairs(self.entity.claims[property_language]) do
if claim.mainsnak.datavalue.type == 'wikibase-entityid' then
local entityId = 'Q' .. claim.mainsnak.datavalue.value['numeric-id']
Line 141 ⟶ 143:
local language_code = claims[1] and claims[1].mainsnak.datavalue.value
if language_code then
table.insert(interwiki,if language_codeproject ..== 'wikisource') and language_code == 'grc' then
self.lingua[ language_code ..= 'wikisourceel'] = language_code
end
table.insert(interwiki, language_code .. project)
self.lingua[language_code .. project] = language_code
end
end
Line 184 ⟶ 189:
self.collegamenti[key_progetto] = sitelink
end
if i == 1 and self.entity.sitelinks[interwiki].badges and not self.lingua[interwiki] then
local badge_class = {}
local badge_title = {}
Line 213 ⟶ 218:
function Wikidata_entity:hasPropertyValue(propertyId, values)
if self.entity.claims and self.entity.claims[propertyId] then
localfor claims_, =claim in ipairs(self.entity.claims[propertyId]) do
if claim and claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value then
for _, claim in pairs(claims) do
if claim and claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value then
local datavalue = claim.mainsnak.datavalue
if datavalue.type == 'wikibase-entityid' thenand
if datavalue.value['entity-type'] == 'item' thenand
if (type(values) == 'table' thenand values[tostring(datavalue.value['numeric-id'])]) or
ifvalues == values[tostring(datavalue.value['numeric-id'])] then
return true
end
elseif values == tostring(datavalue.value['numeric-id']) then
return true
end
end
end
end
Line 286 ⟶ 285:
self.testo_dopo = ' <small>' .. args.data .. '</small>'
end
local lingua = key_progetto == 's_el' and 'lingua greca' or
entity.lingua[key_progetto] and require('Modulo:Linguaggi').get_voce(entity.lingua[key_progetto]) or
args[key_progetto .. '_lingua'] and 'lingua ' .. args[key_progetto .. '_lingua']
if default_progetto.lingua and lingua then
Riga 400:
-- ============================================================================================================
-- Scandisce la tabella progetti e produce il codice html per l'elenco dei collegamenti nella barra di sinistra
-- Imposta il tag div id="interProject" (vedi accessorio [[MediaWiki:Gadget-InterProject.js]] incluso da [[Mediawiki:Common.js]])
-- ============================================================================================================
local function RenderLeftBar(progetti)
local leftbar = mw.html.create('ul')
 
local leftbar = mw.html.create('ul'):attr('title', 'Collegamenti verso gli altri progetti Wikimedia')
for _, progetto in ipairs(progetti) do
leftbar:newline()
:tag('pli')
leftbar:wikitext('<li class=\"', progetto.badge_leftbar.class, '\" title=\"', progetto.badge_leftbar.title, '\">')
leftbar :wikitextattr('title', progetto:Link_lb().badge_leftbar.title)
:addClass(progetto.badge_leftbar.class)
:wikitext('Altri progetti'progetto:Link_lb())
if progetto.default_progetto.nome_leftbar then
leftbar:wikitext('<br />(', progetto.default_progetto.nome_progetto, ')')
end
leftbar:wikitext('</li>')
end
root
:tag('div')
:attr('id', 'interProject')
:addClasscssText('toccoloursdisplay: none')
:cssText('display: none; clear: both; margin-top: 2em')
:tag('p')
:attr('id', 'sisterProjects')
:cssText('background-color: #efefef; font-weight: bold; margin: 0')
:tag('span')
:wikitext('Altri progetti')
:done()
:done()
:node(leftbar)
end
Line 553 ⟶ 546:
if entity.corsivo then
default.etichetta = '<span style=\"font-style:italic;\">' .. default.etichetta .. '</span>'
default.etichetta_lower = '<span style=\"font-style:italic;\">' .. default.etichetta .. '</span>'
end
end
Line 613 ⟶ 606:
end
-- ====================================================================================================
-- Aggiunge il collegamento da Wikidata se non è presente quello compilato manualmente o se rinvia a
-- un progetto in lingua non italiana che non è registrato nella configurazione e non va sovrascritto
-- ====================================================================================================
for key_progetto, collegamento in pairs(entity.collegamenti) do
if not newArgscfg.automatic_link[key_progetto] andor not (cfg.automatic_linknewArgs[key_progetto] and cfg.automatic_link[key_progetto].alias andor newArgs[cfg.automatic_link[key_progetto].alias]) then
newArgs[key_progetto] = collegamento
-- Segnala che il collegamento è stato aggiunto da Wikidata