Modulo:Bio/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
ciaffo
ok sono soddisfatto e aggiorno
Riga 139:
-- è ammessa l'iniziale maiuscola per i parametri per attività e nazionalità
-- (complicazione inutile. basta eliminare dalle voci le maiuscole esistenti)
if retArgs.Categorie ~= "no" then
local lang = mw.getContentLanguage()
for _, param in ipairs(attivitaParams) do
if retArgs[param] and not cfg.attivita_maiuscolo[retArgs[param]] then
retArgs[param] = lang:lcfirst(retArgs[param])
end
end
for _, param in ipairs(nazionalitaParams) do
retArgs[param] = retArgs[param] and lang:lcfirst(retArgs[param])
end
end
for _, param in ipairs(nazionalitaParams) do
retArgs[param] = retArgs[param] and lang:lcfirst(retArgs[param])
end
 
Riga 190 ⟶ 189:
if args.ForzaOrdinamento then
sortkey = args.ForzaOrdinamento:gsub("(.-)%s*,%s*(.*)", "%1 ,%2")
elseif args.Soprannome and args.Cognome and currentTitleEquals(args.Soprannome .. " " .. args.Cognome) then
sortkey = mString.collate( { args = { args.Cognome .. " ," .. args.Soprannome } } )
elseif args.Pseudonimo and currentTitleEquals(args.Pseudonimo) then
local pseudonimo = mString.collate( { args = { args.Pseudonimo } } )
Riga 211 ⟶ 212:
end
end
self:_addAttivita(self.plurals)
-- Categorie impostato a "no" disabilita la categorizzazione per attività
if args.Categorie ~= "no" then
self:_addAttivita(self.plurals)
end
self:_addNatiMorti()
self:_addCategory(cfg.categorie["bot"])
Riga 359 ⟶ 357:
function CategoryManager:_getPluralsAttivitaNazionalita()
local plurals = {}
local attnaznecessarie = not (args.Categorie == "no" and args.FineIncipit)
 
-- Nazionalità può essere vuota solo quando c'è Categorie=no e FineIncipit
if not args["Nazionalità"] and not (args.Categorie == "no" and args.FineIncipit)attnaznecessarie then
addAvviso(cfg.warningN.testo .. cfg.warningN.testo2b .. cfg.warningN.testo3, "warning")
end
for _, nazionalita in ipairs(nazionalitaParams) do
-- Nazionalità può essere sbagliata solo quando c'è Categorie=no e manca FineIncipit
if args[nazionalita] then
if not (args.Categorie == "no" and not args.FineIncipit) then
for _, plurals[nazionalita] in= ipairsself:_getPluralNazionalita(nazionalitaParamsargs[nazionalita]) do
if args[nazionalita] then
plurals[nazionalita] = self:_getPluralNazionalita(args[nazionalita])
end
end
end
-- Attività può essere vuota solo quando c'è Categorie=no e FineIncipit
if not args["Attività"] and not (args.Categorie == "no" and args.FineIncipit)attnaznecessarie then
addAvviso(cfg.warningA.testo .. cfg.warningA.testo2b .. cfg.warningA.testo3, "warning")
end
for _, attivita in ipairs(attivitaParams) do
-- Attività può essere sbagliata solo quando c'è Categorie=no e manca FineIncipit
if args[attivita] then
if not (args.Categorie == "no" and not args.FineIncipit) then
for _, plurals[attivita] in= ipairsself:_getPluralAttivita(attivitaParamsargs[attivita]) do
if args[attivita] then
plurals[attivita] = self:_getPluralAttivita(args[attivita])
end
end
end
Riga 397 ⟶ 390:
annoNascita = annoNascita and tonumber(annoNascita) * -1
end
if notannoNascita annoMorteand annoNascita >= 2000 then
return "2000"
end
if not annoMorte and args.AnnoMorte then
annoMorte = args.AnnoMorte:match('^(%d+) a%.C%.$')
annoMorte = annoMorte and tonumber(annoMorte) * -1
Riga 417 ⟶ 413:
 
return ret
end
 
-- Aggiunge Categoria:X dei secoli, se esistono
function CategoryManager:_addCatSecolo(catname, epoca1, epoca2)
local ok = false
for _, epoca in ipairs({ epoca1, epoca2 }) do
if epoca and titleExists("Categoria:" .. catname .. " " .. epoca) then
self:_addCategory(catname .. " " .. epoca)
ok = true
end
end
return ok
end
 
-- Aggiunge le categorie: Attività nazionalità [del XYZ secolo]
function CategoryManager:_addAttivita(plurals)
local catname, epoca1, epoca2, added, addatt, addnaz, add1
addatt = {}
addnaz = {}
 
-- se Epoca e Epoca2 non sono stati inseriti dall'utente
-- e AnnoNascita e AnnoMorte cadono nello stesso secolo
-- calcola epoca1 automaticamente
if not args.Epoca and not args.Epoca2 and args.AnnoNascita and args.AnnoMorte then
epoca1 = self:_getEpoca()
epoca1 = epoca1 and cfg.epoche[epoca1]
Riga 432 ⟶ 442:
epoca1 = args.Epoca and cfg.epoche[args.Epoca]
epoca2 = args.Epoca2 and cfg.epoche[args.Epoca2]
end
if not epoca1 and not epoca2 then
self:_addCategory(cfg.categorie["no-epoca"])
end
 
if args.Categorie ~= "no" then
for _, attivita in ipairs(attivitaParams) do
iffor _, plurals[attivita] thenin ipairs(attivitaParams) do
if plurals[attivita] then
for _, nazionalita in ipairs(nazionalitaParams) do
iffor _, plurals[nazionalita] thenin ipairs(nazionalitaParams) do
if plurals[nazionalita] then
added = false
catname = plurals[attivita] .. " " .. plurals[nazionalita]
for added _, epoca in= ipairsself:_addCatSecolo({catname, epoca1, epoca2 }) do
-- se non è stata aggiunta la categoria per epoca1 e epoca2
if epoca and titleExists("Categoria:" .. catname .. " " .. epoca) then
-- aggiunge la cat. semplice, es. "Scrittori italiani"
self:_addCategory(catname .. " " .. epoca)
addedif =added truethen
add1 = true
addatt[attivita] = true
addnaz[nazionalita] = true
else
self:_addCategory(catname)
end
end
-- se non è stata aggiunta la categoria per epoca1 e epoca2
-- aggiunge la cat. semplice, e.g. "Scrittori italiani"
if not added then
self:_addCategory(catname)
end
end
Riga 455 ⟶ 468:
end
end
-- in mancanza di "A N del S" prova "A del S" e "N del S"
for _, attivita in ipairs(attivitaParams) do
if plurals[attivita] and not addatt[attivita] then
add1 = self:_addCatSecolo(plurals[attivita], epoca1, epoca2) or add1
end
end
for _, nazionalita in ipairs(nazionalitaParams) do
if plurals[nazionalita] and not addnaz[nazionalita] then
add1 = self:_addCatSecolo(plurals[nazionalita], epoca1, epoca2) or add1
end
end
if not add1 then
self:_addCatSecolo("Persone", epoca1, epoca2)
end
end
 
Riga 583 ⟶ 612:
self:_addNomeCognome()
self:_addNascitaMorte()
if args.Soprannome or args.Pseudonimo or args.PostCognomeVirgola then
self:_addText(",")
end
Riga 649 ⟶ 678:
 
 
-- Restituisce true se text necessita di uno spazio iniziale (PostCognome, PostSoprannome, PostPseudonimo, LuogoNascitaAlt, NoteNascita, LuogoMorteAlt, NoteMorte, AttivitàAltre, PostNazionalità, FineIncipit)
-- Restituisce true se text (AttivitàAltre, PostNazionalità, PostCognome e FineIncipit) necessita di uno spazio iniziale
function Incipit:_needSpace(text)
return mw.ustring.match(mw.ustring.sub(text, 1, 1), "%w") ~= nil or
Riga 691 ⟶ 720:
elseif args.Pseudonimo and currentTitleEquals(args.Pseudonimo) then
caption = args.Pseudonimo
elseif args.Soprannome and args.Cognome and currentTitleEquals(args.Soprannome .. " " .. args.Cognome) then
caption = args.Soprannome .. " " .. args.Cognome
elseif args.Soprannome and currentTitleEquals(args.Soprannome) then
caption = args.Soprannome
else
if args.CognomePrima and args.Nome and args.Cognome then
Riga 710 ⟶ 743:
-- parentesi () extra per non restituire anche il gsub.count
self:_addText( (cfg.didascalia2:gsub("$1", args.Didascalia2)) )
end
end
 
function Incipit:_addNomeCognome()
if args.Pseudonimo and currentTitleEquals(args.Pseudonimo) then
self:_addText("'''", args.Pseudonimo, "'''")
if args.PostPseudonimo then
if self:_needSpace(args.PostPseudonimo) then
self:_addText(" ")
end
self:_addText(args.PostPseudonimo)
end
self:_addText(", pseudonimo di ")
end
if args.Titolo then
self:_addText(args.Titolo, " ")
end
 
-- inizio grassetto
self:_addText("'''")
 
if args.CognomePrima and args.Nome and args.Cognome then
self:_addText(args.Cognome, " ", args.Nome, mw.getCurrentFrame():expandTemplate{
title = "Nota nome",
args = { [1] = args.CognomePrima, [2] = args.Cognome }
})
else
local no_space
if args.Nome then
self:_addText(args.Nome)
-- niente spazio prima di Cognome se Nome termina con «d'»
no_space = mw.ustring.match(args.Nome, " d'$") and ''
end
if args.Cognome then
self:_addText(no_space or " ", args.Cognome)
end
end
 
-- fine grassetto
self:_addText("'''")
 
if args.PostCognomeVirgola then
self:_addText(", ", args.PostCognomeVirgola)
elseif args.PostCognome then
if self:_needSpace(args.PostCognome) then
self:_addText(" ")
end
self:_addText(args.PostCognome)
end
 
if args.Pseudonimo and not currentTitleEquals(args.Pseudonimo) then
self:_addText(", ", (not args.Sesso or args.Sesso == "M") and "noto" or "nota",
" anche con lo pseudonimo di ", "'''", args.Pseudonimo, "'''")
if args.PostPseudonimo then
if self:_needSpace(args.PostPseudonimo) then
self:_addText(" ")
end
self:_addText(args.PostPseudonimo)
end
end
end
Riga 863 ⟶ 836:
-- si apre la parentesi
self:_addText(" (")
local floruit = false
if (args.Floruit or cfg.epoche[args.Epoca]) and not (args.LuogoNascita or args.GiornoMeseNascita or args.LuogoMorte or args.GiornoMeseMorte) then
floruit = true
end
 
if args.PreData then
Riga 901 ⟶ 868:
end
else
self:_addText("...")
if not floruit then
self:_addText("...")
end
end
 
Riga 913 ⟶ 878:
end
 
if args.AnnoMorte and not floruit then
self:_addText(" – ")
if args.LuogoMorte then
Riga 936 ⟶ 901:
 
if args.AnnoMorte then
if args.AnnoMorte == "?" and not floruit then
self:_addText("...")
else
Riga 950 ⟶ 915:
-- se date ignote, usa Floruit o lo ricava da Epoca
if not args.AnnoNascita and args.AnnoMorte == "?" then
local fl = args.Floruit
if not fl and cfg.epoche[args.Epoca] then
fl = mw.ustring.gsub(cfg.epoche[args.Epoca], "^del ?l?'?", "")
Riga 965 ⟶ 930:
fl = "[[" .. fl .. "]]"
end
self:_addText("; [[floruit|fl.]] ", fl)
if args.LuogoNascita or args.GiornoMeseNascita or args.LuogoMorte or args.GiornoMeseMorte then
self:_addText("; ")
end
self:_addText("[[floruit|fl.]] ", fl, ")")
end
return
end