Module:Article history/doc
This is a documentation subpage for Module:Article history. It may contain usage information, categories and other content that is not part of the original module page. |
මෙම Lua module පිටු 42,000 පමණ භාවිතා වන නිසා සිදුකරන වෙනස් කිරීම් බොහෝ ස්ථානවලට බලපානු ඇත. ඔබ සිදුකිරීමට අදහස් කරන වෙනස්කම් මෙම මොඩියුලයට අදාළ /sandbox හෝ /testcases උපපිටු. එම වෙනස්කම් සිදුකිරීමට ප්රථම අදාළ සාකච්ඡා පිටුවේ ඒ පිළිබඳව සංවාදයක් ගොඩනැගීමට කාරුණික වන්න.
Transclusion count updated automatically (ප්රලේඛනය වෙතට යොමුවන්න). |
මෙම මොඩියුලය මතු දැක්වෙන මොඩියුල මත යැපෙයි: |
This module uses TemplateStyles: |
This module implements සැකිල්ල:Article history (සංස්කරණය|සාකච්ඡාව|ඉතිහාසය|සබැඳි|මුරකිරීම|ලඝු-සටහන්). Please see the template page for documentation of how to use it.
Technical details
[සංස්කරණය]This module has a configuration module at Module:Article history/config, which can be used to translate/modify the template for use on other wikis. See the config module for instructions on how to modify it. The configuration for the English Wikipedia is very complicated, but it is also possible to use it much more simply. If you want to use the more advanced features provided by the module, you can consult the class documentation below.
There is also a Category class at Module:Article history/Category, which is used by both the main module and the config module.
Class documentation
[සංස්කරණය]This is technical documentation for Lua programmers who are looking to adapt this module for use on different wikis.
Category
[සංස්කරණය]The Category class is used to generate all of the module's categories. It is loaded in both Module:Article history and Module:Article history/config. You can create a category with Category.new:
Category.new(cat, sort)
The cat variable is the category text, and sort is its sort key.
Once category objects are created, they have the following properties:
category
- the category namesortKey
- the sort key
They can be rendered into category links by calling tostring()
on them.
Message
[සංස්කරණය]The Message mixin contains common message-related methods which are available in all classes apart from the Category class. These methods are:
Message:message(key, ...)
- fetches a message with the key key from the config's msg table, and substitutes parameters $1, $2 etc. with the subsequent values it is passed.Message:raiseError(msg, help)
- formats msg and uses it to raise an error. help is an optional page that will provide help for the error that the user encountered. This is intended to be caught with ArticleHistory:try, and is for errors after which further processing in that object becomes impossible.Message:addWarning(msg, help)
- formats msg and uses it to add a warning. help is an optional page that will provide help for the error that the user encountered. This is for errors that should be fixed, but that do not prevent the module from outputting something useful for that object.Message:getWarnings()
- returns an array of all warnings added for the object.
ArticleHistory
[සංස්කරණය]An ArticleHistory object does the main work of the module. It fetches the different Row objects, renders the box, renders the error messages, and renders category links. ArticleHistory objects can use all methods from the Message mixin. They also have the following public properties:
args
- a table of the arguments passed to the module by the user.currentTitle
- the title object for the current page.cfg
- the module config table. This is taken from the config module at Module:Article history/config, but is structured slightly differently due to preprocessing by the main module. Any table with an "aliases" subtable has this table removed, and the aliases are added as keys that the table can be accessed from. Conceptually, the config table{ foo = {"a value", aliases = {"bar", "baz"} } }
would become{foo = {"a value"}, bar = {"a value"}, baz = {"a value"} }
. (Although "bar" and "baz" would actually be references to the "foo" table, rather than completely new tables.)prefixArgs
- a table of the arguments passed to the module by the user, sorted by their prefix and then their number. Non-string keys and keys that don't contain a number are ignored. (This means that positional parameters are ignored, as they are numbers, not strings.) The parameter numbers are stored in the first positional parameter of the subtables, and any gaps are removed so that the tables can be iterated over with ipairs. For example, the arguments{a1x = 'eggs', a1y = 'spam', a2x = 'chips', b1z = 'beans', b3x = 'bacon'}
would translate into the prefixArgs table{a = { {1, x = 'eggs', y = 'spam'}, {2, x = 'chips'} }, b = { {1, z = 'beans'}, {3, x = 'bacon'} } }
.
ArticleHistory objects have the following public methods:
ArticleHistory:try(func, ...)
- calls the function func with the arguments passed, and returns the first value produced by it. If any errors are encountered, they are caught and added to the object's internal errors table for later rendering by ArticleHistory:getErrorMessages.ArticleHistory:getActionObjects()
- returns an array containing the Action objects for any actions specified by the user.ArticleHistory:getStatusIdForCode(code)
- for the status code code, returns the canonical status ID.ArticleHistory:getStatusObj()
- gets the status object for the template. This returns nil if no current status can be found.ArticleHistory:getStatusId()
- returns the status ID for the template. This returns nil if no current status can be found.ArticleHistory:getNoticeObjects()
- returns an array containing the template's Notice objects.ArticleHistory:getCollapsibleNoticeObjects()
- returns an array containing the template's CollapsibleNotice objects.ArticleHistory:getAllObjects(addSelf)
- returns an array containing all Status/MultiStatus, Notice, Action and CollapsibleNotice objects. if addSelf is true, the ArticleHistory object is appended to the array as well.ArticleHistory:getNoticeBarIcons()
- returns an array of icons to be displayed on the notice bar (at the top-left of the collapsible table).ArticleHistory:getErrorMessages()
- returns an array containing all error and warning strings. Errors are typically raised with Message:raiseError and caught with ArticleHistory:try, and warnings are added to individual objects with Message:addWarning.ArticleHistory:renderHtml()
- renders the HTML table comprising all the visible output of the template, including status, notices, actions, collapsible notices, error messages and warnings. The result is returned as a string.ArticleHistory:renderCategories()
- renders all category links and returns them as a string.
Calling tostring()
on an ArticleHistory object gives you the HTML table made with ArticleHistory:renderHtml concatenated with the category links made with ArticleHistory:renderCategories.
Row
[සංස්කරණය]Row objects can use all methods from the Message mixin. They also have the following public properties:
currentTitle
- the same as ArticleHistory.currentTitle.cfg
- the same as ArticleHistory.cfg.
Row objects have the following public methods:
Row:getData(articleHistoryObj)
- get memoized data for the object that has been created with a makeData function in the module config page. This mechanism is used to stop config page functions from having to do the same data processing more than once. It must be passed an ArticleHistory object to find the data from. This returns nil if no data was generated or an error was encountered while generating the data.Row:setIconValues(icon, caption, size)
- set icon values for the object. icon is the icon filename without any namespace prefix, caption is a caption to use with the icon, and size is the size of the icon when output with a large banner. icon and caption can be functions which take an ArticleHistory object as input and return the icon or caption value respectively. Sizes should include any suffixes, e.g. "30px".Row:getIcon(articleHistoryObj)
- get the icon filename. It must be passed an ArticleHistory object. Returns nil if no icon was set.Row:getIconCaption(articleHistoryObj)
- get the icon caption. It must be passed an ArticleHistory object. Returns nil if no caption was set.Row:getIconSize()
- get the icon size.Row:renderIcon(articleHistoryObj)
- renders the icon for the object. Returns nil if no icon was set.Row:setNoticeBarIconValues(icon, caption, size)
- set notice bar icon values for the object. (The notice bar icons are the small icons that appear at the top left of the collapsible box containing the actions.) icon is the icon filename without any namespace prefix, caption is a caption to use with the icon, and size is the size of the icon. icon and caption can be functions which take an ArticleHistory object as input and return the icon or caption value respectively. Sizes should include any suffixes, e.g. "15px".Row:getNoticeBarIcon(articleHistoryObj)
- get the notice bar icon filename. It must be passed an ArticleHistory object. Returns nil if no icon was set.Row:getNoticeBarCaption(articleHistoryObj)
- get the notice bar icon caption. It must be passed an ArticleHistory object. Returns nil if no caption was set.Row:getNoticeBarIconSize()
- get the notice bar icon size.Row:exportNoticeBarIcon(articleHistoryObject)
- returns the rendered notice bar icon link. This method must be passed an ArticleHistory object.Row:setText(text)
- set the text for the object to output. This may be a string or a function that takes an ArticleHistory object as input and returns the text as output.Row:getText(articleHistoryObject)
- gets the row text. This method must be passed an ArticleHistory object.Row:exportHtml(articleHistoryObject)
- returns the rendered row. This method must be passed an ArticleHistory object.Row:setCategories(val)
- sets the objects categories. val may be either an array of strings, or a function that takes an ArticleHistory object as input and returns an array of Category objects as output.Row:getCategories(articleHistoryObj)
- returns an array containing the object's Category objects. This method must be passed an ArticleHistory object.
Status
[සංස්කරණය]Status objects generate the row detailing the current status of the article. They inherit all properties and methods from Row objects, including the Message mixin methods. They have the following additional properties:
id
- the status ID.name
- the status name.statusCfg
- the status config table for the object's status ID.
MultiStatus
[සංස්කරණය]MultiStatus objects are variations on Status objects for articles that can have multiple current statuses, e.g. Good Article and Former Featured Article. They can be used interchangeably with Status objects.
Notice
[සංස්කරණය]Notice objects generate rows containing notices about the article that aren't part of its current status, e.g. the date the article was featured on the Main Page. They inherit all the properties and methods from Row objects, including the Message mixin methods. They don't have any additional properties or methods.
Action
[සංස්කරණය]Action objects generate rows detailing a single action in the history of an article, e.g. a Featured Article candidacy. They inherit all properties and methods from Row objects, including the Message mixin methods. They have the following additional properties:
paramNum
- the parameter number for that action. Used to format error messages.id
- the action ID. For example, featured article candidacies have an ID of "FAC". There is only one ID for each kind of action.actionCfg
- the action config table for the object's action ID.link
- the link set for the action, or the current talk page name if not set.resultId
- the ID for the result of the action. For example, featured article candidates that were promoted have a resultId of "promoted". There is only one resultId for each possible result of an action.date
- the date the action was carried out, or the 'action-date-missing' message if a date was not set.oldid
- the oldid for the action. Nil if not set.
Action objects have the following additional methods:
Action:getParameter(key)
- finds the original parameter name for the key key that was passed to Action.new.Action:getName(articleHistoryObject)
- gets the name of the action. This method must be passed an ArticleHistory object.Action:getResult(articleHistoryObject)
- gets the result text of the action. This method must be passed an ArticleHistory object.
CollapsibleNotice
[සංස්කරණය]CollapsibleNotice objects generate rows containing notices that go in the collapsible part of the template, underneath the list of actions. They can also include a collapsible text field. This is used for notices that are not important enough to be displayed as a (more prominent) Notice object, e.g. DYK notices. CollapsibleNotice objects inherit all the properties and methods from Row objects, including the Message mixin methods. They don't have any additional properties, but they have the following additional methods:
CollapsibleNotice:setCollapsibleText(s)
- set's s as the text to be displayed in the object's collapsible text field.CollapsibleNotice:getCollapsibleText(s)
- returns the text to be displayed in the object's collapsible text field.