Jump to content

Module:Odot control: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Debug
date output
Line 28: Line 28:
local year = args['year'] or ''
local year = args['year'] or ''
local editionProcessed
return editionSwitch(year)
editionString = tostring(year) --force conversion to string to make sure comparisons work right

--Lots of possibilities to get 2010–2011.
--(The -1 is there in case someone typed "2010-2011", which Lua might try to subtract.)
if editionString == "2010" or editionString == "2011" or editionString == "2010–2011" or editionString == "2010-2011" or editionString == "-1" then
editionProcessed = "2010–2011"
elseif editionString == "2008" then
editionProcessed = "2008"
else
editionProcessed = ""
end

return editionProcessed
--return editionSwitch(year)
end
end

function p.dateOutput(frame)
--This function fills in the date field of cite map.
local pframe = frame:getParent() --get arguments passed to the template
local args = pframe.args
local year = args['year'] or ''
local edition = p.edition
local dateOutput
if edition == "2010–2011" then
dateOutput = "2010-01-01"
elseif edition == "2008" then
dateOutput = "2010-01-01"
end
return dateOutput
end



function editionSwitch(editionString)
function editionSwitch(editionString)

Revision as of 09:45, 27 April 2013

local p = { } --Package to be exported

function p.url(frame)
    --This function builds URLs.
    local pframe = frame:getParent() --get arguments passed to the template
    local args = pframe.args
    local county = args['county'] or '' --this string holds the raw county name
    local countyProcessed --this string holds the processed county name to be added to the URL
    
    --Le Flore and Roger Mills need special treatment to handle the spaces.
    --Everything else just gets converted to lower case.
    if county == "Le Flore" then
        countyProcessed = "leflore"
    elseif county == "Roger Mills" then
        countyProcessed = "rogermills"
    else
        countyProcessed = county:lower()
    end
    
    --Shove the county name in the URL and call it good
    return "http://www.odot.org/hqdiv/p-r-div/maps/control-maps/" .. countyProcessed .. ".pdf"
end

function p.edition(frame)
    --This function fills in the edition field of cite map.
    local pframe = frame:getParent() --get arguments passed to the template
    local args = pframe.args
    local year = args['year'] or ''
    
    local editionProcessed
    editionString = tostring(year) --force conversion to string to make sure comparisons work right

    --Lots of possibilities to get 2010–2011.
    --(The -1 is there in case someone typed "2010-2011", which Lua might try to subtract.)
    if editionString == "2010" or editionString == "2011" or editionString == "2010–2011" or editionString == "2010-2011" or editionString == "-1" then
        editionProcessed = "2010–2011"  
    elseif editionString == "2008" then
        editionProcessed = "2008"
    else        
        editionProcessed = ""
    end

    return editionProcessed
    
    --return editionSwitch(year)  
end

function p.dateOutput(frame)
    --This function fills in the date field of cite map.
    local pframe = frame:getParent() --get arguments passed to the template
    local args = pframe.args
    local year = args['year'] or ''
    
    local edition = p.edition
    local dateOutput
    
    if edition == "2010–2011" then
        dateOutput = "2010-01-01"
    elseif edition == "2008" then
        dateOutput = "2010-01-01"
    end
    
    return dateOutput
end


function editionSwitch(editionString)
    --This function rationalizes edition input.
    --(It is called by p.edition and p.date)
    local editionProcessed
    editionString = tostring(editionString) --force conversion to string to make sure comparisons work right

    --Lots of possibilities to get 2010–2011.
    --(The -1 is there in case someone typed "2010-2011", which Lua might try to subtract.)
    if editionString == "2010" or editionString == "2011" or editionString == "2010–2011" or editionString == "2010-2011" or editionString == "-1" then
        editionProcessed = "2010–2011"  
    elseif editionString == "2008" then
        editionProcessed = "2008"
    else        
        editionProcessed = ""
    end

    return editionProcessed
end

return p