Module:Catwithfiles

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Lua
CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules

Documentation for this module may be created at Module:Catwithfiles/doc

Code

local function get(frame)
	local args = frame.args
	local which = mw.site.stats.pagesInCategory( args[1], "*" )
	local r
	--[=[
	table#1 {
	  ["all"] = 289,
	  ["files"] = 231,
	  ["pages"] = 4,
	  ["subcats"] = 54
	}
	]=]

	if which.all == 0 then
		r = args[2].."0!"
	elseif which.files == 0 then
		r = " –"
	elseif which.files == tonumber(args[3]) then
		r = args[2].."("..args[3]..")"
	else
		r =  "<b>"..args[2]..args[3].." ".. which.files .."</b>"
	end
	return "[[:Category:"..args[1].."|"..r.."]]"
end

return { get = get }