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

Conteúdo apagado Conteúdo adicionado
m Pequenos ajustes na formatação do código.
Uso do Módulo:HtmlBuilder para esboçar uma função getBanner para gerar o HTML que hoje é produzido com Parser Functions na Predefinição:Marca de projeto (p/ posteriormente substituir seu conteúdo por "{{#invoke:Classification|getBanner}}")
Linha 243:
 
return getClassForText( pageTitle:getContent() )
end
 
local getBanner = function ( page, quality )
--FIXME: Get the page name from frame.args or frame:getParent().args
page = page
--FIXME: Get the quality provided by the user, or an automatic estimative
local quality = quality or getClassForPage( page )
-- FIXME: Get the list of project names from template parameters
local proj = { 'Matemática', 'Física', 'Ciência' }
-- FIXME: Get the importance for each project from template parameters
local importanceForProj = { 1, 2, 3 }
-- FIXME: Get the date of latest review from template parameters
local dateOfLastestReview = '20140215'
local HtmlBuilder = require( 'Módulo:HtmlBuilder' )
local root = HtmlBuilder.create()
local banner = root.tag( 'table' )
-- FIXME: {{#if: {{{6|}}} |collapsible collapsed}}
.addClass( 'plainlinks tmbox tmbox-content' )
.css( 'margin', '4px 10%' )
.css( 'border-collapse', 'collapse' )
.css( 'background', '#f8eaba' )
.css( 'border', '2px solid #f28500' )
.css( 'width', '80%' )
local firstRow = banner.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( '[[Imagem:Escala-azul-' .. quality[1] .. 'de6.svg]]' )
-- FIXME: {{#if: {{{2|}}} |th|td}}
local qualityCell = firstRow.tag( '{{{2|}}}' 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' )
-- FIXME: Differentiate namespaces, and also good/featured pages
.wikitext( 'Este artigo foi avaliado [[Wikipédia:Avaliação automática|automaticamente]] com ' )
.tag( 'b' )
.attr( 'title', quality[2] )
.wikitext( '[[Wikipédia:Qualidade|qualidade]] ' .. quality[1] )
if #proj < 1 then
qualityCell.wikitext( '.' )
elseif #proj == 1 then
qualityCell.wikitext( ' e faz parte do âmbito de um WikiProjeto: ' .. proj[1] .. '.' )
else
qualityCell.wikitext(
' e faz parte do âmbito de ' .. #proj .. ' WikiProjetos: ' ..
mw.text.listToText( proj ) .. '.'
)
end
for i = 1, #proj do
banner.wikitext(
'{{marca de projeto/' ..
-- FIXME: Convert the first character to lower case
proj[i] ..
-- The template uses this for categorization
'|' .. quality[1] .. '|' .. importanceForProj[i] ..
'|' .. dateOfLastestReview .. '}}'
)
end
if #proj > 0 then
banner.tag( 'tr' )
.tag( 'td' )
.attr( 'colspan', 3 )
.css( 'text-align', 'center' )
.css( 'font-size', '90%' )
.wikitext( 'Se não tiver suas questões respondidas nesta página de discussão procure o(s) wikiprojeto(s) acima.' )
end
--FIXME: Categorize!
local cats = ''
return tostring( root ) .. cats
end
 
Linha 248 ⟶ 323:
_getClassForText = getClassForText,
_getClassForPage = getClassForPage,
_getBanner = getBanner,
qualidade = function( frame )
local page = frame.args['página'] or frame.args[1]