Content deleted Content added
update helper function docs, add quality row and importance row classes, add a couple of banner methods |
add some new methods and begin conversion to wikitext |
||
Line 1:
== Helper functions ==
==== checkString ====
<code style="white-space: nowrap;">checkString( s )</code>
Checks to see if <code style="white-space: nowrap;">s</code> is a non-blank string. Returns <code style="white-space: nowrap;">s</code> if true, and returns <code style="white-space: nowrap;">false</code> if not.
:Input type: string
==== addStringToArray ====
<code style="white-space: nowrap;">addStringToArray( t, s )</code>
Adds the string <code style="white-space: nowrap;">s</code> to the array <code style="white-space: nowrap;">t</code>. Returns <code style="white-space: nowrap;">nil</code> on an attempt to add a non-string value or a blank string, and raises an error on an attempt to add a string to a non-table value. If the array is not present, it is created.
==== checkObject ====
<code style="white-space: nowrap;">checkObject( obj, objType )</code>
Checks to see if the object <code style="white-space: nowrap;">obj</code> inherits from <code style="white-space: nowrap;">objType</code> (a string value). Returns <code style="white-space: nowrap;">obj</code> if true, and returns <code style="white-space: nowrap;">false</code> if not.
== Class definitions ==
Line 15 ⟶ 24:
=== All classes ===
All classes have a property <code style="white-space: nowrap;">class._type</code>, which
==== class:makeCheckSelfFunction ====
<code style="white-space: nowrap;">class:makeCheckSelfFunction()</code>
This method generates a function that checks for mistaken use of the dot syntax with methods. It is used like this:
<source lang="lua">
local newClass = class:new()
local checkSelfNewClass = newClass:makeCheckSelfFunction()
function newClass:method1()
checkSelfNewClass( self, 'method1' )
-- Method code
end
function newClass:method2()
checkSelfNewClass( self, 'method2' )
-- Method code
end
</source>
This function may fail in a small subset of cases: it only checks that an object inherits from <code style="white-space: nowrap;">newClass</code>, not that it is the right object. This should account for most errors, however, and changing the code to check for 100% of cases would be non-trivial.
=== banner class ===
The main class for WikiProject banners. Defines the wikitext for the banner box, specifies the project name, the main image, and other things relevant to the banner as a whole.
Initiated with:
<code style="white-space: nowrap;">banner:new()</code>
Methods:
<code style="white-space: nowrap;">banner:setProject( s )</code>
Sets the string <code style="white-space: nowrap;">s</code> as the project value. The project value is the name of the project without any surrounding text. For example, the project value for WikiProject Tulips would be <code style="white-space: nowrap;">Tulips</code>. The project value is required for the banner to be displayed.
==== banner:getProject ====
<code style="white-space: nowrap;">banner:getProject()</code>
Gets the project value. If no project value is set, raises an error.
==== banner:setProjectLink ====
<code style="white-space: nowrap;">banner:setProjectLink( s )</code>
Sets the string <code style="white-space: nowrap;">s</code> as the project link. The project link is the name of the WikiProject's main page on Wikipedia. For example, the main page for WikiProject Tulips would be <code style="white-space: nowrap;">Wikipedia: WikiProject Tulips</code>.
==== banner:getProjectLink ====
<code style="white-space: nowrap;">banner:getProjectLink()</code>
Gets the project link. If no project link was specified with <code style="white-space: nowrap;">banner:setProjectLink</code>, then it is generated using <code style="white-space: nowrap;">banner:getProject</code>.
==== banner:setProjectName ====
<code style="white-space: nowrap;">banner:setProjectName( s )</code>
Sets the string <code style="white-space: nowrap;">s</code> as the project name. The project name is the name of the WikiProject's main page on Wikipedia. For example, the main page for WikiProject Tulips would be <code style="white-space: nowrap;">Wikipedia: WikiProject Tulips</code>.
==== banner:getProjectName ====
<code style="white-space: nowrap;">banner:getProjectName()</code>
Gets the project name. If no project name was specified with <code style="white-space: nowrap;">banner:setProjectName</code>, then it is generated using <code style="white-space: nowrap;">banner:getProject</code>.
==== banner:setBannerName ====
<code style="white-space: nowrap;">banner:setBannerName( s )</code>
Sets the string <code style="white-space: nowrap;">s</code> as the banner name. The banner name is the name of the WikiProject's main page on Wikipedia. For example, the main page for WikiProject Tulips would be <code style="white-space: nowrap;">Wikipedia: WikiProject Tulips</code>.
==== banner:getBannerName ====
<code style="white-space: nowrap;">banner:getBannerName()</code>
Gets the banner name. If no banner name was specified with <code style="white-space: nowrap;">banner:setBannerName</code>, then it is generated using <code style="white-space: nowrap;">banner:getProject</code>.
==== banner:setAssessmentCategory ====
<code style="white-space: nowrap;">banner:setAssessmentCategory( s )</code>
Sets the string <code style="white-space: nowrap;">s</code> as the assessment category. The assessment category is the name of the WikiProject's main page on Wikipedia. For example, the main page for WikiProject Tulips would be <code style="white-space: nowrap;">Wikipedia: WikiProject Tulips</code>.
==== banner:getAssessmentCategory ====
<code style="white-space: nowrap;">banner:getAssessmentCategory()</code>
Gets the assessment category. If no assessment category was specified with <code style="white-space: nowrap;">banner:setAssessmentCategory</code>, then it is generated using <code style="white-space: nowrap;">banner:getProject</code>.
==== banner:setImage ====
<code style="white-space: nowrap;">banner:setImage( s )</code>
Sets the main image for the banner.
:Input type: string
==== banner:getImage ====
<code style="white-space: nowrap;">banner:getImage()</code>
Gets the main image for the banner.
<code style="white-space: nowrap;">banner:addCategory( s )</code>
Adds one category to the banner object.
:Input type: string (no double brackets and no "Category:" text)
==== banner:addCategories ====
<code style="white-space: nowrap;">banner:addCategories( t )</code>
Adds multiple categories to the banner object.
:Input type: array of strings
==== banner:getCategories ====
<code style="white-space: nowrap;">banner:getCategories()</code>
Gets an array containing the category names for the banner object.
<code style="white-space: nowrap;">banner:exportCategories()</code>
Returns a string containing all the banner's categories ready for output on a wiki page.
<code style="white-space: nowrap;">banner:addRow( rowObject )</code>
Adds a row object to the banner.
:Input type: Row object.
==== banner:addRows ====
<code style="white-space: nowrap;">banner:addRows( t )</code>
Adds an array of row objects to the banner object.
:Input type: array of row objects.
==== banner:export ====
<code style="white-space: nowrap;">banner:export()</code>
Exports the banner to wikitext ready for display on wiki pages.
Line 71 ⟶ 183:
Initiated with:
<code style="white-space: nowrap;">row:new()</code>
Methods:
<code style="white-space: nowrap;">row:addCategory( s )</code>
Adds a category to the row object.
:Input type: string (no double brackets and no "Category:" text)
==== row:addCategories ====
<code style="white-space: nowrap;">row:addCategories( t )</code>
Adds multiple categories to the row object.
:Input type: array of strings
==== row:getCategories ====
<code style="white-space: nowrap;">row:getCategories()</code>
Gets an array containing the category names for the row object.
<code style="white-space: nowrap;">row:export()</code>
Exports the row object to wikitext to be passed to the banner object's export method.
Line 94 ⟶ 219:
Initiated with:
<code style="white-space: nowrap;">qualityRow:new()</code>
Methods:
<code style="white-space: nowrap;">qualityRow:setQualityScale( obj )</code>
Sets the quality scale for the quality row.
:Input type: qualityScale object
==== qualityRow:setStandardQualityScale ====
<code style="white-space: nowrap;">qualityRow:setStandardQualityScale()</code>
Sets the standard quality scale with default settings.
<code style="white-space: nowrap;">qualityRow:setExtendedQualityScale()</code>
Sets the extended quality scale with default settings.
<code style="white-space: nowrap;">qualityRow:getQualityScale()</code>
Gets the quality scale object if it is set.
Line 116 ⟶ 254:
Initiated with:
<code style="white-space: nowrap;">importanceRow:new()</code>
Methods:
<code style="white-space: nowrap;">importanceRow:setImportanceScale( obj )</code>
Sets the importance scale for the importance row.
:Input type: importanceScale object
==== importanceRow:setStandardImportanceScale ====
<code style="white-space: nowrap;">importanceRow:setStandardImportanceScale()</code>
Sets the standard importance scale with default settings.
<code style="white-space: nowrap;">importanceRow:getImportanceScale()</code>
Gets the importance scale object if it is set.
Line 135 ⟶ 283:
Initiated with:
<code style="white-space: nowrap;">assessmentScale:new()</code>
Methods:
<code style="white-space: nowrap;">assessmentScale:setParamName( s )</code>
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".
:Input type: string
==== assessmentScale:getParamName ====
<code style="white-space: nowrap;">assessmentScale:getParamName()</code>
Gets the parameter name.
<code style="white-space: nowrap;">assessmentScale:setCategoryFamily( s )</code>
Sets the name of the category family. For example, for a quality scale with categories such as <code><nowiki>[[Category:C-class tulips articles]]</nowiki></code> and <code><nowiki>[[Category:List-class tulips articles]]</nowiki></code> the category family name would be "tulips articles".
:Input type: string
==== assessmentScale:getCategoryFamily ====
<code style="white-space: nowrap;">assessmentScale:getCategoryFamily()</code>
Gets the category family name.
<code style="white-space: nowrap;">assessmentScale:addGrade( assessmentGradeObject )</code>
Adds an assessmentGrade object to the assessment scale (usually this will be a qualityGrade or an importanceGrade object). The assessmentGrade objects added to an assessmentScale object determine the grades on its assessment scale. If the assessmentGrade object is already present in the assessment scale, an error will be raised.
:Input type: assessmentGrade object
==== assessmentScale:addGrades ====
<code style="white-space: nowrap;">assessmentScale:addGrades( t )</code>
Adds an array of multiple assessmentGrade objects to the assessmentScale object.
:Input type: array of assessmentGrade objects
==== assessmentScale:removeGrade ====
<code style="white-space: nowrap;">assessmentScale:removeGrade( s )</code>
Removes one grade from the assessment scale.
:Input type: string
==== assessmentScale:removeGrades ====
<code style="white-space: nowrap;">assessmentScale:removeGrades( t )</code>
Removes multiple grades from the assessment scale.
:Input type: array of strings
==== assessmentScale:getGrades ====
<code style="white-space: nowrap;">assessmentScale:getGrades()</code>
Returns the table containing the assessmentGrade objects.
<code style="white-space: nowrap;">assessmentScale:getGrade( s )</code>
Returns the specified grade object if it is set in the assessment scale.
<code style="white-space: nowrap;">assessmentScale:editGrade( gradeName, method, ... )</code>
Edits the assessment grade object named "gradeName", using the assessment grade object's method "method". The third and subsequent arguments are passed as arguments to "method". This is a convenience function, to avoid having to remove a whole assessment grade object from the assessment scale, edit it, and then add it again.
gradeName input type: string
method input type: string
<code style="white-space: nowrap;">assessmentScale:checkForDuplicateTriggers()</code>
Checks for duplicate triggers in the grade objects added to the assessment scale. If any are found, displays an error.
Line 188 ⟶ 373:
Initiated with:
<code style="white-space: nowrap;">qualityScale:new()</code>
Methods:
<code style="white-space: nowrap;">qualityScale:setFaGrade()</code>
Sets an FA (Featured Article) grade with the default settings. The grade name is set to "fa", there is one trigger of "fa", the color is "#6699ff", and the icon is "Featured article star.svg".
<code style="white-space: nowrap;">qualityScale:setAGrade()</code>
Sets an A grade with the default settings. The grade name is set to "a", there is one trigger of "a", the color is "#66ffff", and the icon is "Symbol a class.svg.svg".
<code style="white-space: nowrap;">qualityScale:setGaGrade()</code>
Sets a GA (Good Article) grade with the default settings. The grade name is set to "ga", there is one trigger of "ga", the color is "#66ff66", and the icon is "Symbol support vote.svg".
<code style="white-space: nowrap;">qualityScale:setBGrade()</code>
Sets a B grade with the default settings. The grade name is set to "b", there is one trigger of "b", and the color is "#b2ff66".
<code style="white-space: nowrap;">qualityScale:setCGrade()</code>
Sets a C grade with the default settings. The grade name is set to "c", there is one trigger of "c", and the color is "#ffff66".
<code style="white-space: nowrap;">qualityScale:setStartGrade()</code>
Sets a Start grade with the default settings. The grade name is set to "start", there is one trigger of "start", and the color is "#ffaa66".
<code style="white-space: nowrap;">qualityScale:setStubGrade()</code>
Sets a Stub grade with the default settings. The grade name is set to "stub", there is one trigger of "stub", and the color is "#ff6666".
<code style="white-space: nowrap;">qualityScale:setFlGrade()</code>
Sets an FL (Featured List) grade with the default settings. The grade name is set to "fl", there is one trigger of "fl", the color is "#6699ff", and the icon is "Featured article star.svg".
<code style="white-space: nowrap;">qualityScale:setListGrade()</code>
Sets a List grade with the default settings. The grade name is set to "list", there is one trigger of "list", and the color is "#aa88ff".
<code style="white-space: nowrap;">qualityScale:setNaGrade()</code>
Sets a NA (not applicable) grade with the default settings. The grade name is set to "na", there are two triggers of "na" and "n/a", and the color is "#f5f5f5".
<code style="white-space: nowrap;">qualityScale:setCategoryGrade()</code>
Sets a Category grade with the default settings. The grade name is set to "category", there are three triggers of "category", "cat" and "categ", and the color is "#ffdb58".
<code style="white-space: nowrap;">qualityScale:setDisambigGrade()</code>
Sets a Disambig (disambiguation) grade with the default settings. The grade name is set to "disambig", there are four triggers of "disambiguation", "disambig", "disamb" and "dab", and the color is "#00fa9a".
<code style="white-space: nowrap;">qualityScale:setFileGrade()</code>
Sets a File grade with the default settings. The grade name is set to "file", there are three triggers of "file", "img" and "image", and the color is "#ddccff".
<code style="white-space: nowrap;">qualityScale:setPortalGrade()</code>
Sets a Portal grade with the default settings. The grade name is set to "portal", there is one trigger of "portal", and the color is "#cc8899".
<code style="white-space: nowrap;">qualityScale:setProjectGrade()</code>
Sets a Project grade with the default settings. The grade name is set to "project", there are three triggers of "project", "proj" and "prj", and the color is "#c0c090".
<code style="white-space: nowrap;">qualityScale:setTemplateGrade()</code>
Sets a Template grade with the default settings. The grade name is set to "template", there are five triggers of "template", "temp", "tpl", "tmp" and "templ", and the color is "#fbceb1".
<code style="white-space: nowrap;">qualityScale:setRedirectGrade()</code>
Sets a Redirect grade with the default settings. The grade name is set to "redirect", there are three triggers of "redirect", "red" and "redir", and the color is "#c0c0c0".
<code style="white-space: nowrap;">qualityScale:setFmGrade()</code>
Sets an FM (Featured Media) grade with the default settings. The grade name is set to "fm", there is one trigger of "fm", the color is "#6699ff", and the icon is "Featured article star.svg".
<code style="white-space: nowrap;">qualityScale:setStandardQualityScale()</code>
Sets the standard quality scale, with grades of FA, A, GA, B, C, Start, Stub, FL, List and NA. All the grades have the default values.
<code style="white-space: nowrap;">qualityScale:setExtendedQualityScale()</code>
Sets the extended quality scale, with the grades in the standard quality scale plus grades of Category, Disambig, File, Portal, Project, and Template. All the grades have the default values.
Line 257 ⟶ 503:
Initiated with:
<code style="white-space: nowrap;">importanceScale:new()</code>
Methods:
<code style="white-space: nowrap;">importanceScale:setTopGrade()</code>
Sets a Top importance grade with the default settings. The grade name is set to "top", there is one trigger of "top", and the color is "#ff00ff".
<code style="white-space: nowrap;">importanceScale:setHighGrade()</code>
Sets a High importance grade with the default settings. The grade name is set to "high", there is one trigger of "high", and the color is "#ff88ff".
<code style="white-space: nowrap;">importanceScale:setMidGrade()</code>
Sets a Mid importance grade with the default settings. The grade name is set to "mid", there is one trigger of "mid", and the color is "#ffbbff".
<code style="white-space: nowrap;">importanceScale:setLowGrade()</code>
Sets a Low importance grade with the default settings. The grade name is set to "low", there is one trigger of "low", and the color is "#ffddff".
<code style="white-space: nowrap;">importanceScale:setBottomGrade()</code>
Sets a Bottom importance grade with the default settings. The grade name is set to "bottom", there is one trigger of "bottom", and the color is "#ffeeff".
<code style="white-space: nowrap;">importanceScale:setNoGrade()</code>
Sets a No importance grade with the default settings. The grade name is set to "no", there is one trigger of "no", and the color is "#ffffff".
<code style="white-space: nowrap;">importanceScale:setNaGrade()</code>
Sets a NA importance grade with the default settings. The grade name is set to "na", there are two triggers of "na" and "n/a", and the color is "#f5f5f5".
<code style="white-space: nowrap;">importanceScale:setCoreGrade()</code>
Sets a Core importance grade with the default settings. The grade name is set to "core", there is one trigger of "core", and the color is "#ff00ff".
<code style="white-space: nowrap;">importanceScale:setStandardImportanceScale()</code>
Sets the standard importance scale of Top, High, Mid, Low, and NA, with the default settings.
Line 293 ⟶ 567:
Initiated with:
<code style="white-space: nowrap;">assessmentGrade:new()</code>
Methods:
<code style="white-space: nowrap;">assessmentGrade:setGradeName( s )</code>
Sets the name of the assessment grade. For example, for a C-class quality grade, the grade name would be "c".
:Input type: string
==== assessmentGrade:getGradeName ====
<code style="white-space: nowrap;">assessmentGrade:getGradeName()</code>
Gets the name of the assessment grade.
<code style="white-space: nowrap;">assessmentGrade:addTrigger( s )</code>
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".
:Input type: string
==== assessmentGrade:addTriggers ====
<code style="white-space: nowrap;">assessmentGrade:addTriggers( t )</code>
Adds multiple triggers for the assessment grade.
:Input type: array of strings
==== assessmentGrade:getTriggers ====
<code style="white-space: nowrap;">assessmentGrade:getTriggers()</code>
Gets the array of triggers for the assessment grade.
<code style="white-space: nowrap;">assessmentGrade:setCategory( s )</code>
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 assessmentScale objects or banner objects.
<code style="white-space: nowrap;">assessmentGrade:getCategory()</code>
Gets the category for the assessment grade, if one was set with assessmentGrade:setCategory.
<code style="white-space: nowrap;">assessmentGrade:setColor( s )</code>
Sets the color used for icon boxes etc. used by the assessment grade.
:Input type: string (should be a valid css color value, e.g. '#gg99ff')
==== assessmentGrade:getColor ====
<code style="white-space: nowrap;">assessmentGrade:getColor()</code>
Gets the assessment grade color.
<code style="white-space: nowrap;">assessmentGrade:setIcon( s )</code>
Sets the icon for the assessment grade, e.g. the featured article star for featured articles. This is optional - not every assessmentGrade object needs an icon. If specified, it should be a valid file name, without the "File:" prefix.
:Input type: string
==== assessmentGrade:getIcon ====
<code style="white-space: nowrap;">assessmentGrade:getIcon()</code>
Gets the icon file name.
=== qualityGrade class ===
The quality grade class defines quality grades on a quality scale. It inherits methods from the <code style="white-space: nowrap;">assessmentGrade</code> class.
Methods:
Line 345 ⟶ 653:
=== importanceGrade class ===
The
Methods:
|