Modulo:Progetti interessati: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
+controllo presenza monitoraggio |
+classi |
||
Riga 27:
end
local function project(param, args, subpage)
mw.language.getContentLanguage():ucfirst(args[param]) -- subpage: per le icone e per l'etichetta del wikilink del progetto
if ret and subpage then
ret = mw.title.new('Progetto:' .. ret).subpageText
end
return ret
end
local function grade(param, args)
return args[param] or 'nc'
end
Riga 99 ⟶ 100:
return args, table.concat(errcat)
end
local function getSpanGrade(value)
local spanStyle = {
['font-weight'] = 'bold',
['font-size'] = '155%',
['border'] = '1px solid lightsteelblue',
background = cfg.colors[value] or 'white'
}
local spanNode = mw.html.create('span')
value = string.format(" '''<tt>%s </tt>'''",
value and value:upper() or '<small>nc</small>')
spanNode
:css(spanStyle)
:wikitext(value)
return spanNode
end
Riga 208 ⟶ 225:
-------------------------------------------------------------------------------
-- classe
-------------------------------------------------------------------------------
local ProjectsTable = {}
function ProjectsTable:new(args)
local self = {}
setmetatable(self, { __index = ProjectsTable })
self.args = args
return self
end
local tableStyle = {
margin = '5px 10% 0 10%',
width = '80%',
border = '1px solid #a7d7f9',
['background-color'] = '#EAF7ED',
}
local tableNode = mw.html.create('table'):css(tableStyle)
-- intestazione
local projects = {}
for _, param in ipairs(projParams) do
if self.args[param] then
table.insert(projects, self.args[param])
end
end
local text = 'La voce <b>' .. mw.title.getCurrentTitle().text .. '</b> rientra tra gli argomenti trattati' ..
(#projects > 1 and " dai seguenti [[Wikipedia:Progetto|progetti]]:" or
" dal seguente [[Wikipedia:Progetto|progetto]]:")
tableNode
:tag('tr')
:
:css('padding-left', '.3em')
:wikitext(text)
:done()
:tag('tr')
:tag('td')
:node(self:getNodeProjects())
:done()
return tostring(tableNode)
end
function ProjectsTable:getNodeProjects()
local tableStyle = {
width = '100%',
['border-collapse'] = 'collapse'
}
local tableNode = mw.html.create('table'):css(tableStyle)
-- progetti
for _, param in ipairs(projParams) do
if self.args[param] then
tableNode:tag('tr')
:css('background-color', 'white')
Riga 249 ⟶ 286:
:css('width', '28px')
:css('text-align', 'center')
:wikitext(self:getIconProject
:done()
:tag('td')
:css('width', '1px')
:css('white-space', 'nowrap')
:wikitext(string.format("'''[[Progetto:%s|%s]]'''", project(param, self.args),
:done()
:tag('td')
:wikitext('<div class="plainlinks" style="padding-left: 5px">' .. self:getWlinkProject(param
:done()
end
Riga 265 ⟶ 302:
end
local icon = mw.getCurrentFrame():expandTemplate {
args = { name }
}
icon = icon == '' and 'Crystal Clear app ksirtet.png' or icon
return string.format('[[File:%s|25x40px]]', icon)
end
local fmt = '<small>([[Discussioni progetto:%s|leggi discussioni]]' ..
' <b>·</b> [%s nuova discussione]' ..
' <b>·</b> [[Progetto:%s/Monitoraggio voci|monitoraggio]])</small>'
return string.format(fmt,
project(param, self.args),
mw.title.new('Discussioni progetto:' ..
project(param, self.args)):fullUrl( { action = 'edit', section = 'new' } ),
project(param, self.args))
--importanceFromProject(param, self.args))
end
-------------------------------------------------------------------------------
-- classe AssessmentTable
-------------------------------------------------------------------------------
local AssessmentTable = {}
function AssessmentTable:new(livello, args)
local self = {}
setmetatable(self, { __index = AssessmentTable })
self.livello = livello
self.args = args
return self
end
function AssessmentTable:getHTML()
local tableStyle = {
margin = '0 10% 5px 10%',
width = '80%',
border = '1px solid #a7d7f9',
['background-color'] = '#EAF7ED',
['border-top'] = '0',
}
local tableNode = mw.html.create('table')
tableNode
:addClass('mw-collapsible mw-collapsed')
:css(tableStyle)
-- livello
tableNode
:node(self:getNodeLivello())
-- valutazioni
tableNode
:tag('tr')
:tag('td')
:attr('colspan', '3')
:css('background-color', 'none')
:css('font-size', '95%')
:tag('table')
:css('width', '100%')
:css('border-collapse', 'collapse')
:node(self:getNodeGrade('accuratezza'))
:node(self:getNodeGrade('scrittura'))
:node(self:getNodeGrade('fonti'))
:node(self:getNodeGrade('immagini'))
-- note
if self.args.note then
tableNode
:tag('tr')
:tag('td')
:attr('colspan', '3')
:wikitext(string.format("<ul><li>''note:'' %s</li></ul>", self.args.note))
end
return tostring(tableNode)
end
local url = mw.title.getCurrentTitle():fullUrl( { action = 'edit' } )
local trNode = mw.html.create('tr')
Riga 312 ⟶ 387:
:css('background-color', 'none')
:css('width', '90px')
:node(self:getWlinkLivello(
:done()
:tag('td')
:wikitext(self.livello and cfg.livello[self.livello].msg .. ' ' .. self:getTextData(
"<div class=\"plainlinks\">La voce non è stata ancora monitorata, [" .. url .. " fallo ora]!</div>")
:done()
Riga 326 ⟶ 401:
end
local spanStyle = {
['font-weight'] = 'bold',
['font-size'] = '
background = (self.livello and cfg.
color = 'blue'
}
local spanNode = mw.html.create('span')
local text
if self.livello and cfg.livello[self.livello].label then
text = string.format('[[:Categoria:Voci monitorate - %s|%s]]',
cfg.livello[self.livello].cat, cfg.livello[self.livello].label)
elseif not self.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
function AssessmentTable:getTextData()
local ret
if self.args.data then
local cat = string.format('Categoria:Voci monitorate - %s', self.args.data)
if titleExists(cat) then
ret = '<small>(' .. self.args.data .. ')</small>'
end
end
return ret or "(<span style=\"color:red;\"><small>'''''mese e anno'''''</small></span>)"
end
function AssessmentTable:getNodeGrade(param)
local trNode = mw.html.create('tr')
local descr = cfg[param][self.args[param] or 'nc'] .. ' ' .. cfg[param].help
trNode
:css('background-color', 'white')
Riga 351 ⟶ 450:
:css('width', '40px')
:css('padding-left', '5px')
:node(getSpanGrade(self.args[param]))
:done()
:tag('td')
Riga 358 ⟶ 457:
return trNode
end
Riga 467 ⟶ 497:
local categories = mw.title.getCurrentTitle().namespace == 1 and
(table.concat(getCategories(livello, args)) .. errorCat) or ''
return
AssessmentTable:new(livello, args):getHTML() ..
categories
end
|