Modulo:Bozza: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
mostra richieste precedenti
+
Riga 18:
new_text = replace(new_text, old_tmp, tmp)
 
if tmp:matchfind('^%{ *[Rr]ichiesta *revisione *bozza *[%|%}]') then
local requestsubmission = string.format('{%s}', tmp)
new_text = replace(new_text, requestsubmission, '')
tmp = tmp:gsub('%{%b{}%}', '{{')
 
iflocal ts = tmp:match('%| *esitots *= *[^(%sd%d%d%d%d%d%d%d%d%d%d%d%d%d) *[%|%}]') then
local key = tmp:find('%| *esito *= *[^%s%|%}]') and 'old' or 'current'
table.insert(stored_submissions.old, request)
 
if type(stored_submissions[key][ts]) == 'table' then
table.insert(stored_submissions.old[key][ts], requestsubmission)
else
table.insert(stored_submissions.current,[key][ts] request)= { submission }
end
end
Line 32 ⟶ 35:
 
return stored_submissions, new_text
end
 
local function pairsByTimestamp(t)
local a = {}
local i = 0
local function comp(ts1, ts2)
return ts1 > ts2
end
 
for ts in pairs(t) do
table.insert(a, ts)
end
 
table.sort(a, comp)
 
return function ()
i = i + 1
if not a[i] then
return
else
return a[i], t[a[i]]
end
end
end
 
Line 57 ⟶ 83:
 
if state ~= 'S' then
if #next(submissions.current > 0) then
state = 'R'
elseif #next(submissions.old > 0) and state ~= 'A' then
state = 'N'
end
Line 66 ⟶ 92:
local history_table
 
if #next(submissions.old > 0) then
local styles = frame:extensionTag{
history_table = mw.html.create('table')
name = 'templatestyles',
:cssText('border-collapse: collapse; font-size: 95%; width: 100%')
args = { src = 'Modulo:Bozza/styles.css' }
:tag('tr')
}
:tag('th')
 
:cssText('padding-right: 2em; text-align: right')
history_table = mw.html.create('tablediv')
:wikitext('Richieste precedenti')
:addClass('bozza-history')
:done()
:tag('trdiv')
:wikitext('RichiesteData precedentirichiesta')
:done()
:tag('thdiv')
:wikitext('Esito revisione')
:done()
 
for _ts, submissiona in ipairspairsByTimestamp(submissions.old) do
local success, jFY = pcall(lang.formatDate, lang, 'j F Y', ts)
submission = submission:gsub('%}%}$', '|mostra esito=x}}')
 
history_table
if success then
:tag('tr')
for _, submission in ipairs(a) do
:cssText('border-top: thin solid #D8D8D8')
submission = submission:gsub('%}%}$', '|mostra esito=x}}')
:wikitext(frame:preprocess(submission))
history_table
:tag('trdiv')
:wikitext(jFY)
:done()
:tag('div')
:wikitext(frame:preprocess(submission))
:done()
end
end
end
 
history_table = styles .. tostring(history_table)
end