Documentação do módulo[ver] [editar] [histórico] [purgar]

Descrição

Este módulo destina-se a implementar a {{NM}}, mas apenas coloca as categorias. Aceita a data no formato Década de 2000, e Século XX, e um número positivo. Não coloca categorias de anos a.C..

Uso

{{#invoke:CategoriaNM|build|data nascimento|data da morte}}

Utilize DESCONHECIDO, ?, VIVA para incluir em outras categoria de monitoramento.


Outra documentação:

-- Módulo para implementar predefinição:NM sem controle de autoridade

local p = {}
local Ferramentas = require 'Módulo:Ferramentas'

local function addCat(cat)
        return  '[[Category:' .. cat .. ']]'
end

function p.nascimento(frame, ...)
    local args = Ferramentas.extractArgs( frame, ... )
    local nascimento = args[1]
    local wikitext = '' -- cadeia devolvida com cats de monitoramento
    local title = mw.title.getCurrentTitle()
    if title.namespace ~= 0 and title.namespace ~= 14 then
        return ''
    end
    if not Ferramentas.notEmpty(nascimento) then
        wikitext = wikitext .. addCat('Nascidos em ano desconhecido')
        return wikitext
    end
   
    nascimento = Ferramentas.trim(nascimento)
    local m = string.upper(nascimento)
    local decada = nascimento:gsub("^[D]", 'd')
    local seculo = nascimento:gsub("^[S]", 's')
    if m == 'MISSING' or m == 'UNKNOWN' or m == '?' or m == 'DESCONHECIDO' or not Ferramentas.notEmpty(nascimento) then
        -- nenhuma mensagem de erro que possa travar a função de chamada
        -- para ela gerenciar esse retorno.
        wikitext = wikitext .. addCat('Nascidos em ano desconhecido')
    elseif string.match(decada, 'década' ) then
        wikitext = wikitext .. addCat('Nascidos na ' .. decada)
    elseif string.match(seculo, 'século' ) then
        wikitext = wikitext .. addCat('Nascidos no ' .. seculo)
    elseif string.match(nascimento, 'a.C.' ) or tonumber( nascimento ) then     
        wikitext = wikitext .. addCat('Nascidos em ' .. nascimento)
    else
        wikitext = wikitext .. addCat('Nascidos em ano desconhecido')
    end
end

function p.morte(frame, ...)
    local args = Ferramentas.extractArgs( frame, ... )
    local nascimento, morte = args[1], args[2]
    local wikitext = '' -- cadeia devolvida com cats de monitoramento
    local title = mw.title.getCurrentTitle()
    if title.namespace ~= 0 and title.namespace ~= 14 then
        return ''
    end
    nascimento = Ferramentas.trim(nascimento)
    morte = Ferramentas.trim(morte)
    if not Ferramentas.notEmpty(nascimento) and not Ferramentas.notEmpty(morte) then
        wikitext = wikitext .. addCat('!Artigos que usam a predefinição NM sem data')
    return wikitext
    end
   
    local m = string.upper( nascimento or '')
    if m == 'MISSING' or m == 'UNKNOWN' or m == '?' or m == 'DESCONHECIDO' or not Ferramentas.notEmpty(nascimento) then
        -- nenhuma mensagem de erro que possa travar a função de chamada
        -- para ela gerenciar esse retorno.
        wikitext = wikitext .. addCat('Nascidos em ano desconhecido')
    else 
        local decada = nascimento:gsub("^[D]", 'd') or ''
        local seculo = nascimento:gsub("^[S]", 's') or ''
        if string.match(decada, 'década' ) then
            wikitext = wikitext .. addCat('Nascidos na ' .. decada)
        elseif string.match(seculo, 'século' ) then
            wikitext = wikitext .. addCat('Nascidos no ' .. seculo)
        elseif string.match(nascimento, 'a.C.' ) or tonumber( nascimento ) then     
            wikitext = wikitext .. addCat('Nascidos em ' .. nascimento)
        else
            wikitext = wikitext .. addCat('Nascidos em ano desconhecido')
        end
    end

---- morte
    m = string.upper( morte or '')
    if m == 'LIVING' or m == 'VIVA' then
        wikitext = wikitext .. addCat('Pessoas vivas')
    elseif m == 'MISSING' or m == 'UNKNOWN' or m == '?' or m == 'DESCONHECIDO' or not Ferramentas.notEmpty(morte) then
        wikitext = wikitext .. addCat('Mortos em ano desconhecido')
    else
        decada = morte:gsub("^[D]", 'd') or ''
	seculo = morte:gsub("^[S]", 's') or ''
	if string.match(decada, 'década' ) then
    	    wikitext = wikitext .. addCat('Mortos na ' .. decada)
	elseif string.match(seculo, 'século' ) then
            wikitext = wikitext .. addCat('Mortos no ' .. seculo)
        elseif string.match(morte, 'a.C.' ) or tonumber( morte ) then
            wikitext = wikitext .. addCat('Mortos em ' .. morte)
        else
            wikitext = wikitext .. addCat('Mortos em ano desconhecido')
        end
     end
    return wikitext   
end

function p.main( frame )
	return p.morte( frame )
end

return p