FANDOM


local data = mw.loadData('Module:StaffCorrection/data')
 
----------------------------
-- Libraries of functions --
----------------------------
-- stands for High Frequency
-- local HF = require('Module:ComicsHF')
-- Parses invocation parameters, trims whitespace, and removes blanks.
local getArgs = require('Dev:Arguments').getArgs
 
----------------------------------------------------------
-- Public functions (called from a Template or article) --
----------------------------------------------------------
local StaffCorrection = {}
 
function StaffCorrection.correction( frame )
    local args = getArgs(frame)
    -- Throws an error if there's a blank or absent parameter.
    assert( type( args[1] ) == 'string', "Template:StaffCorrection has no value" )
    return StaffCorrection:normalize( args[1] )
end
 
--------------------------------------------------------
-- Internal functions (used in this and other Modules --
--------------------------------------------------------
function StaffCorrection:normalize( name )
    lowername = string.lower( name )
    if type( data[lowername] ) == 'string' then
        return data[lowername]
    else
        return name
    end
end
 
function StaffCorrection:link( name )
    return string.format('[['..'%s]]', self:normalize(name))
end
 
-- This uses {{TheSort}} and that needs to be fixed.
function StaffCorrection:cat_role( name, role )
    category = self:normalize(name)..'/'..role
    return string.format(
        '[['..'Category:%s|{{TheSort}}]]',
        category
    )
end
 
function StaffCorrection:in_database( name )
    if type( data[ string.lower( name ) ] ) == 'string' then
        return true
    else
        return nil
    end
end
 
-------------------------------------------------
-- Output (send it back to whatever called it) --
-------------------------------------------------
return StaffCorrection
Community content is available under CC-BY-SA unless otherwise noted.