From Wikipedia, the free encyclopedia

local p = {

    --collect categories to avoid cluttering the HTML tree.

    category = {},

    includeonly = {},

    errors = {},

    title = mw.title.getCurrentTitle(),

}



--If the latest FAR failed

--If currentstatus is FA or FL ==> Do nothing

--If there is no currentstatus ==> Error

--Else ==> FFA tr

function p._statusFFA(args, action)

    local row = mw.html.create()

    local result = mw.ustring.upper(args'action' .. action .. 'result'])

    local status = mw.ustring.upper(args'currentstatus'])



    if result == 'FAILED' or result == 'REMOVED'  or result == 'FAIL' or result == 'REMOVE' or result == 'DEMOTED' then

        if status == 'FA' and status == 'FL' then

            -- Do nothing

        elseif status then

            if status == 'FFA/GA' or args'small' == 'yes' then

                iconsize = 30

            else

                iconsize = 50

            end

            

            row

                :tag('tr')

                :tag('td')

                    :addClass('mbox-image')

                    :wikitext('[[File:Featured article star - cross.svg|' .. iconsize .. 'px|Former featured article]]')

                    :done()

                :tag('td')

                    :addClass('mbox-text')

                    :wikitext("'''" .. p.title.prefixedText .. "''' is a [[Wikipedia:Former featured articles|former featured article]]. "..

                        "Please see the links under Article milestones below for its original nomination page (for older articles, check " ..

                        "[[Wikipedia:Featured article candidates/Archived nominations/Index|the nomination archive]]) and why it was removed.")

                    table.insert(p.includeonly, "[[Category:Wikipedia former featured articles]]")

        else

            row

                :tag('tr')

                :addClass('error')

                :tag('td')

                    :addClass('mbox-image')

                    :wikitext("[[File:Imbox deletion.png]]")

                    :done()

                :tag('td')

                    :addClass('mbox-text')

                    :wikitext('Former featured articles should have a current status!')

                    :done()

                :done()

                table.insert(p.errors, '[[Category:ArticleHistory error]]')

        end

    end

    return tostring(row)

end



function p.statusFAC(args)

    local row = mw.html.create()

    row

        :tag('tr')

            :addClass('error')

            :tag('td')

                :addClass('mbox-image')

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''Use the template {{[[Template:fac|fac]]}} to nominate an article for Featured article status; " ..

                    "this simplifies the nomination procedure. A bot will add the details to the ArticleHistory template when the FAC process is closed.'''")

            :done()

        :done()

        table.insert(p.errors, '[[Category:ArticleHistory error]]')

    return tostring(row)

end



function p.statusFFAC(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-former.svg|" .. iconsize .. "px]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''" .. p.title.prefixedText .. "''' is a former [[Wikipedia:Featured article candidates|featured article candidate]]. "..

                    "Please view the links under Article milestones below to see why the nomination failed. " ..

                    "For older candidates, please check the [[Wikipedia:Featured article candidates/Archived nominations/Index|archive]].")

                table.insert(p.includeonly, "[[Category:Wikipedia featured article candidates (contested)]]")

    return tostring(row)

end



function p.statusFA(args)

    local row = mw.html.create()

    for i=20 , 1 , -1 do

        if args"action".. i and mw.ustring.upper(args"action".. i]) == "FAC" then

            actionlink = args"action" .. i .. "link"

            break

        end

    end

    if not actionlink then

        actionlink = "Wikipedia:Featured article candidates/" .. p.title.prefixedText

    end

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 48

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Featured article star.svg|" ..iconsize .. "px|Featured article]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' is a [[Wikipedia:Featured articles|featured article]]; " ..

                    "it (or a previous version of it) has been '''''[[" .. actionlink .. "|identified]]''''' " ..

                    "as one of the best articles produced by the [[Wikipedia:Wikipedians|Wikipedia community]]. " ..

                    "Even so, if you can update or improve it, [[Wikipedia:Be bold|please do so]].")

                table.insert(p.includeonly, "[[Category:Wikipedia featured articles]]")

    return tostring(row)

end



function p.statusFAR(args)

    local row = mw.html.create()

    row

        :tag('tr')

            :addClass('error')

            :tag('td')

                :addClass('mbox-image')

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''Use the template {{[[Template:FAR|FAR]]}} to nominate an article for Featured article status; " ..

                    "this simplifies the nomination procedure. A bot will add the details to the ArticleHistory template when the FAR process is closed.'''")

    table.insert(p.errors, "[[Category:ArticleHistory error]]")

    return tostring(row)

end



function p.statusFFLC(args)

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    local row = mw.html.create()

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-former.svg|".. iconsize .. "px|Former FLC]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' is a former [[Wikipedia:Featured list candidates|featured list candidate]]. " ..

                    "Please view the link under Article milestones below to see why the nomination failed. " ..

                    "Once the objections have been addressed you may [[Wikipedia:Featured list candidates#Resubmitting nominations|resubmit]] the article for featured list status.")

    table.insert(p.includeonly, "[[Category:Wikipedia featured list candidates (contested)]]")

    return tostring(row)

end



function p.statusFL(args)

    local row = mw.html.create()

    for i=20 , 1 , -1 do

        if args"action".. i == "FL" then

            actionlink = args"action" .. i .. "link"

            break

        end

    end

    if not actionlink then

        actionlink = "Wikipedia:Featured list candidates/" .. p.title.prefixedText

    end

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 48

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Featured article star.svg|" .. iconsize .. "px|Featured list]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' is a [[Wikipedia:Featured lists|featured list]], " ..

                    "which means it has been '''''[[" .. actionlink .. "|identified]]''''' as one of the best [[Wikipedia:Lists|lists]] produced by the [[Wikipedia:Wikipedians|Wikipedia community]]. " ..

                    "If you can update or improve it, [[Wikipedia:Be bold|please do so]].")

    table.insert(p.includeonly, "[[Category:Wikipedia featured lists]]")

    return tostring(row)

end



function p.statusFFL(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-featured-strike.svg|" .. iconsize .. "px|Former featured list]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' is a [[Wikipedia:Former featured lists|former featured list]]. " ..

                    "Please see the links under Article milestones below for its original nomination page and why it was removed. " ..

                    "If it has improved again to [[Wikipedia:Featured list criteria|featured list standard]], you may " ..

                    "[[Wikipedia:Featured list candidates|renominate]] the article to become a [[Wikipedia:Featured list|featured list]].")

            :done()

        :done()

   return tostring(row)

end



function p.statusGA(args, gatopic)

    local row = mw.html.create()

    if string.len(gatopic) > 0 then

        topiclink = '/' .. gatopic

    else

        topiclink = ''

    end



    if args'currentstatus' =='FFA/GA' then

        iconsize = 25

    elseif args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 40

    end



    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Symbol support vote.svg|" .. iconsize .. "px|Good article]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' has been listed as one of the '''''[[Wikipedia:Good articles" .. topiclink .."|" ..gatopic.."good articles]]''''' " ..

                    "under the [[Wikipedia:Good article criteria|good article criteria]]. If you can improve it further, [[Wikipedia:Be bold|please do so]]. " ..

                    "<small>''If it no longer meets these criteria, you can '''[[Wikipedia:Good article reassessment|reassess]]''' it''.</small>")

                

    if p.title:inNamespace("Talk") then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles]][[Category:Wikipedia CD Selection-GAs]][[Category:GA-Class Good articles]]")

        if gatopic then

            table.insert(p.includeonly,"[[Category:"..gatopic.." good articles|"..p.title.prefixedText.."]]")

        else

            table.insert(p.includeonly, "|[[Category:Uncategorized good articles|"..p.title.prefixedText.."]]")

        end

    end          

    return tostring(row)

end



function p.statusFGAN(args, gatopic)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Symbol unsupport vote.svg|" .. iconsize .. "px|Former good article nominee]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' was one of the '''''[[Wikipedia:Good articles|" .. gatopic .." good article]]''''' nominees, " ..

                    "but did not meet the [[Wikipedia:Good article criteria|good article criteria]] at the time. There are suggestions below for improving the article. " ..

                    "Once these issues have been addressed, the article can be [[Wikipedia:Good article nominations|renominated]]. " ..

                    "Editors may also seek a '''[[Wikipedia:Good article reassessment|reassessment]]''' of the decision if they believe there was a mistake.")

    table.insert(p.includeonly, "[[Category:Former good article nominees]]")

    return tostring(row)

end



function p.statusDGA(args, gatopic)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Symbol unsupport vote.svg|" .. iconsize .. "px|Former good article]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' was one of the '''''[[Wikipedia:Good articles|" .. gatopic .." good articles]]''''', " ..

                    "but it has been removed from the list. There are suggestions below for improving the article to meet the [[Wikipedia:Good article criteria|good article criteria]]. " ..

                    "Once these issues have been addressed, the article can be [[Wikipedia:Good article nominations|renominated]]. " ..

                    "Editors may also seek a '''[[Wikipedia:Good article reassessment|reassessment]]''' of the decision if they believe there was a mistake.")

     table.insert(p.includeonly, "[[Category:Delisted good articles]]")

     return tostring(row)

end



function p.statusFFT(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-featured-strike.svg|" .. iconsize .. "px|Former featured topic]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("This article is part of a ''[[Wikipedia:Former featured topics|former featured topic]]'' series. " ..

                    "If it has improved again to [[Wikipedia:Featured topic criteria|featured topic standard]], " ..

                    "you may [[Wikipedia:Featured topic candidates|renominate]] the topic to become a [[Wikipedia:Featured topic|featured topic]].")

            :done()

        :done()

    return tostring(row)

end



function p.statusFFTC(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-former.svg|" .. iconsize.. "px|Former featured topic candidate]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("This article is part of a ''former'' [[Wikipedia:Featured topic candidates|featured topic candidate]]. " ..

                    "Please view the links under Article milestones below to see why the nomination failed.")

    return tostring(row)

end



function p.statusFPO(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-featured.svg|" .. iconsize .. "px|Former featured topic candidate]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("The '''"..p.title.text .." Portal''' is a [[Wikipedia:Featured portals|featured portal]], " ..

                    "which means it has been '''''[[Wikipedia:Featured portal candidates/Portal:"..p.title.prefixedText .."|identified]]''''' " ..

                    "as one of the best portals on [[Wikipedia]]. If you see a way this portal can be updated or improved without compromising previous work, please feel free to contribute.")

    table.insert(p.includeonly, "[[Category:Wikipedia featured portals|"..p.title.text .."]]")

    return tostring(row)

end



function p.statusFFPO(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Featured article star - cross.svg|" .. iconsize .. "px|Former featured portal]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("This portal is a [[Wikipedia:Former featured portals|former featured portal]]. " ..

                    "Please see the links under Portal milestones below for its original nomination page and why it was removed.")

   table.insert(p.includeonly, "[[Category:Wikipedia former featured portals|"..p.title.text .."]]")

   return tostring(row)

end



function p.statusFFPOC(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-former.svg|" .. iconsize .. "px|Former featured portal candidate]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("This portal is a '''''former''''' [[Wikipedia:Featured portal candidates|featured portal candidate]]. " ..

                    "Please see the links under Portal milestones below for its original nomination page and why the nomination failed.")

    table.insert(p.includeonly, "[[Category:Wikipedia featured portal candidates (contested)|"..p.title.text .."]]")

    return tostring(row)

end



function p.statusInvalid(args)

    local row = mw.html.create()

    row

        :tag('tr')

            :addClass('error')

            :tag('td')

                :addClass('mbox-image')

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("Please do not use " .. args'currentstatus' .." as a ''currentstatus'' parameter: " ..

                    "these assessments are the responsibility of individual WikiProjects.")

    table.insert(p.errors, "[[Category:ArticleHistory error]]")

    return tostring(row)

end



function p.statusUnknown(args)

    local row = mw.html.create()

    row

        :tag('tr')

            :addClass('error')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Imbox deletion.png]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("Unknown current status!")

            :done()

        :done()

    table.insert(p.errors, "[[Category:ArticleHistory error]]")

    return tostring(row)

end



function p.statusFT(args)

    local isFA = false

    if args'ftname' then

    if p.featuredTopicSum(args'ftname']) then

            isFA = true

        elseif args'ft2name' then

            if p.featuredTopicSum(args'ft2name']) then

                isFA = true

            elseif args'ft3name' then

                if p.featuredTopicSum(args'ft3name']) then

                    isFA = true

                elseif args'ft4name' then

                    if p.featuredTopicSum(args'ft4name']) then

                        isFA = true

                    end

                end

            end

        end

    end



    if args'small' then

        iconsize = 30

    else

        iconsize = 48

    end



    if isFA then

        image = '[[File:cscr-featuredtopic.svg|' .. iconsize ..'px|Featured topic star]]'

    else

        image = '[[File:Support cluster.svg|' .. iconsize ..'px|Good topic star]]'

    end

    local row = mw.html.create():tag('tr')

        :tag('td')

            :addClass('mbox-image')

            :wikitext(image)

        :done()

    local cell = row:tag('td')

            :addClass('mbox-text')



            :wikitext("'''"..p.title.prefixedText .. "''' is ")

            if (args'ftmain' == 'yes') then

                cell:wikitext('the main article in')

            else

                cell:wikitext('part of')

            end

            cell:wikitext(" the '''[[Wikipedia:Featured topics/" .. args'ftname' .. '|' .. args'ftname' .. "]] series''', a ")

            if p.featuredTopicSum(args'ftname']) then

                cell:wikitext('[[Wikipedia:Featured topics|featured topic]]. ')

            else

                cell:wikitext('[[Wikipedia:Good topics|good topic]]. ')

            end



            if (args'ft2name']) then

                cell:wikitext('It is also ')

                if (args'ft2main' == 'yes') then

                    cell:wikitext('the main article in')

                else

                    cell:wikitext('part of')

                end

                cell:wikitext(" the '''[[Wikipedia:Featured topics/" .. args'ft2name' .. '|' .. args'ft2name' .. "]] series''', a ")

                if p.featuredTopicSum(args'ft2name']) then

                    cell:wikitext('[[Wikipedia:Featured topics|featured topic]]')

                else

                    cell:wikitext('[[Wikipedia:Good topics|good topic]]')

                end

            end





            if (args'ft3name']) then

                cell:wikitext('It is also ')

                if (args'ft3main' == 'yes') then

                    cell:wikitext('the main article in')

                else

                    cell:wikitext('part of')

                end

                cell:wikitext(" the '''[[Wikipedia:Featured topics/" .. args'ft3name' .. '|' .. args'ft3name' .. "]] series''', a ")

                if p.featuredTopicSum(args'ft3name']) then

                    cell:wikitext('[[Wikipedia:Featured topics|featured topic]]')

                else

                    cell:wikitext('[[Wikipedia:Good topics|good topic]]')

                end

            end



            if (args'ft4name']) then

                cell:wikitext('It is also ')

                if (args'ft4main' == 'yes') then

                    cell:wikitext('the main article in')

                else

                    cell:wikitext('part of')

                end

                cell:wikitext(" the '''[[Wikipedia:Featured topics/" .. args'ft4name' .. '|' .. args'ft4name' .. "]] series''', a ")

                if p.featuredTopicSum(args'ft4name']) then

                    cell:wikitext('[[Wikipedia:Featured topics|featured topic]]')

                else

                    cell:wikitext('[[Wikipedia:Good topics|good topic]]')

                end

        end



        if args'ft2name' then

            cell:wikitext('These are ')

        else

            cell:wikitext('This is ')

        end

        cell:wikitext("identified as among the best series of articles produced by the [[Wikipedia:Wikipedians|Wikipedia community]]. If you can update or improve ")

        if args'ft2name' then

            cell:wikitext('them')

        else

            cell:wikitext('it')

        end

        cell:wikitext(", [[Wikipedia:Be bold|please do so]].")



        -- Categories

        if args'currentstatus' == 'FA' then

            table.insert(p.includeonly,'[[Category:FA-Class Featured topics articles]]')

            table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ftname'..' featured content]]')

            if args'ft2name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft2name'..' featured content]]')

            end

            if args'ft3name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft3name'..' featured content]]')

            end

            if args'ft4name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft4name'..' featured content]]')

            end



        elseif args'currentstatus' == 'FL' then

            table.insert(p.includeonly,'[[Category:FL-Class Featured topics articles]]')

            table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ftname'..' featured content]]')

            if args'ft2name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft2name'..' featured content]]')

            end

            if args'ft3name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft3name'..' featured content]]')

            end

            if args'ft4name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft4name'..' featured content]]')

            end

            

        elseif args'currentstatus' == 'FFA/GA' or args'currentstatus' == 'GA' then

            table.insert(p.includeonly,'[[Category:GA-Class Featured topics articles]]')

            table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ftname'..' good content]]')

            if args'ft2name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft2name'..' good content]]')

            end

            if args'ft3name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft3name'..' good content]]')

            end

            if args'ft4name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft4name'..' good content]]')

            end

        else

            table.insert(p.includeonly,'[[Category:Unassessed Featured topics articles]]')

            table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ftname'..']]')

            if args'ft2name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft2name'..']]')

            end

            if args'ft3name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft3name'..']]')

            end

            if args'ft4name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft4name'..']]')

            end

        end



        if p.featuredTopicSum(args'ftname']) then

            if args'ftmain' == 'yes' then

               table.insert(p.includeonly,'[[Category:Top-importance Featured topics articles|'..args'ftname'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:High-importance Featured topics articles]]')

            end

        else

            if args'ftmain' == 'yes' then

                table.insert(p.includeonly,'[[Category:Mid-importance Featured topics articles|'..args'ftname'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:Low-importance Featured topics articles]]')

            end

        end



        if args'ft2name' then

            if p.featuredTopicSum(args'ft2name']) then

                if args'ft2main' == 'yes' then

                    table.insert(p.includeonly,'[[Category:Top-importance Featured topics articles|'..args'ft2name'.. ' ' .. p.title.text .. ']]')

                else

                    table.insert(p.includeonly,'[[Category:High-importance Featured topics articles]]')

                end

            else

                if args'ft2main' == 'yes' then

                    table.insert(p.includeonly,'[[Category:Mid-importance Featured topics articles|'..args'ft2name'.. ' ' .. p.title.text .. ']]')

                else

                    table.insert(p.includeonly,'[[Category:Low-importance Featured topics articles]]')

                end

            end

        end

    if args'ft3name' then

        if p.featuredTopicSum(args'ft3name']) then

            if args'ft3main' == 'yes' then

                table.insert(p.includeonly,'[[Category:Top-importance Featured topics articles|'..args'ft3name'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:High-importance Featured topics articles)')

            end

        else

            if args'ft3main' == 'yes' then

                table.insert(p.includeonly,'[[Category:Mid-importance Featured topics articles|'..args'ft3name'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:Low-importance Featured topics articles)')

            end

        end

    end



    if args'ft4name' then

        if p.featuredTopicSum(args'ft4name']) then

            if args'ft4main' == 'yes' then

                table.insert(p.includeonly,'[[Category:Top-importance Featured topics articles|'..args'ft4name'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:High-importance Featured topics articles)')

            end

        else

            if args'ft4main' == 'yes' then

                table.insert(p.includeonly,'[[Category:Mid-importance Featured topics articles|'..args'ft4name'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:Low-importance Featured topics articles)')

            end

        end

    end



    return tostring(row)

end



function p.featuredTopicSum(topic)

    --featured topics need at least two featured-class articles (FT criteria 3(a)(i)); if this criterion is not met, the article is a GT.-->

    --at least 50% of the articles in the topic need to be featured for the topic to be an FT

    return mw.site.stats.pagesInCategory('Wikipedia featured topics ' .. topic .. ' featured content') > 1 and

            mw.site.stats.pagesInCategory('Wikipedia featured topics ' .. topic .. ' featured content') >=

            (mw.site.stats.pagesInCategory('Wikipedia featured topics ' .. topic) +  mw.site.stats.pagesInCategory('Wikipedia featured topics ' .. topic .. ' good content')-2)

end



function p.milestoneMainPage(args)

    local lang = mw.language.getContentLanguage()

    local status = args'currentstatus'



    if lang:formatDate('Ymd', args'maindate']) < lang:formatDate('Ymd', '20110613') then

        mptype = 'article'

    elseif args'currentstatus' == 'FL' or args'currentstatus' == 'FFL' then

        mptype = 'list'

    else

        mptype = 'article'

    end

    if args'small' == 'yes' then

        iconsize = 15

    else

        iconsize = 30

    end

    local row = mw.html.create('tr')

        :tag('td')

            :addClass('mbox-image')

            :wikitext("[[File:Wikipedia-logo-v2.svg|"  .. iconsize ..  "px|Main Page trophy]]")

            :done()



        local text = "This article "

        if lang:formatDate('Ymd', args'maindate']) < lang:formatDate('Ymd') then

            text = text .. "appeared"

        elseif lang:formatDate('Ymd', args'maindate']) > lang:formatDate('Ymd') then

            text = text .. "will appear"

        else

            text = text .. "is currently"

        end



        text = text .. " on Wikipedia's [[Main Page]] as [[Wikipedia:Today's featured " .. mptype .. "/" .. lang:formatDate('F j, Y',args'maindate']) .. "|Today's featured " .. mptype .. "]]"

        if lang:formatDate('Ymd', args'maindate']) ~= lang:formatDate('Ymd') then 

            text = text .. " on " .. lang:formatDate('F j, Y',args'maindate'])

        end

        text = text .. "."

        

    row:tag('td')

        :addClass('mbox-text')

        :wikitext(text)

        

    if args'currentstatus' == 'FA' or args'currentstatus' == 'FL' then

        table.insert(p.includeonly, "[[Category:Featured " .. mptype .. "s that have not appeared on the main page]]")

    end



    return tostring(row)

end



function p.historyheader(args)

    local status = args'currentstatus'

    local images = ""

    if status == 'PR' or status == 'NA' or not status then

            images = images .. ('[[File:Nuvola apps kedit.svg|15px]]')

    end

    if args'dykdate' then

        images = images .. ('[[File:DYK questionmark icon.svg|Did You Know|15px]]')

    end

    if args'itndate' then

        images = images .. ('[[File:Globe current.svg|In the news|20px]]')

    end

    if args'otddate' then

        images = images .. ('[[File:Nuvola apps date.svg|On this day...|20px]]')

    end

    if args'aciddate' then

        images = images .. ('[[File:Article_Collaboration_and_Improvement_Drive.svg|20px]]')

    end

    if args'loceNotAnActiveOption' then

        images = images .. ('[[File:LoCiconRevised.png|15px]]')

    end

    if args'v1.0NotAnActiveOption' then

       images = images .. ('[[File:WP1 0 Icon.svg|15px]]')

    end

    local header = mw.html.create('tr')

        :tag('th')

            :attr('colspan', 3)

            :attr('style', 'font-size:110%')

            :tag('span')

                :attr('style', 'float:left')

                :wikitext(images)

                :done()

    if status == 'FL' or status == 'FFLC' or status == 'FFL' then

        header:wikitext('List')

    else

        header:wikitext(p.title.subjectNsText)

    end

    header:wikitext(' milestones')



    return header:allDone()

end



function p.historyoutput(action, date, link, result, oldid, args)

    local output = mw.html.create():tag('tr')

    if action then

        action = mw.ustring.upper(action)

    end

    if result then

        result = mw.ustring.lower(result)

    end

    --Date

    local datecell = output:tag('td')

    if oldid then

        datecell:tag('span')

            :addClass('plainlinks')

            :wikitext('['.. p.title:fullUrl('oldid='..oldid))

            if date then

                datecell:wikitext(' ' .. mw.language.getContentLanguage():formatDate('F j, Y', date))

            else

                datecell:wikitext(' ?')

                table.insert(p.errors, [[Category:ArticleHistory error]])

            end

            datecell:wikitext(']')

        datecell:done()

    else

        if date then

            datecell:wikitext(mw.language.getContentLanguage():formatDate('F j, Y', date))

        else

            datecell:wikitext(' ?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    end

    output:done()



 --Process

    if link == nil or link == "" then

        link = tostring(p.title.talkPageTitle) 

    end

    local processcell = output:tag('td'):wikitext("'''[[" .. link .. "|")

    if action == 'FAC' then

        processcell:wikitext('Featured article candidate')

    elseif action == 'FAR' or action == 'FARC' then

        processcell:wikitext('Featured article review')

    elseif action == 'BP' then

        processcell:wikitext('Brilliant prose')

    elseif action == 'RBP' then

        processcell:wikitext('Refreshing brilliant prose')

    elseif action == 'PR' then

        processcell:wikitext('Peer review')

    elseif action == 'WPR' and (result == "Approved" or result == "approved" or result == "Approved version" or result == "approved version") then

        processcell:wikitext('WikiProject approved revision')

    elseif action == 'WPR' and (result == "Copyedit" or result == "copyedit" or result == "Copyedited" or result == "copyedited" or result == "Proofread" or result == "proofread") then

        processcell:wikitext('Guild of Copy Editors')

    elseif action == 'WPR' and (result == "COTW" or result == "CotW" or result == "Cotw" or result == "cotw" or 

                    result == "Collaborated" or result == "collaborated" or result == "Collaboration" or result == "collaboration") then

        processcell:wikitext('WikiProject collaboration')

    elseif action == 'WPR' and (result == "Maindate" or result == "maindate") then

        processcell:wikitext("Today's featured article")

    elseif action == 'WPR' then

        processcell:wikitext("WikiProject peer review")

    elseif action == 'WAR' then

        processcell:wikitext("WikiProject A-class review")

    elseif action == 'GAN' or action == 'GAC' then

        processcell:wikitext("Good article nominee")

    elseif action == 'GAR' then

        processcell:wikitext("Good article reassessment")

    elseif action == 'MFD' then

        processcell:wikitext("Miscellanea for deletion")

    elseif action == 'AFD' then

        processcell:wikitext("Articles for deletion")

    elseif action == 'IFD' then

        processcell:wikitext("Images for deletion")

    elseif action == 'TFD' then

        processcell:wikitext("Templates for deletion")

    elseif action == 'CSD' then

        processcell:wikitext("Candidate for speedy deletion")

    elseif action == 'PROD' then

        processcell:wikitext("Proposed deletion")

    elseif action == 'DRV' then

        processcell:wikitext("Deletion review")

    elseif action == 'FTC' then

        processcell:wikitext("Featured topic candidate")

    elseif action == 'FTR' then

        processcell:wikitext("Featured topic removal candidate")

    elseif action == 'GTC' then

        processcell:wikitext("Good topic candidate")

    elseif action == 'GTR' then

        processcell:wikitext("Good topic removal candidate")

    elseif action == 'FLC' then

        processcell:wikitext("Featured list candidate")

    elseif action == 'FLR' then

        processcell:wikitext("Featured list removal candidate")

    elseif action == 'FPOC' then

        processcell:wikitext("Featured portal candidate")

    elseif action == 'FPOR' then

        processcell:wikitext("Featured portal review")

    end



    processcell:wikitext("]]'''")

    output:done()



    --Result

    local resultcell = output:tag('td')



    if action == 'FAC' or action == 'FLC' or action == 'FTC' or action == 'GTC' or action == 'FPOC' then

        if result == 'pass' or result == 'passed' or result == 'promoted' then

            resultcell:wikitext('Promoted')

        elseif result == 'fail' or result == 'failed' or result == 'not promoted' then

            resultcell:wikitext('Not promoted')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'FAR' or action == 'FARC' or action == 'FLR' or action == 'FTR' or action == 'GTR' or action == 'FPOR' then

        if result == 'pass' or result == 'passed' or result == 'keep' or result == 'kept' then

            resultcell:wikitext('Kept')

            if action == 'FAR' or action == 'FARC' then

               table.insert(p.category, '[[Category:Wikipedia featured article review candidates (closed)]]')

            end

        elseif result == 'fail' or result == 'failed' or result == 'remove' or result == 'removed' or result == 'demoted' then

            resultcell:wikitext('Demoted')

        elseif result == 'merged' or result == 'merge' then

            resultcell:wikitext('Merged')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'RBP' then

        if result == 'pass' or result == 'keep' or result == 'kept' then

            resultcell:wikitext('Kept')

        elseif result == 'fail' or result == 'failed' or result == 'remove' or result == 'removed' or result == 'demoted' then

            resultcell:wikitext('Not kept')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'BP' then

        if result == 'pass' or result == 'promoted' or result == 'nominated' or result == 'nom' then

            resultcell:wikitext('Nominated')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'GAN' or action == 'GAC' then

        if result == 'pass' or result == 'passed' or result == 'promoted' or result == 'listed' then

            resultcell:wikitext('Listed')

        elseif result == 'fail' or result == 'failed' or result == 'not promoted' or result == 'not listed' then

            resultcell:wikitext('Not liseted')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'GAR' then

        if result == 'pass' or result == 'passed' or result == 'keep' or result == 'kept' then

            resultcell:wikitext('Kept')

        elseif result == 'fail' or result == 'failed' or result == 'delisted' then

            resultcell:wikitext('Delisted')

        elseif result == 'listed' then

            resultcell:wikitext('Listed')

        elseif result == 'not listed' then

            resultcell:wikitext('Not listed')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'MFD' or action == 'AFD' or action == 'TFD' or action == 'IFD' or action == 'CSD' or action == 'PROD' then

        if result == 'withdrawn' or result == 'keep' or result == 'kept' then

            resultcell:wikitext('Kept')

        elseif result == 'delete' or result == 'deleted'then

            resultcell:wikitext('Deleted')

        elseif result == 'merged' or result == 'merge' then

            resultcell:wikitext('Merged')

        elseif result == 'no consensus' then

            resultcell:wikitext('No consensus')

        elseif result == 'speedy keep' or result == 'speedily kept' then

            resultcell:wikitext('Speedily kept')

        elseif result == 'speedy delete' or result == 'speedily deleted' then

            resultcell:wikitext('Speedily deleted')

        elseif result == 'redirect' or result == 'redirected' then

            resultcell:wikitext('Redirected')

        elseif result == 'rename' or result == 'renamed' or result == 'move' or result == 'moved' then

            resultcell:wikitext('Renamed')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end



    elseif action == 'DRV' then

        if result == 'endorse' or result == 'endorsed' then

            resultcell:wikitext('Endorsed')

        elseif result == 'relisted' or result == 'relist' then

            resultcell:wikitext('Relisted')

        elseif result == 'overturn' or result == 'overturned' then

            resultcell:wikitext('Overturned')

        elseif result == 'no consensus' then

            resultcell:wikitext('No consensus')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end



    elseif action == 'PR' then

        if result == 'not reviewed' then

            resultcell:wikitext('Not reviewed')

        else

            resultcell:wikitext('Reviewed')

        end



    elseif action == 'WPR' then

        if result == 'approved' or result == 'approved version' then

            if oldid then

                resultcell:tag('small')

                :wikitext('[' .. p.title:fullUrl('diff=cur&oldid='..oldid) .. ' Diff to current version]')

                :done()

            else

                resultcell:wikitext('?')

                table.insert(p.errors, [[Category:ArticleHistory error]])

            end

        elseif result == 'copyedit' or result == 'copyedited' or result == 'proofread' then

            resultcell:wikitext('Copyedited')

        elseif result == 'maindate' then

            resultcell:wikitext('Main Page')

        elseif result == 'cotw' or result == 'collaborated' or result == 'collaboration' then

            resultcell:wikitext('Collaborated')

        elseif result == 'reviewed' then

            resultcell:wikitext('Reviewed')

        elseif result == 'not reviewed' then

            resultcell:wikitext('Not reviewed')

        else

            resultcell:wikitext('Reviewed')

        end



        elseif action == 'WAR' then

            if result == 'pass' or result == 'passed' or result == 'approved' then

                resultcell:wikitext('Approved')

            elseif result == 'fail' or result == 'failed' or result == 'not approved' or result == 'not reviewed' then

                resultcell:wikitext('Not approved')

            elseif result == 'reviewed' or result == '' then

                resultcell:wikitext('Reviewed')

            elseif result == 'keep' or result == 'kept' then

                resultcell:wikitext('kept')

            elseif result == 'demote' or result == 'demoted' then

                resultcell:wikitext('Demoted')

            else

                resultcell:wikitext('?')

                table.insert(p.errors, [[Category:ArticleHistory error]])

            end

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

        output:done():done()



        --Categories

        if action == 'FAR' or action == 'FARC' then

            if result == 'fail' or result == 'failed' or result == 'remove' or result == 'removed' or result == 'demoted' or result == 'merged' or result == 'merge' then

                if args'currentstatus' == 'FA' or args'currentstatus' == 'FL' then

                    table.insert(p.category, '[[Category:Wikipedia former featured articles|#'..p.title.text..']]')

                else

                    table.insert(p.category, '[[Category:Wikipedia former featured articles|'..p.title.text..']]')

                end

            end

        elseif action == 'RBP' then

            if result == 'fail' or result == 'failed' or result == 'remove' or result == 'removed' or result == 'demoted' then

                table.insert(p.category, '[[Category:Wikipedia former brilliant prose|'..p.title.text..']]')

            end

        elseif action == 'GAN' or action == 'GAC' then

            if result == 'fail' or result == 'failed' or result == 'not promoted' or result == 'not listed' then

                if args'currentstatus' == 'FA' or args'currentstatus' == 'GA'  or args'currentstatus' == 'FFA'  or args'currentstatus' == 'FFA/GA' then



                else

                    table.insert(p.category, '[[Category:Former good article nominees|'..p.title.text..']]')

                end

            end

         elseif action == 'GAR' then

            if result == 'fail' or result == 'failed' or result == 'delisted' then

                if args'currentstatus' == 'FA' or args'currentstatus' == 'GA'  or args'currentstatus' == 'FFA/GA' then



                else

                   table.insert(p.category, '[[Category:Delisted good articles|'..p.title.text..']]')

                end

            end

        elseif action == 'FLR' then

            if result == 'fail' or result == 'failed' or result == 'remove' or result == 'removed' or result == 'demoted' or result == 'merged' or result == 'merge' then

                if args'currentstatus' == 'FL' then

                    table.insert(p.category, '[[Category:Wikipedia former featured lists|#'..p.title.text..']]')

                else

                    table.insert(p.category, '[[Category:Wikipedia former featured lists|'..p.title.text..']]')

                end

        end

        elseif action == 'PR' then

            table.insert(p.category, '[[Category:Old requests for peer review]]')

        end

    return output

end



function p.milestoneDYK(args)

    local td = mw.html.create('tr')

    local row = td

    if args'action1' then

        row = row:tag('td')

            :attr('colspan', '3')

            :attr('width', '100%')

        if args'dykentry' then

           row = row:tag('table')

            :addClass('collapsible collapsed')

             :attr('style', 'margin: 0; padding: 0; border-collapse: collapse; width: 100%; background: transparent')

            :tag('tr')

            :tag('th')

            :attr('style', 'font-weight: normal; text-align: left; width: 100%')

        end

        row = row:wikitext('[[File:DYK questionmark icon.svg|Did You Know|' .. ((args'small' == 'yes' and '15') or '20') ..'px]]&#32;')

    else

        row = row:tag('td')

            :addClass('mbox-image')

            :wikitext('[[File:DYK questionmark icon.svg|Did You Know|' .. ((args'small' == 'yes' and '15') or '20') ..'px]]')

            :done()

        if args'dykentry' then

            row = row:tag('td')

            :addClass('mbox-text')

            :tag('table')

            :addClass('collapsible collapsed')

            :attr('style', 'margin: 0; padding: 0; border-collapse: collapse; width: 100%; background: transparent')

            :tag('tr')

            :tag('th')

            :attr('style', 'font-weight: normal; text-align: left; width: 100%')

        else

            row = row:tag('td')

            :addClass('mbox-text')

        end

    end

    local lang = mw.language.getContentLanguage()

    local text

    if mw.title.makeTitle('Wikipedia', 'Recent additions/' .. lang:formatDate('Y/F#j F Y', args'dykdate'])).exists then

        text = "A '''[[Wikipedia:Recent additions/"..lang:formatDate('Y/F#j F Y', args'dykdate']).."|fact from this article]]'''"

    else

        text = "A '''[[Wikipedia:Recent additions|fact from this article]]'''"

    end

    text = text .." appeared on Wikipedia's [[Main Page]] in the '' \"[[:Template:Did you know|Did you know?]]\" '' column on ".. lang:formatDate('F j, Y',args'dykdate'])

    if args'dykdate2' then

       text = text .. ', and on '.. lang:formatDate('F j, Y',args'dykdate'])

    end

    text = text .. '.'

    row = row:wikitext(text)

    if args'dykentry' then

        row = row:done():done()

        :tag('tr')

        :tag('td')

        :attr('style', 'border: 1px silver solid')

        :wikitext("The text of the entry was: ''Did you know " .. args'dykentry'.."''")

        :done():done():done()

    elseif args'action1' then

        row:done()

    end

    if args'action1' then

        row:done()

    end

    row:done()



    if args'currentstatus' == FA then

       table.insert(p.includeonly, '[[Category:Wikipedia Did you know articles that are featured articles]]')

    elseif args'currentstatus' == FL then

        table.insert(p.includeonly, '[[Category:Wikipedia Did you know articles that are featured lists]]')

    elseif args'currentstatus' == 'FFA/GA' or args'currentstatus' == 'GA' then

       table.insert(p.includeonly, '[[Category:Wikipedia Did you know articles that are good articles]]')

    else

       table.insert(p.includeonly, '[[Category:Wikipedia Did you know articles]]')

    end



    return row:allDone()

end



function p.milestoneITN(args)

    local lang = mw.language.getContentLanguage()

   table.insert(p.category,"[[Category:Wikipedia In the news articles]]")

    local mboximage = "[[File:Globe current.svg|In the news|20px]]"

    local text = "A news item involving this article was featured on Wikipedia's [[Main Page]] in the ''\"[[:Template:In the news|In the news]]\"''"

        if args'itnlink' then

            text = text .. " [[" .. args'itnlink'.."|column]]"

        else

            text = text .. " column"

        end

        text = text .. " on " .. lang:formatDate('F j, Y', args'itndate'])

        if args'itndate2' then

            text = text .. ", and on " .. lang:formatDate('F j, Y', args'itndate2'])

        end

        text = text .. '.'



    local row = mw.html.create('tr')

    if args'action1' then

        row:tag('td')

        :attr('colspan', '3')

        :wikitext(mboximage .. " " .. text)

     else

        row:tag('td')

         :addClass('mbox-image')

         :wikitext(mboximage)

         :done()

         :tag('td')

         :addClass('mbox-text')

         :wikitext(text)

     end

     return row

end



function p.milestoneOTD(args)

    local lang = mw.language.getContentLanguage()

    table.insert(p.category, "[[Category:Selected anniversaries articles]]")

    local mboximage = "[[File:Nuvola apps date.svg|On this day...|20px]]"

    local text = "A fact from this article was featured on Wikipedia's [[Main Page]] in the  ''\"[[Wikipedia:Selected anniversaries|On this day...]]\"''"

        if args'otdlink' then

            text = text .. " [[" .. args'otdlink'.."|column]]"

        else

            text = text .. " column"

        end

        text = text .. " on " .. lang:formatDate('F j, Y', args'otddate'])

        if args'otddate2' then

            text = text .. ", and on " .. lang:formatDate('F j, Y', args'otddate2'])

        end

        text = text .. '.'



    local row = mw.html.create('tr')

    if args'action1' then

        row:tag('td')

        :attr('colspan', '3')

        :wikitext(mboximage .. " " .. text)

     else

        row:tag('td')

         :addClass('mbox-image')

         :wikitext(mboximage)

         :done()

         :tag('td')

         :addClass('mbox-text')

         :wikitext(text)

     end

     return row

end



function p.milestoneACID(args)

    local lang = mw.language.getContentLanguage()

    local mboximage = "[[File:Article_Collaboration_and_Improvement_Drive.svg|Article Collaboration and Improvement Drive|20px]]"

    local text = "This article was on the [[WP:ACID|Article Collaboration and Improvement Drive]] for the week of  " .. lang:formatDate('F j, Y', args'aciddate']) .. '.'



    local row = mw.html.create('tr')

    if args'action1' then

        row:tag('td')

        :attr('colspan', '3')

        :wikitext(mboximage .. " " .. text)

     else

        row:tag('td')

         :addClass('mbox-image')

         :wikitext(mboximage)

         :done()

         :tag('td')

         :addClass('mbox-text')

         :wikitext(text)

     end

     return row

end



function p.milestoneLoC(args)

    local mboximage = "[[File:LoCiconRevised.png|League of Copyeditors|" .. ((args'small' == "yes") and "20px") or "25px" .. "]]"

    local text = "This article, or a portion of it, was copyedited by the [[WP:LoCE|League of Copyeditors]]."



    local row = mw.html.create('tr')

    if args'action1' then

        row:tag('td')

        :attr('colspan', '3')

        :wikitext(mboximage .. " " .. text)

     else

        row:tag('td')

         :addClass('mbox-image')

         :wikitext(mboximage)

         :done()

         :tag('td')

         :addClass('mbox-text')

         :wikitext(text)

     end

     return row

end



function p.currentstatus(args)

    local row = mw.html.create()

    local statuses = {

        FA="Featured article",

        FAR="Featured article review candidate",

        FARC="Featured article review candidate",

        FFA="Former featured article",

        "FFA/GA"="Former featured article, current good article",

        FFAC="Former featured article candidate",

        FACFAILED="Former featured article candidate",

        FFLC="Former featured list candidate",

        FL="Featured list",

        FFL="Former featured list",

        GA="Good article",

        FGAN="Former good article nominee",

        FAILEDGA="Former good article nominee",

        DGA="Delisted good article",

        DELISTEDGA="Delisted good article",

        FFT="Part of former featured topic",

        FFTC="Former featured topic candidate",

        FPO="Featured portal",

        FFPO="Former featured portal",

        FFPOC="Former featured portal candidate",

        PR="Peer reviewed",

   }



    local currentstatus = false

    for i=2, 20, 1 do

        if args'action'..i then

            currentstatus = true

        end

    end

    if currentstatus then

        local td = row:tag('tr'):tag('td')

        :attr('colspan', '3')

        if statusesargs'currentstatus']] then

            td:wikitext("Current status: '''" .. statusesargs'currentstatus']] .. "'''")

            if args'currentstatus' == "FA" or args'currentstatus' == "FL" or args'currentstatus' == "FFA/GA" or args'currentstatus' == "GA" then

                if args'gacat' then

                    td:wikitext(" (" .. args'gacat' .. ")")

                end

            end

        else

            td:wikitext("Current status: '''?'''")

        end

    elseif args'action1' == nil then

        row:tag('tr')

        :addClass('error')

        :tag('td')

        :addClass('mbox-image')

        :wikitext("[[File:Imbox deletion.png]]")

        :done()

        :tag('td')

        :addClass('mbox-text')

        :wikitext("Current status is supplied without any actions!")

        table.insert(p.errors,"[[Category:ArticleHistory error|#]]")

    end

    return row

end



function p.fourawardtest(args, status)

    -- If article has not yet been tested for [[WP:FOUR]]

    if args'four' then

        return false

    end

    -- If article has been on DYK

    if not args'dykdate' then

        return false

    end

    -- If article is currently FA

    if status ~= FA then

        return false

    end

    -- If successful GAN is anywhere in the history

    for i=1, 20, 1 do

        if args'action'..i and mw.ustring.upper(args'action' .. i]) == 'GAN' then

            if args'action'..i .. 'result' and mw.ustring.lower(args'action' .. i .. 'result']) == 'listed' then 

                return true

            end

        end

    end

    --No successful GAN in history

    return false

end



function p._articlehistory(args, frame)

    local status = args'currentstatus'

    local gatopic = frame:expandTemplate { title='GA/Topic' , args = {args'topic']}}

    if status then

        status = mw.ustring.upper(args'currentstatus'])

    end



    local tbl = mw.html.create('table')



    tbl

        :addClass('tmbox')

        :addClass('tmbox-notice')



    if args.small == 'yes' then

        tbl:addClass('mbox-small')

    end



    --Sorting current status

    

    --FFA check based on most recent FAR (if there is one)

    for i=20 , 1 , -1 do

        if args"action".. i and mw.ustring.upper(args"action".. i]) == "FAR" then

            tbl:node(p._statusFFA(args, i))

            break

        end

    end



    if status == 'FFA' then

        -- Already covered in FFA check previously--

    elseif status == 'FAC' then

        tbl:node(p.statusFAC(args))

    elseif status == 'FFAC' or status == 'FACFAILED' then

        tbl:node(p.statusFFAC(args))

    elseif status == 'FA' then

        tbl:node(p.statusFA(args))

    elseif status == 'FAR' then

        tbl:node(p.statusFAR(args))

    elseif status == 'FFLC' then

        tbl:node(p.statusFFLC(args))

    elseif status == 'FL' then

        tbl:node(p.statusFL(args))

    elseif status == 'FFL' then

        tbl:node(p.statusFFL(args))

    elseif status == 'FFA/GA' or status == 'GA' then

        tbl:node(p.statusGA(args, gatopic))

    elseif status == 'FGAN' or status == 'FAILEDGA' then

        tbl:node(p.statusFGAN(args, gatopic))

    elseif status == 'DGA' or status == 'DELISTEDGA' then

        tbl:node(p.statusDGA(args, gatopic    ))

    elseif status == 'FFT' then

        tbl:node(p.statusFFT(args))

    elseif status == 'FFTC' then

        tbl:node(p.statusFFTC(args))

    elseif status == 'FPO' then

        tbl:node(p.statusFPO(args))

    elseif status == 'FFPO' then

        tbl:node(p.statusFFPO(args))

    elseif status == 'FFPOC' then

        tbl:node(p.statusFFPOC(args))

    elseif status == 'START' or status == 'STUB' or status == 'B' or status == 'A' then

        tbl:node(p.statusInvalid(args))

    elseif status == 'PR' or status == 'NA' or status == nil or status == '' then

        --do nothing if no status selected

    else

        tbl:node(p.statusUnknown(args))

    end



    if args'ftname' then

        tbl:node(p.statusFT(args))

    end

    

    if args'maindate' then

        tbl:node(p.milestoneMainPage(args))

    --If the article is an FA or FL but has not been on the main page, add it to a category

    elseif status == 'FA' then

        table.insert(p.category,"[[Category:Featured articles that have not appeared on the main page]]")

    elseif status == 'FL' then

        table.insert(p.category,"[[Category:Featured lists that have not appeared on the main page]]")

    end

    

    --Article milestones

    

    local history = tbl

    if args'action1' then

        history = history:tag('tr')

            :tag('td')

                :attr('colspan', 2)

                :attr('style', 'width: 100%;')

            :tag('table')

                :attr('style','width:100%; background:transparent; font-size:90%')

                :addClass('AH-milestones')



        if args'action2' or args'dykdate' or args'itndate' or args'otddate' or args'aciddate' or args'loceNotAnActiveOption' then

            history:addClass('collapsible collapsed')

            history:node(p.historyheader(args))

            history:tag('tr')

                :attr('style', 'text-align: left')

                :tag('th'):wikitext('Date'):done()

                :tag('th'):wikitext('Process'):done()

                :tag('th'):wikitext('Result'):done()

        end







    for i=1, 20, 1 do

        if args'action'..i then

            history:node(p.historyoutput(args'action'..i], args'action'..i..'date'], args'action'..i..'link'], args'action'..i..'result'], args'action'..i..'oldid'], args))

        elseif args'action'..i..'date' or args'action'..i..'link' or args'action'..i..'result' or args'action'..i..'oldid' then

            table.insert(p.errors, '[[Category:ArticleHistory error|$]]')

        end

    end

    end

    if args'dykdate' then

         history:node(p.milestoneDYK(args))

    end

    if args'four' and mw.ustring.lower(args'four']) == 'yes' then

        table.insert(p.includeonly,"[[Category:Wikipedia four award articles]]")

    end

    if args'itndate' then

        history:node(p.milestoneITN(args))

    end

    if args'otddate' then

        history:node(p.milestoneOTD(args))

    end

    if args'aciddate' then

        history:node(p.milestoneACID(args))

    end

    if args'loceNotAnActiveOption' then

        history:node(p.milestoneLoC(args))

    end

    if args'currentstatus' ~= nil and args'currentstatus' ~= "" then

        history:node(p.currentstatus(args))

    end

    if args'action1' then

        --width hack

        history:done():done():tag('td')

    end

    

    --Categories

    

    if args'categories' or args'category' then

        table.insert(p.errors, "[[Category:ArticleHistory error]]")

    end

    if args'list' then

        table.insert(p.errors, "[[Category:ArticleHistory error]]")

    end

    if args'topic' then

        if not gatopic or gatopic == "" then

            table.insert(p.errors, "[[Category:ArticleHistory error]]")

        end

    end

    if status == "FFA/GA" or status == "GA" then

        if args'gacat' == 'actors' then

            table.insert(p.includeonly, "[[Category:Wikipedia good articles on actors, models and celebrities]]" ..

                "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == 'bands' then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles on performers and composers]]")

        elseif args'gacat' == 'hist figures' then

            table.insert(p.includeonly, "[[Category:Wikipedia good articles on historical figures]]" ..

                "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == 'musicians' then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles on performers and composers]]" ..

            "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == 'politicians' then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles on politicians]]" ..

            "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == 'royalty' then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles on royalty]]" ..

            "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == 'writers' then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles on writers and critics]]" ..

            "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == "" then

        else

             table.insert(p.errors, "[[Category:ArticleHistory error]]")

        end

        if p.fourawardtest(args, status) then

            table.insert(p.includeonly, "[[Category:Possible Wikipedia four award articles]]")

        end

     end   

        

    return tostring(tbl) .. table.concat(p.category) .. table.concat(p.includeonly) .. table.concat(p.errors)

end



function p.articlehistory(frame)

   local pframe = frame:getParent()



    local args = {};

    for k, v in pairs( pframe.args ) do

        argsk = v;

    end

    for k, v in pairs( frame.args ) do

        argsk = v;

    end



    return p._articlehistory( args , frame )

end



return p
From Wikipedia, the free encyclopedia

local p = {

    --collect categories to avoid cluttering the HTML tree.

    category = {},

    includeonly = {},

    errors = {},

    title = mw.title.getCurrentTitle(),

}



--If the latest FAR failed

--If currentstatus is FA or FL ==> Do nothing

--If there is no currentstatus ==> Error

--Else ==> FFA tr

function p._statusFFA(args, action)

    local row = mw.html.create()

    local result = mw.ustring.upper(args'action' .. action .. 'result'])

    local status = mw.ustring.upper(args'currentstatus'])



    if result == 'FAILED' or result == 'REMOVED'  or result == 'FAIL' or result == 'REMOVE' or result == 'DEMOTED' then

        if status == 'FA' and status == 'FL' then

            -- Do nothing

        elseif status then

            if status == 'FFA/GA' or args'small' == 'yes' then

                iconsize = 30

            else

                iconsize = 50

            end

            

            row

                :tag('tr')

                :tag('td')

                    :addClass('mbox-image')

                    :wikitext('[[File:Featured article star - cross.svg|' .. iconsize .. 'px|Former featured article]]')

                    :done()

                :tag('td')

                    :addClass('mbox-text')

                    :wikitext("'''" .. p.title.prefixedText .. "''' is a [[Wikipedia:Former featured articles|former featured article]]. "..

                        "Please see the links under Article milestones below for its original nomination page (for older articles, check " ..

                        "[[Wikipedia:Featured article candidates/Archived nominations/Index|the nomination archive]]) and why it was removed.")

                    table.insert(p.includeonly, "[[Category:Wikipedia former featured articles]]")

        else

            row

                :tag('tr')

                :addClass('error')

                :tag('td')

                    :addClass('mbox-image')

                    :wikitext("[[File:Imbox deletion.png]]")

                    :done()

                :tag('td')

                    :addClass('mbox-text')

                    :wikitext('Former featured articles should have a current status!')

                    :done()

                :done()

                table.insert(p.errors, '[[Category:ArticleHistory error]]')

        end

    end

    return tostring(row)

end



function p.statusFAC(args)

    local row = mw.html.create()

    row

        :tag('tr')

            :addClass('error')

            :tag('td')

                :addClass('mbox-image')

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''Use the template {{[[Template:fac|fac]]}} to nominate an article for Featured article status; " ..

                    "this simplifies the nomination procedure. A bot will add the details to the ArticleHistory template when the FAC process is closed.'''")

            :done()

        :done()

        table.insert(p.errors, '[[Category:ArticleHistory error]]')

    return tostring(row)

end



function p.statusFFAC(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-former.svg|" .. iconsize .. "px]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''" .. p.title.prefixedText .. "''' is a former [[Wikipedia:Featured article candidates|featured article candidate]]. "..

                    "Please view the links under Article milestones below to see why the nomination failed. " ..

                    "For older candidates, please check the [[Wikipedia:Featured article candidates/Archived nominations/Index|archive]].")

                table.insert(p.includeonly, "[[Category:Wikipedia featured article candidates (contested)]]")

    return tostring(row)

end



function p.statusFA(args)

    local row = mw.html.create()

    for i=20 , 1 , -1 do

        if args"action".. i and mw.ustring.upper(args"action".. i]) == "FAC" then

            actionlink = args"action" .. i .. "link"

            break

        end

    end

    if not actionlink then

        actionlink = "Wikipedia:Featured article candidates/" .. p.title.prefixedText

    end

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 48

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Featured article star.svg|" ..iconsize .. "px|Featured article]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' is a [[Wikipedia:Featured articles|featured article]]; " ..

                    "it (or a previous version of it) has been '''''[[" .. actionlink .. "|identified]]''''' " ..

                    "as one of the best articles produced by the [[Wikipedia:Wikipedians|Wikipedia community]]. " ..

                    "Even so, if you can update or improve it, [[Wikipedia:Be bold|please do so]].")

                table.insert(p.includeonly, "[[Category:Wikipedia featured articles]]")

    return tostring(row)

end



function p.statusFAR(args)

    local row = mw.html.create()

    row

        :tag('tr')

            :addClass('error')

            :tag('td')

                :addClass('mbox-image')

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''Use the template {{[[Template:FAR|FAR]]}} to nominate an article for Featured article status; " ..

                    "this simplifies the nomination procedure. A bot will add the details to the ArticleHistory template when the FAR process is closed.'''")

    table.insert(p.errors, "[[Category:ArticleHistory error]]")

    return tostring(row)

end



function p.statusFFLC(args)

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    local row = mw.html.create()

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-former.svg|".. iconsize .. "px|Former FLC]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' is a former [[Wikipedia:Featured list candidates|featured list candidate]]. " ..

                    "Please view the link under Article milestones below to see why the nomination failed. " ..

                    "Once the objections have been addressed you may [[Wikipedia:Featured list candidates#Resubmitting nominations|resubmit]] the article for featured list status.")

    table.insert(p.includeonly, "[[Category:Wikipedia featured list candidates (contested)]]")

    return tostring(row)

end



function p.statusFL(args)

    local row = mw.html.create()

    for i=20 , 1 , -1 do

        if args"action".. i == "FL" then

            actionlink = args"action" .. i .. "link"

            break

        end

    end

    if not actionlink then

        actionlink = "Wikipedia:Featured list candidates/" .. p.title.prefixedText

    end

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 48

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Featured article star.svg|" .. iconsize .. "px|Featured list]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' is a [[Wikipedia:Featured lists|featured list]], " ..

                    "which means it has been '''''[[" .. actionlink .. "|identified]]''''' as one of the best [[Wikipedia:Lists|lists]] produced by the [[Wikipedia:Wikipedians|Wikipedia community]]. " ..

                    "If you can update or improve it, [[Wikipedia:Be bold|please do so]].")

    table.insert(p.includeonly, "[[Category:Wikipedia featured lists]]")

    return tostring(row)

end



function p.statusFFL(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-featured-strike.svg|" .. iconsize .. "px|Former featured list]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' is a [[Wikipedia:Former featured lists|former featured list]]. " ..

                    "Please see the links under Article milestones below for its original nomination page and why it was removed. " ..

                    "If it has improved again to [[Wikipedia:Featured list criteria|featured list standard]], you may " ..

                    "[[Wikipedia:Featured list candidates|renominate]] the article to become a [[Wikipedia:Featured list|featured list]].")

            :done()

        :done()

   return tostring(row)

end



function p.statusGA(args, gatopic)

    local row = mw.html.create()

    if string.len(gatopic) > 0 then

        topiclink = '/' .. gatopic

    else

        topiclink = ''

    end



    if args'currentstatus' =='FFA/GA' then

        iconsize = 25

    elseif args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 40

    end



    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Symbol support vote.svg|" .. iconsize .. "px|Good article]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' has been listed as one of the '''''[[Wikipedia:Good articles" .. topiclink .."|" ..gatopic.."good articles]]''''' " ..

                    "under the [[Wikipedia:Good article criteria|good article criteria]]. If you can improve it further, [[Wikipedia:Be bold|please do so]]. " ..

                    "<small>''If it no longer meets these criteria, you can '''[[Wikipedia:Good article reassessment|reassess]]''' it''.</small>")

                

    if p.title:inNamespace("Talk") then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles]][[Category:Wikipedia CD Selection-GAs]][[Category:GA-Class Good articles]]")

        if gatopic then

            table.insert(p.includeonly,"[[Category:"..gatopic.." good articles|"..p.title.prefixedText.."]]")

        else

            table.insert(p.includeonly, "|[[Category:Uncategorized good articles|"..p.title.prefixedText.."]]")

        end

    end          

    return tostring(row)

end



function p.statusFGAN(args, gatopic)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Symbol unsupport vote.svg|" .. iconsize .. "px|Former good article nominee]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' was one of the '''''[[Wikipedia:Good articles|" .. gatopic .." good article]]''''' nominees, " ..

                    "but did not meet the [[Wikipedia:Good article criteria|good article criteria]] at the time. There are suggestions below for improving the article. " ..

                    "Once these issues have been addressed, the article can be [[Wikipedia:Good article nominations|renominated]]. " ..

                    "Editors may also seek a '''[[Wikipedia:Good article reassessment|reassessment]]''' of the decision if they believe there was a mistake.")

    table.insert(p.includeonly, "[[Category:Former good article nominees]]")

    return tostring(row)

end



function p.statusDGA(args, gatopic)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Symbol unsupport vote.svg|" .. iconsize .. "px|Former good article]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("'''"..p.title.prefixedText .. "''' was one of the '''''[[Wikipedia:Good articles|" .. gatopic .." good articles]]''''', " ..

                    "but it has been removed from the list. There are suggestions below for improving the article to meet the [[Wikipedia:Good article criteria|good article criteria]]. " ..

                    "Once these issues have been addressed, the article can be [[Wikipedia:Good article nominations|renominated]]. " ..

                    "Editors may also seek a '''[[Wikipedia:Good article reassessment|reassessment]]''' of the decision if they believe there was a mistake.")

     table.insert(p.includeonly, "[[Category:Delisted good articles]]")

     return tostring(row)

end



function p.statusFFT(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-featured-strike.svg|" .. iconsize .. "px|Former featured topic]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("This article is part of a ''[[Wikipedia:Former featured topics|former featured topic]]'' series. " ..

                    "If it has improved again to [[Wikipedia:Featured topic criteria|featured topic standard]], " ..

                    "you may [[Wikipedia:Featured topic candidates|renominate]] the topic to become a [[Wikipedia:Featured topic|featured topic]].")

            :done()

        :done()

    return tostring(row)

end



function p.statusFFTC(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-former.svg|" .. iconsize.. "px|Former featured topic candidate]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("This article is part of a ''former'' [[Wikipedia:Featured topic candidates|featured topic candidate]]. " ..

                    "Please view the links under Article milestones below to see why the nomination failed.")

    return tostring(row)

end



function p.statusFPO(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-featured.svg|" .. iconsize .. "px|Former featured topic candidate]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("The '''"..p.title.text .." Portal''' is a [[Wikipedia:Featured portals|featured portal]], " ..

                    "which means it has been '''''[[Wikipedia:Featured portal candidates/Portal:"..p.title.prefixedText .."|identified]]''''' " ..

                    "as one of the best portals on [[Wikipedia]]. If you see a way this portal can be updated or improved without compromising previous work, please feel free to contribute.")

    table.insert(p.includeonly, "[[Category:Wikipedia featured portals|"..p.title.text .."]]")

    return tostring(row)

end



function p.statusFFPO(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Featured article star - cross.svg|" .. iconsize .. "px|Former featured portal]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("This portal is a [[Wikipedia:Former featured portals|former featured portal]]. " ..

                    "Please see the links under Portal milestones below for its original nomination page and why it was removed.")

   table.insert(p.includeonly, "[[Category:Wikipedia former featured portals|"..p.title.text .."]]")

   return tostring(row)

end



function p.statusFFPOC(args)

    local row = mw.html.create()

    if args'small' == 'yes' then

        iconsize = 30

    else

        iconsize = 50

    end

    row

        :tag('tr')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Cscr-former.svg|" .. iconsize .. "px|Former featured portal candidate]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("This portal is a '''''former''''' [[Wikipedia:Featured portal candidates|featured portal candidate]]. " ..

                    "Please see the links under Portal milestones below for its original nomination page and why the nomination failed.")

    table.insert(p.includeonly, "[[Category:Wikipedia featured portal candidates (contested)|"..p.title.text .."]]")

    return tostring(row)

end



function p.statusInvalid(args)

    local row = mw.html.create()

    row

        :tag('tr')

            :addClass('error')

            :tag('td')

                :addClass('mbox-image')

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("Please do not use " .. args'currentstatus' .." as a ''currentstatus'' parameter: " ..

                    "these assessments are the responsibility of individual WikiProjects.")

    table.insert(p.errors, "[[Category:ArticleHistory error]]")

    return tostring(row)

end



function p.statusUnknown(args)

    local row = mw.html.create()

    row

        :tag('tr')

            :addClass('error')

            :tag('td')

                :addClass('mbox-image')

                :wikitext("[[File:Imbox deletion.png]]")

            :done()

            :tag('td')

                :addClass('mbox-text')

                :wikitext("Unknown current status!")

            :done()

        :done()

    table.insert(p.errors, "[[Category:ArticleHistory error]]")

    return tostring(row)

end



function p.statusFT(args)

    local isFA = false

    if args'ftname' then

    if p.featuredTopicSum(args'ftname']) then

            isFA = true

        elseif args'ft2name' then

            if p.featuredTopicSum(args'ft2name']) then

                isFA = true

            elseif args'ft3name' then

                if p.featuredTopicSum(args'ft3name']) then

                    isFA = true

                elseif args'ft4name' then

                    if p.featuredTopicSum(args'ft4name']) then

                        isFA = true

                    end

                end

            end

        end

    end



    if args'small' then

        iconsize = 30

    else

        iconsize = 48

    end



    if isFA then

        image = '[[File:cscr-featuredtopic.svg|' .. iconsize ..'px|Featured topic star]]'

    else

        image = '[[File:Support cluster.svg|' .. iconsize ..'px|Good topic star]]'

    end

    local row = mw.html.create():tag('tr')

        :tag('td')

            :addClass('mbox-image')

            :wikitext(image)

        :done()

    local cell = row:tag('td')

            :addClass('mbox-text')



            :wikitext("'''"..p.title.prefixedText .. "''' is ")

            if (args'ftmain' == 'yes') then

                cell:wikitext('the main article in')

            else

                cell:wikitext('part of')

            end

            cell:wikitext(" the '''[[Wikipedia:Featured topics/" .. args'ftname' .. '|' .. args'ftname' .. "]] series''', a ")

            if p.featuredTopicSum(args'ftname']) then

                cell:wikitext('[[Wikipedia:Featured topics|featured topic]]. ')

            else

                cell:wikitext('[[Wikipedia:Good topics|good topic]]. ')

            end



            if (args'ft2name']) then

                cell:wikitext('It is also ')

                if (args'ft2main' == 'yes') then

                    cell:wikitext('the main article in')

                else

                    cell:wikitext('part of')

                end

                cell:wikitext(" the '''[[Wikipedia:Featured topics/" .. args'ft2name' .. '|' .. args'ft2name' .. "]] series''', a ")

                if p.featuredTopicSum(args'ft2name']) then

                    cell:wikitext('[[Wikipedia:Featured topics|featured topic]]')

                else

                    cell:wikitext('[[Wikipedia:Good topics|good topic]]')

                end

            end





            if (args'ft3name']) then

                cell:wikitext('It is also ')

                if (args'ft3main' == 'yes') then

                    cell:wikitext('the main article in')

                else

                    cell:wikitext('part of')

                end

                cell:wikitext(" the '''[[Wikipedia:Featured topics/" .. args'ft3name' .. '|' .. args'ft3name' .. "]] series''', a ")

                if p.featuredTopicSum(args'ft3name']) then

                    cell:wikitext('[[Wikipedia:Featured topics|featured topic]]')

                else

                    cell:wikitext('[[Wikipedia:Good topics|good topic]]')

                end

            end



            if (args'ft4name']) then

                cell:wikitext('It is also ')

                if (args'ft4main' == 'yes') then

                    cell:wikitext('the main article in')

                else

                    cell:wikitext('part of')

                end

                cell:wikitext(" the '''[[Wikipedia:Featured topics/" .. args'ft4name' .. '|' .. args'ft4name' .. "]] series''', a ")

                if p.featuredTopicSum(args'ft4name']) then

                    cell:wikitext('[[Wikipedia:Featured topics|featured topic]]')

                else

                    cell:wikitext('[[Wikipedia:Good topics|good topic]]')

                end

        end



        if args'ft2name' then

            cell:wikitext('These are ')

        else

            cell:wikitext('This is ')

        end

        cell:wikitext("identified as among the best series of articles produced by the [[Wikipedia:Wikipedians|Wikipedia community]]. If you can update or improve ")

        if args'ft2name' then

            cell:wikitext('them')

        else

            cell:wikitext('it')

        end

        cell:wikitext(", [[Wikipedia:Be bold|please do so]].")



        -- Categories

        if args'currentstatus' == 'FA' then

            table.insert(p.includeonly,'[[Category:FA-Class Featured topics articles]]')

            table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ftname'..' featured content]]')

            if args'ft2name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft2name'..' featured content]]')

            end

            if args'ft3name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft3name'..' featured content]]')

            end

            if args'ft4name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft4name'..' featured content]]')

            end



        elseif args'currentstatus' == 'FL' then

            table.insert(p.includeonly,'[[Category:FL-Class Featured topics articles]]')

            table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ftname'..' featured content]]')

            if args'ft2name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft2name'..' featured content]]')

            end

            if args'ft3name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft3name'..' featured content]]')

            end

            if args'ft4name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft4name'..' featured content]]')

            end

            

        elseif args'currentstatus' == 'FFA/GA' or args'currentstatus' == 'GA' then

            table.insert(p.includeonly,'[[Category:GA-Class Featured topics articles]]')

            table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ftname'..' good content]]')

            if args'ft2name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft2name'..' good content]]')

            end

            if args'ft3name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft3name'..' good content]]')

            end

            if args'ft4name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft4name'..' good content]]')

            end

        else

            table.insert(p.includeonly,'[[Category:Unassessed Featured topics articles]]')

            table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ftname'..']]')

            if args'ft2name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft2name'..']]')

            end

            if args'ft3name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft3name'..']]')

            end

            if args'ft4name' then

                table.insert(p.includeonly,'[[Category:Wikipedia featured topics '..args'ft4name'..']]')

            end

        end



        if p.featuredTopicSum(args'ftname']) then

            if args'ftmain' == 'yes' then

               table.insert(p.includeonly,'[[Category:Top-importance Featured topics articles|'..args'ftname'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:High-importance Featured topics articles]]')

            end

        else

            if args'ftmain' == 'yes' then

                table.insert(p.includeonly,'[[Category:Mid-importance Featured topics articles|'..args'ftname'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:Low-importance Featured topics articles]]')

            end

        end



        if args'ft2name' then

            if p.featuredTopicSum(args'ft2name']) then

                if args'ft2main' == 'yes' then

                    table.insert(p.includeonly,'[[Category:Top-importance Featured topics articles|'..args'ft2name'.. ' ' .. p.title.text .. ']]')

                else

                    table.insert(p.includeonly,'[[Category:High-importance Featured topics articles]]')

                end

            else

                if args'ft2main' == 'yes' then

                    table.insert(p.includeonly,'[[Category:Mid-importance Featured topics articles|'..args'ft2name'.. ' ' .. p.title.text .. ']]')

                else

                    table.insert(p.includeonly,'[[Category:Low-importance Featured topics articles]]')

                end

            end

        end

    if args'ft3name' then

        if p.featuredTopicSum(args'ft3name']) then

            if args'ft3main' == 'yes' then

                table.insert(p.includeonly,'[[Category:Top-importance Featured topics articles|'..args'ft3name'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:High-importance Featured topics articles)')

            end

        else

            if args'ft3main' == 'yes' then

                table.insert(p.includeonly,'[[Category:Mid-importance Featured topics articles|'..args'ft3name'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:Low-importance Featured topics articles)')

            end

        end

    end



    if args'ft4name' then

        if p.featuredTopicSum(args'ft4name']) then

            if args'ft4main' == 'yes' then

                table.insert(p.includeonly,'[[Category:Top-importance Featured topics articles|'..args'ft4name'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:High-importance Featured topics articles)')

            end

        else

            if args'ft4main' == 'yes' then

                table.insert(p.includeonly,'[[Category:Mid-importance Featured topics articles|'..args'ft4name'.. ' ' .. p.title.text .. ']]')

            else

                table.insert(p.includeonly,'[[Category:Low-importance Featured topics articles)')

            end

        end

    end



    return tostring(row)

end



function p.featuredTopicSum(topic)

    --featured topics need at least two featured-class articles (FT criteria 3(a)(i)); if this criterion is not met, the article is a GT.-->

    --at least 50% of the articles in the topic need to be featured for the topic to be an FT

    return mw.site.stats.pagesInCategory('Wikipedia featured topics ' .. topic .. ' featured content') > 1 and

            mw.site.stats.pagesInCategory('Wikipedia featured topics ' .. topic .. ' featured content') >=

            (mw.site.stats.pagesInCategory('Wikipedia featured topics ' .. topic) +  mw.site.stats.pagesInCategory('Wikipedia featured topics ' .. topic .. ' good content')-2)

end



function p.milestoneMainPage(args)

    local lang = mw.language.getContentLanguage()

    local status = args'currentstatus'



    if lang:formatDate('Ymd', args'maindate']) < lang:formatDate('Ymd', '20110613') then

        mptype = 'article'

    elseif args'currentstatus' == 'FL' or args'currentstatus' == 'FFL' then

        mptype = 'list'

    else

        mptype = 'article'

    end

    if args'small' == 'yes' then

        iconsize = 15

    else

        iconsize = 30

    end

    local row = mw.html.create('tr')

        :tag('td')

            :addClass('mbox-image')

            :wikitext("[[File:Wikipedia-logo-v2.svg|"  .. iconsize ..  "px|Main Page trophy]]")

            :done()



        local text = "This article "

        if lang:formatDate('Ymd', args'maindate']) < lang:formatDate('Ymd') then

            text = text .. "appeared"

        elseif lang:formatDate('Ymd', args'maindate']) > lang:formatDate('Ymd') then

            text = text .. "will appear"

        else

            text = text .. "is currently"

        end



        text = text .. " on Wikipedia's [[Main Page]] as [[Wikipedia:Today's featured " .. mptype .. "/" .. lang:formatDate('F j, Y',args'maindate']) .. "|Today's featured " .. mptype .. "]]"

        if lang:formatDate('Ymd', args'maindate']) ~= lang:formatDate('Ymd') then 

            text = text .. " on " .. lang:formatDate('F j, Y',args'maindate'])

        end

        text = text .. "."

        

    row:tag('td')

        :addClass('mbox-text')

        :wikitext(text)

        

    if args'currentstatus' == 'FA' or args'currentstatus' == 'FL' then

        table.insert(p.includeonly, "[[Category:Featured " .. mptype .. "s that have not appeared on the main page]]")

    end



    return tostring(row)

end



function p.historyheader(args)

    local status = args'currentstatus'

    local images = ""

    if status == 'PR' or status == 'NA' or not status then

            images = images .. ('[[File:Nuvola apps kedit.svg|15px]]')

    end

    if args'dykdate' then

        images = images .. ('[[File:DYK questionmark icon.svg|Did You Know|15px]]')

    end

    if args'itndate' then

        images = images .. ('[[File:Globe current.svg|In the news|20px]]')

    end

    if args'otddate' then

        images = images .. ('[[File:Nuvola apps date.svg|On this day...|20px]]')

    end

    if args'aciddate' then

        images = images .. ('[[File:Article_Collaboration_and_Improvement_Drive.svg|20px]]')

    end

    if args'loceNotAnActiveOption' then

        images = images .. ('[[File:LoCiconRevised.png|15px]]')

    end

    if args'v1.0NotAnActiveOption' then

       images = images .. ('[[File:WP1 0 Icon.svg|15px]]')

    end

    local header = mw.html.create('tr')

        :tag('th')

            :attr('colspan', 3)

            :attr('style', 'font-size:110%')

            :tag('span')

                :attr('style', 'float:left')

                :wikitext(images)

                :done()

    if status == 'FL' or status == 'FFLC' or status == 'FFL' then

        header:wikitext('List')

    else

        header:wikitext(p.title.subjectNsText)

    end

    header:wikitext(' milestones')



    return header:allDone()

end



function p.historyoutput(action, date, link, result, oldid, args)

    local output = mw.html.create():tag('tr')

    if action then

        action = mw.ustring.upper(action)

    end

    if result then

        result = mw.ustring.lower(result)

    end

    --Date

    local datecell = output:tag('td')

    if oldid then

        datecell:tag('span')

            :addClass('plainlinks')

            :wikitext('['.. p.title:fullUrl('oldid='..oldid))

            if date then

                datecell:wikitext(' ' .. mw.language.getContentLanguage():formatDate('F j, Y', date))

            else

                datecell:wikitext(' ?')

                table.insert(p.errors, [[Category:ArticleHistory error]])

            end

            datecell:wikitext(']')

        datecell:done()

    else

        if date then

            datecell:wikitext(mw.language.getContentLanguage():formatDate('F j, Y', date))

        else

            datecell:wikitext(' ?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    end

    output:done()



 --Process

    if link == nil or link == "" then

        link = tostring(p.title.talkPageTitle) 

    end

    local processcell = output:tag('td'):wikitext("'''[[" .. link .. "|")

    if action == 'FAC' then

        processcell:wikitext('Featured article candidate')

    elseif action == 'FAR' or action == 'FARC' then

        processcell:wikitext('Featured article review')

    elseif action == 'BP' then

        processcell:wikitext('Brilliant prose')

    elseif action == 'RBP' then

        processcell:wikitext('Refreshing brilliant prose')

    elseif action == 'PR' then

        processcell:wikitext('Peer review')

    elseif action == 'WPR' and (result == "Approved" or result == "approved" or result == "Approved version" or result == "approved version") then

        processcell:wikitext('WikiProject approved revision')

    elseif action == 'WPR' and (result == "Copyedit" or result == "copyedit" or result == "Copyedited" or result == "copyedited" or result == "Proofread" or result == "proofread") then

        processcell:wikitext('Guild of Copy Editors')

    elseif action == 'WPR' and (result == "COTW" or result == "CotW" or result == "Cotw" or result == "cotw" or 

                    result == "Collaborated" or result == "collaborated" or result == "Collaboration" or result == "collaboration") then

        processcell:wikitext('WikiProject collaboration')

    elseif action == 'WPR' and (result == "Maindate" or result == "maindate") then

        processcell:wikitext("Today's featured article")

    elseif action == 'WPR' then

        processcell:wikitext("WikiProject peer review")

    elseif action == 'WAR' then

        processcell:wikitext("WikiProject A-class review")

    elseif action == 'GAN' or action == 'GAC' then

        processcell:wikitext("Good article nominee")

    elseif action == 'GAR' then

        processcell:wikitext("Good article reassessment")

    elseif action == 'MFD' then

        processcell:wikitext("Miscellanea for deletion")

    elseif action == 'AFD' then

        processcell:wikitext("Articles for deletion")

    elseif action == 'IFD' then

        processcell:wikitext("Images for deletion")

    elseif action == 'TFD' then

        processcell:wikitext("Templates for deletion")

    elseif action == 'CSD' then

        processcell:wikitext("Candidate for speedy deletion")

    elseif action == 'PROD' then

        processcell:wikitext("Proposed deletion")

    elseif action == 'DRV' then

        processcell:wikitext("Deletion review")

    elseif action == 'FTC' then

        processcell:wikitext("Featured topic candidate")

    elseif action == 'FTR' then

        processcell:wikitext("Featured topic removal candidate")

    elseif action == 'GTC' then

        processcell:wikitext("Good topic candidate")

    elseif action == 'GTR' then

        processcell:wikitext("Good topic removal candidate")

    elseif action == 'FLC' then

        processcell:wikitext("Featured list candidate")

    elseif action == 'FLR' then

        processcell:wikitext("Featured list removal candidate")

    elseif action == 'FPOC' then

        processcell:wikitext("Featured portal candidate")

    elseif action == 'FPOR' then

        processcell:wikitext("Featured portal review")

    end



    processcell:wikitext("]]'''")

    output:done()



    --Result

    local resultcell = output:tag('td')



    if action == 'FAC' or action == 'FLC' or action == 'FTC' or action == 'GTC' or action == 'FPOC' then

        if result == 'pass' or result == 'passed' or result == 'promoted' then

            resultcell:wikitext('Promoted')

        elseif result == 'fail' or result == 'failed' or result == 'not promoted' then

            resultcell:wikitext('Not promoted')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'FAR' or action == 'FARC' or action == 'FLR' or action == 'FTR' or action == 'GTR' or action == 'FPOR' then

        if result == 'pass' or result == 'passed' or result == 'keep' or result == 'kept' then

            resultcell:wikitext('Kept')

            if action == 'FAR' or action == 'FARC' then

               table.insert(p.category, '[[Category:Wikipedia featured article review candidates (closed)]]')

            end

        elseif result == 'fail' or result == 'failed' or result == 'remove' or result == 'removed' or result == 'demoted' then

            resultcell:wikitext('Demoted')

        elseif result == 'merged' or result == 'merge' then

            resultcell:wikitext('Merged')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'RBP' then

        if result == 'pass' or result == 'keep' or result == 'kept' then

            resultcell:wikitext('Kept')

        elseif result == 'fail' or result == 'failed' or result == 'remove' or result == 'removed' or result == 'demoted' then

            resultcell:wikitext('Not kept')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'BP' then

        if result == 'pass' or result == 'promoted' or result == 'nominated' or result == 'nom' then

            resultcell:wikitext('Nominated')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'GAN' or action == 'GAC' then

        if result == 'pass' or result == 'passed' or result == 'promoted' or result == 'listed' then

            resultcell:wikitext('Listed')

        elseif result == 'fail' or result == 'failed' or result == 'not promoted' or result == 'not listed' then

            resultcell:wikitext('Not liseted')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'GAR' then

        if result == 'pass' or result == 'passed' or result == 'keep' or result == 'kept' then

            resultcell:wikitext('Kept')

        elseif result == 'fail' or result == 'failed' or result == 'delisted' then

            resultcell:wikitext('Delisted')

        elseif result == 'listed' then

            resultcell:wikitext('Listed')

        elseif result == 'not listed' then

            resultcell:wikitext('Not listed')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

    elseif action == 'MFD' or action == 'AFD' or action == 'TFD' or action == 'IFD' or action == 'CSD' or action == 'PROD' then

        if result == 'withdrawn' or result == 'keep' or result == 'kept' then

            resultcell:wikitext('Kept')

        elseif result == 'delete' or result == 'deleted'then

            resultcell:wikitext('Deleted')

        elseif result == 'merged' or result == 'merge' then

            resultcell:wikitext('Merged')

        elseif result == 'no consensus' then

            resultcell:wikitext('No consensus')

        elseif result == 'speedy keep' or result == 'speedily kept' then

            resultcell:wikitext('Speedily kept')

        elseif result == 'speedy delete' or result == 'speedily deleted' then

            resultcell:wikitext('Speedily deleted')

        elseif result == 'redirect' or result == 'redirected' then

            resultcell:wikitext('Redirected')

        elseif result == 'rename' or result == 'renamed' or result == 'move' or result == 'moved' then

            resultcell:wikitext('Renamed')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end



    elseif action == 'DRV' then

        if result == 'endorse' or result == 'endorsed' then

            resultcell:wikitext('Endorsed')

        elseif result == 'relisted' or result == 'relist' then

            resultcell:wikitext('Relisted')

        elseif result == 'overturn' or result == 'overturned' then

            resultcell:wikitext('Overturned')

        elseif result == 'no consensus' then

            resultcell:wikitext('No consensus')

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end



    elseif action == 'PR' then

        if result == 'not reviewed' then

            resultcell:wikitext('Not reviewed')

        else

            resultcell:wikitext('Reviewed')

        end



    elseif action == 'WPR' then

        if result == 'approved' or result == 'approved version' then

            if oldid then

                resultcell:tag('small')

                :wikitext('[' .. p.title:fullUrl('diff=cur&oldid='..oldid) .. ' Diff to current version]')

                :done()

            else

                resultcell:wikitext('?')

                table.insert(p.errors, [[Category:ArticleHistory error]])

            end

        elseif result == 'copyedit' or result == 'copyedited' or result == 'proofread' then

            resultcell:wikitext('Copyedited')

        elseif result == 'maindate' then

            resultcell:wikitext('Main Page')

        elseif result == 'cotw' or result == 'collaborated' or result == 'collaboration' then

            resultcell:wikitext('Collaborated')

        elseif result == 'reviewed' then

            resultcell:wikitext('Reviewed')

        elseif result == 'not reviewed' then

            resultcell:wikitext('Not reviewed')

        else

            resultcell:wikitext('Reviewed')

        end



        elseif action == 'WAR' then

            if result == 'pass' or result == 'passed' or result == 'approved' then

                resultcell:wikitext('Approved')

            elseif result == 'fail' or result == 'failed' or result == 'not approved' or result == 'not reviewed' then

                resultcell:wikitext('Not approved')

            elseif result == 'reviewed' or result == '' then

                resultcell:wikitext('Reviewed')

            elseif result == 'keep' or result == 'kept' then

                resultcell:wikitext('kept')

            elseif result == 'demote' or result == 'demoted' then

                resultcell:wikitext('Demoted')

            else

                resultcell:wikitext('?')

                table.insert(p.errors, [[Category:ArticleHistory error]])

            end

        else

            resultcell:wikitext('?')

            table.insert(p.errors, [[Category:ArticleHistory error]])

        end

        output:done():done()



        --Categories

        if action == 'FAR' or action == 'FARC' then

            if result == 'fail' or result == 'failed' or result == 'remove' or result == 'removed' or result == 'demoted' or result == 'merged' or result == 'merge' then

                if args'currentstatus' == 'FA' or args'currentstatus' == 'FL' then

                    table.insert(p.category, '[[Category:Wikipedia former featured articles|#'..p.title.text..']]')

                else

                    table.insert(p.category, '[[Category:Wikipedia former featured articles|'..p.title.text..']]')

                end

            end

        elseif action == 'RBP' then

            if result == 'fail' or result == 'failed' or result == 'remove' or result == 'removed' or result == 'demoted' then

                table.insert(p.category, '[[Category:Wikipedia former brilliant prose|'..p.title.text..']]')

            end

        elseif action == 'GAN' or action == 'GAC' then

            if result == 'fail' or result == 'failed' or result == 'not promoted' or result == 'not listed' then

                if args'currentstatus' == 'FA' or args'currentstatus' == 'GA'  or args'currentstatus' == 'FFA'  or args'currentstatus' == 'FFA/GA' then



                else

                    table.insert(p.category, '[[Category:Former good article nominees|'..p.title.text..']]')

                end

            end

         elseif action == 'GAR' then

            if result == 'fail' or result == 'failed' or result == 'delisted' then

                if args'currentstatus' == 'FA' or args'currentstatus' == 'GA'  or args'currentstatus' == 'FFA/GA' then



                else

                   table.insert(p.category, '[[Category:Delisted good articles|'..p.title.text..']]')

                end

            end

        elseif action == 'FLR' then

            if result == 'fail' or result == 'failed' or result == 'remove' or result == 'removed' or result == 'demoted' or result == 'merged' or result == 'merge' then

                if args'currentstatus' == 'FL' then

                    table.insert(p.category, '[[Category:Wikipedia former featured lists|#'..p.title.text..']]')

                else

                    table.insert(p.category, '[[Category:Wikipedia former featured lists|'..p.title.text..']]')

                end

        end

        elseif action == 'PR' then

            table.insert(p.category, '[[Category:Old requests for peer review]]')

        end

    return output

end



function p.milestoneDYK(args)

    local td = mw.html.create('tr')

    local row = td

    if args'action1' then

        row = row:tag('td')

            :attr('colspan', '3')

            :attr('width', '100%')

        if args'dykentry' then

           row = row:tag('table')

            :addClass('collapsible collapsed')

             :attr('style', 'margin: 0; padding: 0; border-collapse: collapse; width: 100%; background: transparent')

            :tag('tr')

            :tag('th')

            :attr('style', 'font-weight: normal; text-align: left; width: 100%')

        end

        row = row:wikitext('[[File:DYK questionmark icon.svg|Did You Know|' .. ((args'small' == 'yes' and '15') or '20') ..'px]]&#32;')

    else

        row = row:tag('td')

            :addClass('mbox-image')

            :wikitext('[[File:DYK questionmark icon.svg|Did You Know|' .. ((args'small' == 'yes' and '15') or '20') ..'px]]')

            :done()

        if args'dykentry' then

            row = row:tag('td')

            :addClass('mbox-text')

            :tag('table')

            :addClass('collapsible collapsed')

            :attr('style', 'margin: 0; padding: 0; border-collapse: collapse; width: 100%; background: transparent')

            :tag('tr')

            :tag('th')

            :attr('style', 'font-weight: normal; text-align: left; width: 100%')

        else

            row = row:tag('td')

            :addClass('mbox-text')

        end

    end

    local lang = mw.language.getContentLanguage()

    local text

    if mw.title.makeTitle('Wikipedia', 'Recent additions/' .. lang:formatDate('Y/F#j F Y', args'dykdate'])).exists then

        text = "A '''[[Wikipedia:Recent additions/"..lang:formatDate('Y/F#j F Y', args'dykdate']).."|fact from this article]]'''"

    else

        text = "A '''[[Wikipedia:Recent additions|fact from this article]]'''"

    end

    text = text .." appeared on Wikipedia's [[Main Page]] in the '' \"[[:Template:Did you know|Did you know?]]\" '' column on ".. lang:formatDate('F j, Y',args'dykdate'])

    if args'dykdate2' then

       text = text .. ', and on '.. lang:formatDate('F j, Y',args'dykdate'])

    end

    text = text .. '.'

    row = row:wikitext(text)

    if args'dykentry' then

        row = row:done():done()

        :tag('tr')

        :tag('td')

        :attr('style', 'border: 1px silver solid')

        :wikitext("The text of the entry was: ''Did you know " .. args'dykentry'.."''")

        :done():done():done()

    elseif args'action1' then

        row:done()

    end

    if args'action1' then

        row:done()

    end

    row:done()



    if args'currentstatus' == FA then

       table.insert(p.includeonly, '[[Category:Wikipedia Did you know articles that are featured articles]]')

    elseif args'currentstatus' == FL then

        table.insert(p.includeonly, '[[Category:Wikipedia Did you know articles that are featured lists]]')

    elseif args'currentstatus' == 'FFA/GA' or args'currentstatus' == 'GA' then

       table.insert(p.includeonly, '[[Category:Wikipedia Did you know articles that are good articles]]')

    else

       table.insert(p.includeonly, '[[Category:Wikipedia Did you know articles]]')

    end



    return row:allDone()

end



function p.milestoneITN(args)

    local lang = mw.language.getContentLanguage()

   table.insert(p.category,"[[Category:Wikipedia In the news articles]]")

    local mboximage = "[[File:Globe current.svg|In the news|20px]]"

    local text = "A news item involving this article was featured on Wikipedia's [[Main Page]] in the ''\"[[:Template:In the news|In the news]]\"''"

        if args'itnlink' then

            text = text .. " [[" .. args'itnlink'.."|column]]"

        else

            text = text .. " column"

        end

        text = text .. " on " .. lang:formatDate('F j, Y', args'itndate'])

        if args'itndate2' then

            text = text .. ", and on " .. lang:formatDate('F j, Y', args'itndate2'])

        end

        text = text .. '.'



    local row = mw.html.create('tr')

    if args'action1' then

        row:tag('td')

        :attr('colspan', '3')

        :wikitext(mboximage .. " " .. text)

     else

        row:tag('td')

         :addClass('mbox-image')

         :wikitext(mboximage)

         :done()

         :tag('td')

         :addClass('mbox-text')

         :wikitext(text)

     end

     return row

end



function p.milestoneOTD(args)

    local lang = mw.language.getContentLanguage()

    table.insert(p.category, "[[Category:Selected anniversaries articles]]")

    local mboximage = "[[File:Nuvola apps date.svg|On this day...|20px]]"

    local text = "A fact from this article was featured on Wikipedia's [[Main Page]] in the  ''\"[[Wikipedia:Selected anniversaries|On this day...]]\"''"

        if args'otdlink' then

            text = text .. " [[" .. args'otdlink'.."|column]]"

        else

            text = text .. " column"

        end

        text = text .. " on " .. lang:formatDate('F j, Y', args'otddate'])

        if args'otddate2' then

            text = text .. ", and on " .. lang:formatDate('F j, Y', args'otddate2'])

        end

        text = text .. '.'



    local row = mw.html.create('tr')

    if args'action1' then

        row:tag('td')

        :attr('colspan', '3')

        :wikitext(mboximage .. " " .. text)

     else

        row:tag('td')

         :addClass('mbox-image')

         :wikitext(mboximage)

         :done()

         :tag('td')

         :addClass('mbox-text')

         :wikitext(text)

     end

     return row

end



function p.milestoneACID(args)

    local lang = mw.language.getContentLanguage()

    local mboximage = "[[File:Article_Collaboration_and_Improvement_Drive.svg|Article Collaboration and Improvement Drive|20px]]"

    local text = "This article was on the [[WP:ACID|Article Collaboration and Improvement Drive]] for the week of  " .. lang:formatDate('F j, Y', args'aciddate']) .. '.'



    local row = mw.html.create('tr')

    if args'action1' then

        row:tag('td')

        :attr('colspan', '3')

        :wikitext(mboximage .. " " .. text)

     else

        row:tag('td')

         :addClass('mbox-image')

         :wikitext(mboximage)

         :done()

         :tag('td')

         :addClass('mbox-text')

         :wikitext(text)

     end

     return row

end



function p.milestoneLoC(args)

    local mboximage = "[[File:LoCiconRevised.png|League of Copyeditors|" .. ((args'small' == "yes") and "20px") or "25px" .. "]]"

    local text = "This article, or a portion of it, was copyedited by the [[WP:LoCE|League of Copyeditors]]."



    local row = mw.html.create('tr')

    if args'action1' then

        row:tag('td')

        :attr('colspan', '3')

        :wikitext(mboximage .. " " .. text)

     else

        row:tag('td')

         :addClass('mbox-image')

         :wikitext(mboximage)

         :done()

         :tag('td')

         :addClass('mbox-text')

         :wikitext(text)

     end

     return row

end



function p.currentstatus(args)

    local row = mw.html.create()

    local statuses = {

        FA="Featured article",

        FAR="Featured article review candidate",

        FARC="Featured article review candidate",

        FFA="Former featured article",

        "FFA/GA"="Former featured article, current good article",

        FFAC="Former featured article candidate",

        FACFAILED="Former featured article candidate",

        FFLC="Former featured list candidate",

        FL="Featured list",

        FFL="Former featured list",

        GA="Good article",

        FGAN="Former good article nominee",

        FAILEDGA="Former good article nominee",

        DGA="Delisted good article",

        DELISTEDGA="Delisted good article",

        FFT="Part of former featured topic",

        FFTC="Former featured topic candidate",

        FPO="Featured portal",

        FFPO="Former featured portal",

        FFPOC="Former featured portal candidate",

        PR="Peer reviewed",

   }



    local currentstatus = false

    for i=2, 20, 1 do

        if args'action'..i then

            currentstatus = true

        end

    end

    if currentstatus then

        local td = row:tag('tr'):tag('td')

        :attr('colspan', '3')

        if statusesargs'currentstatus']] then

            td:wikitext("Current status: '''" .. statusesargs'currentstatus']] .. "'''")

            if args'currentstatus' == "FA" or args'currentstatus' == "FL" or args'currentstatus' == "FFA/GA" or args'currentstatus' == "GA" then

                if args'gacat' then

                    td:wikitext(" (" .. args'gacat' .. ")")

                end

            end

        else

            td:wikitext("Current status: '''?'''")

        end

    elseif args'action1' == nil then

        row:tag('tr')

        :addClass('error')

        :tag('td')

        :addClass('mbox-image')

        :wikitext("[[File:Imbox deletion.png]]")

        :done()

        :tag('td')

        :addClass('mbox-text')

        :wikitext("Current status is supplied without any actions!")

        table.insert(p.errors,"[[Category:ArticleHistory error|#]]")

    end

    return row

end



function p.fourawardtest(args, status)

    -- If article has not yet been tested for [[WP:FOUR]]

    if args'four' then

        return false

    end

    -- If article has been on DYK

    if not args'dykdate' then

        return false

    end

    -- If article is currently FA

    if status ~= FA then

        return false

    end

    -- If successful GAN is anywhere in the history

    for i=1, 20, 1 do

        if args'action'..i and mw.ustring.upper(args'action' .. i]) == 'GAN' then

            if args'action'..i .. 'result' and mw.ustring.lower(args'action' .. i .. 'result']) == 'listed' then 

                return true

            end

        end

    end

    --No successful GAN in history

    return false

end



function p._articlehistory(args, frame)

    local status = args'currentstatus'

    local gatopic = frame:expandTemplate { title='GA/Topic' , args = {args'topic']}}

    if status then

        status = mw.ustring.upper(args'currentstatus'])

    end



    local tbl = mw.html.create('table')



    tbl

        :addClass('tmbox')

        :addClass('tmbox-notice')



    if args.small == 'yes' then

        tbl:addClass('mbox-small')

    end



    --Sorting current status

    

    --FFA check based on most recent FAR (if there is one)

    for i=20 , 1 , -1 do

        if args"action".. i and mw.ustring.upper(args"action".. i]) == "FAR" then

            tbl:node(p._statusFFA(args, i))

            break

        end

    end



    if status == 'FFA' then

        -- Already covered in FFA check previously--

    elseif status == 'FAC' then

        tbl:node(p.statusFAC(args))

    elseif status == 'FFAC' or status == 'FACFAILED' then

        tbl:node(p.statusFFAC(args))

    elseif status == 'FA' then

        tbl:node(p.statusFA(args))

    elseif status == 'FAR' then

        tbl:node(p.statusFAR(args))

    elseif status == 'FFLC' then

        tbl:node(p.statusFFLC(args))

    elseif status == 'FL' then

        tbl:node(p.statusFL(args))

    elseif status == 'FFL' then

        tbl:node(p.statusFFL(args))

    elseif status == 'FFA/GA' or status == 'GA' then

        tbl:node(p.statusGA(args, gatopic))

    elseif status == 'FGAN' or status == 'FAILEDGA' then

        tbl:node(p.statusFGAN(args, gatopic))

    elseif status == 'DGA' or status == 'DELISTEDGA' then

        tbl:node(p.statusDGA(args, gatopic    ))

    elseif status == 'FFT' then

        tbl:node(p.statusFFT(args))

    elseif status == 'FFTC' then

        tbl:node(p.statusFFTC(args))

    elseif status == 'FPO' then

        tbl:node(p.statusFPO(args))

    elseif status == 'FFPO' then

        tbl:node(p.statusFFPO(args))

    elseif status == 'FFPOC' then

        tbl:node(p.statusFFPOC(args))

    elseif status == 'START' or status == 'STUB' or status == 'B' or status == 'A' then

        tbl:node(p.statusInvalid(args))

    elseif status == 'PR' or status == 'NA' or status == nil or status == '' then

        --do nothing if no status selected

    else

        tbl:node(p.statusUnknown(args))

    end



    if args'ftname' then

        tbl:node(p.statusFT(args))

    end

    

    if args'maindate' then

        tbl:node(p.milestoneMainPage(args))

    --If the article is an FA or FL but has not been on the main page, add it to a category

    elseif status == 'FA' then

        table.insert(p.category,"[[Category:Featured articles that have not appeared on the main page]]")

    elseif status == 'FL' then

        table.insert(p.category,"[[Category:Featured lists that have not appeared on the main page]]")

    end

    

    --Article milestones

    

    local history = tbl

    if args'action1' then

        history = history:tag('tr')

            :tag('td')

                :attr('colspan', 2)

                :attr('style', 'width: 100%;')

            :tag('table')

                :attr('style','width:100%; background:transparent; font-size:90%')

                :addClass('AH-milestones')



        if args'action2' or args'dykdate' or args'itndate' or args'otddate' or args'aciddate' or args'loceNotAnActiveOption' then

            history:addClass('collapsible collapsed')

            history:node(p.historyheader(args))

            history:tag('tr')

                :attr('style', 'text-align: left')

                :tag('th'):wikitext('Date'):done()

                :tag('th'):wikitext('Process'):done()

                :tag('th'):wikitext('Result'):done()

        end







    for i=1, 20, 1 do

        if args'action'..i then

            history:node(p.historyoutput(args'action'..i], args'action'..i..'date'], args'action'..i..'link'], args'action'..i..'result'], args'action'..i..'oldid'], args))

        elseif args'action'..i..'date' or args'action'..i..'link' or args'action'..i..'result' or args'action'..i..'oldid' then

            table.insert(p.errors, '[[Category:ArticleHistory error|$]]')

        end

    end

    end

    if args'dykdate' then

         history:node(p.milestoneDYK(args))

    end

    if args'four' and mw.ustring.lower(args'four']) == 'yes' then

        table.insert(p.includeonly,"[[Category:Wikipedia four award articles]]")

    end

    if args'itndate' then

        history:node(p.milestoneITN(args))

    end

    if args'otddate' then

        history:node(p.milestoneOTD(args))

    end

    if args'aciddate' then

        history:node(p.milestoneACID(args))

    end

    if args'loceNotAnActiveOption' then

        history:node(p.milestoneLoC(args))

    end

    if args'currentstatus' ~= nil and args'currentstatus' ~= "" then

        history:node(p.currentstatus(args))

    end

    if args'action1' then

        --width hack

        history:done():done():tag('td')

    end

    

    --Categories

    

    if args'categories' or args'category' then

        table.insert(p.errors, "[[Category:ArticleHistory error]]")

    end

    if args'list' then

        table.insert(p.errors, "[[Category:ArticleHistory error]]")

    end

    if args'topic' then

        if not gatopic or gatopic == "" then

            table.insert(p.errors, "[[Category:ArticleHistory error]]")

        end

    end

    if status == "FFA/GA" or status == "GA" then

        if args'gacat' == 'actors' then

            table.insert(p.includeonly, "[[Category:Wikipedia good articles on actors, models and celebrities]]" ..

                "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == 'bands' then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles on performers and composers]]")

        elseif args'gacat' == 'hist figures' then

            table.insert(p.includeonly, "[[Category:Wikipedia good articles on historical figures]]" ..

                "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == 'musicians' then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles on performers and composers]]" ..

            "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == 'politicians' then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles on politicians]]" ..

            "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == 'royalty' then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles on royalty]]" ..

            "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == 'writers' then

        table.insert(p.includeonly, "[[Category:Wikipedia good articles on writers and critics]]" ..

            "[[Category:Wikipedia CD Selection - People]]")

        elseif args'gacat' == "" then

        else

             table.insert(p.errors, "[[Category:ArticleHistory error]]")

        end

        if p.fourawardtest(args, status) then

            table.insert(p.includeonly, "[[Category:Possible Wikipedia four award articles]]")

        end

     end   

        

    return tostring(tbl) .. table.concat(p.category) .. table.concat(p.includeonly) .. table.concat(p.errors)

end



function p.articlehistory(frame)

   local pframe = frame:getParent()



    local args = {};

    for k, v in pairs( pframe.args ) do

        argsk = v;

    end

    for k, v in pairs( frame.args ) do

        argsk = v;

    end



    return p._articlehistory( args , frame )

end



return p

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook