打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

Module:SubpageTable:修订间差异

来自OTTOWiki
琪露若
琪露若留言 | 贡献 (debug)
琪露若
琪露若留言 | 贡献 (debug)
第1行: 第1行:
local p = {}
local p = {}


function p.showSubpages(frame)
function p.table(frame)
    local currentTitle = mw.title.getCurrentTitle()
     local args = frame.args
     local args = frame.args
    local currentTitle = mw.title.getCurrentTitle()
      
      
     -- 参数处理
     -- 构建表格
     local namespace = args.namespace or currentTitle.namespace
     local tableHtml = '{| class="wikitable sortable"\n! 页面名称\n! 最后修改\n! 大小\n'
    local limit = tonumber(args.limit) or 100
    local class = args.class or 'wikitable sortable'
    local showCount = args.showcount or 'yes'
      
      
     -- 获取子页面
     for page in mw.site.allPages({
    local subpages = {}
    local allPages = mw.site.allPages({
         prefix = currentTitle.prefixedText .. '/',
         prefix = currentTitle.prefixedText .. '/',
        namespace = namespace,
         limit = 100
         limit = limit
     }) do
     })
   
    -- 构建表格
    local tableHtml =
        '{| class="' .. class .. '"\n' ..
        '! 页面名称\n' ..
        '! 最后修改\n' ..
        '! 大小\n' ..
        '! 编辑者\n'
   
    for page in allPages do
         local pageTitle = mw.title.new(page)
         local pageTitle = mw.title.new(page)
         if pageTitle then
         if pageTitle then
            local revision = pageTitle.getCurrentRevision and pageTitle:getCurrentRevision()
             tableHtml = tableHtml .. '|-\n'
            local timestamp = revision and revision.timestamp or '未知'
            tableHtml = tableHtml .. '| [[' .. pageTitle.prefixedText .. ']]\n'
            local user = revision and revision.user or '未知'
            tableHtml = tableHtml .. '| ' .. (pageTitle.getCurrentRevision and pageTitle:getCurrentRevision().timestamp or '未知') .. '\n'
           
            tableHtml = tableHtml .. '| ' .. pageTitle.length .. ' 字节\n'
             tableHtml = tableHtml ..
                '|-\n' ..
                '| [[' .. pageTitle.prefixedText .. ']]\n' ..
                '| ' .. timestamp .. '\n' ..
                '| ' .. pageTitle.length .. ' 字节\n' ..
                '| ' .. user .. '\n'
        end
    end
   
    tableHtml = tableHtml .. '|}'
   
    -- 添加计数信息
    if showCount == 'yes' then
        local count = 0
        for _ in mw.site.allPages({prefix = currentTitle.prefixedText .. '/', namespace = namespace}) do
            count = count + 1
         end
         end
       
        tableHtml = tableHtml ..
            '<div class="subpage-count" style="font-size:90%; color:#666; margin-top:5px;">' ..
            '注:共 ' .. count .. ' 个子页面(显示最近 ' .. limit .. ' 个)' ..
            '</div>'
     end
     end
      
      
     return tableHtml
     return tableHtml .. '|}'
end
end


return p
return p

2025年10月3日 (五) 01:20的版本

local p = {}

function p.table(frame)
    local currentTitle = mw.title.getCurrentTitle()
    local args = frame.args
    
    -- 构建表格
    local tableHtml = '{| class="wikitable sortable"\n! 页面名称\n! 最后修改\n! 大小\n'
    
    for page in mw.site.allPages({
        prefix = currentTitle.prefixedText .. '/',
        limit = 100
    }) do
        local pageTitle = mw.title.new(page)
        if pageTitle then
            tableHtml = tableHtml .. '|-\n'
            tableHtml = tableHtml .. '| [[' .. pageTitle.prefixedText .. ']]\n'
            tableHtml = tableHtml .. '| ' .. (pageTitle.getCurrentRevision and pageTitle:getCurrentRevision().timestamp or '未知') .. '\n'
            tableHtml = tableHtml .. '| ' .. pageTitle.length .. ' 字节\n'
        end
    end
    
    return tableHtml .. '|}'
end

return p