Module:Page assessment raw
Appearance
![]() | This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
This is a simplified version of Module:Page assessment with limited functions, designed for usage in frequently-transcluded templates where limiting the expensive function count is needed. It is recommended to use the other module in most cases.
Usage
Returns the class as text.
{{#invoke:Page assessment raw|get_class|page=page name|project=WikiProject name}}
- Examples
{{#invoke:Page assessment raw|get_class|project=Project-independent assessment|page=Wikipedia}}
→ Script error: The function "get_class" does not exist.{{#invoke:Page assessment raw|get_class|project=Project-independent assessment|page=Wiktionary}}
→ Script error: The function "get_class" does not exist.{{#invoke:Page assessment raw|get_class|project=Project-independent assessment|page=Wikt}}
→ Script error: The function "get_class" does not exist.
-- Dependencies
require('strict')
local getArgs = require('Module:Arguments').getArgs
local mDisambiguation = require('Module:Disambiguation')
-- Packapge to export
local p = {}
-- Namespace for utlity functions
local util = {}
--[[
Entry point for invoking the module.
Gets the class rating as text.
]]--
function p.main(frame)
local args = getArgs(frame, {
parentFirst = true
})
return util.class(args[1], args[2])
end
--[[
Gets the class rating for a page
@param {string} pageName - either subject or talk page name
@returns {string} class rating, or empty string if none found
]]--
function util.class(namePage, nameProject)
local subjectPage = mw.title.new(namePage) -- create new object for given page title
for _, entry in ipairs(subjectPage) do -- iterate over all assessments
if entry["name"] == nameProject then -- if assessment is for given WikiProject
local subjectAssessment = entry -- save assessment of given WikiProject
end
end
local subjectAssessment = nil -- nil if no matching WikiProject is found
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