Module:SubpageTable:修订间差异
来自OTTOWiki
更多操作
| 第1行: | 第1行: | ||
local p = {} | local p = {} | ||
function p. | function p.table(frame) | ||
local currentTitle = mw.title.getCurrentTitle() | |||
local args = frame.args | local args = frame.args | ||
-- 参数处理 | -- 参数处理 | ||
local limit = args.limit or '50' | |||
local class = args.class or 'wikitable sortable' | |||
local namespace = args.namespace or currentTitle.namespace | local namespace = args.namespace or currentTitle.namespace | ||
-- | -- 使用 DPL 查询子页面 | ||
local dplQuery = { | local dplQuery = { | ||
'namespace = ' .. namespace, | 'namespace = ' .. namespace, | ||
'titlematch = ' .. currentTitle.prefixedText .. '/%', | 'titlematch = ' .. currentTitle.prefixedText .. '/%', | ||
'mode = userformat', | 'mode = userformat', | ||
'listseparators = {| class="' .. class .. '" | 'listseparators = {| class="' .. class .. '"\n! 页面名称\n! 最后修改\n! 大小\n|-,\n| [[%PAGE%]]\n| %DATE%\n| %SIZE% 字节,\n|-,\n|}', | ||
'ordermethod = ' | 'ordermethod = title', | ||
'order = ' | 'order = ascending', | ||
'count = ' .. limit, | 'count = ' .. limit, | ||
'suppresserrors = true' | 'suppresserrors = true' | ||
} | } | ||
local | -- 构建 DPL 标签 | ||
local dplTag = '<dpl>\n' .. table.concat(dplQuery, '\n|') .. '\n</dpl>' | |||
return | -- 执行 DPL | ||
return frame:preprocess(dplTag) | |||
end | end | ||
return p | return p | ||
2025年10月3日 (五) 01:25的版本
local p = {}
function p.table(frame)
local currentTitle = mw.title.getCurrentTitle()
local args = frame.args
-- 参数处理
local limit = args.limit or '50'
local class = args.class or 'wikitable sortable'
local namespace = args.namespace or currentTitle.namespace
-- 使用 DPL 查询子页面
local dplQuery = {
'namespace = ' .. namespace,
'titlematch = ' .. currentTitle.prefixedText .. '/%',
'mode = userformat',
'listseparators = {| class="' .. class .. '"\n! 页面名称\n! 最后修改\n! 大小\n|-,\n| [[%PAGE%]]\n| %DATE%\n| %SIZE% 字节,\n|-,\n|}',
'ordermethod = title',
'order = ascending',
'count = ' .. limit,
'suppresserrors = true'
}
-- 构建 DPL 标签
local dplTag = '<dpl>\n' .. table.concat(dplQuery, '\n|') .. '\n</dpl>'
-- 执行 DPL
return frame:preprocess(dplTag)
end
return p