首页
随机
登录
设置
关于NeuroWiki
免责声明
NeuroWiki
搜索
查看“Module:DateTitleList”的源代码
←
Module:DateTitleList
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
local p = {} -- 格式化日期和生成链接 local function formatDate(date, title, year, baseYear) local dateYear = string.sub(date, 1, 4) local monthDay = os.date("%m月%d日", os.time{year=string.sub(date, 1, 4), month=string.sub(date, 5, 6), day=string.sub(date, 7, 8)}) local categoryLink = "[[:Category:" .. monthDay .. "|" .. monthDay .. "]]" local pageLink = "[[直播记录/vedal987频道/" .. dateYear .. "年" .. monthDay .. "|" .. title .. "]]" -- 如果年份不同于baseYear,则显示小号斜体年份 if dateYear ~= baseYear then categoryLink = "[[:Category:" .. monthDay .. "|{{ruby|" .. monthDay .. "|''<small>" .. dateYear .. "年</small>''}}]]" end return "* '''" .. categoryLink .. "''' " .. pageLink end -- 主函数 function p.render(frame) local args = frame:getParent().args local year = args.year or os.date("%Y") -- 默认年份为当前年份 local entries = {} -- 收集date和title的对 for i = 1, 7 do local date = args["date" .. i] local title = args["title" .. i] if date and title then table.insert(entries, {date = date, title = title}) end end -- 按日期排序 table.sort(entries, function(a, b) return a.date < b.date end) -- 生成输出 local output = {} for _, entry in ipairs(entries) do table.insert(output, formatDate(entry.date, entry.title, year, year)) end return table.concat(output, "\n") end return p
该页面使用的模板:
Module:DateTitleList/doc
(
查看源代码
)
返回
Module:DateTitleList
。