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

模块:Featured picture list

来自从零开始

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

local randoms = mw.loadData 'Module:Featured picture list/randoms'
local dates = mw.loadData 'Module:Featured picture 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