Module:PageType
From IdleOn MMO Wiki
Documentation for this module may be created at Module:PageType/doc
require('strict')
--- Contains special naming rules for the thing.
local PAGE_TYPES = {
[''] = 'article',
['File'] = 'image',
['Category'] = 'category',
['Template'] = 'template',
['Module'] = 'module',
['IdleOn'] = 'project page',
}
local p = {}
--- Entry point for use by templates.
--- @param frame table The frame object provided by the template.
--- @return string pageType The page type
function p.main(frame)
return p._main(frame.args[1])
end
--- Entry point for use by modules.
--- @param namespace string The namespace to get the page type of.
--- @return string pageType The page type
function p._main(namespace)
namespace = namespace or ''
-- Use special naming rule if one exists for the namespace.
local pageType = PAGE_TYPES[namespace]
if pageType ~= nil then
return pageType
end
-- Check if the namespace is a talk page.
if namespace:find(' talk$') ~= nil then
return 'talk page'
end
-- Use the default naming convention.
return namespace:lower() .. ' page'
end
return p