-- Modulo per gestire le liste di monumenti di Wiki Loves Monuments
require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local mWikidata = require('Modulo:Wikidata')
local p = {}
-- Associa il nome della regione (come usato nelle sottopagine di
-- [[Progetto:Wiki Loves Monuments 2019/Monumenti]] con il nome (inglese)
-- usato nelle categorie su Commons e la presenza o meno di un concorso regionale
local regioni = {
['Abruzzo'] = {'Abruzzo', false},
['Basilicata'] = {'Basilicata', true},
['Calabria'] = {'Calabria', false},
['Campania'] = {'Campania', false},
['Emilia-Romagna'] = {'Emilia-Romagna', false},
['Friuli-Venezia Giulia'] = {'Friuli-Venezia Giulia', false},
['Lazio'] = {'Lazio', false},
['Liguria'] = {'Liguria', true},
['Lombardia'] = {'Lombardy', false},
['Marche'] = {'Marche', false},
['Molise'] = {'Molise', false},
['Piemonte'] = {'Piedmont', false},
['Puglia'] = {'Apulia', false},
['Sardegna'] = {'Sardinia', false},
['Sicilia'] = {'Sicily', false},
['Toscana'] = {'Tuscany', true},
['Trentino-Alto Adige'] = {'Trentino-South Tyrol', false},
['Umbria'] = {'Umbria', true},
['Valle d\'Aosta'] = {'Aosta Valley', false},
['Veneto'] = {'Veneto', true},
}
local function titleparts(inputstr)
local t = {}
for str in mw.ustring.gmatch(inputstr, "([^/]+)") do
table.insert(t, str)
end
return t
end
function p.categories(frame)
local args = getArgs(frame)
local qid = args[1]
local categories = {}
-- se il monumento ha una categoria associata, usa quella. Altrimenti, quella del comune.
local main_category = mWikidata._getProperty({'P373', from = qid, snaktype = 'value'})
if main_category then
table.insert(categories, main_category)
else
local municipality_category = mWikidata._getProperty({'P131', from = qid, showprop = 'P373', snaktype = 'value'})
table.insert(categories, municipality_category)
end
-- alberi monumentali
if mWikidata._instanceOf({'Q811534', from = qid}) then
table.insert(categories, 'Images from Wiki Loves Monuments 2019 in Italy - veteran trees')
end
-- foto per regione
local tp = titleparts(mw.title.getCurrentTitle().fullText)
local regione = tp[3]
if regioni[regione] then
table.insert(categories, 'Images from Wiki Loves Monuments 2019 in Italy - ' .. regioni[regione][0])
if not regioni[regione][1] then
table.insert(categories, 'Images from Wiki Loves Monuments 2019 in Italy - without regional award')
end
else
table.insert(categories, 'Images from Wiki Loves Monuments 2019 in Italy - unknown region')
end
-- Wiki Loves Lake Como
local provincia = tp[4]
if provincia == 'Provincia di Como' or provincia == 'Provincia di Lecco' then
table.insert(categories, 'Images from Wiki Loves Monuments 2019 in Italy - Lake Como')
end
return table.concat(categories, '|')
end
return p