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

模块:Featured phrase list

来自从零开始
Aladedalu留言 | 贡献2026年1月30日 (五) 14:08的版本 (创建页面,内容为“--- 复制自:Module:Featured picture list local randoms = mw.loadData 'Module:Featured phrase list/randoms' local dates = mw.loadData 'Module:Featured phrase list/dates' local p = {} function p.main(frame) local lang = mw.language.getContentLanguage() local year = lang:formatDate('Y', nil, true) local month = lang:formatDate('n', nil, true) local day = lang:formatDate('j', nil, true) if dates[year] and dates[year][month] and dates[year][month][da…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

此模块的文档可以在模块:Featured phrase list/doc创建

--- 复制自:[[Module:Featured picture list]]
local randoms = mw.loadData 'Module:Featured phrase list/randoms'
local dates = mw.loadData 'Module:Featured phrase list/dates'

local p = {}
function p.main(frame)
	local lang = mw.language.getContentLanguage()
	local year = lang:formatDate('Y', nil, true)
	local month = lang:formatDate('n', nil, true)
	local day = lang:formatDate('j', nil, true)
	
	if dates[year] and dates[year][month] and dates[year][month][day] then
		return frame:preprocess(dates[year][month][day])
	elseif dates['any'] and dates['any'][month] and dates['any'][month][day] then
		return frame:preprocess(dates['any'][month][day])
	end
	
	local edits = mw.site.stats.edits
	local title = randoms[edits % randoms.length + 1]
	return frame:expandTemplate {title = title}
end

function p.list(frame)
	local node = mw.html.create ''
	node:wikitext '共有以下页面可以显示:'
	node:newline()
	
	local ul = node:tag 'ul'
	
	for _, v in ipairs(randoms) do
		ul:tag 'li'
			:wikitext('[[' .. v .. ']]')
	end
	
	local edits = mw.site.stats.edits
	local title = randoms[edits % randoms.length + 1]
	node:wikitext('当前显示的页面名称为:[[' ..title .. ']]')
	
	return node
end

function p.listRandoms(frame)
	local node = mw.html.create ''
	node:wikitext '本站随机展示的文段中共有以下内容:'
	local ol = mw.html.create 'ol'
	for _, v in ipairs(randoms) do
		local li = ol:tag 'li'
		li:wikitext(string.format('[[%s]]([[Special:EditPage/%s|编辑]])', v, v))
		li:newline()
		
		local successes, result = pcall(frame.expandTemplate, frame, {title = v})
		li:wikitext(result)
	end
	return ol
end

return p