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:40, 3 May 2013 (do supports, opposes, and neutrals). 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.retrieve_open_requests( frame )
    return ""
end

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 page_object = mw.title.new( "Wikipedia:Requests for adminship/MZMcBride" ) -- idk
    local text = page_object:getContent()
    --[==[
        page_text = page.read()
        support_find = re.search(r'(=|\'\'\')[ ]*Support[ ]*(=|\'\'\')+\n(.*)(=|\'\'\')[ ]*Oppose[ ]*(=|\'\'\')+\n', page_text, re.I|re.U|re.DOTALL)
        oppose_find = re.search(r'(=|\'\'\')[ ]*Oppose[ ]*(=|\'\'\')+\n(.*)(=|\'\'\')[ ]*Neutral[ ]*(=|\'\'\')+\n', page_text, re.I|re.U|re.DOTALL)
        neutral_find = re.search(r'(=|\'\'\')[ ]*Neutral[ ]*(=|\'\'\')+\n(.*)', page_text, re.I|re.U|re.DOTALL)
        votes_find = re.compile(r'^#[^:*\n]', re.I|re.U|re.M)
        supports = len(votes_find.findall(support_find.group(3)))
        opposes = len(votes_find.findall(oppose_find.group(3)))
        neutrals = len(votes_find.findall(neutral_find.group(3)))
        percent = float(supports)/(supports+opposes)*100
]==]
    local s_pattern = "'''Support'''"
    local o_pattern = "'''Oppose'''"
    local n_pattern = "'''Neutral'''"
    local s, o, n = 0, 0, 0
    for match in mw.ustring.gmatch( text, s_pattern ) do
        s = s + 1
    end
    for match in mw.ustring.gmatch( text, o_pattern ) do
        o = o + 1
    end
    for match in mw.ustring.gmatch( text, n_pattern ) do
        n = n + 1
    end
    return s, o, n
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