Módulo:Atualizações
Documentação do módulo
Esta documentação é transcluída de Predefinição:Sem documentação/doc. [editar] [atualizar]
Este módulo não possui nenhuma documentação. Por favor, considere adicionar uma documentação em Módulo:Atualizações/doc. [editar]
Módulo:Atualizações requer Módulo:Enum.
Módulo:Atualizações requer Módulo:LanguageUtil.
local contains = require('Módulo:Enum').contains
local engdate = require('Módulo:LanguageUtil').engdate
local p = {}
local lang = mw.getContentLanguage()
local looporder = {
{ 'Dezembro', 31 },
{ 'Novembro', 30 },
{ 'Outubro', 31 },
{ 'Setembro', 30 },
{ 'Agosto', 31 },
{ 'Julho', 31 },
{ 'Junho', 30},
{ 'Maio', 31 },
{ 'Abril', 30 },
{ 'Março', 31 },
{ 'Fevereiro', 29 },
{ 'Janeiro', 31 }
}
function sortFunc(a,b)
return a[2] < b[2]
end
function lookup(cat)
local r = mw.getCurrentFrame():preprocess(string.format([=[
{{#dpl:
|namespace=Notícia
|category=%s
|include={Notícia}:date,{Modificações Recentes}:date,{DevBlog}:date
|format=,¦UD¦%%PAGE%%@[email protected],,
|ordermethod=sortkey
}}
]=], cat))
local ret = { }
local keys = {}
for v in mw.text.gsplit(r, '|UD|', true) do
if v:find('@') then
local u,_d = unpack(mw.text.split(v, '@[email protected]'))
u = mw.text.trim(u)
u = string.sub(u, 10, -1)
_d = engdate(mw.text.trim(_d))
local y,m,d = unpack(mw.text.split(lang:formatDate('Y-F-j', _d), '-', true))
y = tonumber(y)
d = tonumber(d)
if not ret[y] then
ret[y] = {}
end
if not ret[y][m] then
ret[y][m] = {}
end
if not ret[y][m][d] then
ret[y][m][d] = {u}
else
table.insert(ret[y][m][d], u)
end
end
end
return ret
end
function p.year(frame)
return p._year(frame:getParent().args)
end
function p._year(args)
local year = args[1] or mw.title.getCurrentTitle().text
local data = lookup('Notícias de ' .. year)
data = data[tonumber(year)]
local gameUpdQ = mw.smw.ask{ '[[Categoria:Notícias de ' .. year .. ']][[Categoria:Notícias do Jogo]]', '?#-'}
local gameUpdates = {}
for _,v in ipairs(gameUpdQ) do
table.insert(gameUpdates, v[1])
end
local ret = {'\'\'\'Note:\'\'\' Títulos em negrito indicam uma Atualização do jogo.'}
local data_m, data_d
for _,m in ipairs(looporder) do
local month_lower = mw.ustring.lower(m[1])
data_m = data[month_lower]
if data_m then
table.insert(ret, '\n\n=='..m[1]..'==')
for d = m[2], 1, -1 do
data_d = data_m[d]
if data_d then
table.insert(ret, string.format('\n* [[%s de %s]]', tostring(d), month_lower))
table.sort(data_d)
for _,u in ipairs(data_d) do
-- bold game updates
local updBullet = contains(gameUpdates, 'Notícia:' .. u) and string.format('\n** \'\'\'[[Notícia:%s|%s]]\'\'\'', u, u) or string.format('\n** [[Notícia:%s|%s]]', u, u)
table.insert(ret, updBullet)
end
end
end
end
end
return mw.text.trim(table.concat(ret, ''))
end
return p