Jump to content

Module:RFX report

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Legoktm (talk | contribs) at 04:29, 3 May 2013 (thx franny). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

--[==[
Bugs:

* Add a purge link?
** Or have the bot purge the page every so often, heh.
* Only output bureaucrat header as needed.
* Only output table as needed....
* Extract color logic from {{bureaucrat candidate}}?

----
|{{#ifeq:{{{expired}}}|yes|style="background:#F8CDC6"}}|[[Wikipedia:Requests for {{#ifeq:{{{rfa}}}|yes|adminship|bureaucratship}}/{{{candidate}}}{{#if:{{{run|}}}|_{{{run}}}}}|{{{candidate}}}]]
|align="right" {{#ifeq:{{{expired}}}|yes|style="background:#F8CDC6"}}|[[Wikipedia:Requests for {{#ifeq:{{{rfa}}}|yes|adminship|bureaucratship}}/{{{candidate}}}{{#if:{{{run|}}}|_{{{run}}}}}#Support|{{{support}}}]]
|align="right" {{#ifeq:{{{expired}}}|yes|style="background:#F8CDC6"}}|[[Wikipedia:Requests for {{#ifeq:{{{rfa}}}|yes|adminship|bureaucratship}}/{{{candidate}}}{{#if:{{{run|}}}|_{{{run}}}}}#Oppose|{{{oppose}}}]]
|align="right" {{#ifeq:{{{expired}}}|yes|style="background:#F8CDC6"}}|[[Wikipedia:Requests for {{#ifeq:{{{rfa}}}|yes|adminship|bureaucratship}}/{{{candidate}}}{{#if:{{{run|}}}|_{{{run}}}}}#Neutral|{{{neutral}}}]]
|align="right" bgcolor="{{Template:Bureaucrat candidate/expr{{#if:{{{crat|}}}|2}}|{{#ifeq:{{{support|}}}{{{oppose|}}}|0||{{#if:{{{support|}}}{{{oppose|}}}|{{#expr: ({{{support}}} / ({{{support}}} + {{{oppose}}}) ) * 100 round 0 }}}}}}}}" |{{#ifeq:{{{support|}}}{{{oppose|}}}|0||{{#if:{{{support|}}}{{{oppose|}}}|{{#expr: ({{{support}}} / ({{{support}}} + {{{oppose}}}) ) * 100 round 0 }}}}}}
|{{#ifeq:{{{expired}}}|yes|style="background:#F8CDC6"}}|{{{end date}}}
|{{#ifeq:{{{expired}}}|yes|style="background:#F8CDC6"}}|{{{time left}}}
|{{#ifeq:{{{expired}}}|yes|style="background:#F8CDC6"}}|<center>{{{dups}}}</center>
|{{#ifeq:{{{expired}}}|yes|style="background:#F8CDC6"}}|[http://toolserver.org/~tparis/rfa/?p=Wikipedia:Requests_for_{{#ifeq:{{{rfa}}}|yes|adminship|bureaucratship}}/{{urlencode:{{{candidate}}}}} report]
----
]==]

local p = {}

function p.parse( frame ) 
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template
    -- Page is a string of the page name
    local page = frame.page
    local pgobject = mw.title.new( "Wikipedia:Requests for adminship/MZMcBride" ) -- idk
    local text = pgobject:getContent()
    --support_find = re.search(r'(=|\'\'\')[ ]*Support[ ]*(=|\'\'\')+\n(.*)(=|\'\'\')[ ]*Oppose[ ]*(=|\'\'\')+\n', page_text, re.I|re.U|re.DOTALL)
    local spattern = "'''Support'''" --lets start simple..
    local count = 0
    for thing in mw.ustring.gmatch( text, spattern ) do
        count = count + 1
    end
    return count
end

function p.print( frame )
    report = [===[
{| align="right" cellspacing="0" cellpadding="0" style="white-space:wrap; clear: left; margin-top: 0em; margin-bottom: .5em; float: right;padding: .5em 0em 0em 1.4em; background: none;"
|
{| class="wikitable"
! RfA candidate
! <abbr title="Supports">S</abbr>
! <abbr title="Opposes">O</abbr>
! <abbr title="Neutrals">N</abbr>
! <abbr title="Percent supporting">S%</abbr>
! Ending ([[Coordinated Universal Time|UTC]])
! Time remaining
! Report
|-
| [[Wikipedia:Requests for adminship/Example|Example]]
| align="right" | [[Wikipedia:Requests for adminship/Example#Support|10]]
| align="right" | [[Wikipedia:Requests for adminship/Example#Oppose|10]]
| align="right" | [[Wikipedia:Requests for adminship/Example#Neutral|10]]
| align="right" bgcolor="b1ffbb" | 50
| 03:20, 9 May 2013
| 6 days, 1 hours
| [http://toolserver.org/~tparis/rfa/?p=Wikipedia:Requests_for_adminship/Example report]
|-
| [[Wikipedia:Requests for adminship/Example|Example]]
| align="right" | [[Wikipedia:Requests for adminship/Example#Support|0]]
| align="right" | [[Wikipedia:Requests for adminship/Example#Oppose|0]]
| align="right" | [[Wikipedia:Requests for adminship/Example#Neutral|0]]
| align="right" bgcolor="b4ffbb" | 0
| 23:41, 7 May 2013
| 4 days, 22 hours
| [http://toolserver.org/~tparis/rfa/?p=Wikipedia:Requests_for_adminship/Example report]
|}
|}
]===]
    return report
end
 
return p