“模块:首页”的版本间的差异

来自iFx Wiki
跳到导航 跳到搜索
第30行: 第30行:
 
     local first = true
 
     local first = true
 
     for i, t in ipairs(pages) do
 
     for i, t in ipairs(pages) do
        ul:wikitext("[[" .. t .. "]]")
 
 
         if first then
 
         if first then
 
             first = false
 
             first = false
第36行: 第35行:
 
             ul:wikitext(",")
 
             ul:wikitext(",")
 
         end
 
         end
 +
        ul:tag("span"):wikitext("[[" .. t .. "]]")
 
     end
 
     end
 
     return ul:done()
 
     return ul:done()

2021年4月2日 (五) 13:50的版本

此模块的文档可以在模块:首页/doc创建

local smw = require("Module:SMWUtils")
local p = {}

function p.latest_list(frame)
    local user_query = frame.args.query
    local query = user_query .. [[ 
        |limit=20
        |offset=0
        |sort=Modification date
        |order=desc
     ]]
    local pages = smw.query_pages(query)
    local ul = mw.html.create("ul")
    for i, t in ipairs(pages) do
        ul:tag("li"):wikitext("[[" .. t .. "]]")
    end
    return ul:done()
end

function p.latest_flat_list(frame)
    local user_query = frame.args.query
    local query = user_query .. [[ 
        |limit=20
        |offset=0
        |sort=Modification date
        |order=desc
     ]]
    local pages = smw.query_pages(query)
    local ul = mw.html.create()
    local first = true
    for i, t in ipairs(pages) do
        if first then
            first = false
        else
            ul:wikitext(",")
        end
        ul:tag("span"):wikitext("[[" .. t .. "]]")
    end
    return ul:done()
end

return p