Edge Rewrite
// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a27bb9da1a405751

Jump to content

Module:Page assessment raw

From Wikipedia, the free encyclopedia

-- Package to export
local p = {}

-- Namespace for utility functions
local util = {}

--[[
Entry point for invoking the module.

@param {string} frame.args.page subject page name
@param {string} frame.args.project WikiProject with class assessment
@return {string} The class rating as text, or empty string if none found
]]--
function p.get_class(frame)
	return util.class(frame.args.page, frame.args.project)
end

--[[
Gets the class rating for a page

@param {string} namePage subject page name
@param {string} nameProject WikiProject with class assessment
@returns {string} The class rating as text, or empty string if none found
]]--
function util.class(namePage, nameProject)
	local subjectAssessment = nil
	
	local subjectPage = mw.title.new(namePage)                   -- create new object for given page title
	for project, entry in pairs(subjectPage.pageAssessments) do  -- iterate over all assessments
		if project == nameProject then                           -- if assessment is for given WikiProject
			subjectAssessment = entry                            -- save assessment of given WikiProject
		end
	end
	
    if subjectAssessment ~= nil then                             -- if there are assessments in pageAssessments
        return subjectAssessment["class"]                        -- return class parameter from pageAssessments
    end
	
	return ""
end



-- Export util, for testing purposes
p.test = util
return p