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

Module:SubpageTable:修订间差异

来自OTTOWiki
琪露若
琪露若留言 | 贡献 (debug)
琪露若
琪露若留言 | 贡献 (debug)
 
(未显示同一用户的4个中间版本)
第1行: 第1行:
local p = {}
local p = {}


function p.showSubpages(frame)
function p.table(frame)
    local args = frame.args
     local currentTitle = mw.title.getCurrentTitle()
     local currentTitle = mw.title.getCurrentTitle()
      
      
     -- 参数处理
     -- 获取子页面的另一种方法
     local namespace = args.namespace or currentTitle.namespace
     local result = frame:preprocess('{{Special:PrefixIndex/' .. currentTitle.prefixedText .. '/|hideredirects=1|stripprefix=1|format=table}}')
    local limit = tonumber(args.limit) or 100
    local class = args.class or 'wikitable sortable'
    local showCount = args.showcount or 'yes'
      
      
     -- 获取子页面
     -- 如果返回空,添加提示
     local subpages = {}
     if result == "" then
    local allPages = mw.site.allPages({
         return "此页面没有子页面。"
        prefix = currentTitle.prefixedText .. '/',
        namespace = namespace,
        limit = limit
    })
   
    -- 构建表格
    local tableHtml =  
        '{| class="' .. class .. '"\n' ..
        '! 页面名称\n' ..
        '! 最后修改\n' ..
        '! 大小\n' ..
        '! 编辑者\n'
   
    for page in allPages do
        local pageTitle = mw.title.new(page)
        if pageTitle then
            local revision = pageTitle.getCurrentRevision and pageTitle:getCurrentRevision()
            local timestamp = revision and revision.timestamp or '未知'
            local user = revision and revision.user or '未知'
           
            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
       
        tableHtml = tableHtml ..
            '<div class="subpage-count" style="font-size:90%; color:#666; margin-top:5px;">' ..
            '注:共 ' .. count .. ' 个子页面(显示最近 ' .. limit .. ' 个)' ..
            '</div>'
     end
     end
      
      
     return tableHtml
     return result
end
end


return p
return p

2025年10月3日 (五) 01:27的最新版本

local p = {}

function p.table(frame)
    local currentTitle = mw.title.getCurrentTitle()
    
    -- 获取子页面的另一种方法
    local result = frame:preprocess('{{Special:PrefixIndex/' .. currentTitle.prefixedText .. '/|hideredirects=1|stripprefix=1|format=table}}')
    
    -- 如果返回空,添加提示
    if result == "" then
        return "此页面没有子页面。"
    end
    
    return result
end

return p