Modulo:Bio/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
ciaffo
aggiorno
 
(8 versioni intermedie di uno stesso utente non sono mostrate)
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
 
Line 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 } } )
Line 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"])
Line 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
Line 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
Line 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, addbase
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]
Line 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)
addbase = true
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
Line 455 ⟶ 469:
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
for k, v in ipairs({"cecoslovacchi", "jugoslavi", "sovietici"}) do
if plurals[nazionalita] == v and not add1 and not addbase then
self:_addCategory(plurals[nazionalita])
add1 = true
end
end
end
end
if not add1 and not addbase then
self:_addCatSecolo("Persone", epoca1, epoca2)
end
end
 
Line 583 ⟶ 619:
self:_addNomeCognome()
self:_addNascitaMorte()
if args.Soprannome or args.Pseudonimo or args.PostCognomeVirgola then
self:_addText(",")
end
Line 649 ⟶ 685:
 
 
-- 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
Line 691 ⟶ 727:
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
Line 710 ⟶ 750:
-- 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
Line 787 ⟶ 767:
end
self:_addText(", pseudonimo di ")
end
 
local soprannomecognome = args.Soprannome
if args.Soprannome and args.Cognome then
soprannomecognome = args.Soprannome .. " " .. args.Cognome
end
 
if soprannomecognome and currentTitleEquals(soprannomecognome) then
self:_addText("'''", soprannomecognome, "'''")
if args.PostSoprannome then
if self:_needSpace(args.PostSoprannome) then
self:_addText(" ")
end
self:_addText(args.PostSoprannome)
end
self:_addText(", vero nome ")
end
 
Line 837 ⟶ 801:
end
 
if args.Soprannome then
if soprannomecognome and not currentTitleEquals(soprannomecognome) then
self:_addText(", ", (not args.Sesso or args.Sesso == "M") and "detto" or "detta",
" ", "'''", args.Soprannome, "'''")
Line 864 ⟶ 828:
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
self:_addText(args.PreData, "; ")
end
local datimancanti = not (args.LuogoNascita or args.GiornoMeseNascita or args.NoteNascita or args.LuogoMorte or args.GiornoMeseMorte)
local floruit = args.AnnoMorte == "?" and (args.Floruit or cfg.epoche[args.Epoca])
 
if args.LuogoNascita then
Line 900 ⟶ 861:
self:_addText(args.AnnoNascita)
end
elseif not floruit or not datimancanti then
else
self:_addText("...")
if not floruit then
self:_addText("...")
end
end
 
if args.NoteNascita then
if self:_needSpace(args.NoteNascita) then
Line 913 ⟶ 872:
end
 
if args.AnnoMorte and (not floruit or not datimancanti) then
self:_addText(" – ")
if args.LuogoMorte then
Line 936 ⟶ 895:
 
if args.AnnoMorte then
if args.AnnoMorte == "?" and not floruit then
self:_addText("...")
else
Line 965 ⟶ 924:
fl = "[[" .. fl .. "]]"
end
if not datimancanti then
if args.LuogoNascita or args.GiornoMeseNascita or args.LuogoMorte or args.GiornoMeseMorte then
self:_addText("; ")
end
self:_addText("[[floruit|fl.]] ", fl, ")")
end
return
end
 
if args.NoteMorte then
if self:_needSpace(args.NoteMorte) then
self:_addText(" ")
end
self:_addText(args.NoteMorte)
end
 
-- si chiude la parentesi
self:_addText(")")
end