Modulo:Sandbox/Laurentius: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
genera le categorie per Wiki Loves Monuments
 
Omega Bot (discussione | contributi)
m Bot: rimuovo no globals obsoleto
 
(15 versioni intermedie di un altro utente non mostrate)
Riga 1:
-- Modulo per gestire le liste di monumenti di Wiki Loves Monuments
 
require('Module:No globalsstrict')
local getArgs = require('Module:Arguments').getArgs
local mWikidata = require('Modulo:Wikidata')
Riga 7:
local p = {}
 
function p.map_point(qid)
-- Associa il nome della regione (come usato nelle sottopagine di
local tdata = {}
-- [[Progetto:Wiki Loves Monuments 2019/Monumenti]] con il nome (inglese)
local regionedesc = tp[3]''
-- usato nelle categorie su Commons e la presenza o meno di un concorso regionale
end
local regioni = {
desc = desc .. '{{WLM-link-2019|' .. qid .. '}}'
['Abruzzo'] = {'Abruzzo', false},
local main_categoryimg = mWikidata._getProperty({'P373P18', from = qid, snaktype = 'value', n=1, pattern="[[File:$1|200px]]"})
['Basilicata'] = {'Basilicata', true},
if main_categoryimg then
['Calabria'] = {'Calabria', false},
['Campania'] desc = {desc .. 'Campania<br/>', false},.. img
['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
data.type = "Feature"
return t
data.properties = {
title = mWikidata._getLink({qid}),
description = desc,
["marker-color"] = "#B80000"
end}
data.geometry = {
type = "Point",
coordinates = {
local municipality_category = tonumber(mWikidata._getProperty({'P131P625', from = qid, showpropsnaktype = 'P373value', snaktype coord= 'valuelongitude', n=1})),
tonumber(mWikidata._getProperty({'P625', from = qid, snaktype = 'value', coord='latitude', n=1}))
else }
}
return tdata
end
 
function p.categories_map_data(frameargs)
local argspoints = getArgs(frame){}
local qid = args[1]
 
local categories = {}
 
if args.area then
-- se il monumento ha una categoria associata, usa quella. Altrimenti, quella del comune.
local regionishape = {
local main_category = mWikidata._getProperty({'P373', from = qid, snaktype = 'value'})
type = "ExternalData",
if main_category then
service = "geoshape",
table.insert(categories, main_category)
ids = args.area,
else
service = "geomask"
local municipality_category = mWikidata._getProperty({'P131', from = qid, showprop = 'P373', snaktype = 'value'})
}
table.insert(categories, municipality_category)
table.insert(categoriespoints, main_categoryshape)
end
 
for _, qid in ipairs(args) do
-- alberi monumentali
if mWikidata._instanceOf_getProperty({'Q811534P625', from = qid, snaktype = 'value'}) then
table.insert(tpoints, strp.map_point(qid))
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
 
return mw.text.jsonEncode(points)
-- Wiki Loves Lake Como
end
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
 
function p.map_data(frame)
return table.concat(categories, '|')
local args = getArgs(frame)
return p._map_data(args)
end