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: | Linha 18: | ||
['format'] = 'predefinição', |
['format'] = 'predefinição', |
||
['date'] = 'rev', |
['date'] = 'rev', |
||
['reason'] = 'motivo' |
['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] = { |
quality[2] = { |
||
Linha 265: | Linha 313: | ||
-- Nada encontrado; Nothing found |
-- 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 |
end |
||
Linha 292: | Linha 340: | ||
quality = nil |
quality = nil |
||
end |
end |
||
local image = args['image'] or ' |
local image = args['image'] or cfg['default-image'] |
||
local size = args['size'] or '75x50px' |
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' ) |
local row = mw.html.create( 'tr' ) |
||
:tag( 'td' ) |
:tag( 'td' ) |
||
Linha 301: | Linha 355: | ||
:css( 'padding', '2px 0px 2px 0.9em' ) |
:css( 'padding', '2px 0px 2px 0.9em' ) |
||
:css( 'text-align', 'center' ) |
:css( 'text-align', 'center' ) |
||
:wikitext( '[[ |
:wikitext( '[[File:' .. image .. '|' .. size .. ']]' ) |
||
:done() |
:done() |
||
:tag( 'td' ) |
:tag( 'td' ) |
||
Linha 307: | Linha 361: | ||
:css( 'border-bottom', '1px solid #fc8' ) |
:css( 'border-bottom', '1px solid #fc8' ) |
||
:css( 'text-align', 'center' ) |
:css( 'text-align', 'center' ) |
||
:wikitext( |
:wikitext( '[[File:' .. imgImportance .. ']]' ) |
||
'[[Imagem:Escala-laranja-' .. |
|||
( importance and ( importance .. 'de4' ) or 'PA' ) .. |
|||
'.svg]]' |
|||
) |
|||
:done() |
:done() |
||
local textCell = row:tag( 'td' ) |
local textCell = row:tag( 'td' ) |
||
Linha 326: | Linha 376: | ||
page = args['page'] or mw.title.getCurrentTitle().subjectPageTitle.prefixedText |
page = args['page'] or mw.title.getCurrentTitle().subjectPageTitle.prefixedText |
||
local nsNum = mw.title.new( page ).namespace |
local nsNum = mw.title.new( page ).namespace |
||
local pageTypes = { |
|||
[102] = 'anexo', |
|||
[100] = 'portal' |
|||
} |
|||
local lang = mw.language.getContentLanguage() |
local lang = mw.language.getContentLanguage() |
||
local link = args['link'] |
local link = args['link'] |
||
Linha 349: | Linha 395: | ||
end |
end |
||
local text = args['text'] or link |
local text = args['text'] or link |
||
local pageType = |
local pageType = msg( cfg['pagetype-' .. nsNum] or cfg['pagetype-other'] ) |
||
local about = args['category'] or args['title'] |
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 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 |
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 |
end |
||
cats = cats .. ' sobre ' .. about .. ']]\n' |
|||
end |
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 args['date'] then |
||
if lang:formatDate( 'Ymd', '-6 months' ) > ( args['date'] or '99999999' ) 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 |
||
end |
end |
||
return tostring( row ) .. cats |
return tostring( row ) .. ( #cats ~= 0 and ( '[[Category:' .. table.concat(cats, ']]\n[[Category:') .. ']]' ) or '' ) |
||
end |
end |
||
Linha 392: | Linha 426: | ||
local qualityByUser = args[1] or args[cfg['quality']] |
local qualityByUser = args[1] or args[cfg['quality']] |
||
local qualityByModule = getClassForPage( page ) |
local qualityByModule = getClassForPage( page ) |
||
local reason = args[cfg['reason']] or ' |
local reason = args[cfg['reason']] or msg(cfg['no-reason']) |
||
local lang = mw.language.getContentLanguage() |
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['quality-max'] then |
|||
qualityByUser = { qualityByUser, 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 |
end |
||
Linha 445: | Linha 469: | ||
:css( 'text-align', 'right' ) |
:css( 'text-align', 'right' ) |
||
:css( 'background', 'transparent' ) |
:css( 'background', 'transparent' ) |
||
:wikitext( '[[ |
:wikitext( '[[File:' .. msg(cfg['image-quality'], quality[1]) .. ']]' ) |
||
local qualityCell = firstRow:tag( #proj > 0 and 'th' or 'td' ) |
local qualityCell = firstRow:tag( #proj > 0 and 'th' or 'td' ) |
||
Linha 456: | Linha 480: | ||
local nsNum = mw.title.new( page ).namespace |
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 |
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 |
|||
) ) |
|||
else |
|||
:wikitext( 'Este ' .. pageType .. ' foi ' ) |
|||
qualityCell:wikitext( msg(cfg['quality-text-with-date'], pageEvaluation ) ) |
|||
:tag( 'b' ) |
|||
:wikitext( 'eleito um ' .. pageType .. ' destacado' ) |
|||
end |
end |
||
else |
else |
||
if #proj > 0 then |
|||
qualityCell |
|||
local projects |
|||
:wikitext( 'Este ' .. pageType .. ' foi avaliado [[Wikipédia:Avaliação automática|automaticamente]] com ' ) |
|||
if #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 |
end |
||
local banners = mw.loadData( 'Módulo:Avaliação/Marcas' ) |
local banners = mw.loadData( 'Módulo:Avaliação/Marcas' ) |
||
Linha 542: | Linha 568: | ||
:css( 'text-align', 'center' ) |
:css( 'text-align', 'center' ) |
||
:css( 'font-size', '90%' ) |
: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 |
end |
||
Linha 549: | Linha 575: | ||
args = mw.title.new( page ).prefixedText |
args = mw.title.new( page ).prefixedText |
||
} ) or 0 |
} ) or 0 |
||
local cats = |
local cats = {} |
||
-- Categorizar somente se a página for um artigo (ou anexo) |
-- Categorizar somente se a página for um artigo (ou anexo) |
||
if mw.site.contentNamespaces[nsNum] then |
if mw.site.contentNamespaces[nsNum] then |
||
Linha 561: | Linha 587: | ||
if articleTimestamp <= userTimestamp then |
if articleTimestamp <= userTimestamp then |
||
-- A revisão atual do artigo é a mesma que foi analisada por um usuário |
-- 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 |
if qualityByUser[1] ~= qualityByModule[1] then |
||
table.insert( cats, msg( cfg['category-quality-conflict'], qualityByModule[1] ) ) |
|||
end |
end |
||
-- else |
-- else |
||
Linha 573: | Linha 599: | ||
end |
end |
||
else |
else |
||
table.insert( cats, msg( cfg['category-quality-by-module'] ) ) |
|||
cats = cats .. '[[Categoria:!Artigos com qualidade estimada automaticamente]]\n' |
|||
end |
end |
||
-- else |
-- else |
||
Linha 579: | Linha 605: | ||
end |
end |
||
return tostring( root ) .. cats |
return tostring( root ) .. ( #cats ~= 0 and ( '[[Category:' .. table.concat(cats, ']]\n[[Category:') .. ']]' ) or '' ) |
||
end |
end |
||
Linha 596: | Linha 622: | ||
local args = getArgs( frame ) |
local args = getArgs( frame ) |
||
local page = args[cfg['page']] or args[1] |
local page = args[cfg['page']] or args[1] |
||
local template = args[cfg['format']] or args[2] or ' |
local template = args[cfg['format']] or args[2] or msg( cfg['quality-format'] ) |
||
if page == nil then |
if page == nil then |
Revisão das 21h37min de 10 de julho de 2014
Este módulo é usado em aproximadamente 454 000 páginas. (Ver Wikipedia:Predefinições em alto risco) Para evitar sobrecargas desnecessárias ao servidor e outros transtornos, quaisquer mudanças devem ser previamente testadas, seja na subpágina de testes deste módulo, na subpágina de testes de módulos (ou ainda em sua subpágina de testes). Por favor, sempre considere expor eventuais mudanças na página de discussão, antes de implementá-las. |
Este módulo está na categoria sujeitos a proteção de página. Ele é um módulo de alta visibilidade em uso por um grande número de páginas, ou é transcluído muito frequentemente. Por causa do vandalismo ou erros que podem afectar muitas páginas, e mesmo edições triviais podem causar cargas substanciais nos servidores, ele está protegido de editar. |
Descrição
Este módulo implementa a Predefinição:Marca de projeto.
Ver também
- Módulo:Avaliação/Marcas
- Wikipédia:Avaliação automática
- User:Danilo.bot/marcas.py
- en:Module:WikiProjectBanner
- AssessmentHelper.js
- Wikipédia:Projetos/Padronização/Marcas
- Wikipedia article quality classification
A documentação acima é transcluída de Módulo:Avaliação/doc. (editar | histórico) Editores podem experimentar nas páginas de teste (editar | dif) e de exemplos para testes (criar) deste módulo. Subpáginas deste módulo. |
-- Ver também:
-- [[Wikipédia:Avaliação automática]]
-- [[User:Danilo.bot/marcas.py]]
-- [[b:User:Helder.wiki/Tools/AssessmentHelper.js]]
local getArgs = require('Module:Arguments').getArgs
local quality = {}
local cfg = {
['link'] = 'link',
['text'] = 'texto do link',
['category'] = 'sobre',
['image'] = 'imagem',
['size'] = 'tamanho',
['description'] = 'texto',
['talk'] = 'discussão',
['page'] = 'página',
['quality'] = 'qualidade',
['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] = {
minBytesRef = {2000, 'menos de 2000 bytes'},
minBytesNoRefSection = {8000, 'menos de 8000 bytes e não tem seção de referências'},
noTemplates = {{'mínimo', 'contexto', 'reciclagem', 'reciclar-sobre'}, 'encontrada predefinição:%s'},
parMaxBytes = {2500, 'parágrafo muito grande (%d bytes): \'%s...\''},
links = {10, 'menos de 10 ligações internas'},
minParagraphs = {5, 'menos de 5 parágrafos'}
}
quality[3] = {
noTemplates = {{'esboço', 'wikificação', 'revisão', 'revisão-sobre'}, 'encontrada predefinição:%s'},
needRefSection = {true, 'não tem seção de referências'},
minBytes = {12000, 'menos de 12000 bytes'},
links = {30, 'menos de 30 ligações internas'},
sections = {2, 'menos de 2 seções'},
refs = {5, 'menos de 5 referências'},
images = {1, 'não tem imagem'},
allSecRef = {true, 'não encontrada referência na seção \'%s\''}
}
quality[4] = {
noTemplates = {{'artigo com problemas', 'artigo longo', 'artigo sobre direito com problemas', 'bsre', 'coi', 'caracteres não-padrão',
'conflito interwiki', 'contextualizar2', 'conteúdo parcial', 'controverso', 'corrigir', 'ctx2', 'curiosidades', 'direitos-autorais',
'disputa-bpv', 'divisão', 'em tradução', 'expandir', 'expandir2', 'fusão', 'fusão com', 'fusão de', 'fusão vot', 'global',
'global/brasil', 'global/lusofonia', 'global/portugal', 'hanzi', 'idioma estrangeiro', 'matrad', 'mtag', 'multitag', 'má introdução',
'má tradução', 'não informado', 'não informado n', 'não-enc', 'não-enciclopédico', 'não-enciclopédico2', 'parcial', 'parcialcontroverso',
'publicidade', 'rec', 'reciclagem', 'reciclar-sobre', 'ren-pag', 'renomear página', 'revisão', 'revisão de tradução', 'revisão-sobre',
's-fontes-bpv', 'sem cat', 'sem-fontes-bpv', 'sem-fontes-sobre', 'semimagem-arquitetura', 'semimagem-sobre', 'separar', 'suspeito2',
'tradução de', 'vda2', 'wikificação'}, 'encontrado predefinição:%s'},
minBytes = {20000, 'menos de 20000 bytes'},
links = {50, 'menos de 50 ligações internas'},
sections = {4, 'menos de 4 seções'},
refs = {10, 'menos de 10 referências'},
images = {2, 'só tem uma imagem'}
}
quality[5] = {
template = {'artigo bom', 'anexo bom'}
}
quality[6] = {
template = {'artigo destacado', 'anexo destacado'}
}
local refTemplates = {'referências', 'ref-section', 'refsection', 'rodapé referências', 'reflist'}
local refNoTemplates = {'==%s-[Rr]eferências%s-=='}
local imageTemplates = {'imagem dupla'}
local fileNsAliases = {'ficheiro', 'imagem', 'image', 'file', 'arquivo'}
local otherImages = {'{{.-[Ii]magem *=.-%.%a%a%a%a?'}
local exceptions = {'Referências', 'Ver também', 'Notas', 'Notas e referências','Discografia','Galeria de imagens',
'Referências gerais', 'Leitura adicional', 'Subdivisões', 'Leitura recomendada', 'Ligações externas', 'Bibliografia'}
local getClassForText = function(text)
local bytes = #text
local hasRefSection = false
local images = 0
local tList = {}
local paragraphs = 0
local lang = mw.language.getContentLanguage()
local hasitem = function(tbl, item)
for i = 1, #tbl do
if tbl[i] == item then
return true
end
end
return false
end
local count = function(txt, pattern)
local c = 0
for i in mw.ustring.gmatch(txt, pattern) do
c = c + 1
end
return c
end
if bytes < quality[2].minBytesRef[1] then
return {1, quality[2].minBytesRef[2]} -- Q1: Artigo é muito pequeno; Article is too small
end
-- Verificando as predefinições; Checking the templates
for t in mw.ustring.gmatch(text, '{{ *([^|}\n]+)[ \n]*[|}]') do
t = lang:lcfirst(t)
if t == quality[6].template[1] then
return {6, quality[6].template[2]} -- Q6: Artigo destacado; Featured article
elseif t == quality[5].template[1] then
return {5, quality[5].template[1]} -- Q5: Artigo bom; Good article
elseif not hasRefSection and hasitem(refTemplates, t) then
hasRefSection = true
elseif hasitem(imageTemplates, t) then
--FIXME: Imagem dupla deve contar como uma única imagem?
images = images + 1
elseif hasitem(quality[2].noTemplates[1], t) then
noTemplate = {1, mw.ustring.format(quality[2].noTemplates[2], t)} -- Q1: Predefinição proibida para Q2; Template proibited for Q2
elseif hasitem(quality[3].noTemplates[1], t) then
noTemplate = {2, mw.ustring.format(quality[3].noTemplates[2], t)} -- Q2: Predefinição proibida para Q3; Template proibited for Q3
elseif hasitem(quality[4].noTemplates[1], t) then
noTemplate = {3, mw.ustring.format(quality[4].noTemplates[2], t)} -- Q3: Predefinição proibida para Q4; Template proibited for Q4
end
if not hasitem(tList, t) then
table.insert(tList, t)
end
end
-- Verificando referências fora de predefinição; Checking referências outside templates
if not hasRefSection then
local n = 0
for i = 1, #refNoTemplates do
text, n = mw.ustring.gsub(text, refNoTemplates[i], '')
if n > 0 then
hasRefSection = true
end
end
end
if not hasRefSection and bytes < quality[2].minBytesNoRefSection[1] then
return {1, quality[2].minBytesNoRefSection[2]} -- Q1: Artigo pequeno sem referências; Small article without references
end
-- Removendo e contando notas de rodapé; Removing and counting citations
-- FIXME: "refs" deveria ser 1 (não 2) quando text='A<ref>B</ref>C<ref>B</ref>D'
local textNoRef, refs1, refs2, refs
textNoRef, refs1 = mw.ustring.gsub(text, '<[Rr][Ee][Ff]>.-</[Rr][Ee][Ff]>', '')
textNoRef, refs2 = mw.ustring.gsub(textNoRef, '<[Rr][Ee][Ff] [^>]-[^/]>.-</[Rr][Ee][Ff]>', '')
-- FIXME: Guardar a quantidade de nomes (únicos) de refs reutilizados?
textNoRef = mw.ustring.gsub(textNoRef, '<[Rr][Ee][Ff].-/>', '')
refs = refs1 + refs2
-- Paragrafos; Paragraphs
local paragraph = '\n([^*{\n|[]' .. mw.ustring.rep('[^\n]', 99) .. '+)\n'
for p in mw.ustring.gmatch( textNoRef, paragraph ) do
if #p > quality[2].parMaxBytes[1] then
return {1, mw.ustring.format(quality[2].parMaxBytes[2], #p, mw.ustring.sub(p,1, 25))} -- Q1: parágrafo muito grande; Too big paragraph
else
paragraphs = paragraphs + (mw.ustring.find(p, '%. ') and 1 or 0.5)
end
end
local wikilinks = count(textNoRef, '%[%[[^:\n][^:\n]-%]%]')
textNoRef = nil
if wikilinks < quality[2].links[1] then
return {1, quality[2].links[2]} -- Q1: Poucas ligações internas; Few internal links
end
if paragraphs < quality[2].minParagraphs[1] then
return {1, quality[2].minParagraphs[2]} -- Q1: Poucos parágrafos; Few paragraphs
end
if noTemplate and noTemplate[1] == 1 then
return noTemplate
end
-- Check if some requirement for Q3 is not satisfied
if quality[3].needRefSection[1] and not hasRefSection then
return {2, quality[3].needRefSection[2]} -- Q2: Não tem seção de referências; There is no references section
end
if bytes < quality[3].minBytes[1] then
return {2, quality[3].minBytes[2]} -- Q2: Muito pequeno para Q3; Too small for Q3
end
if wikilinks < quality[3].links[1] then
return {2, quality[3].links[2]} -- Q2: Poucas ligações internas; Few internal links
end
local sections = count(text, '\n==[^=}{\n][^=}{\n]-==')
sections = sections + count(text, '\n===[^=}{\n][^=}{\n]-===') / 5
if sections < quality[3].sections[1] then
return {2, quality[3].sections[2]} -- Q2: Poucas seções; Few sections
end
if refs < quality[3].refs[1] then
return {2, quality[3].refs[2]} -- Q2: Poucas referências; Few references
end
for l in mw.ustring.gmatch(text, '%[%[ *(%a+) *:[^%]\n]-%]%]') do
if hasitem(fileNsAliases, lang:lc(l)) then
images = images + 1
end
end
for i = 1, #otherImages do
images = images + count(text, otherImages[i])
end
if images < quality[3].images[1] then
return {2, quality[3].images[2]} -- Q2: Sem imagens; No images
end
-- Só retorna Q2 depois de todos testes para Q1
if noTemplate and noTemplate[1] == 2 then
return noTemplate
end
-- Check if some requirement for Q4 is not satisfied
if bytes < quality[4].minBytes[1] then
return {3, quality[4].minBytes[2]} -- Q3: Muito pequeno para Q4; Too small for Q4
end
if wikilinks < quality[4].links[1] then
return {3, quality[4].links[2]} -- Q3: Poucas ligações internas; Few internal links
end
if sections < quality[4].sections[1] then
return {3, quality[4].sections[2]} -- Q3: Poucas seções; Few sections
end
--FIXME: "refs" tem um valor impreciso, como exemplificado acima
if refs < quality[4].refs[1] then
return {3, quality[4].refs[2]} -- Q3: Poucas referências; Few references
end
if images < quality[4].images[1] then
return {3, quality[4].images[2]} -- Q3: Poucas imagens; Few images
end
-- Só retorna Q3 depois de todos testes para Q1 e Q2
if noTemplate and noTemplate[1] == 3 then
return noTemplate
end
local a, b, s = mw.ustring.find(text, '\n==+ *([^={}\n]-) *==+')
local a2, b2, s2 = 0, 0, ''
while quality[3].allSecRef[1] and b do
local r = mw.ustring.find(text, '<[Rr][Ee][Ff]', b)
local p = mw.ustring.find(text, '\n[^*\n]' .. mw.ustring.rep('[^\n]', 99) .. '+', b)
a2, b2, s2 = mw.ustring.find(text, '\n==+ *([^={}\n]-) *==+', b)
if ( ( a2 and p and r and p < a2 and r > a2 ) or (p and not r) ) and not hasitem(exceptions, s) then
return {3, mw.ustring.format(quality[3].allSecRef[2], s)} -- Q3: Existem seções sem referências; There are sections with no citations
end
a, b, s = a2, b2, s2
end
-- Nada encontrado; Nothing found
return {4, msg(cfg['nominate-to-GA'])}
end
local getClassForPage = function ( page )
local pageTitle = mw.title.new( page )
if pageTitle.isRedirect then
-- Redefine the title to the target page after extracting it from wikicode
local text = mw.ustring.match( pageTitle:getContent(), '^[^\n]-%[%[([^\n]-)%|', 10 )
if not text then
text = mw.ustring.match( pageTitle:getContent(), '^[^\n]-%[%[([^\n]-)%]%]', 10 )
end
pageTitle = mw.title.new( mw.uri.decode( text ) )
end
return getClassForText( pageTitle:getContent() or '' )
end
local _getBannerRow = function ( args )
local importance = tonumber( args['importance'] )
if importance and ( importance < 1 or 4 < importance ) then
importance = nil
end
local quality = tonumber( args['quality'] )
if quality and ( quality < 1 or 6 < quality ) then
quality = nil
end
local image = args['image'] or cfg['default-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' )
:addClass( 'tmbox-image' )
:css( 'border-top', '1px solid #fc8' )
:css( 'border-bottom', '1px solid #fc8' )
:css( 'padding', '2px 0px 2px 0.9em' )
:css( 'text-align', 'center' )
:wikitext( '[[File:' .. image .. '|' .. size .. ']]' )
:done()
:tag( 'td' )
:css( 'border-top', '1px solid #fc8' )
:css( 'border-bottom', '1px solid #fc8' )
:css( 'text-align', 'center' )
:wikitext( '[[File:' .. imgImportance .. ']]' )
:done()
local textCell = row:tag( 'td' )
:addClass( 'tmbox-text' )
:css( 'border-top', '1px solid #fc8' )
:css( 'border-bottom', '1px solid #fc8' )
:css( 'padding', '1em 2px 1em 0.9em' )
:css( 'width', '100%' )
if args['description'] then
textCell
:tag( 'p' )
:wikitext( args['description'] )
end
page = args['page'] or mw.title.getCurrentTitle().subjectPageTitle.prefixedText
local nsNum = mw.title.new( page ).namespace
local lang = mw.language.getContentLanguage()
local link = args['link']
if not( link and mw.title.new( link ) and mw.title.new( link ).exists ) then
-- link does not contain a valid title to an existing page
local title = lang:ucfirst( args['title'] )
local proj = 'Wikipédia:Projetos/' .. title
if mw.title.new( proj ) and mw.title.new( proj ).exists then
link = proj
else
local portal = 'Portal:' .. title
if mw.title.new( portal ) and mw.title.new( portal ).exists then
link = portal
else
-- No valid title was found! Create a red link for a future project
link = proj
end
end
end
local text = args['text'] or link
local pageType = msg( cfg['pagetype-' .. nsNum] or cfg['pagetype-other'] )
local about = args['category'] or args['title']
local importanceText = importance or msg( cfg['importance-unknown'] )
local projPage = msg( cfg['project-talk-page'], args['talk'] or lang:ucfirst( about or '' ) )
textCell:wikitext( msg(cfg['importance-text'], link, text, pageType, importanceText, projPage ) )
local cats = {}
if mw.site.contentNamespaces[nsNum] and about then
if quality then
table.insert( cats, msg(cfg['category-quality-' .. quality] or cfg['category-quality'], quality, about) )
else
table.insert( cats, msg(cfg['category-quality-unknown'], about) )
end
end
if importance then
table.insert( cats, msg(cfg['category-importance'], importance, about) )
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) )
end
end
return tostring( row ) .. ( #cats ~= 0 and ( '[[Category:' .. table.concat(cats, ']]\n[[Category:') .. ']]' ) or '' )
end
-- [[Predefinição:Marca de projeto]]
local _getBanners = function ( args )
page = args[cfg['page']] or mw.title.getCurrentTitle().subjectPageTitle.prefixedText
local qualityByUser = args[1] or args[cfg['quality']]
local qualityByModule = getClassForPage( page )
local reason = args[cfg['reason']] or msg(cfg['no-reason'])
local lang = mw.language.getContentLanguage()
-- Convert to numbers
qualityByUser = tonumber( cfg['quality-aliases'][ qualityByUser ] or qualityByUser )
if qualityByUser and cfg['quality-min'] <= qualityByUser and qualityByUser <= cfg['quality-max'] then
qualityByUser = { qualityByUser, reason }
end
local quality = qualityByUser or qualityByModule
local proj = {}
local importanceForProj = {}
local pos = 2
while args[pos] do
table.insert( proj, args[pos] )
table.insert( importanceForProj, args[pos+1] or '?' )
pos = pos + 2
end
local dateOfLastestReview = args[cfg['date']]
local root = mw.html.create('')
local bannerTable = root:tag( 'table' )
:addClass( 'plainlinks tmbox tmbox-content' )
:css( 'margin', '4px 10%' )
:css( 'border-collapse', 'collapse' )
:css( 'background', '#f8eaba' )
:css( 'border', '2px solid #f28500' )
:css( 'width', '80%' )
if #proj > 2 then
bannerTable:addClass( 'collapsible collapsed' )
end
local firstRow = bannerTable:tag( 'tr' )
firstRow:tag( 'td' )
:attr( 'colspan', 2 )
:addClass( 'tmbox-text' )
:css( 'border', 'none' )
:css( 'padding', '0.25em 0.9em' )
:css( 'text-align', 'right' )
:css( 'background', 'transparent' )
:wikitext( '[[File:' .. msg(cfg['image-quality'], quality[1]) .. ']]' )
local qualityCell = firstRow:tag( #proj > 0 and 'th' or 'td' )
qualityCell:addClass( 'tmbox-text' )
:css( 'border', 'none' )
:css( 'padding', '0.25em 0.9em' )
:css( 'text-align', 'left' )
:css( 'font-weight', 'normal' )
local nsNum = mw.title.new( page ).namespace
local pageType = msg( cfg['pagetype-' .. nsNum] or cfg['pagetype-other'] )
local pageEvaluation
local pageQuality = msg(cfg['quality-value-' .. quality[1]] or cfg['quality-value'], quality[1], quality[2], pageType )
if quality[1] >= 5 then
pageEvaluation = msg(cfg['page-elected'], pageType, pageQuality )
else
if qualityByUser then
pageEvaluation = msg(cfg['page-evaluated'], pageType, pageQuality )
else
pageEvaluation = msg(cfg['page-evaluated-by-module'], pageType, pageQuality )
end
end
if dateOfLastestReview and mw.ustring.len( dateOfLastestReview ) == 8 then
if #proj > 0 then
local projects
if #proj == 1 then
projects = msg(cfg['projects-singular'])
else
projects = msg(cfg['projects-plural'], #proj)
end
qualityCell:wikitext( msg(
cfg['quality-text-with-date-and-projects'],
pageEvaluation,
lang:formatDate( 'd "de" F "de" Y', dateOfLastestReview ),
projects,
mw.text.listToText( proj )
) )
else
qualityCell:wikitext( msg(cfg['quality-text-with-date'], pageEvaluation ) )
end
else
if #proj > 0 then
local projects
if #proj == 1 then
projects = msg(cfg['projects-singular'])
else
projects = msg(cfg['projects-plural'], #proj)
end
qualityCell:wikitext( msg(
cfg['quality-text-and-projects'],
pageEvaluation,
projects,
mw.text.listToText( proj )
) )
else
qualityCell:wikitext( msg(cfg['quality-text'], pageEvaluation ) )
end
end
local banners = mw.loadData( 'Módulo:Avaliação/Marcas' )
for i = 1, #proj do
--local projBanner = 'Marca de projeto/' .. lang:ucfirst( proj[i] )
local title = lang:lcfirst( proj[i] )
local banner = banners[ title ]
if not banner then
title = lang:ucfirst( proj[i] )
banner = banners[ title ]
end
if type( banner ) == 'string' then
-- Redirect
title = banner
banner = banners[ title ]
end
local params = {
['quality'] = quality[1],
['date'] = dateOfLastestReview or '',
['title'] = title,
['importance'] = importanceForProj[i]
}
if banner then
params['link'] = banner[cfg['link']]
params['text'] = banner[cfg['text']]
params['category'] = banner[cfg['category']]
params['image'] = banner[cfg['image']]
params['size'] = banner[cfg['size']]
params['description'] = banner[cfg['description']]
params['talk'] = banner[cfg['talk']]
-- else
-- FIXME: Informar o usuário que o projeto é desconhecido? Categorizar?
end
bannerTable:wikitext( _getBannerRow( params ) )
end
if #proj > 0 then
bannerTable:tag( 'tr' )
:tag( 'td' )
:attr( 'colspan', 3 )
:css( 'text-align', 'center' )
:css( 'font-size', '90%' )
:wikitext( msg( cfg['project-contact'] ) )
end
local articleTimestamp = tonumber( mw.getCurrentFrame():callParserFunction{
name = 'REVISIONTIMESTAMP',
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
local userTimestamp = tonumber( args[cfg['date']] ) or 0
if qualityByUser then
if userTimestamp then
if articleTimestamp == 0 then
--FIXME: A página não existe?
else
-- FIXME: Outra opção é verificar, como acima, se userTimestamp foi há mais de 6 meses
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'] ) )
if qualityByUser[1] ~= qualityByModule[1] then
table.insert( cats, msg( cfg['category-quality-conflict'], qualityByModule[1] ) )
end
-- else
-- FIXME: O artigo foi editado depois de sua qualidade ter sido analisada (talvez ela já esteja obsoleta)
end
end
-- else
--FIXME: Um usuário estimou a qualidade mas não informou a data. Categorizar? Mostrar Erro?
end
else
table.insert( cats, msg( cfg['category-quality-by-module'] ) )
end
-- else
-- FIXME: A predefinição foi usada em um domínio inadequado. Categorizar? Mostrar Erro?
end
return tostring( root ) .. ( #cats ~= 0 and ( '[[Category:' .. table.concat(cats, ']]\n[[Category:') .. ']]' ) or '' )
end
return {
_getClassForText = getClassForText,
_getClassForPage = getClassForPage,
projeto = function( frame )
local args = getArgs( frame )
return _getBannerRow( args )
end,
marcas = function( frame )
local args = getArgs( frame )
return _getBanners( args )
end,
qualidade = function( frame )
local args = getArgs( frame )
local page = args[cfg['page']] or args[1]
local template = args[cfg['format']] or args[2] or msg( cfg['quality-format'] )
if page == nil then
page = mw.title.getCurrentTitle().subjectPageTitle.prefixedText
end
local quality = getClassForPage( page )
local text = mw.ustring.gsub(mw.ustring.gsub(template,'$1', tostring(quality[1])),'$2', quality[2])
return text
end
}