Main Page and Module:Yesno: Difference between pages

From Frontierpedia, the Microsoft Agent encyclopedia
(Difference between pages)
No edit summary
 
en>Mr. Stradivarius
(removing code that's no longer used)
 
Line 1: Line 1:
<templatestyles src="Frontierpedia:Main Page/styles.css" />
local p = {}
<div id="mp-topbanner" class="mp-box">
<div id="mp-welcomecount">
<div id="mp-welcome"><h1>Welcome to [[Frontierpedia]]</h1>,</div>
<div id="mp-free">an encyclopedia centered around TMAFE and related communities.</div>
<div id="articlecount">Before corruption, there were over 5,000 edits.</div>
</div>
</div>
under maintenance!
Of course it is. hello fpv6! hello webhook!


== Welcome ==
function p.yesno(frame)


=== What happened? ===
    -- defaults
Frontierpedia V5's database has had stability issues since its creation and as a result finally gave out.
    local retvals = {
        yes  = "yes",
        no    = "",
        ["¬"] = ""
    }


=== When will articles be restored? ===
    -- Allow arguments to override defaults.
An attempt to restore some articles will be done tomorrow. In the meantime, please create your account again.
    -- 'any' tracks the presence of any arguments at all.
    local args = frame.args
    local any = false
    for k,v in pairs(args) do
        any = true
        retvals[k] = v
    end
    -- If there are no arguments, try and get them from the parent frame.
    if any == false then
        local pframe = frame:getParent()
        args = pframe.args
        for k,v in pairs(args) do
            retvals[k] = v
        end
    end   


=== How can I help? ===
    val = args[1]
You can help by testing out the wiki and its features to make sure MediaWiki 1.38 is stable enough.


__NOTOC____NOEDITSECTION__
    -- First deal with the case if val is nil or "¬", then deal with other cases.
    if val == nil or val == '¬' then
        return retvals['¬']
    end
 
    val = val:lower()          -- Make lowercase.
    val = val:match'^%s*(.*%S)' or ''  -- Trim whitespace.
 
    if val == '' then
        return retvals['blank'] or retvals['no']
    elseif val == 'n' or val == 'no'  or val == '0' then
        return retvals['no']
    elseif val == 'y' or val == 'yes' or val == '1' or retvals['def'] == nil then
        return retvals['yes']
    else
        return retvals['def']
    end
end
 
return p

Revision as of 10:29, 23 March 2013

Documentation for this module may be created at Module:Yesno/doc

local p = {}

function p.yesno(frame)

    -- defaults
    local retvals = {
        yes   = "yes",
        no    = "",
        ["¬"] = ""
    }

    -- Allow arguments to override defaults.
    -- 'any' tracks the presence of any arguments at all.
    local args = frame.args
    local any = false
    for k,v in pairs(args) do
        any = true
        retvals[k] = v
    end
    -- If there are no arguments, try and get them from the parent frame.
    if any == false then
        local pframe = frame:getParent()
        args = pframe.args
        for k,v in pairs(args) do
            retvals[k] = v
        end
    end    

    val = args[1]

    -- First deal with the case if val is nil or "¬", then deal with other cases.
    if val == nil or val == '¬' then
        return retvals['¬']
    end

    val = val:lower()          -- Make lowercase.
    val = val:match'^%s*(.*%S)' or ''  -- Trim whitespace.

    if val == '' then
        return retvals['blank'] or retvals['no']
    elseif val == 'n' or val == 'no'  or val == '0' then
        return retvals['no']
    elseif val == 'y' or val == 'yes' or val == '1' or retvals['def'] == nil then
        return retvals['yes']
    else
        return retvals['def']
    end
end

return p