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

Module:FeaturedArticle:修订间差异

武外梗百科 爱国好学自强图新的百科全书
创建页面,内容为“local p = {} function p.show(frame) local smw = mw.smw if not smw then return "⚠️ Semantic MediaWiki 未启用" end -- 查询所有 IsFeatured::Yes 页面 local q = smw.ask{ query = "IsFeatured::Yes", limit = 0, -- 获取全部 format = "o" -- 返回对象 } if not q or #q == 0 then return "(暂无特色条目)" end -- 随机选择一条 math.randomseed(os.…”
标签已重建
 
无编辑摘要
第1行: 第1行:
local p = {}
local p = {}


-- 显示随机特色条目
function p.show(frame)
function p.show(frame)
     local smw = mw.smw
     local smw = mw.smw
第8行: 第9行:


     -- 查询所有 IsFeatured::Yes 页面
     -- 查询所有 IsFeatured::Yes 页面
     local q = smw.ask{
     local results = smw.ask{
         query = "[[IsFeatured::Yes]]",
         query = "[[IsFeatured::Yes]]",
         limit = 0,      -- 获取全部
         limit = 0,      -- 获取全部
第14行: 第15行:
     }
     }


     if not q or #q == 0 then
     if not results or #results == 0 then
         return "(暂无特色条目)"
         return "(暂无特色条目)"
     end
     end


     -- 随机选择一条
     -- 随机选择一个条目
     math.randomseed(os.time() % 2147483647)
     math.randomseed(os.time() % 2147483647)
     local row = q[math.random(1, #q)]
     local row = results[math.random(1, #results)]
     local title = row.fulltext or row.printouts[1] or "未知页面"
     local title = row.fulltext or "未知页面"


     -- 构造卡片 HTML
     -- 构造 HTML 卡片
     local html = mw.html.create('div'):addClass('fa-box')
     local html = mw.html.create('div'):addClass('fa-box')
     html:tag('div'):addClass('fa-title'):wikitext('⭐ 今日特色条目')
     html:tag('div'):addClass('fa-title'):wikitext('⭐ 今日特色条目')

2025年11月30日 (日) 12:47的版本

此模块的文档可以在Module:FeaturedArticle/doc创建

local p = {}

-- 显示随机特色条目
function p.show(frame)
    local smw = mw.smw
    if not smw then
        return "⚠️ Semantic MediaWiki 未启用"
    end

    -- 查询所有 IsFeatured::Yes 页面
    local results = smw.ask{
        query = "[[IsFeatured::Yes]]",
        limit = 0,       -- 获取全部
        format = "o"     -- 返回对象
    }

    if not results or #results == 0 then
        return "(暂无特色条目)"
    end

    -- 随机选择一个条目
    math.randomseed(os.time() % 2147483647)
    local row = results[math.random(1, #results)]
    local title = row.fulltext or "未知页面"

    -- 构造 HTML 卡片
    local html = mw.html.create('div'):addClass('fa-box')
    html:tag('div'):addClass('fa-title'):wikitext('⭐ 今日特色条目')
    html:tag('div'):addClass('fa-article-title'):wikitext('[['..title..']]')
    html:tag('div'):addClass('fa-link'):wikitext('[['..title..'|阅读全文 →]]')

    return html:allHtml()
end

return p