Module:RC by category

Invoked by {{RC}}.


local p = {}

function p.show(frame)
	local namespace = ""
    local category = ""
	
	if frame ~= nil then
    	if frame.args[1] ~= nil and frame.args[1] ~= "" then
    	    category = mw.text.trim(frame.args[1])
        else
    	    category = mw.title.getCurrentTitle().text
        end
    else
    	category = mw.title.getCurrentTitle().text
    end
        
	local categoryadd = mw.getCurrentFrame():callParserFunction{
		name = "#tag",
		args = {
			"DynamicPageList",
			"category=" .. category .. "\n" ..
			"namespace=" .. namespace .. "\n" ..
			"count=5\n" ..
			"mode=ordered\n" ..
			"ordermethod=categoryadd\n" ..
			"order=descending"
		}
	}
	
	local lastedit = mw.getCurrentFrame():callParserFunction{
		name = "#tag",
		args = {
			"DynamicPageList",
			"category=" .. category .. "\n" ..
			"namespace=" .. namespace .. "\n" ..
			"count=5\n" ..
			"mode=ordered\n" ..
			"ordermethod=lastedit\n" ..
			"order=descending"
		}
	}
	
	return [=[
{| class="wikitable" style="float: right; clear: both; margin: 0 0 .5em 1em;"
! Recent additions
|-
| style="font-size:0.9em;" | ]=] .. categoryadd .. [=[

|-
! Recent edits
|-
| style="font-size:0.9em;" | ]=] .. lastedit .. [=[

|}]=]
end

return p