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 | local results = smw.ask{ | ||
query = "[[IsFeatured::Yes]]", | query = "[[IsFeatured::Yes]]", | ||
limit = 0, -- 获取全部 | limit = 0, -- 获取全部 | ||
| 第14行: | 第15行: | ||
} | } | ||
if not | if not results or #results == 0 then | ||
return "(暂无特色条目)" | return "(暂无特色条目)" | ||
end | end | ||
-- | -- 随机选择一个条目 | ||
math.randomseed(os.time() % 2147483647) | math.randomseed(os.time() % 2147483647) | ||
local row = | local row = results[math.random(1, #results)] | ||
local title = row.fulltext | local title = row.fulltext or "未知页面" | ||
-- | -- 构造 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('⭐ 今日特色条目') | ||