モジュール:特定日のニュース/sandbox

出典:『ウィキニュース』(ベータ版)

このモジュールについての説明文ページを モジュール:特定日のニュース/sandbox/doc に作成できます

news = {};

news.list = function(frame)
	local args = frame.args
	local y = args[1]
	local m = args[2]
	local d = args[3]
	
	local cat = string.format('%d年%d月%d日',y,m,d)
	local prj = string.format('ウィキニュース:%d年/%d月/%d日',y,m,d)
	
	local pages = mw.site.stats.pagesInCategory(cat,'pages')
	
	local wikitext = nil
	if pages > 2 then
		if mw.title.new(prj).exists then
			wikitext = frame:preprocess(string.format('{{%s}}', prj))
		end
	end
	
	if not wikitext then
		wikitext = frame:preprocess('{{No-day}}')
	end
	
	return wikitext
end

return news