Modulo:Progetti interessati: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
+controllo presenza monitoraggio
+classi
Riga 27:
end
 
local function project(param, args, subpage)
returnlocal ret = cfg.alias[args[param] and args[param]:lower()] or
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
 
-- utilizzata per le icone e per l'etichetta del wikilink del progetto
local function subpage(title)
return mw.title.new('Progetto:' .. title).subpageText
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("&thinsp;'''<tt>%s&thinsp;</tt>'''",
value and value:upper() or '<small>nc</small>')
spanNode
:css(spanStyle)
:wikitext(value)
return spanNode
end
 
Riga 208 ⟶ 225:
 
-------------------------------------------------------------------------------
-- classe Creazione HTMLProjectsTable
-------------------------------------------------------------------------------
 
local ProjectsTable = {}
local function getIconProject(name)
local icon = mw.getCurrentFrame():expandTemplate {
title = 'Icona argomento',
args = { name }
}
icon = icon == '' and 'Crystal Clear app ksirtet.png' or icon
 
function ProjectsTable:new(args)
return string.format('[[File:%s|25x40px]]', icon)
local self = {}
setmetatable(self, { __index = ProjectsTable })
self.args = args
return self
end
 
local function getWlinkProjectProjectsTable:getHTML(param, args)
local tableStyle = {
local fmt = '<small>([[Discussioni progetto:%s|leggi discussioni]]' ..
margin = '5px 10% 0 10%',
' <b>·</b> [%s nuova discussione]' ..
width = '80%',
' <b>·</b> [[Progetto:%s/Monitoraggio voci|monitoraggio]])</small>'
border = '1px solid #a7d7f9',
return string.format(fmt,
['background-color'] = '#EAF7ED',
project(param, args),
}
mw.title.new('Discussioni progetto:' ..
local tableNode = mw.html.create('table'):css(tableStyle)
project(param, args)):fullUrl( { action = 'edit', section = 'new' } ),
project(param, args))
--importanceFromProject(param, args))
end
 
local function getNodeProjects(args)
local tableNode = mw.html.create('table')
 
-- 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('border-collapse', 'collapse')
:csstag('width', '100%td')
: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(subpage(project(param, self.args), true)))
:done()
:tag('td')
:css('width', '1px')
:css('white-space', 'nowrap')
:wikitext(string.format("'''[[Progetto:%s|%s]]'''", project(param, self.args), subpage(project(param, self.args), true)))
:done()
:tag('td')
:wikitext('<div class="plainlinks" style="padding-left: 5px">' .. self:getWlinkProject(param, args) .. '</div>')
:done()
end
Riga 265 ⟶ 302:
end
 
local function getWlinkLivelloProjectsTable:getIconProject(livelloname)
local icon = mw.getCurrentFrame():expandTemplate {
local spanStyle = {
['font-weight']title = 'boldIcona argomento',
args = { name }
['font-size'] = '125%',
['border'] = '1px solid lightsteelblue',
['background'] = (livello and cfg.livello[livello].color) and cfg.livello[livello].color or 'white',
['color'] = 'blue'
}
icon = icon == '' and 'Crystal Clear app ksirtet.png' or icon
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>&nbsp;%s&nbsp;</tt>'''", text)
else
text = '[[File:Symbol stub class.svg|25px|center]]'
end
spanNode:wikitext(text)
 
return string.format('[[File:%s|25x40px]]', icon)
return spanNode
end
 
local function getTextDataProjectsTable:getWlinkProject(argsparam)
local fmt = '<small>([[Discussioni progetto:%s|leggi discussioni]]' ..
local ret
' <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
 
-------------------------------------------------------------------------------
if args.data then
-- classe AssessmentTable
local cat = string.format('Categoria:Voci monitorate - %s', args.data)
-------------------------------------------------------------------------------
if titleExists(cat) then
 
ret = '<small>(' .. args.data .. ')</small>'
local AssessmentTable = {}
end
 
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)
return ret or "(<span style=\"color:red;\"><small>'''''mese e anno'''''</small></span>)"
end
 
local function AssessmentTable:getNodeLivello(livello, args)
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(livello))
:done()
:tag('td')
:wikitext(self.livello and cfg.livello[self.livello].msg .. ' ' .. self:getTextData(args) or
"<div class=\"plainlinks\">La voce non è stata ancora monitorata, [" .. url .. " fallo ora]!</div>")
:done()
Riga 326 ⟶ 401:
end
 
local function getSpanGradeAssessmentTable:getWlinkLivello(value)
local spanStyle = {
['font-weight'] = 'bold',
['font-size'] = '155125%',
['border'] = '1px solid lightsteelblue',
background = (self.livello and cfg.colorslivello[valueself.livello].color) and cfg.livello[self.livello].color or 'white',
color = 'blue'
}
local spanNode = mw.html.create('span')
local text
value = string.format("&thinsp;'''<tt>%s&thinsp;</tt>'''",
if self.livello and cfg.livello[self.livello].label then
value and value:upper() or '<small>nc</small>')
text = string.format('[[:Categoria:Voci monitorate - %s|%s]]',
spanNode
cfg.livello[self.livello].cat, cfg.livello[self.livello].label)
:css(spanStyle)
elseif not self.livello then
:wikitext(value)
text = '[[:Categoria:Voci monitorate - non compilate|NC]]'
end
if text then
spanNode:css(spanStyle)
text = string.format("'''<tt>&nbsp;%s&nbsp;</tt>'''", text)
else
text = '[[File:Symbol stub class.svg|25px|center]]'
end
spanNode:wikitext(text)
 
return spanNode
end
 
function AssessmentTable:getTextData()
local function getNodeGrade(param, args)
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
 
local function getHTML(livello, args)
local tableStyle = {
margin = '5px 10%',
width = '80%',
border = '1px solid #a7d7f9',
['background-color'] = '#EAF7ED'
}
local tableNode1 = mw.html.create('table')
tableNode1
:css(tableStyle)
:css('margin-bottom', '0px')
 
-- intestazione
local projects = {}
for _, param in ipairs(projParams) do
if args[param] then
table.insert(projects, 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]]:")
tableNode1
:tag('tr')
:tag('td')
:css('padding-left', '.3em')
:wikitext(text)
:done()
:tag('tr')
:tag('td')
:node(getNodeProjects(args))
:done()
 
local tableNode2 = mw.html.create('table')
tableNode2
:addClass('mw-collapsible mw-collapsed')
:css(tableStyle)
:css('border-top', '0px')
:css('margin-top', '0px')
 
-- livello
tableNode2
:node(getNodeLivello(livello, args))
-- valutazioni
tableNode2
: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(getNodeGrade('accuratezza', args))
:node(getNodeGrade('scrittura', args))
:node(getNodeGrade('fonti', args))
:node(getNodeGrade('immagini', args))
-- note
if args.note then
tableNode2
:tag('tr')
:tag('td')
:attr('colspan', '3')
:wikitext(string.format("<ul><li>''note:'' %s</li></ul>", args.note))
end
 
return tostring(tableNode1) .. tostring(tableNode2)
end
 
Riga 467 ⟶ 497:
local categories = mw.title.getCurrentTitle().namespace == 1 and
(table.concat(getCategories(livello, args)) .. errorCat) or ''
return getHTMLProjectsTable:new(livello, args):getHTML() .. categories
AssessmentTable:new(livello, args):getHTML() ..
categories
end