Jump to content

Module:WPX cards

From Wikipedia, the free encyclopedia
local p = {}
function p.main(frame) 
	local title = frame.args.title .. "/Report"
	local all = require("Module:Yesno")(frame.args.all)
	return p._main(title, all)
end
function p._main(title, all)
	local mode = "";
	if not all then
		mode = "compact"
	end
	local content = mw.title.new(title):getContent()
	local cards = {}
	for _, line in pairs(mw.text.split(content, "\n")) do
		local success, title = pcall(mw.title.new, line, "User")
		if success and title and title.exists then
			cards[#cards + 1] = mw.getCurrentFrame():expandTemplate{title=title.fullText, args={mode=mode}}
		end
	end
	if all then
		return require("Module:List").makeList("unbulleted", cards)
	else
		cards.limit = 3
		return require("Module:Random").main("list", cards)
	end
end
return p