Modulo:Wikidata/sandbox e Erika Ferrara: differenze tra le pagine

(Differenze fra le pagine)
Contenuto cancellato Contenuto aggiunto
m aggiornato
 
Nessun oggetto della modifica
 
Riga 1:
{{Sportivo
--[[
|Nome = Erika Ferrara
* Modulo per implementare le funzionalità dei template {{Wikidata}}, {{WikidataQ}} e {{WikidataN}}.
|Immagine =
* Permette di accedere a Wikidata in modo più avanzato rispetto a {{#property}}.
|Sesso = F
|CodiceNazione = {{ITA}}
|Disciplina = Calcio a 5
|Squadra = {{Calcio a 5 femminile Falconara}}
|Ruolo = [[Intermedio (calcio a 5)|Laterale]]
|TermineCarriera =
|SquadreGiovanili =
|Squadre =
{{Carriera sportivo
|2016-2017|{{Calcio a 5 femminile Real Lions Ancona|G}}|21 (16)
|2017|{{Calcio Dorica Torrette}}|9 (1)
|2017-|{{Calcio a 5 femminile Falconara|G}}|54 (4)
}}
|SquadreNazionali =
|Disciplina2 = Calcio
|Squadra2 =
|Ruolo2 = [[Centrocampista]]
|TermineCarriera2 =
|SquadreGiovanili2 =
{{Carriera sportivo
|2014-2015|{{Calcio femminile Jesina}} [[Campionato Primavera (calcio femminile)|Prim.]]|? (?)
}}
|Squadre2 =
{{Carriera sportivo
|2013-2014|{{simbolo|600px Giallo e Blu.svg}} Porto Sant'Elpidio|? (?)
|2015-2016|{{Calcio femminile Riviera di Romagna|G}}|15 (0)
}}
|SquadreNazionali2 =
|Aggiornato = 21 maggio 2016 (calcio a 11)
}}
{{Bio
| Nome = Erika
| Cognome = Ferrara
| Sesso = F
| LuogoNascita = Fermo
| GiornoMeseNascita = 16 luglio
| AnnoNascita = 1999
| LuogoMorte =
| GiornoMeseMorte =
| AnnoMorte =
| Attività = calciatrice
| Attività2 = giocatrice di calcio a 5
| Nazionalità = italiana
| PostNazionalità = , [[Intermedio (calcio a 5)|laterale]] del [[Città di Falconara]]
}}
 
== Carriera ==
* Il modulo è stato importato inizialmente da:
=== Club ===
* http://test2.wikipedia.org/w/index.php?title=Module:Wikidata&oldid=52322
Erika Ferrara si appassiona al mondo del [[calcio (sport)|calcio]] fin dalla giovanissima età, tesserandosi con il Porto Sant'Elpidio e giocando in [[Eccellenza (calcio femminile)|Serie C]] dalla stagione 2013-2014 nel ruolo di [[centrocampista]].<ref name="RdRPDF">{{Cita web|url=http://www.rivieradiromagnacalcio.it/archivio/giocatori/145/erika%20ferrara.pdf|Scheda Erika Ferrara|sito=rivieradiromagnacalcio.it|accesso=22 aprile 2017}}</ref>
]]
 
Nell'estate 2014 decide di passare alla [[Associazione Polisportiva Dilettantistica E.D.P. Jesina Femminile|E.D.P. Jesina]] che la inserisce nella sua formazione che partecipa al [[Campionato Primavera (calcio femminile)|Campionato Primavera]] di categoria.<ref name="RdRPDF" />
local getArgs = require('Module:Arguments').getArgs
 
Durante il calciomercato estivo 2015 coglie l'occasione per compiere un salto di categoria sottoscrivendo con la [[Associazione Sportiva Dilettantistica Riviera di Romagna|Riviera di Romagna]] un contratto per giocare in [[Serie A (calcio femminile)|Serie A]] per la [[Associazione Sportiva Dilettantistica Riviera di Romagna 2015-2016|stagione entrante]]. Ferrara, impiegata in 15 occasioni alle quali si aggiungono le due in [[Coppa Italia (calcio femminile)|Coppa Italia]], condivide le sorti della squadra la quale, dopo un girone di andata concluso all'ottavo posto e mantenendosi in zona salvezza anche per gran parte del campionato, in virtù dei risultati negativi degli ultimi incontri non riesce a evitare la retrocessione in [[Serie B (calcio femminile)|Serie B]], arrivata alla penultima giornata.<ref>{{Cita|Football.it|Erika Ferrara}}.</ref>
-- Messaggi di errore
local i18n = {
["errors"] = {
["property-param-not-provided"] = "Parametro ''property'' non fornito.",
["qualifier-param-not-provided"] = "Parametro ''qualifier'' non fornito.",
["entity-not-found"] = "Entità non trovata.",
["unknown-claim-type"] = "Tipo asserzione sconosciuta.",
["unknown-snak-type"] = "Tipo di snak sconosciuto.",
["unknown-datavalue-type"] = "Tipo di dato sconosciuto.",
["unknown-entity-type"] = "Tipo di entità sconosciuta."
},
["somevalue"] = "''valore sconosciuto''",
["novalue"] = "''nessun valore''"
}
 
=== Calcio a 5 ===
-------------------------------------------------------------------------------
La decisione della società di non iscriversi al campionato successivo svincola la giocatrice che decide di cambiare categoria accettando la proposta del Real Lions Ancona per la sua prima esperienza nel [[calcio a 5]] femminile, per giocare in [[Serie A 2016-2017 (calcio a 5 femminile)|Serie A la stagione entrante]].<ref>{{Cita|ladyfutsal.com|Erika Ferrara}}.</ref>
-- Formatters
-------------------------------------------------------------------------------
 
La stagione successiva il Real Lions Ancona non si iscrive e la sua eredità viene presa dalla Dorica Torrette Femminile, nel campionato di A2. A dicembre 2017, durante la sessione invernale del futsalmercato, viene acquistata dal [[Città di Falconara]].
local function formatError(key)
return '<span class="error">' .. i18n.errors[key] .. '</span>'
end
 
== Note ==
local function formatEntityId(entityId, options, formatting)
<references />
if formatting == 'raw' then
return entityId
end
 
== Collegamenti esterni ==
local label = mw.wikibase.label(entityId)
* {{Collegamenti esterni}}
local link = mw.wikibase.sitelink(entityId)
* {{Cita web|url=http://www.ladyfutsal.com/giocatori/ferrara/|Erika Ferrara|sito=ladyfutsal.com}}
if link then
* {{Cita web|url=http://www.realanconac5.it/rosa.asp|2=Erika Ferrara|sito=realanconac5.it|cid=realanconac5.it|urlmorto=sì|urlarchivio=https://web.archive.org/web/20170423064350/http://www.realanconac5.it/rosa.asp|dataarchivio=23 aprile 2017}}
if label then
return '[[' .. link .. '|' .. label .. ']]'
else
return '[[' .. link .. ']]'
end
else
return label or ''
end
end
 
{{Portale|biografie|calcio}}
local function formatTime(value, options)
local year, month, day
local ret = ''
year, month, day = value.time:match('.+(%d%d%d%d%d)%-(%d%d)%-(%d%d).+')
if value.precision == 9 then
ret = tonumber(year)
elseif value.precision == 10 then
ret = mw.getLanguage('it'):formatDate('F Y', tonumber(year) .. '-' .. month)
elseif value.precision == 11 then
ret = mw.getLanguage('it'):formatDate('j F Y', tonumber(year) .. '-' .. month .. '-' .. day)
ret = ret:gsub('^1%s', '1º ')
end
if value.precision >= 9 and value.precision <= 11 then
ret = ret .. (value.time:sub(1, 1) == '-' and ' a.C.' or '')
end
 
return ret
end
 
local function formatGlobecoordinate(value, options)
local ret
if options.formatting == 'latitude' then
ret = value.latitude
elseif options.formatting == 'longitude' then
ret = value.longitude
else
ret = value.latitude .. ', ' .. value.longitude
end
return ret
end
 
local function formatFromPattern(str, options)
-- la parentesi () extra serve per non ritornare anche il gsub.count
return (mw.ustring.gsub(options.pattern, '$1', str))
end
 
local function getEntityIdFromValue(value)
local prefix = ''
if value['entity-type'] == 'item' then
prefix = 'Q'
elseif value['entity-type'] == 'property' then
prefix = 'P'
else
return formatError('unknown-entity-type')
end
return prefix .. value['numeric-id']
end
 
local function formatDatavalue(datavalue, options, formatting)
local ret
 
--Default formatters
if datavalue.type == 'wikibase-entityid' then
ret = formatEntityId(getEntityIdFromValue(datavalue.value), options, formatting)
elseif datavalue.type == 'string' then
ret = datavalue.value
elseif datavalue.type == 'time' then
ret = formatTime(datavalue.value, options)
elseif datavalue.type == 'globecoordinate' then
ret = formatGlobecoordinate(datavalue.value, options)
elseif datavalue.type == 'quantity' then
ret = tonumber(datavalue.value.amount)
else
ret = formatError('unknown-datavalue-type')
end
 
return ret
end
 
local function formatSnak(snak, options, formatting)
if snak.snaktype == 'somevalue' then
return i18n['somevalue']
elseif snak.snaktype == 'novalue' then
return i18n['novalue']
elseif snak.snaktype == 'value' then
return formatDatavalue(snak.datavalue, options, formatting)
else
return formatError('unknown-snak-type')
end
end
 
local function formatStatement(statement, options)
if not statement.type or statement.type ~= 'statement' then
return formatError('unknown-claim-type')
end
return formatSnak(statement.mainsnak, options)
end
 
local function formatStatements(claims, options)
--Format statement and concat them cleanly
local formattedStatements = {}
local list_end, formattedStatement
if options.list or options.orderedlist then
if options.list then
formattedStatements[1] = '<ul><li>'
list_end = '</li></ul>'
else
formattedStatements[1] = '<ol><li>'
list_end = '</li></ol>'
end
options.separator = '</li><li>'
options.conjunction = options.separator
end
for i, claim in pairs(claims) do
formattedStatement = formatStatement(claim, options)
-- eventuale pattern
if options.pattern then
formattedStatement = formatFromPattern(formattedStatement, options)
end
table.insert(formattedStatements, formattedStatement)
end
 
if list_end then table.insert(formattedStatements, list_end) end
return mw.text.listToText(formattedStatements, options.separator, options.conjunction)
end
 
-------------------------------------------------------------------------------
-- Lettura e selezione statement
-------------------------------------------------------------------------------
 
-- Ritorna true se lo statement contiene il qualifier richiesto con un dato valore
local function hasQualifierValue(statement, options)
local ret = false
for i, qualifier in pairs(statement.qualifiers[options.qualifier]) do
if formatSnak(qualifier, options, 'raw') == options.qualifiervalue then
ret = true
break
end
end
return ret
end
 
-- Ritorna i claim con il rank richiesto
local function filterRankValue(claims, rank)
local ret = {}
for i, claim in pairs(claims) do
if claim.rank == rank then
table.insert(ret, claim)
end
end
return ret
end
 
-- Ritorna una table contenente gli statement per la property richiesta.
-- Gli statement ritornati sono eventualmente filtrati in base ai parametri:
-- "rank", "qualifier", "qualifiertype" e "n"
local function getClaims(options)
local entity, claims, filteredClaims
-- get entity
entity = mw.wikibase.getEntityObject()
if not entity then
error('') -- error(formatError('entity-not-found'))
end
 
-- get property
if not options.property then
error(formatError('property-param-not-provided'))
end
 
if entity.claims and entity.claims[options.property] and
#entity.claims[options.property] > 0 then
claims = entity.claims[options.property]
else
error('') --TODO error?
end
 
-- statements filtrati per rank
if options.rank then
if options.rank == 'best' then
filteredClaims = filterRankValue(claims, 'preferred')
if #filteredClaims == 0 then
filteredClaims = filterRankValue(claims, 'normal')
end
else
filteredClaims = filterRankValue(claims, options.rank)
end
claims = filteredClaims
end
 
-- statements filtrati per qualifier
if options.qualifier then
filteredClaims = {}
for i, claim in pairs(claims) do
if claim.qualifiers and claim.qualifiers[options.qualifier] then
if options.qualifiervalue then
if hasQualifierValue(claim, options) then
table.insert(filteredClaims, claim)
end
else
table.insert(filteredClaims, claim)
end
end
end
claims = filteredClaims
end
 
-- con options.qualifiertype=latest ritorna solo il più recente
if options.qualifier and options.qualifiertype == 'latest' then
local latest, latestTime
for i, claim in pairs(claims) do
if claim.qualifiers and claim.qualifiers[options.qualifier] then
for j, qualifier in pairs(claim.qualifiers[options.qualifier]) do
if qualifier.datavalue.type == 'time' then
if not latestTime or qualifier.datavalue.value.time > latestTime then
latest = claim
latestTime = qualifier.datavalue.value.time
end
end
end
end
end
claims = latest and {latest} or {}
end
 
-- con options.n ritorna solo l'n-esimo elemento
if options.n then
local n = tonumber(options.n)
claims = (n and n <= #claims) and {claims[n]} or {}
end
 
return claims
end
 
-------------------------------------------------------------------------------
-- API
-------------------------------------------------------------------------------
 
local p = {}
 
-- Entry-point per {{#invoke:Wikidata|formatStatements}}
function p.formatStatements(frame)
local args, ret, claims
 
args = getArgs(frame, {parentOnly = true})
-- Per riabilitare eventualmente la chiamata al modulo diretta,
-- pur usando sempre solo getParent per il template, sostituire con:
-- args = getArgs(frame, {wrappers = 'Template:Wikidata'})
 
-- parametri posizionali
args.property = args[1] and string.upper(args[1]) or nil
args.value = args[2]
-- fix uppercase
args.qualifier = args.qualifier and string.upper(args.qualifier) or nil
-- default rank
args.rank = args.rank or 'best'
 
-- if parameter value is already set, use it
if args.value then
return args.pattern and formatFromPattern(args.value, args) or args.value
end
-- get claims
ret, claims = pcall(getClaims, args)
if not ret then
return claims:match('.+%d:%s(.+)$')
end
 
return formatStatements(claims, args)
end
 
-- Entry-point per {{#invoke:Wikidata|getQualifier}}
function p.getQualifier(frame)
local args, ret, claims, formattedQualifier, formattedQualifiers
 
args = getArgs(frame, {parentOnly = true})
-- args = getArgs(frame, {wrappers = 'Template:WikidataQ'})
-- parametri posizionali
args.property = args[1] and string.upper(args[1]) or nil
args.qualifier = args[2] and string.upper(args[2]) or nil
args.value = args[3]
-- default rank
args.rank = args.rank or 'best'
 
-- if parameter value is already set, use it
if args.value then
return args.pattern and formatFromPattern(args.value, args) or args.value
end
 
-- get qualifier name
if not args.qualifier then
return formatError('qualifier-param-not-provided')
end
 
-- get claims
ret, claims = pcall(getClaims, args)
if not ret then
return claims:match('.+%d:%s(.+)$')
end
 
-- get qualifiers and format them
formattedQualifiers = {}
for i, claim in pairs(claims) do
if claim.qualifiers and claim.qualifiers[args.qualifier] then
for j, qualifier in pairs(claim.qualifiers[args.qualifier]) do
formattedQualifier = formatSnak(qualifier, args)
if args.pattern then
formattedQualifier = formatFromPattern(formattedQualifier, args)
end
table.insert(formattedQualifiers, formattedQualifier)
end
end
end
 
return mw.text.listToText(formattedQualifiers, args.separator, args.conjunction)
end
 
-- Entry-point per {{#invoke:Wikidata|N}}
function p.N(frame)
local args, entity, property, count
 
args = getArgs(frame, {parentOnly = true})
-- args = getArgs(frame, {wrappers = 'Template:WikidataN'})
 
-- parametri posizionali
property = args[1] and string.upper(args[1]) or nil
 
if not property then
return formatError('property-param-not-provided')
end
 
entity = mw.wikibase.getEntityObject()
if entity and entity.claims and entity.claims[property] then
count = #entity.claims[property]
end
 
return count or 0
end
return p