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

使い方 編集

{{#invoke:特定日のニュース|list|2006|12|7}}というように使います。

「list」は今のところ固定です。それ以降は「年」「月」「日」を渡します。年月日はゼロパディングしないでください。(7日の場合は「07」とするのではなく「7」)


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