Modulo:Progetti interessati: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m ordine categorie |
+creazione HTML |
||
Riga 25:
local function project(param, args)
return cfg.alias[args[param]] or mw.language.getContentLanguage():ucfirst(args[param])
end
Riga 44:
args[param] = validGrades[args[param]] and args[param] or nil
end
args.data = args.data and args.data:lower() or nil
return args
Riga 110 ⟶ 111:
-- per la "Situazione monitoraggio per parametro" di [[Progetto:Qualità/Monitoraggio voci/Tabella]]
cat = string.format('[[Categoria:Voci monitorate - %s %s]]',
gradeParam,
table.insert(ret, cat)
Riga 148 ⟶ 149:
end
return ret
end
-------------------------------------------------------------------------------
-- Creazione HTML
-------------------------------------------------------------------------------
local function getIconProject(name)
local icon = mw.getCurrentFrame():expandTemplate {
title = 'Icona argomento',
args = { name }
}
icon = icon == '' and 'Crystal Clear app ksirtet.png' or icon
return string.format('[[File:%s|35x50px]]', icon)
end
local function getWlinkProjects(args)
local ret = ''
for _, param in ipairs(projParams) do
if args[param] then
ret = ret .. string.format("%s[[Progetto:%s/Monitoraggio voci|'''%s%s''']]",
#ret == 0 and '' or ' - ',
project(param, args),
#ret == 0 and 'Monitoraggio ' or '',
project(param, args))
end
end
return ret
end
local function getNodeProjects(args)
local tableStyle = {
['text-align'] = 'center',
['background'] = 'none',
width = '100%'
}
local tableNode = mw.html.create('table')
local trNode = tableNode:css(tableStyle):tag('tr')
for _, param in ipairs(projParams) do
trNode
:tag('td')
:attr('width', '5%')
:wikitext(args[param] and getIconProject(args[param]) or '')
:done()
end
trNode
:tag('td')
:wikitext(getWlinkProjects(args))
:done()
:tag('td')
:attr('width', '10%')
:wikitext('')
:done()
return tableNode
end
local function getWlinkLivello(livello)
local spanStyle = {
['font-weight'] = 'bold',
['font-size'] = '145%',
['border'] = '1px solid lightsteelblue',
['background'] = (livello and cfg.livello[livello].color) and cfg.livello[livello].color or 'white',
['color'] = 'blue'
}
local spanNode = mw.html.create('span')
local text
if livello and cfg.livello[livello].label then
text = string.format('[[:Categoria:Voci monitorate - %s|%s]]',
cfg.livello[livello].cat, cfg.livello[livello].label)
elseif not livello then
text = '[[:Categoria:Voci monitorate - non compilate|NC]]'
end
if text then
spanNode:css(spanStyle)
text = string.format("'''<tt> %s </tt>'''", text)
else
text = '[[File:Symbol stub class.svg|25px|center]]'
end
spanNode:wikitext(text)
return spanNode
end
local function getTextData(args)
local ret
if args.data then
local cat = string.format('Categoria:Voci monitorate - %s', args.data)
if titleExists(cat) then
ret = 'Voce monitorata nel mese di ' .. args.data
end
end
return ret or "Voce monitorata nel mese di <span style=\"color:red;\"><small>'''''inserisci mese e anno'''''</small></span>"
end
local function getNodeLivello(livello, args)
local url = mw.title.getCurrentTitle():fullUrl( { action = 'edit' } )
local trNode = mw.html.create('tr')
trNode
:tag('td')
:css({
['background-color'] = 'none',
width = '90px'
})
:node(getWlinkLivello(livello))
:done()
:tag('td')
:css('font-size', '107%')
:wikitext(livello and cfg.livello[livello].msg or
"<div class=\"plainlinks\">La voce non è stata ancora monitorata, [" .. url .. " fallo ora]!</div>")
:done()
:tag('td')
:css({
color = 'grey',
['text-align'] = 'right',
['padding-right'] = '6px',
['font-size'] = '95%'
})
:wikitext(getTextData(args))
:done()
return trNode
end
local function getNodeGrade(param, args)
local tableStyle = {
['margin-top'] = '2px',
['border-bottom'] = param ~= 'immagini' and '1px solid #B5D9D3' or nil,
['width'] = '100%'
}
local spanStyle = {
['font-weight'] = 'bold',
['font-size'] = '155%',
['border'] = '1px solid lightsteelblue',
background = cfg.colors[args[param]] or 'white'
}
local tableNode = mw.html.create('table')
local descr = cfg[param][args[param] or 'nc'] .. ' ' .. cfg[param].help
local grade = args[param] and args[param]:upper() or '<small>nc</small>'
grade = " '''<tt>" .. grade .. " </tt>'''"
tableNode
:css(tableStyle)
:tag('tr')
:tag('td')
:css('width', '40px')
:tag('span')
:css(spanStyle)
:wikitext(grade)
:done()
:done()
:tag('td')
:wikitext(descr)
:done()
return tableNode
end
local function getHTML(livello, args)
local tableStyle = {
border = '1px solid silver',
['margin-bottom'] = '0.2em',
['margin-left'] = 'auto',
['margin-right'] = 'auto',
['background-color'] = '#FFFFFF'
}
local tableNode = mw.html.create('table')
tableNode
:addClass('messagebox')
:addClass('standard-talk')
:css(tableStyle)
:attr('align', 'center')
-- progetti
tableNode
:tag('tr')
:tag('td')
:attr('colspan', '4')
:css({
background = '#B5D9D3',
border = '0px solid #C0C090'
})
:node(getNodeProjects(args))
-- livello
tableNode
:node(getNodeLivello(livello, args))
-- valutazioni
tableNode
:tag('tr')
:tag('td')
:attr('colspan', '3')
:css({
border = '1px solid #B5D9D3',
['background-color'] = 'none',
['font-size'] = '95%'
})
:node(getNodeGrade('accuratezza', args))
:node(getNodeGrade('scrittura', args))
:node(getNodeGrade('fonti', args))
:node(getNodeGrade('immagini', args))
:done()
-- note
if args.note then
tableNode
:tag('tr')
:tag('td')
:wikitext("* ''note:'' " .. args.note)
:done()
end
return tostring(tableNode)
end
Riga 168 ⟶ 380:
local args = parseArgs(getArgs(frame))
local livello = getLivello(args)
return args.debug and ( table.concat(categories, '<br />'):gsub('%[%[', '[[:') ) .. '<br />' or
table.concat(categories)
end
-- Entry-point per {{#invoke:monitoraggio|main}}
function p.main(frame)
local args = parseArgs(getArgs(frame, {parentOnly = true}))
local livello = getLivello(args)
return getHTML(livello, args) .. table.concat(getCategories(livello, args))
end
|