Difference between revisions of "Module:User:Mr. Stradivarius/sandbox3"

From blackwiki
Jump to navigation Jump to search
blackwiki>Mr. Stradivarius
(add main text and a few more banner methods)
blackwiki>Mr. Stradivarius
(test)
Line 1: Line 1:
local dts = require( 'Module:User:Anomie/deepToString' ).deepToString -- for debugging
+
return {
 
+
foo = "foo",
local htmlBuilder = require( 'Module:HtmlBuilder' )
+
bar = "bar"
 
+
}
----------------------------------------------------------
 
-- Define constants
 
----------------------------------------------------------
 
 
 
local currentTitleObject = mw.title.getCurrentTitle()
 
 
 
----------------------------------------------------------
 
-- Helper functions
 
----------------------------------------------------------
 
 
 
-- Function allowing for consistent treatment of boolean-like wikitext input.
 
-- It works similarly to the template {{yesno}}.
 
local function yesno( val, default )
 
    val = type( val ) == 'string' and mw.ustring.lower( val ) or val -- put in lower case
 
    if not val or val == 'no' or val == 'n' or val == 'false' or tonumber( val ) == 0 then
 
        return false
 
    elseif val == true or val == 'yes' or val == 'y' or val == 'true' or tonumber( val ) == 1 then
 
        return true
 
    else
 
        return default
 
    end
 
end
 
 
 
-- Checks to see if a given variable is a non-blank string. Returns the string if true,
 
-- and returns false if not.
 
local function checkString( s )
 
    if type( s ) == 'string' and s ~= '' then
 
        return s
 
    else
 
        return false
 
    end
 
end
 
 
 
-- Adds a string to an array. Returns nil on an attempt to add a non-string value, and returns
 
-- an error on an attempt to add a string to a non-table value. Checks that the string is not
 
-- the empty string, and if the array is not present, the function creates it.
 
local function addStringToArray( array, s )
 
    s = checkString( s )
 
    if s then
 
        if type( array ) == 'table' then
 
            table.insert( array, s )
 
        elseif type( array ) == 'nil' then
 
            array = {}
 
            table.insert( array, s )
 
        else
 
            error( mw.ustring.format(
 
                'Error in argument #1 to addStringToArray: expected type "table" or "nil", got type "%s"',
 
                type( array )
 
            ), 2 )
 
        end
 
    end
 
    return array or {}
 
end
 
 
 
-- Checks to see if a given variable is an object that has inherited from type objType.
 
-- Returns the object if true, and returns false if not.
 
local function checkObject( obj, objType )
 
    if type( obj ) == 'table' and type( obj._inherits ) == 'table' and obj._inherits[ objType ] then
 
        return obj
 
    else
 
        return false
 
    end
 
end
 
 
 
local function makeClass( classType )
 
    if not checkString( classType ) then
 
        error( 'makeClass: no class type specified, or the class type was invalid. Class types should be a non-blank string' )
 
    end
 
    local class = {}
 
 
 
    -- Set the class type and start the _inherits table. These track the type of the current object and what classes it has
 
    -- inherited from. Used in checkObject and in error messages.
 
    class._type = classType
 
    class._inherits = { [ classType ] = true }
 
 
 
    function class:new( init )
 
        init = type( init ) == 'table' and init or {}
 
        local obj = {}
 
 
 
        -- Set the object type if it is specified.
 
        if checkString( init.type ) then
 
            obj._type = init.type
 
        else
 
            obj._type = self._type
 
        end
 
 
 
        -- Copy the _inherits table and add the new object type.
 
        obj._inherits = {}
 
        for k, v in pairs( self._inherits ) do
 
            obj._inherits[ k ] = v
 
        end
 
        obj._inherits[ obj._type ] = true
 
 
 
        -- Set the index metamethod and the metatable.
 
        self.__index = self
 
        setmetatable( obj, self )
 
       
 
        return obj
 
    end
 
 
 
    -- Makes a function that raises an error if the dot syntax is used with methods. It only checks
 
    -- that the object is in the right object family, not that it is the right object, but it will catch
 
    -- the majority of cases, and it works with inheritance.
 
    function class:makeCheckSelfFunction()
 
        local classType = self._type -- Here, "self" refers to the class used to make the checkSelf function.
 
        return function( self, method )
 
            if type( self ) ~= 'table' or type( self._inherits ) ~= 'table' or not self._inherits[ classType ] then -- Here, "self" refers to the first parameter passed to the method being checked.
 
                error( mw.ustring.format(
 
                    '%s: invalid %s object. Did you call %s with a dot instead of a colon, i.e. %s.%s() instead of %s:%s()?',
 
                    classType, classType, method, classType, method, classType, method
 
                ), 3 )
 
            end
 
        end
 
    end
 
 
 
    return class
 
end
 
 
 
----------------------------------------------------------
 
-- Define the assessmentGrade class
 
--
 
-- The assessmentGrade class sets the categories and
 
-- aliases for one importance scale grade or quality scale
 
-- grade.
 
----------------------------------------------------------
 
 
 
local assessmentGrade = makeClass( 'assessmentGrade' )
 
local checkSelfAssessmentGrade = assessmentGrade:makeCheckSelfFunction()
 
 
 
-- Sets the name of the assessment grade. For example, for a C-class quality grade,
 
-- the grade name would be "c".
 
function assessmentGrade:setGradeName( s )
 
    checkSelfAssessmentGrade( self, 'setGradeName' )
 
    s = checkString( s )
 
    if s then
 
        self.gradeName = mw.ustring.lower( s )
 
    end
 
end
 
 
 
-- Gets the grade name.
 
function assessmentGrade:getGradeName()
 
    checkSelfAssessmentGrade( self, 'getGradeName' )
 
    return self.gradeName
 
end
 
 
 
-- Adds a trigger for the assessment grade. For example, if you want
 
-- the grade to be triggered by the code "|class=foo", then the trigger
 
-- would be "foo".
 
function assessmentGrade:addTrigger( s )
 
    checkSelfAssessmentGrade( self, 'addTrigger' )
 
    self.triggers = addStringToArray( self.triggers, s )
 
end
 
 
 
-- Adds an array of triggers to the assessment grade object.
 
function assessmentGrade:addTriggers( t )
 
    checkSelfAssessmentGrade( self, 'addTriggers' )
 
    if type( t ) ~= 'table' then return end
 
    for i, trigger in ipairs( t ) do
 
        self:addTrigger( trigger )
 
    end
 
end
 
 
 
-- Returns an array containing the trigger values for the assessment grade object.
 
function assessmentGrade:getTriggers()
 
    checkSelfAssessmentGrade( self, 'getTriggers' )
 
    return self.triggers or {}
 
end
 
 
 
-- Sets the category used by the assessment grade. This should only be used if the
 
-- category does not follow the default naming system. Normally categories are set
 
-- by the qualityScale and importanceScale objects or banner objects.
 
function assessmentGrade:setCategory( s )
 
    checkSelfAssessmentGrade( self, 'setCategory' )
 
    s = checkString( s )
 
    if s then
 
        self.category = s
 
    end
 
end
 
 
 
-- Gets the assessment grade's category.
 
function assessmentGrade:getCategory()
 
    checkSelfAssessmentGrade( self, 'getCategory' )
 
    return self.category
 
end
 
 
 
-- Sets the color of the icon box when the assessment grade is used.
 
function assessmentGrade:setColor( s )
 
    checkSelfAssessmentGrade( self, 'setColor' )
 
    s = checkString( s )
 
    if s then
 
        self.color = s
 
    end
 
end
 
 
 
-- Gets the color used for the assessment grade.
 
function assessmentGrade:getColor()
 
    checkSelfAssessmentGrade( self, 'getColor' )
 
    return self.color
 
end
 
 
 
-- Sets an icon for the assessment grade.
 
function assessmentGrade:setIcon( s )
 
    checkSelfAssessmentGrade( self, 'setIcon' )
 
    s = checkString( s )
 
    if s then
 
        self.icon = s
 
    end
 
end
 
 
 
-- Gets the assessment grade icon.
 
function assessmentGrade:getIcon()
 
    checkSelfAssessmentGrade( self, 'getIcon' )
 
    return self.icon
 
end
 
 
 
----------------------------------------------------------
 
-- Define the qualityGrade class
 
----------------------------------------------------------
 
 
 
local qualityGrade = assessmentGrade:new{ type = 'qualityGrade' }
 
 
 
----------------------------------------------------------
 
-- Define the importanceGrade class
 
----------------------------------------------------------
 
 
 
local importanceGrade = assessmentGrade:new{ type = 'importanceGrade' }
 
 
 
----------------------------------------------------------
 
-- Define the assessmentScale class
 
--
 
-- The assessmentScale class provides the infrastructure
 
-- for importance scales and quality scales. It uses
 
-- assessmentGrade objects to define each grade
 
-- on the assessment scale.
 
----------------------------------------------------------
 
 
 
local assessmentScale = makeClass( 'assessmentScale' )
 
local checkSelfAssessmentScale = assessmentScale:makeCheckSelfFunction()
 
 
 
-- Sets the name of the parameter that accepts trigger values from assessmentGrade objects.
 
-- For example, if an article was rated as |class=start, the parameter name would be "class".
 
function assessmentScale:setParamName( s )
 
    checkSelfAssessmentScale( self, 'setParamName' )
 
    s = checkString( s )
 
    if s then
 
        self.param = s
 
    end
 
end
 
 
 
-- Gets the parameter name.
 
function assessmentScale:getParamName()
 
    checkSelfAssessmentScale( self, 'getParamName' )
 
    return self.param
 
end
 
 
 
-- Sets the name of the category family. For example, for a quality scale with categories
 
-- such as [[Category:C-class tulips articles]] and [[Category:List-class tulips articles]]
 
-- the category family name would be "tulips articles".
 
function assessmentScale:setCategoryFamily( s )
 
    checkSelfAssessmentScale( self, 'setCategoryFamily' )
 
    s = checkString( s )
 
    if s then
 
        self.categoryFamily = s
 
    end   
 
end
 
 
 
-- Gets the category family name for the assessment object.
 
function assessmentScale:getCategoryFamily()
 
    checkSelfAssessment( self, 'getCategoryFamily' )
 
    return self.categoryFamily
 
end
 
 
 
-- Adds an assessment grade object.
 
function assessmentScale:addGrade( obj )
 
    checkSelfAssessmentScale( self, 'addGrade' )
 
    obj = checkObject( obj, 'assessmentGrade' )
 
    if obj then
 
        local gradeName = obj:getGradeName()
 
        if not checkString( gradeName ) then
 
            error( mw.ustring.format( 'Grade name not found (was type "%s"). Please set a grade name with the "setGradeName" method of the assessment grade object' , type( gradeName ) ), 2 )
 
        else
 
            self.grades = self.grades or {}
 
            if self.grades[ gradeName ] then
 
                error( mw.ustring.format( 'Attempted to add assessment grade %s, but assessment grade %s was already defined. Assessment grades can only be defined once', gradeName, gradeName ), 2 )
 
            else
 
                self.grades[ gradeName ] = obj
 
            end
 
        end
 
    end
 
end
 
 
 
-- Adds an array of grade objects.
 
function assessmentScale:addGrades( t )
 
    checkSelfAssessmentScale( self, 'addGrades' )
 
    if type( t ) ~= 'table' then return end
 
    for i, gradeObject in ipairs( t ) do
 
        self:addGrade( gradeObject )
 
    end
 
end
 
 
 
-- Removes an assessment grade object from the assessment scale.
 
function assessmentScale:removeGrade( s )
 
    checkSelfAssessmentScale( self, 'removeGrade' )
 
    s = checkString( s )
 
    if s and type( self.grades ) == 'table' and self.grades[ s ] then
 
        self.grades[ s ] = nil
 
    end
 
end
 
 
 
-- Removes multiple assessment grade objects from the assessment scale.
 
function assessmentScale:removeGrades( t )
 
    checkSelfAssessmentScale( self, 'removeGrades' )
 
    if type( t ) == 'table' then
 
        for i, grade in ipairs( t ) do
 
            self:removeGrade( grade )
 
        end
 
    end
 
end
 
 
 
-- Gets the object's grade table.
 
function assessmentScale:getGrades()
 
    checkSelfAssessmentScale( self, 'getGrades' )
 
    return self.grades or {}
 
end
 
 
 
-- Gets the specified grade object.
 
function assessmentScale:getGrade( gradeName )
 
    checkSelfAssessmentScale( self, 'getGrade' )
 
    self.grades = self.grades or {}
 
    gradeName = checkString( gradeName )
 
    if gradeName then
 
        return self.grades[ gradeName ]
 
    end
 
end
 
 
 
-- Edits a grade object in the grades table by calling one of its methods.
 
function assessmentScale:editGrade( gradeName, method, ... )
 
    checkSelfAssessmentScale( self, 'editGrade' )
 
    self.grades = self.grades or {}
 
    gradeName = checkString( gradeName )
 
    method = checkString( method )
 
    if not ( gradeName and method ) then return end
 
    local gradeObj = self.grades[ gradeName ]
 
    if not checkObject( gradeObj, 'assessmentGrade' ) then
 
        error( mw.ustring.format( 'editGrade: no assessment grade object found with grade name "%s"', gradeName ), 2 )
 
    end
 
    if type( gradeObj[ method ] ) ~= 'function' then
 
        error( mw.ustring.format( 'editGrade: method "%s" was not found in the "%s" grade object', method, gradeName ), 2 )
 
    end
 
    self.grades[ gradeName ][ method ]( self.grades[ gradeName ], ... )
 
end
 
 
 
-- Checks for duplicate triggers for the grade objects added to the assessment scale.
 
-- If any are found, displays an error.
 
function assessmentScale:checkForDuplicateTriggers()
 
    checkSelfAssessmentScale( self, 'checkForDuplicateTriggers' )
 
    local grades = self.grades or {}
 
    if type( grades ) ~= 'table' then return end
 
    local exists = {}
 
    for name, gradeObj in pairs( grades ) do
 
        gradeObj = checkObject( gradeObj, 'assessmentGrade' )
 
        if gradeObj then
 
            local triggers = type( gradeObj.getTriggers ) == 'function' and gradeObj:getTriggers()
 
            if type( triggers ) == 'table' then
 
                for i, trigger in ipairs( triggers ) do
 
                    trigger = checkString( trigger )
 
                    if trigger then
 
                        if exists[ trigger ] then
 
                            error( mw.ustring.format(
 
                                'Duplicate trigger value "%s" detected in the assessment grade objects "%s" and "%s"',
 
                                trigger, exists[ trigger ],    name
 
                            ), 2 )
 
                        else
 
                            exists[ trigger ] = name
 
                        end
 
                    end
 
                end
 
            end
 
        end
 
    end
 
end
 
 
 
----------------------------------------------------------
 
-- Define the qualityScale class
 
----------------------------------------------------------
 
 
 
local qualityScale = assessmentScale:new{ type = 'qualityScale' }
 
local checkSelfQualityScale = qualityScale:makeCheckSelfFunction()
 
 
 
-- Sets the FA (Featured Article) grade with default settings.
 
function qualityScale:setFaGrade()
 
    checkSelfQualityScale( self, 'setFaGrade' )
 
    local faGrade = qualityGrade:new()
 
    faGrade:setGradeName( 'fa' )
 
    faGrade:addTrigger( 'fa' )
 
    faGrade:setColor( '#6699ff' )
 
    faGrade:setIcon( 'Featured article star.svg' )
 
    self:addGrade( faGrade )
 
end
 
 
 
-- Sets the A grade with default settings.
 
function qualityScale:setAGrade()
 
    checkSelfQualityScale( self, 'setAGrade' )
 
    local aGrade = qualityGrade:new()
 
    aGrade:setGradeName( 'a' )
 
    aGrade:addTrigger( 'a' )
 
    aGrade:setColor( '#66ffff' )
 
    aGrade:setIcon( 'Symbol a class.svg' )
 
    self:addGrade( aGrade )
 
end
 
 
 
-- Sets the GA (Good Article) grade with default settings.
 
function qualityScale:setGaGrade()
 
    checkSelfQualityScale( self, 'setGaGrade' )
 
    local gaGrade = qualityGrade:new()
 
    gaGrade:setGradeName( 'ga' )
 
    gaGrade:addTrigger( 'ga' )
 
    gaGrade:setColor( '#66ff66' )
 
    gaGrade:setIcon( 'Symbol support vote.svg' )
 
    self:addGrade( gaGrade )
 
end
 
 
 
-- Sets the B grade with default settings.
 
function qualityScale:setBGrade()
 
    checkSelfQualityScale( self, 'setBGrade' )
 
    local bGrade = qualityGrade:new()
 
    bGrade:setGradeName( 'b' )
 
    bGrade:addTrigger( 'b' )
 
    bGrade:setColor( '#b2ff66' )
 
    self:addGrade( bGrade )
 
end
 
 
 
-- Sets the C grade with default settings.
 
function qualityScale:setCGrade()
 
    checkSelfQualityScale( self, 'setCGrade' )
 
    local cGrade = qualityGrade:new()
 
    cGrade:setGradeName( 'c' )
 
    cGrade:addTrigger( 'c' )
 
    cGrade:setColor( '#ffff66' )
 
    self:addGrade( cGrade )
 
end
 
 
 
-- Sets the Start grade with default settings.
 
function qualityScale:setStartGrade()
 
    checkSelfQualityScale( self, 'setStartGrade' )
 
    local startGrade = qualityGrade:new()
 
    startGrade:setGradeName( 'start' )
 
    startGrade:addTrigger( 'start' )
 
    startGrade:setColor( '#ffaa66' )
 
    self:addGrade( startGrade )
 
end
 
 
 
-- Sets the Stub grade with default settings.
 
function qualityScale:setStubGrade()
 
    checkSelfQualityScale( self, 'setStubGrade' )
 
    local stubGrade = qualityGrade:new()
 
    stubGrade:setGradeName( 'stub' )
 
    stubGrade:addTrigger( 'stub' )
 
    stubGrade:setColor( '#ff6666' )
 
    self:addGrade( stubGrade )
 
end
 
 
 
-- Sets the FL (Featured List) grade with default settings.
 
function qualityScale:setFlGrade()
 
    checkSelfQualityScale( self, 'setFlGrade' )
 
    local flGrade = qualityGrade:new()
 
    flGrade:setGradeName( 'fl' )
 
    flGrade:addTrigger( 'fl' )
 
    flGrade:setColor( '#6699ff' )
 
    flGrade:setIcon( 'Featured article star.svg' )
 
    self:addGrade( flGrade )
 
end
 
 
 
-- Sets the List grade with default settings.
 
function qualityScale:setListGrade()
 
    checkSelfQualityScale( self, 'setListGrade' )
 
    local listGrade = qualityGrade:new()
 
    listGrade:setGradeName( 'list' )
 
    listGrade:addTrigger( 'list' )
 
    listGrade:setColor( '#aa88ff' )
 
    self:addGrade( listGrade )
 
end
 
 
 
-- Sets the NA (not applicable) grade with default settings.
 
function qualityScale:setNaGrade()
 
    checkSelfQualityScale( self, 'setNaGrade' )
 
    local naGrade = qualityGrade:new()
 
    naGrade:setGradeName( 'na' )
 
    naGrade:addTriggers{ 'na', 'n/a' }
 
    naGrade:setColor( '#f5f5f5' )
 
    self:addGrade( naGrade )
 
end
 
 
 
-- Sets the Category grade with default settings.
 
function qualityScale:setCategoryGrade()
 
    checkSelfQualityScale( self, 'setCategoryGrade' )
 
    local categoryGrade = qualityGrade:new()
 
    categoryGrade:setGradeName( 'category' )
 
    categoryGrade:addTriggers{ 'category', 'cat', 'categ' }
 
    categoryGrade:setColor( '#ffdb58' )
 
    self:addGrade( categoryGrade )
 
end
 
 
 
-- Sets the Disambig (disambiguation) grade with default settings.
 
function qualityScale:setDisambigGrade()
 
    checkSelfQualityScale( self, 'setDisambigGrade' )
 
    local disambigGrade = qualityGrade:new()
 
    disambigGrade:setGradeName( 'disambig' )
 
    disambigGrade:addTriggers{ 'disambiguation', 'disambig', 'disamb', 'dab' }
 
    disambigGrade:setColor( '#00fa9a' )
 
    self:addGrade( disambigGrade )
 
end
 
 
 
-- Sets the File grade with default settings.
 
function qualityScale:setFileGrade()
 
    checkSelfQualityScale( self, 'setFileGrade' )
 
    local fileGrade = qualityGrade:new()
 
    fileGrade:setGradeName( 'file' )
 
    fileGrade:addTriggers{ 'file', 'img', 'image' }
 
    fileGrade:setColor( '#ddccff' )
 
    self:addGrade( fileGrade )
 
end
 
 
 
-- Sets the Portal grade with default settings.
 
function qualityScale:setPortalGrade()
 
    checkSelfQualityScale( self, 'setPortalGrade' )
 
    local portalGrade = qualityGrade:new()
 
    portalGrade:setGradeName( 'portal' )
 
    portalGrade:addTrigger( 'portal' )
 
    portalGrade:setColor( '#cc8899' )
 
    self:addGrade( portalGrade )
 
end
 
 
 
-- Sets the Project grade with default settings.
 
function qualityScale:setProjectGrade()
 
    checkSelfQualityScale( self, 'setProjectGrade' )
 
    local projectGrade = qualityGrade:new()
 
    projectGrade:setGradeName( 'project' )
 
    projectGrade:addTriggers{ 'project', 'proj', 'prj' }
 
    projectGrade:setColor( '#c0c090' )
 
    self:addGrade( projectGrade )
 
end
 
 
 
-- Sets the Template grade with default settings.
 
function qualityScale:setTemplateGrade()
 
    checkSelfQualityScale( self, 'setTemplateGrade' )
 
    local templateGrade = qualityGrade:new()
 
    templateGrade:setGradeName( 'template' )
 
    templateGrade:addTriggers{ 'template', 'temp', 'tpl', 'tmp', 'templ' }
 
    templateGrade:setColor( '#fbceb1' )
 
    self:addGrade( templateGrade )
 
end
 
 
 
-- Sets the Redirect grade with default settings.
 
function qualityScale:setRedirectGrade()
 
    checkSelfQualityScale( self, 'setRedirectGrade' )
 
    local redirectGrade = qualityGrade:new()
 
    redirectGrade:setGradeName( 'redirect' )
 
    redirectGrade:addTriggers{ 'redirect', 'red', 'redir' }
 
    redirectGrade:setColor( '#c0c0c0' )
 
    self:addGrade( redirectGrade )
 
end
 
 
 
-- Sets the Book grade with default settings.
 
function qualityScale:setBookGrade()
 
    checkSelfQualityScale( self, 'setBookGrade' )
 
    local bookGrade = qualityGrade:new()
 
    bookGrade:setGradeName( 'book' )
 
    bookGrade:addTriggers{ 'book', 'bk' }
 
    bookGrade:setColor( '#98ff98' )
 
    self:addGrade( bookGrade )
 
end
 
 
 
-- Sets the FM (Featured media) grade with default settings.
 
function qualityScale:setFmGrade()
 
    checkSelfQualityScale( self, 'setFmGrade' )
 
    local fmGrade = qualityGrade:new()
 
    fmGrade:setGradeName( 'fm' )
 
    fmGrade:addTrigger( 'fm' )
 
    fmGrade:setColor( '#6699ff' )
 
    fmGrade:setIcon( 'Featured article star.svg' )
 
    self:addGrade( fmGrade )
 
end
 
 
 
-- Set the standard quality scale with default values.
 
function qualityScale:setStandardQualityScale()
 
    checkSelfQualityScale( self, 'setStandardQualityScale' )
 
    self:setFaGrade()
 
    self:setAGrade()
 
    self:setGaGrade()
 
    self:setBGrade()
 
    self:setCGrade()
 
    self:setStartGrade()
 
    self:setStubGrade()
 
    self:setFlGrade()
 
    self:setListGrade()
 
    self:setNaGrade()
 
end
 
 
 
-- Set the extended quality scale with default values.
 
function qualityScale:setExtendedQualityScale()
 
    checkSelfQualityScale( self, 'setExtendedQualityScale' )
 
    self:setStandardQualityScale()
 
    self:setCategoryGrade()
 
    self:setDisambigGrade()
 
    self:setFileGrade()
 
    self:setPortalGrade()
 
    self:setProjectGrade()
 
    self:setTemplateGrade()
 
end
 
 
 
----------------------------------------------------------
 
-- Define the importanceScale class
 
----------------------------------------------------------
 
 
 
local importanceScale = assessmentScale:new{ type = 'importanceScale' }
 
local checkSelfImportanceScale = importanceScale:makeCheckSelfFunction()
 
 
 
-- Sets the Top grade with default settings.
 
function importanceScale:setTopGrade()
 
    checkSelfImportanceScale( self, 'setTopGrade' )
 
    local topGrade = importanceGrade:new()
 
    topGrade:setGradeName( 'top' )
 
    topGrade:addTrigger( 'top' )
 
    topGrade:setColor( '#ff00ff' )
 
    self:addGrade( topGrade )
 
end
 
 
 
-- Sets the High grade with default settings.
 
function importanceScale:setHighGrade()
 
    checkSelfImportanceScale( self, 'setHighGrade' )
 
    local highGrade = importanceGrade:new()
 
    highGrade:setGradeName( 'high' )
 
    highGrade:addTrigger( 'high' )
 
    highGrade:setColor( '#ff88ff' )
 
    self:addGrade( highGrade )
 
end
 
 
 
-- Sets the Mid grade with default settings.
 
function importanceScale:setMidGrade()
 
    checkSelfImportanceScale( self, 'setMidGrade' )
 
    local midGrade = importanceGrade:new()
 
    midGrade:setGradeName( 'mid' )
 
    midGrade:addTrigger( 'mid' )
 
    midGrade:setColor( '#ffbbff' )
 
    self:addGrade( midGrade )
 
end
 
 
 
-- Sets the Low grade with default settings.
 
function importanceScale:setLowGrade()
 
    checkSelfImportanceScale( self, 'setLowGrade' )
 
    local lowGrade = importanceGrade:new()
 
    lowGrade:setGradeName( 'low' )
 
    lowGrade:addTrigger( 'low' )
 
    lowGrade:setColor( '#ffddff' )
 
    self:addGrade( lowGrade )
 
end
 
 
 
-- Sets the Bottom grade with default settings.
 
function importanceScale:setBottomGrade()
 
    checkSelfImportanceScale( self, 'setBottomGrade' )
 
    local bottomGrade = importanceGrade:new()
 
    bottomGrade:setGradeName( 'bottom' )
 
    bottomGrade:addTrigger( 'bottom' )
 
    bottomGrade:setColor( '#ffeeff' )
 
    self:addGrade( bottomGrade )
 
end
 
 
 
-- Sets the No grade with default settings.
 
function importanceScale:setNoGrade()
 
    checkSelfImportanceScale( self, 'setNoGrade' )
 
    local noGrade = importanceGrade:new()
 
    noGrade:setGradeName( 'no' )
 
    noGrade:addTrigger( 'no' )
 
    noGrade:setColor( '#ffffff' )
 
    self:addGrade( noGrade )
 
end
 
 
 
-- Sets the NA grade with default settings.
 
function importanceScale:setNaGrade()
 
    checkSelfImportanceScale( self, 'setNaGrade' )
 
    local naGrade = importanceGrade:new()
 
    naGrade:setGradeName( 'na' )
 
    naGrade:addTriggers{ 'na', 'n/a' }
 
    naGrade:setColor( '#f5f5f5' )
 
    self:addGrade( naGrade )
 
end
 
 
 
-- Sets the Core grade with default settings.
 
function importanceScale:setCoreGrade()
 
    checkSelfImportanceScale( self, 'setCoreGrade' )
 
    local coreGrade = importanceGrade:new()
 
    coreGrade:setGradeName( 'core' )
 
    coreGrade:addTrigger( 'core' )
 
    coreGrade:setColor( '#ff00ff' )
 
    self:addGrade( coreGrade )
 
end
 
 
 
-- Sets the standard importance scale with default settings.
 
function importanceScale:setStandardImportanceScale()
 
    checkSelfImportanceScale( self, 'setStandardImportanceScale' )
 
    self:setTopGrade()
 
    self:setHighGrade()
 
    self:setMidGrade()
 
    self:setLowGrade()
 
    self:setNaGrade()
 
end
 
 
 
----------------------------------------------------------
 
-- Define the row class
 
----------------------------------------------------------
 
 
 
local row = makeClass( 'row' )
 
local checkSelfRow = row:makeCheckSelfFunction()
 
 
 
-- Adds a category to the "categories" table of the row object. Creates the categories table if it doesn't exist.
 
function row:addCategory( s )
 
    checkSelfRow( self, 'addCategory' )
 
    self.categories = addStringToArray( self.categories, s )
 
end
 
 
 
-- Adds all categories in an array to the row's "categories" table.
 
function row:addCategories( t )
 
    checkSelfRow( self, 'addCategories' )
 
    if type( t ) == 'table' then
 
        for i, category in ipairs( t ) do
 
            self:addCategory( category )
 
        end
 
    end
 
end
 
 
 
-- Returns the row object's category table.
 
function row:getCategories()
 
    checkSelfRow( self, 'getCategories' )
 
    return self.categories or {}
 
end
 
 
 
function row:export()
 
    checkSelfRow( self, 'export' )
 
 
 
    -- Get the result of the icon and content export functions, and check the results.
 
    local rowIconOutput = type( self.exportRowIcon ) == 'function' and self:exportRowIcon()
 
    rowIconOutput = checkString( rowIconOutput )
 
    local rowContentOutput = type( self.exportRowContent ) == 'function' and self:exportRowContent()
 
    rowContentOutput = checkString( rowContentOutput )
 
 
 
    -- Export the row wikitext.
 
    local ret = htmlBuilder.create()
 
    if rowIconOutput and rowContentOutput then
 
        ret
 
        .tag( 'tr' )
 
        .tag( 'td' )
 
        .wikitext( rowIconOutput )
 
        .done()
 
        .tag( 'td' )
 
        .attr( 'colspan', '2' )
 
        .wikitext( rowContentOutput )
 
    elseif rowContentOutput and not rowIconOutput then
 
        ret
 
        .tag( 'tr' )
 
        .tag( 'td' )
 
        .attr( 'colspan', '3' )
 
        .wikitext( rowContentOutput )
 
    end
 
    return tostring( ret )
 
end
 
 
 
----------------------------------------------------------
 
-- Define the qualityRow class
 
----------------------------------------------------------
 
 
 
local qualityRow = row:new{ type = 'qualityRow' }
 
local checkSelfQualityRow = qualityRow:makeCheckSelfFunction()
 
 
 
-- Sets the quality scale for the quality row. The input must be a qualityScale object.
 
function qualityRow:setQualityScale( obj )
 
    checkSelfQualityRow( self, 'setQualityScale' )
 
    obj = checkObject( obj, 'qualityScale' )
 
    if obj and type( obj.setFaGrade ) == 'function' then
 
        self.qualityScale = obj
 
    end
 
end
 
 
 
-- Sets the standard quality scale with default settings.
 
function qualityRow:setStandardQualityScale()
 
    checkSelfQualityRow( self, 'setStandardQualityScale' )
 
    local standard = qualityScale:new()
 
    standard:setStandardQualityScale()
 
    self:setQualityScale( standard )
 
end
 
 
 
-- Sets the extended quality scale with default settings.
 
function qualityRow:setExtendedQualityScale()
 
    checkSelfQualityRow( self, 'setExtendedQualityScale' )
 
local extended = qualityScale:new()
 
extended:setExtendedQualityScale()
 
self:setQualityScale( extended )
 
end
 
 
 
-- Gets the quality scale object if it is set.
 
function qualityRow:getQualityScale()
 
checkSelfQualityRow( self, 'getQualityScale' )
 
return self.qualityScale
 
end
 
 
 
----------------------------------------------------------
 
-- Define the importanceRow class
 
----------------------------------------------------------
 
 
 
local importanceRow = row:new{ type = 'importanceRow' }
 
local checkSelfImportanceRow = importanceRow:makeCheckSelfFunction()
 
 
 
-- Sets the importance scale for the importance row. The input must be a importanceScale object.
 
function importanceRow:setImportanceScale( obj )
 
checkSelfImportanceRow( self, 'setImportanceScale' )
 
obj = checkObject( obj, 'importanceScale' )
 
if obj and type( obj.setTopGrade ) == 'function' then
 
self.importanceScale = obj
 
end
 
end
 
 
 
-- Sets the standard importance scale with default settings.
 
function importanceRow:setStandardImportanceScale()
 
checkSelfImportanceRow( self, 'setStandardImportanceScale' )
 
local standard = importanceScale:new()
 
standard:setStandardImportanceScale()
 
self:setImportanceScale( standard )
 
end
 
 
 
-- Gets the importance scale object if it is set.
 
function importanceRow:getImportanceScale()
 
checkSelfImportanceRow( self, 'getImportanceScale' )
 
return self.importanceScale
 
end
 
 
 
----------------------------------------------------------
 
-- Define the taskForce class
 
----------------------------------------------------------
 
 
 
local taskForce = row:new()
 
 
 
----------------------------------------------------------
 
-- Define the banner class
 
----------------------------------------------------------
 
 
 
local banner = makeClass( 'banner' )
 
local checkSelfBanner = banner:makeCheckSelfFunction()
 
 
 
-- Sets the project value.
 
function banner:setProject( s )
 
    checkSelfBanner( self, 'setProject' )
 
    s = checkString( s )
 
    if s then
 
        self.project = s
 
    end
 
end
 
 
 
-- Gets the project value.
 
function banner:getProject()
 
    checkSelfBanner( self, 'getProject' )
 
    return self.project or error( 'getProject: no project value found. Please set a project using banner:setProject()' )
 
end
 
 
 
-- Sets the project link value.
 
function banner:setProjectLink( s )
 
    checkSelfBanner( self, 'setProjectLink' )
 
    s = checkString( s )
 
    if s then
 
        self.projectLink = s
 
    end
 
end
 
 
 
-- Gets the project link name.
 
function banner:getProjectLink()
 
    checkSelfBanner( self, 'getProjectLink' )
 
    return self.projectLink or 'Wikipedia:WikiProject ' .. self:getProject()
 
end
 
 
 
-- Sets the project name.
 
function banner:setProjectName( s )
 
    checkSelfBanner( self, 'setProjectName' )
 
    s = checkString( s )
 
    if s then
 
        self.projectName = s
 
    end
 
end
 
 
 
-- Gets the project name.
 
function banner:getProjectName()
 
    checkSelfBanner( self, 'getProjectName' )
 
    return self.projectName or 'WikiProject ' .. self:getProject()
 
end
 
 
 
-- Sets the banner name.
 
function banner:setBannerName( s )
 
    checkSelfBanner( self, 'setBannerName' )
 
    s = checkString( s )
 
    if s then
 
        self.bannerName = s
 
    end
 
end
 
 
 
-- Gets the banner name.
 
function banner:getBannerName()
 
    checkSelfBanner( self, 'getBannerName' )
 
    return self.bannerName or 'Template:WikiProject ' .. self:getProject()
 
end
 
 
 
-- Sets the assessment category.
 
function banner:setAssessmentCategory( s )
 
    checkSelfBanner( self, 'setAssessmentCategory' )
 
    s = checkString( s )
 
    if s then
 
        self.assessmentCategory = s
 
    end
 
end
 
 
 
-- Gets the assessment category.
 
function banner:getAssessmentCategory()
 
    checkSelfBanner( self, 'getAssessmentCategory' )
 
    return self.assessmentCategory or self:getProject() .. ' articles'
 
end
 
 
 
-- Sets the portal.
 
function banner:setPortal( s )
 
    checkSelfBanner( self, 'setPortal' )
 
    s = checkString( s )
 
    if s then
 
        self.portal = s
 
    end
 
end
 
 
 
-- Gets the portal.
 
function banner:getPortal()
 
    checkSelfBanner( self, 'getPortal' )
 
    return self.portal
 
end
 
 
 
-- Sets the main article.
 
function banner:setMainArticle( s )
 
    checkSelfBanner( self, 'setMainArticle' )
 
    s = checkString( s )
 
    if s then
 
        self.mainArticle = s
 
    end
 
end
 
 
 
-- Gets the main article.
 
function banner:getMainArticle()
 
    checkSelfBanner( self, 'getMainArticle' )
 
    return self.mainArticle
 
end
 
 
 
-- Gets the main text.
 
function banner:getMainText()
 
    checkSelfBanner( self, 'getMainText' )
 
    return self.mainText
 
end
 
 
 
-- Sets the name of the image on the left-hand side of the banner.
 
function banner:setLeftImage( s )
 
    checkSelfBanner( self, 'setLeftImage' )
 
    s = checkString( s )
 
    if s then
 
        self.leftImage = s
 
    end
 
end
 
 
 
-- Sets the name of the image on the left-hand side of the banner.
 
function banner:setLeftImage( s )
 
    checkSelfBanner( self, 'setLeftImage' )
 
    s = checkString( s )
 
    if s then
 
        self.leftImage = s
 
    end
 
end
 
 
 
-- Gets the name of the image on the left-hand side of the banner.
 
function banner:getLeftImage()
 
    checkSelfBanner( self, 'getLeftImage' )
 
    return self.leftImage
 
end
 
 
 
-- Sets the name of the image on the right-hand side of the banner.
 
function banner:setRightImage( s )
 
    checkSelfBanner( self, 'setRightImage' )
 
    s = checkString( s )
 
    if s then
 
        self.rightImage = s
 
    end
 
end
 
 
 
-- Gets the name of the image on the right-hand side of the banner.
 
function banner:getRightImage()
 
    checkSelfBanner( self, 'getRightImage' )
 
    return self.rightImage
 
end
 
 
 
-- Sets the size of the image on the left-hand side of the banner when it is displayed in small mode.
 
function banner:setLeftImageSizeSmall( s )
 
    checkSelfBanner( self, 'setLeftImageSizeSmall' )
 
    s = checkString( s )
 
    if s then
 
        self.leftImageSizeSmall = s
 
    end
 
end
 
 
 
-- Gets the size of the image on the left-hand side of the banner when it is displayed in small mode.
 
function banner:getLeftImageSizeSmall()
 
    checkSelfBanner( self, 'getLeftImageSizeSmall' )
 
    return self.leftImageSizeSmall or '40px'
 
end
 
 
 
-- Sets the size of the image on the left-hand side of the banner when it is displayed in normal mode.
 
function banner:setLeftImageSizeLarge( s )
 
    checkSelfBanner( self, 'setLeftImageSizeLarge' )
 
    s = checkString( s )
 
    if s then
 
        self.leftImageSizeLarge = s
 
    end
 
end
 
 
 
-- Gets the size of the image on the left-hand side of the banner when it is displayed in normal mode.
 
function banner:getLeftImageSizeLarge()
 
    checkSelfBanner( self, 'getLeftImageSizeLarge' )
 
    return self.leftImageSizeLarge or '80px'
 
end
 
 
 
-- Sets the size of the image on the right-hand side of the banner when it is displayed in small mode.
 
function banner:setRightImageSizeSmall( s )
 
    checkSelfBanner( self, 'setRightImageSizeSmall' )
 
    s = checkString( s )
 
    if s then
 
        self.rightImageSizeSmall = s
 
    end
 
end
 
 
 
-- Gets the size of the image on the right-hand side of the banner when it is displayed in small mode.
 
function banner:getRightImageSizeSmall()
 
    checkSelfBanner( self, 'getRightImageSizeSmall' )
 
    return self.rightImageSizeSmall or '40px'
 
end
 
 
 
-- Sets the size of the image on the right-hand side of the banner when it is displayed in normal mode.
 
function banner:setRightImageSizeLarge( s )
 
    checkSelfBanner( self, 'setRightImageSizeLarge' )
 
    s = checkString( s )
 
    if s then
 
        self.rightImageSizeLarge = s
 
    end
 
end
 
 
 
-- Gets the size of the image on the right-hand side of the banner when it is displayed in normal mode.
 
function banner:getRightImageSizeLarge()
 
    checkSelfBanner( self, 'getRightImageSizeLarge' )
 
    return self.rightImageSizeLarge or '80px'
 
end
 
 
 
-- Adds one category to the banner's "categories" table.
 
function banner:addCategory( s )
 
    checkSelfBanner( self, 'addCategory' )
 
    self.categories = addStringToArray( self.categories, s )
 
end
 
 
 
-- Adds all categories in a "categories" array to the banner's "categories" table.
 
function banner:addCategories( categoryTable )
 
    checkSelfBanner( self, 'addCategories' )
 
    if type( categoryTable ) == 'table' then
 
        for i, category in ipairs( rowObject.categories ) do
 
            self:addCategory( category )
 
        end
 
    end
 
end
 
 
 
-- Returns the banner object's category table.
 
function banner:getCategories()
 
    checkSelfBanner( self, 'getCategories' )
 
    return self.categories or {}
 
end
 
 
 
-- Returns a string of category links for the categories in obj.categories.
 
function banner:exportCategories()
 
    checkSelfBanner( self, 'exportCategories' )
 
    if type( self.categories ) == 'table' then
 
        local ret = {}
 
        for i, category in ipairs( self.categories ) do
 
            category = checkString( category )
 
            if category then
 
                table.insert( ret, mw.ustring.format(
 
                    '[[Category:%s|%s]]',
 
                    category,
 
                    type( self.page ) == 'string' and self.page or currentTitleObject.text
 
                ) )
 
            end
 
        end
 
        return table.concat( ret )
 
    end
 
    return ''
 
end       
 
 
 
-- Adds a row object to the banners "rows" table, and adds the row object's categories
 
-- to the banners "categories" table. Categories are deleted from the row object after
 
-- they have been transferred.
 
function banner:addRow( rowObj )
 
    checkSelfBanner( self, 'addRow' )
 
    self.rows = self.rows or {}
 
    rowObj = checkObject( rowObj, 'row' )
 
    if rowObj and type( rowObj.getCategories ) == 'function' then
 
        self:addCategories( rowObj:getCategories() )
 
        rowObj.categories = nil -- Erase the categories from the row object to make sure we don't add the same categories twice.
 
        table.insert( self.rows, rowObj )
 
    end
 
end
 
 
 
-- Adds an array of row objects to the banner object.
 
function banner:addRows( t )
 
    checkSelfBanner( self, 'addRows' )
 
    if type( t ) == 'table' then
 
        for i, rowObj in ipairs( t ) do
 
            self:addRow( rowObj )
 
        end
 
    end
 
end
 
 
 
-- Sets the quality row.
 
function banner:setQualityRow( obj )
 
    checkSelfBanner( self, 'setQualityRow' )
 
    if checkObject( obj, 'qualityRow' ) then
 
        self.rows = self.rows or {}
 
        self.rows.qualityRow = obj
 
    end
 
end
 
 
 
-- Gets the quality row, if it is set.
 
function banner:getQualityRow()
 
    checkSelfBanner( self, 'getQualityRow' )
 
    self.rows = self.rows or {}
 
    return self.rows.qualityRow
 
end
 
 
 
-- Sets the importance row.
 
function banner:setImportanceRow( obj )
 
    checkSelfBanner( self, 'setImportanceRow' )
 
    if checkObject( obj, 'importanceRow' ) then
 
        self.rows = self.rows or {}
 
        self.rows.importanceRow = obj
 
    end
 
end
 
 
 
-- Gets the importance row, if it is set.
 
function banner:getImportanceRow()
 
    checkSelfBanner( self, 'getImportanceRow' )
 
    self.rows = self.rows or {}
 
    return self.rows.importanceRow
 
end
 
 
 
-- Exports a header listing the project name and any applicable task forces.
 
function banner:exportProjectHeader( args )
 
    checkSelfBanner( self, 'exportProjectHeader' )
 
    -- TODO: add this code.
 
end
 
 
 
-- Exports a header listing the assessment status.
 
function banner:exportAssessmentHeader( args )
 
    checkSelfBanner( self, 'exportAssessmentHeader' )
 
    -- TODO: add this code.
 
end
 
 
 
-- Gets the page type.
 
function banner:getPageType( args )
 
    checkSelfBanner( self, 'getPageType' )
 
    return 'page' -- TODO: add the proper code.
 
end
 
 
 
-- Exports the banner to wikitext. The args are the arguments passed from the template invocation.
 
function banner:export( args )
 
    checkSelfBanner( self, 'export' )
 
    args = type( args ) == 'table' and args or {}
 
   
 
    -- Get external modules.
 
    local makePortal = require( 'Module:Portal' ).portal
 
    local makeNavbar = require( 'Module:Navbar' ).navbar
 
   
 
    -- Get the page type.
 
    local pageType = self:getPageType( args )
 
   
 
    -- Get the row output.
 
    local rowOutput = {}
 
    self.rows = self.rows or {}
 
    for i, row in ipairs( self.rows ) do
 
        table.insert( ret, row:export() )
 
    end
 
    rowOutput = table.concat( rowOutput )
 
   
 
    -- Get the main text.
 
    local mainText = self:getMainText()
 
    if not mainText then
 
        local mainArticle = self:getMainArticle()
 
        if mainArticle then
 
            local mainArticleObj = mw.title.new( mainArticle )
 
            if mainArticleObj.exists then
 
                mainArticle = mw.ustring.format( '[[%s]]', mainArticle )
 
            end
 
        else
 
            local projectObj = mw.title.new( self:getProject() )
 
            if projectObj.exists then
 
                mainArticle = mw.ustring.format( '[[%s]]', self:getProject() )
 
            end
 
        end
 
        mainText = mw.ustring.format(
 
            "This %s is within the scope of '''[[%s|%s]]''', a collaborative effort to improve the coverage of %s on Wikipedia.",
 
            pageType, self:getProjectLink(), self:getProjectName(), mainArticle
 
        )
 
        if not yesno( args.small ) then
 
            local projectLinkObj = mw.title.new( self:getProjectLink() )
 
            local projectTalk = projectLinkObj.talkPageTitle
 
            projectTalk = projectTalk and projectTalk.prefixedText
 
            local discussionLink = projectTalk and mw.ustring.format( '[[%s|discussion]]', projectTalk ) or 'discussion'
 
            mainText = mw.ustring.format(
 
                '%s If you would like to participate, please visit the project page, where you can join the %s and see a list of open tasks.',
 
                mainText, discussionLink
 
            )
 
        end
 
    end
 
 
 
    -- Build the banner table.
 
    local root = htmlBuilder.create( 'table' )
 
    root
 
        .addClass( 'tmbox' )
 
        .addClass( 'tmbox-notice' )
 
        .addClass( 'collapsible' )
 
        .addClass( 'innercollapse' )
 
        .addClass( 'wpb' )
 
        .addClass( yesno( args.small ) and 'mbox-small' )
 
        .css( 'height', '0px' ) -- Valid HTML5 substitute for height="0"?
 
   
 
    local projectHeader = root.tag( 'tr' ).addClass( 'wpb-header' )
 
    if not self:getQualityRow() or not self:getImportanceRow() then
 
        projectHeader
 
            .tag( 'td' )
 
                .addClass( 'mbox-empty-cell' )
 
                .done()
 
            .tag( 'th' )
 
                .css( 'width', '100%' )
 
                .css( 'padding', '0.3em' )
 
                .wikitext( self:exportProjectHeader( args ) )
 
    else
 
        projectHeader
 
            .tag( 'td' )
 
                .css( 'text-align', 'right' )
 
                .css( 'padding', '0.3em 1em 0.3em 0.3em' )
 
                .css( 'width', '50%' )
 
                .css( 'font-weight', 'bold' )
 
                .wikitext( self:exportProjectHeader( args ) )
 
                .done()
 
            .tag( 'th' )
 
                .css( 'text-align', 'left' )
 
                .css( 'width', '50%' )
 
                .css( 'padding', '0.3em 0.3em 0.3em 0' )
 
                .wikitext( self:exportAssessmentHeader( args ) )
 
    end
 
   
 
    projectHeader
 
        .tag( 'td' )
 
            .addClass( 'mbox-empty-cell' )
 
            .tag( 'span' )
 
                .addClass( 'metadata' )
 
                .css( 'display', 'none' )
 
                .css( 'speak', 'none' )
 
                .tag( 'span' )
 
                    .addClass( 'wpb-project' )
 
                    .wikitext( self:getProject() )
 
                    .done()
 
                .tag( 'span' )
 
                    .addClass( 'wpb-project_link' )
 
                    .wikitext( self:getProjectLink() )
 
                    .done()
 
                .tag( 'span' )
 
                    .addClass( 'wpb-banner_name' )
 
                    .wikitext( self:getBannerName() )
 
                    .done()
 
                .tag( 'span' )
 
                    .addClass( 'wpb-assessment_cat' )
 
                    .wikitext( self:getAssessmentCategory() )
 
 
 
    local mainDisplayArea = root
 
        .tag( 'tr' )
 
            .tag( 'td' )
 
                .addClass( 'mbox-text' )
 
                .css( 'padding', '3px 0 3px 5px' )
 
                .attr( 'colspan', '2' )
 
                .tag( 'table' )
 
                    .css( 'background', 'transparent' )
 
                    .css( 'border', 'none' )
 
                    .css( 'padding', '0' )
 
                    .css( 'width', '100%' )
 
                    .css( 'border-spacing', '0' ) -- html5 replacement for cellspacing="0"
 
                    .css( 'border-collapse', 'collapse' ) -- this (apparently) emulates cellspacing="0" in Internet Explorer 5-7
 
                    .tag( 'tr' )
 
   
 
    if self:getLeftImage() then
 
        mainDisplayArea
 
            .tag( 'td' )
 
                .addClass( 'mbox-image' )
 
                .css( 'padding', '2px 0' )
 
                .wikitext( mw.ustring.format(
 
                    '[[File:%s|%s|alt=WikiProject icon]]',
 
                    self:getLeftImage(),
 
                    yesno( args.small ) and self:getLeftImageSizeSmall() or self:getLeftImageSizeLarge()
 
                ) )
 
    else
 
        mainDisplayArea
 
            .tag( 'td' )
 
                .addClass( 'mbox-empty-cell' )
 
    end
 
   
 
    mainDisplayArea
 
        .tag( 'td' )
 
            .addClass( 'mbox-text' )
 
            .wikitext( self:getPortal() and yesno( args.small ) and makePortal( getPortal() ) )
 
            .wikitext( makeNavbar{
 
                self:getBannerName(),
 
                mini = '1',
 
                style = 'float:right; clear:right; margin:-1em 0.1em; display:none;'
 
            } )
 
            .wikitext( mainText )
 
 
 
    return tostring( root )
 
end
 
 
 
-----------------------------------------------------------------
 
-- Export objects and functions to be used from other modules
 
-----------------------------------------------------------------
 
 
 
local p = {}
 
 
 
p.banner = banner
 
p.row = row
 
p.makeCheckSelfFunction = makeCheckSelfFunction
 
 
 
-----------------------------------------------------------------
 
-- Testing area
 
-----------------------------------------------------------------
 
 
 
function p.test( frame )
 
    local mybanner = banner:new()
 
    mybanner:setProject( 'Foo' )
 
    return mybanner:export()
 
end
 
 
 
return p
 

Revision as of 04:34, 18 February 2014

Usage

Template:Missing documentation {{#invoke:User:Mr. Stradivarius|function_name}}



return {
	foo = "foo",
	bar = "bar"
}