Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Rfx/doc
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{module rating|general}} This is a library for getting information about individual [[WP:RFA|requests for adminship]] (RfA) and [[WP:RFB|requests for bureaucratship]] (RfB) pages on the English Wikipedia. It is not meant to be used directly from wiki pages, but rather to be used by other Lua modules. === Creating new objects === First of all, the library must be loaded, like this: <syntaxhighlight lang="lua"> local rfx = require( 'Module:Rfx' ) </syntaxhighlight> Once the library is loaded, you can make a new rfx object using <code>rfx.new()</code>. {{red|Caution - this function is expensive}} (see [[#Expensive functions|below]]). <code>rfx.new()</code> is used like this: <syntaxhighlight lang="lua"> local myRfx = rfx.new( pagename ) </syntaxhighlight> The <code>pagename</code> variable should be the name of a valid RfA or RfB page, for example: <syntaxhighlight lang="lua"> local exampleRfa = rfx.new( 'Wikipedia:Requests for adminship/Example' ) </syntaxhighlight> If <code>pagename</code> is not specified, or the page is not a subpage of [[Wikipedia:Requests for adminship]] or [[Wikipedia:Requests for bureaucratship]], then <code>rfx.new</code> will return <code>nil</code>. === Methods and properties === Once you have created a new <code>rfx</code> object, there are a number of methods and properties that you can use. They are all read-only. ; Properties * <code>type</code>: the type of the rfx. This is either "<code>rfa</code>" or "<code>rfb</code>". * <code>supports</code>: the number of supports in the RfX. <code>nil</code> if the supports could not be processed. * <code>opposes</code>: the number of opposes in the RfX. <code>nil</code> if the opposes could not be processed. * <code>neutrals</code>: the number of neutrals in the RfX. <code>nil</code> if the neutrals could not be processed. * <code>percent</code>: the support percentage. Calculated by <math>\frac{\text{supports}}{\text{supports} + \text{opposes}} \times 100</math> and rounded to the nearest integer. <code>nil</code> if it could not be processed. * <code>endTime</code>: the end time of the RfX. This is a string value taken from the RfX page. <code>nil</code> if it could not be found. * <code>user</code>: the username of the RfX candidate. <code>nil</code> if it could not be found. ; Methods Methods must be called with the colon syntax: <syntaxhighlight lang="lua"> local titleObject = exampleRfa:getTitleObject() </syntaxhighlight> * <code>getTitleObject()</code>: gets the title object for the RfX page. See the [[:mw:Extension:Scribunto/Lua reference manual#Title objects|reference manual]] for details on how to use title objects. * <code>getSupportUsers()</code>: gets an array containing the usernames that supported the RfX. If any usernames could not be processed, the text "Error parsing signature" is used instead, along with the text of the comment in question. N.b. this technique relies on the text of comment text being unique - if it is not unique then <code>dupesExist()</code> will treat the identical comments as duplicate votes. If the page content could not be parsed at all, this method returns <code>nil</code>. * <code>getOpposeUsers()</code>: gets an array containing the usernames that opposed the RfX. Functions similarly to <code>getSupportUsers()</code>. * <code>getNeutralUsers()</code>: gets an array containing the usernames that were neutral at the RfX. Functions similarly to <code>getSupportUsers()</code>. * <code>dupesExist()</code>: returns a boolean indicating whether there were any duplicate votes at the RfX. Returns <code>nil</code> if the vote tables couldn't be processed. * <code>getSecondsLeft()</code>: returns the number of seconds left before the RfX is due to close. Once it is due to close, shows zero. If the ending time cannot be found, returns <code>nil</code>. * <code>getTimeLeft()</code>: returns a string showing the time left before the RfX is due to close. The string is in the format "<code>x days, y hours</code>". * <code>getReport()</code>: returns a [[rev:https://www.mediawiki.org/wiki/Extension:Scribunto/Lua reference manual#URI object#URI object|URI object]] for X!'s RfA Analysis tool at Wikimedia Labs, preloaded with the RfX page. * <code>getStatus()</code>: returns a string showing the current status of the RfX. This can be "successful", "unsuccessful", "open", or "pending closure". Returns <code>nil</code> if the status could not be determined. You can compare <code>rfx</code> objects with the <code>==</code> operator. This will return true only if the two objects point to the same page. <code>tostring( rfx )</code> will return <code>prefixedTitle</code> from the RfX page's title object (see the [[:mw:Extension:Scribunto/Lua reference manual#Title objects#Title objects|reference manual]]). === Expensive functions === This module makes use of the [[:mw:Extension:Scribunto/Lua reference manual#Title objects|title:getContent]] method to fetch RfX page sources. This method will be called for each RfX page being looked up, so each use of <code>rfx.new</code> will count as an [[:mw:Manual:$wgExpensiveParserFunctionLimit|expensive function call]]. Please be aware that the library may fail for scripts which create many different RfX objects. (The current limit for the English Wikipedia is 500 expensive function calls per page.) Also, each RfX page that is looked up will count as a [[WP:TRANSCLUSION|transclusion]] in [[Special:WhatLinksHere]].
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Module rating
(
edit
)
Template:Red
(
edit
)