Modulo:Progetti interessati: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m fix break |
aggiunta possibilità di utilizzare il template con progetti senza il monitoraggio e miglioramento grafico |
||
Riga 52:
mw.language.getContentLanguage():ucfirst(args[param])
if titleExists('Progetto:' .. name) then
table.insert(projects, {
name = name,
subpage = mw.title.new('Progetto:' .. name).subpageText,
monitoraggio = titleExists(string.format('Progetto:%s/Monitoraggio voci', name))
})
else
table.insert(errcat, '[[Categoria:Pagine con template Monitoraggio con progetto non esistente]]')
Riga 70 ⟶ 67:
end
return args, projects,
end
Riga 82 ⟶ 79:
background = cfg.colors[value] or 'white'
}
:css(codeStyle)
:wikitext(value and value:upper() or '<small>nc</small>')
end
local function hasMonitoraggio(projects)
local ret = false
for _, project in ipairs(projects) do
if project.monitoraggio then
ret = true
break
end
end
return ret
end
Riga 142 ⟶ 148:
for _, project in ipairs(projects) do
if project.monitoraggio then
cat = string.format('[[Categoria:Voci monitorate Progetto %s]]', project.name)
table.insert(ret, cat)
end
end
Riga 154 ⟶ 162:
-- categorie per il [[template:Tabella monitoraggio]]
for _, project in ipairs(projects) do
if project.monitoraggio then
cat = string.format('Categoria:Progetto:%s/Tabella monitoraggio automatico - %s %s', project.name, gradeParam, args[gradeParam] or 'nc')
if titleExists(cat) then
table.insert(ret, '[[' .. cat .. ']]')
end
end
end
Riga 164 ⟶ 174:
-- categorie per il [[template:Tabella monitoraggio]]
for _, project in ipairs(projects) do
if project.monitoraggio then
cat = string.format('Categoria:Voci monitorate Progetto %s - %s',
project.name, suffix)
if titleExists(cat) then
table.insert(ret, '[[' .. cat .. ']]')
end
end
end
Riga 186 ⟶ 198:
end
-- classe ProjectsTable
-------------------------------------------------------------------------------
Riga 201 ⟶ 213:
function ProjectsTable:getHTML()
local tableStyle = {
margin = '5px
width = '80%',
border = '1px solid #a7d7f9',
['background-color'] =
}
local text = (#self.projects > 1 and cfg.progetti.text2 or cfg.progetti.text) ..
(hasMonitoraggio(self.projects) and
(#self.projects > 1 and cfg.progetti.text4 or cfg.progetti.text3) or '') .. '</p>'
local tableNode = mw.html.create('table'):css(tableStyle)
tableNode
:tag('tr')
:tag('td')
:css('padding-left', '.3em')
:css('padding-right', '1em')
:wikitext(cfg.progetti.icon)
:done()
:tag('td')
:wikitext(mw.getCurrentFrame():preprocess(text))
:done()
:tag('tr')
:tag('td')
:attr('colspan', '2')
:node(self:getNodeProjects())
:done()
Riga 267 ⟶ 283:
function ProjectsTable:getWlinkProject(project)
local links = {}
local fmtIcon = '[[File:Rpb dialog icon.svg|23x15px|bar di progetto|link=Discussioni progetto:%s]]'
local fmtIcon2 = '[[File:VisualEditor - Icon - Search-big.svg|20x20px|monitoraggio delle voci|link=Progetto:%s/Monitoraggio voci]]'
table.insert(links, string.format(
table.insert(links, string.format('[[Discussioni progetto:%s|bar
-- link monitoraggio opzionale
if project.monitoraggio then
table.insert(links, string.format(fmtIcon2, project.name))
table.insert(links, string.format('[[Progetto:%s/Monitoraggio voci|monitoraggio delle voci]]', project.name))
end
return
end
-------------------------------------------------------------------------------
-- classe PreMonitoraggioTable
-------------------------------------------------------------------------------
local PreMonitoraggioTable = {}
function PreMonitoraggioTable:new()
local self = {}
setmetatable(self, { __index = PreMonitoraggioTable })
return self
end
function PreMonitoraggioTable:getHTML()
local tableStyle = {
margin = '5px 10% 0 10%',
width = '80%',
border = '1px solid #a7d7f9',
['background-color'] = cfg.bgcolor,
}
local tableNode = mw.html.create('table'):css(tableStyle)
tableNode
:tag('tr')
:tag('td')
:css('padding-left', '.3em')
:css('padding-right', '1em')
:wikitext(cfg.monitoraggio.icon)
:done()
:tag('td')
:wikitext(cfg.monitoraggio.text)
:done()
return tostring(tableNode)
end
Riga 295 ⟶ 350:
width = '80%',
border = '1px solid #a7d7f9',
['background-color'] =
['border-top'] = '0',
}
Riga 334 ⟶ 389:
function MonitoraggioTable:getNodeLivello()
local url = mw.title.getCurrentTitle():fullUrl( { action = 'edit' } )
:tag('td')
:css('background-color', 'none')
Riga 343 ⟶ 397:
:tag('td')
:wikitext(self.livello and cfg.livello[self.livello].msg .. ' ' .. self:getTextData() or
:done()
:tag('td')
Riga 349 ⟶ 403:
:wikitext('')
:done()
end
function MonitoraggioTable:getWlinkLivello()
local
['font-weight'] = 'bold',
['font-size'] = '125%',
['padding-left'] = '.4em',
['padding-right'] = '.4em',
border = '1px solid lightsteelblue',
background = (self.livello and cfg.livello[self.livello].color) and cfg.livello[self.livello].color or 'white',
color = 'blue'
}
local
local text
if self.livello and cfg.livello[self.livello].label then
Riga 370 ⟶ 424:
end
if text then
else
text = '[[File:Symbol stub class.svg|25px|center]]'
end
return
end
function MonitoraggioTable:getTextData()
local ret
if self.args.data then
local cat = string.format('Categoria:Voci monitorate - %s', self.args.data)
if titleExists(cat) then
ret = string.format('<small>(%s)</small>'
end
end
return ret or "(<span style=\"color:red;\"><small>'''''mese e anno'''''</small></span>)"
end
function MonitoraggioTable:getNodeGrade(param)
:css('background-color', 'white')
:css('border', 'thin solid #D8D8D8')
Riga 405 ⟶ 454:
:done()
:tag('td')
:wikitext(cfg[param][self.args[param] or 'nc'] .. ' ' .. cfg[param].help)
:done()
end
Riga 445 ⟶ 492:
-- Entry-point per il template {{Monitoraggio}}
function p.main(frame)
local args, projects,
if hasMonitoraggio(projects) then
local categories = mw.title.getCurrentTitle().namespace == 1 and (table.concat(getCategories(livello, args, projects)) ..
MonitoraggioTable:new(livello, args):getHTML() ..
categories
else
return ProjectsTable:new(projects):getHTML() ..
table.concat(errcat)
end
end
|