此处为全站公告,通常对读者进行申明或对该WIKI某些规则进行公告,请在确认后修改本通告。
本WIKI编辑权限开放,欢迎收藏起来防止迷路,也希望有爱的小伙伴和我们一起编辑哟~
编辑全站公告 • 编辑帮助:目录 • BWIKI反馈留言板
全站通知:
模块:Activity
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:Activity/doc创建
local p = {}
function p.main(frame)
local title = mw.title.new('Mediawiki:Activity.json')
local content = title and title:getContent() or nil
local data = mw.text.jsonDecode(content)
local progress = data.progress
if not progress or type(progress) ~= 'table' then
return ''
end
local items = {}
local function iso_date_to_ts(iso)
if not iso then return nil end
local y,m,d,h,min,s = iso:match('^(%d+)%-(%d+)%-(%d+)T(%d+):(%d+):(%d+)')
if not y then
return nil
end
return os.time{year=tonumber(y), month=tonumber(m), day=tonumber(d), hour=tonumber(h), min=tonumber(min), sec=tonumber(s)}
end
local function iso_date_to_ymd(iso)
if not iso then return '' end
local y,m,d = iso:match('^(%d+)%-(%d+)%-(%d+)T')
if not y then return '' end
return string.format('%04d/%02d/%02d', tonumber(y), tonumber(m), tonumber(d))
end
local now = os.time()
local today_tbl = os.date('*t', now)
local today_ts = os.time{year=today_tbl.year, month=today_tbl.month, day=today_tbl.day, hour=0, min=0, sec=0}
for key, act in pairs(progress) do
if act and type(act) == 'table' and act.TabBgRes and act.StartTime then
local tab = tostring(act.TabBgRes)
local last = tab:match('.*/([^/]+)$') or tab
local start_iso = tostring(act.StartTime)
local start_y, start_m, start_d = start_iso:match('^(%d+)%-(%d+)%-(%d+)T')
if start_y then
local start_midnight = os.time{year=tonumber(start_y), month=tonumber(start_m), day=tonumber(start_d), hour=0, min=0, sec=0}
if start_midnight <= today_ts then
local end_iso = act.EndTime and tostring(act.EndTime) or ''
local end_short = end_iso:match('^(%d+%-%d+%-%d+T%d+:%d+:%d+)') or end_iso
local filename = '首页_活动_' .. last .. '.png'
local start_fmt = iso_date_to_ymd(start_iso)
if end_short and end_short ~= '' then
local end_ts = iso_date_to_ts(end_short)
if end_ts and end_ts < now then
else
local item = '<div class="activity-item">[[文件:' ..last.. '.png|link=]]\n'
.. '<div class="activity-time" data-end-time="' .. mw.text.nowiki(end_short) .. '">计算中...</div>\n'
.. '<div class="activity-date">' .. mw.text.nowiki(start_fmt) .. '</div>\n'
table.insert(items, item .. '</div>')
end
else
local item = '<div class="activity-item">[[文件:' ..last.. '.png|link=]]\n'
.. '<div class="activity-time" data-end-time="' .. mw.text.nowiki(end_short) .. '">计算中...</div>\n'
.. '<div class="activity-date">' .. mw.text.nowiki(start_fmt) .. '</div>\n'
table.insert(items, item .. '</div>')
end
end
end
end
end
if #items == 0 then
return ''
end
return table.concat(items, '\n')
end
return p

沪公网安备 31011002002714 号