Módulo:Avaliação: diferenças entre revisões

Conteúdo apagado Conteúdo adicionado
Remoção do teste "if mw.title.getCurrentTitle().basePageTitle == 'Marca de projeto' then" que só era necessário para categorizar as subpáginas da Predefinição:Marca de projeto (que não são mais usadas)
Separação entre a interface e a lógica (discussão)
Linha 18:
['format'] = 'predefinição',
['date'] = 'rev',
['reason'] = 'motivo',
['default-image'] = 'Exemplo.svg',
['nominate-to-GA'] = 'indique para EAD quando o artigo satisfizer os critérios de artigo bom',
['image-importance'] = 'Escala-laranja-$1de4.svg',
['image-importance-unknown'] = 'Escala-laranja-PA.svg',
['image-quality'] = 'Escala-azul-$1de6.svg',
['pagetype-0'] = 'artigo',
['pagetype-100'] = 'portal',
['pagetype-102'] = 'anexo',
['pagetype-other'] = 'conteúdo', -- "página" teria problemas de concordância
['importance-text'] = 'Para o \'\'\'[[$1|$2]]\'\'\' este $3 possui \'\'\'[[Predefinição:Escala de importância|importância]] $4\'\'\'. ' ..
'Se você se interessa pelo assunto, visite o projeto para conhecer as tarefas e [[$5|discussões]] em curso.',
['importance-unknown'] = 'ainda não avaliada',
['project-talk-page'] = 'Wikipédia Discussão:Projetos/$1',
['no-reason'] = 'motivo não informado',
['category-quality'] = '!Artigos de qualidade $1 sobre $2',
['category-quality-5'] = '!Artigos bons sobre $2',
['category-quality-6'] = '!Artigos destacados sobre $2',
['category-quality-unknown'] = '!Artigos de qualidade desconhecida sobre $1',
['category-quality-outdated'] = '!Artigos sobre $1 por reavaliar',
['category-quality-reviewed'] = '!Artigos com avaliação revisada',
['category-quality-conflict'] = '!Artigos com avaliações conflitantes-$1',
['category-quality-by-module'] = '!Artigos com qualidade estimada automaticamente',
['category-importance'] = '!Artigos de importância $1 sobre $2',
['category-importance-unknown'] = '!Artigos de importância desconhecida sobre $1',
['quality-aliases'] = {
['AB'] = 5,
['AD'] = 6
},
['quality-min'] = 1,
['quality-max'] = 6,
['quality-format'] = 'Qualidade $1 ($2)',
['project-contact'] = 'Se não tiver suas questões respondidas nesta página de discussão procure o(s) wikiprojeto(s) acima.',
['page-evaluated'] = 'Este $1 foi avaliado $2',
['page-evaluated-by-module'] = 'Este $1 foi avaliado [[Wikipédia:Avaliação automática|automaticamente]] $2',
['page-elected'] = 'Este $1 foi eleito $2',
['quality-value'] = 'com <b title="$2">[[Wikipédia:Qualidade|qualidade]] $1</b>',
['quality-value-5'] = 'um <b>$3 bom</b>',
['quality-value-6'] = 'um <b>$3 destacado</b>',
['quality-text'] = '$1.',
['quality-text-and-projects'] = '$1 e faz parte do âmbito de $2: $3.',
['quality-text-with-date'] = '$1 em $2.',
['quality-text-with-date-and-projects'] = '$1 em $2 e faz parte do âmbito de $3: $4.',
['projects-singular'] = 'um WikiProjeto',
['projects-plural'] = '$1 WikiProjetos'
}
 
local function msg(m, ...)
return mw.message.newRawMessage(m):params{...}:plain()
end
 
quality[2] = {
Linha 265 ⟶ 313:
 
-- Nada encontrado; Nothing found
return {4, msg(cfg['nominate-to-GA'])}
return {4, 'indique para EAD quando o artigo satisfizer os critérios de artigo bom'}
end
 
Linha 292 ⟶ 340:
quality = nil
end
local image = args['image'] or cfg['Exemplo.svgdefault-image']
local size = args['size'] or '75x50px'
local imgImportance
if importance then
imgImportance = msg(cfg['image-importance'], importance )
else
imgImportance = msg(cfg['image-importance-unknown'] )
end
local row = mw.html.create( 'tr' )
:tag( 'td' )
Linha 301 ⟶ 355:
:css( 'padding', '2px 0px 2px 0.9em' )
:css( 'text-align', 'center' )
:wikitext( '[[ImagemFile:' .. image .. '|' .. size .. ']]' )
:done()
:tag( 'td' )
Linha 307 ⟶ 361:
:css( 'border-bottom', '1px solid #fc8' )
:css( 'text-align', 'center' )
:wikitext( '[[File:' .. imgImportance .. ']]' )
'[[Imagem:Escala-laranja-' ..
( importance and ( importance .. 'de4' ) or 'PA' ) ..
'.svg]]'
)
:done()
local textCell = row:tag( 'td' )
Linha 326 ⟶ 376:
page = args['page'] or mw.title.getCurrentTitle().subjectPageTitle.prefixedText
local nsNum = mw.title.new( page ).namespace
local pageTypes = {
[102] = 'anexo',
[100] = 'portal'
}
local lang = mw.language.getContentLanguage()
local link = args['link']
Linha 349 ⟶ 395:
end
local text = args['text'] or link
local pageType = pageTypesmsg( cfg['pagetype-' .. nsNum] or cfg['artigopagetype-other'] )
local about = args['category'] or args['title']
local importanceText = importance or msg( cfg['importance-unknown'] )
textCell
local projPage = msg( cfg['project-talk-page'], args['talk'] or lang:ucfirst( about or '' ) )
:wikitext(
textCell:wikitext( msg(cfg['importance-text'], link, text, pageType, importanceText, projPage ) )
'Para o \'\'\'[[' .. link .. '|' .. text .. ']]\'\'\' este ' .. pageType ..
local cats = {}
' possui \'\'\'[[Predefinição:Escala de importância|importância]] ' ..
( importance or 'ainda não avaliada' ) ..
'\'\'\'. Se você se interessa pelo assunto, visite o projeto para conhecer as tarefas e [[Wikipédia Discussão:Projetos/' ..
( args['talk'] or lang:ucfirst( about or '' ) ) ..
'|discussões]] em curso.'
)
local cats = ''
if mw.site.contentNamespaces[nsNum] and about then
if quality then
cats = cats .. '[[categoria:!Artigos '
table.insert( cats, msg(cfg['category-quality-' .. quality] or cfg['category-quality'], quality, about) )
if not quality then
cats = cats .. 'de qualidade desconhecida'
else
table.insert( cats, msg(cfg['category-quality-unknown'], about) )
if quality <= 4 then
cats = cats .. 'de qualidade ' .. quality
elseif quality == 5 then
cats = cats .. 'bons'
elseif quality == 6 then
cats = cats .. 'destacados'
end
end
cats = cats .. ' sobre ' .. about .. ']]\n'
end
if importance then
cats = cats .. '[[categoria:!Artigos de importância ' ..
table.insert( cats, msg(cfg['category-importance'], importance, about) )
( importance or 'desconhecida' ) .. ' sobre ' .. about .. ']]\n'
else
table.insert( cats, msg(cfg['category-importance-unknown'], about) )
end
if args['date'] then
if lang:formatDate( 'Ymd', '-6 months' ) > ( args['date'] or '99999999' ) then
table.insert( cats, msg(cfg['category-quality-outdated'], about) )
cats = cats .. '[[Categoria:!Artigos sobre ' .. about ..
' por reavaliar|' .. page .. ']]'
end
end
return tostring( row ) .. ( #cats ~= 0 and ( '[[Category:' .. table.concat(cats, ']]\n[[Category:') .. ']]' ) or '' )
end
 
Linha 392 ⟶ 426:
local qualityByUser = args[1] or args[cfg['quality']]
local qualityByModule = getClassForPage( page )
local reason = args[cfg['reason']] or msg(cfg['motivo não informadono-reason'])
local lang = mw.language.getContentLanguage()
 
-- Convert to numbers
if qualityByUser then
qualityByUser = tonumber( cfg['quality-aliases'][ qualityByUser ] or qualityByUser )
-- Convert to numbers
if qualityByUser and cfg['quality-min'] <= qualityByUser and qualityByUser <= cfg['ABquality-max'] then
qualityByUser = { 5qualityByUser, reason }
elseif qualityByUser == 'AD' then
qualityByUser = { 6, reason }
else
qualityByUser = tonumber( qualityByUser )
if qualityByUser and 1 <= qualityByUser and qualityByUser <= 6 then
qualityByUser = { qualityByUser, reason }
else
qualityByUser = nil
end
end
end
 
Linha 445 ⟶ 469:
:css( 'text-align', 'right' )
:css( 'background', 'transparent' )
:wikitext( '[[ImagemFile:Escala-azul-' .. msg(cfg['image-quality'], quality[1]) .. 'de6.svg]]' )
 
local qualityCell = firstRow:tag( #proj > 0 and 'th' or 'td' )
Linha 456 ⟶ 480:
 
local nsNum = mw.title.new( page ).namespace
local pageType = msg( cfg['pagetype-' .. nsNum] or cfg['pagetype-other'] )
local pageTypes = {
local pageEvaluation
[102] = 'anexo',
local pageQuality = msg(cfg['quality-value-' .. quality[1]] or cfg['quality-value'], quality[1], quality[2], pageType )
[100] = 'portal'
if quality[1] >= 5 then
}
pageEvaluation = msg(cfg['page-elected'], pageType, pageQuality )
local pageType = pageTypes[nsNum] or 'artigo'
else
 
if qualityByUser then
pageEvaluation = msg(cfg['page-evaluated'], pageType, pageQuality )
if quality[1] <= 4 then
else
qualityCell
pageEvaluation = msg(cfg['page-evaluated-by-module'], pageType, pageQuality )
:wikitext( 'Este ' .. pageType .. ' foi avaliado com ' )
end
:tag( 'b' )
end
:attr( 'title', quality[2] )
if dateOfLastestReview and mw.ustring.len( dateOfLastestReview ) == 8 then
:wikitext( '[[Wikipédia:Qualidade|qualidade]] ' .. quality[1] )
if #proj > 0 then
 
local projects
if dateOfLastestReview and mw.ustring.len( dateOfLastestReview ) == 8 then
if #proj == 1 then
qualityCell:wikitext( ' em ' .. lang:formatDate( 'd "de" F "de" Y', dateOfLastestReview ) )
projects = msg(cfg['projects-singular'])
else
projects = msg(cfg['projects-plural'], #proj)
end
qualityCell:wikitext( msg(
elseif quality[1] == 5 then
cfg['quality-text-with-date-and-projects'],
qualityCell
pageEvaluation,
:wikitext( 'Este ' .. pageType .. ' foi ' )
lang:formatDate( 'd "de" F "de" Y', dateOfLastestReview ),
:tag( 'b' )
projects,
:wikitext( 'eleito um ' .. pageType .. ' bom' )
mw.text.listToText( proj )
elseif quality[1] == 6 then
qualityCell) )
else
:wikitext( 'Este ' .. pageType .. ' foi ' )
qualityCell:wikitext( msg(cfg['quality-text-with-date'], pageEvaluation ) )
:tag( 'b' )
:wikitext( 'eleito um ' .. pageType .. ' destacado' )
end
else
if #proj > 0 then
qualityCell
local projects
:wikitext( 'Este ' .. pageType .. ' foi avaliado [[Wikipédia:Avaliação automática|automaticamente]] com ' )
:tag(if 'b'#proj )== 1 then
projects = msg(cfg['projects-singular'])
:attr( 'title', quality[2] )
else
:wikitext( '[[Wikipédia:Qualidade|qualidade]] ' .. quality[1] )
projects = msg(cfg['projects-plural'], #proj)
end
end
 
qualityCell:wikitext( msg(
if #proj < 1 then
cfg['quality-text-and-projects'],
qualityCell:wikitext( '.' )
pageEvaluation,
elseif #proj == 1 then
projects,
qualityCell:wikitext( ' e faz parte do âmbito de um WikiProjeto: ' .. proj[1] .. '.' )
mw.text.listToText( proj )
else
) )
qualityCell:wikitext(
else
' e faz parte do âmbito de ' .. #proj .. ' WikiProjetos: ' ..
qualityCell:wikitext( msg(cfg['quality-text'], pageEvaluation ) )
mw.text.listToText( proj ) .. '.'
)end
end
local banners = mw.loadData( 'Módulo:Avaliação/Marcas' )
Linha 542 ⟶ 568:
:css( 'text-align', 'center' )
:css( 'font-size', '90%' )
:wikitext( msg( cfg['project-contact'] ) )
:wikitext( 'Se não tiver suas questões respondidas nesta página de discussão procure o(s) wikiprojeto(s) acima.' )
end
 
Linha 549 ⟶ 575:
args = mw.title.new( page ).prefixedText
} ) or 0
local cats = ''{}
-- Categorizar somente se a página for um artigo (ou anexo)
if mw.site.contentNamespaces[nsNum] then
Linha 561 ⟶ 587:
if articleTimestamp <= userTimestamp then
-- A revisão atual do artigo é a mesma que foi analisada por um usuário
table.insert( cats, msg( cfg['category-quality-reviewed'] ) )
cats = cats .. '[[Categoria:!Artigos com avaliação revisada]]\n'
if qualityByUser[1] ~= qualityByModule[1] then
cats =table.insert( cats, ..msg( cfg['[[Categoria:!Artigos com avaliações conflitantescategory-quality-conflict' ..], qualityByModule[1] ..) ']]\n')
end
-- else
Linha 573 ⟶ 599:
end
else
table.insert( cats, msg( cfg['category-quality-by-module'] ) )
cats = cats .. '[[Categoria:!Artigos com qualidade estimada automaticamente]]\n'
end
-- else
Linha 579 ⟶ 605:
end
 
return tostring( root ) .. ( #cats ~= 0 and ( '[[Category:' .. table.concat(cats, ']]\n[[Category:') .. ']]' ) or '' )
end
 
Linha 596 ⟶ 622:
local args = getArgs( frame )
local page = args[cfg['page']] or args[1]
local template = args[cfg['format']] or args[2] or msg( cfg['Qualidadequality-format'] $1 ($2)'
 
if page == nil then