Dokumentasion ti modulo

Daytoy a modulo ket maus-usar para kadagiti napili a linaon ti Umuna a Panid, Umuna a Panid/Intono bigat, ken Umuna a Panid/Idi kalman.

Panagusar

Agdama

  • {{#invoke:Umuna a Panid|agdama|potd}} - para iti napili a ladawan
  • {{#invoke:Umuna a Panid|agdama|dyk}} - para iti ammom kadi
  • {{#invoke:Umuna a Panid|agdama|tfa}} - para iti napili nga artikulo

Intono bigat

  • {{#invoke:Umuna a Panid|intonobigat|potd}} - para iti napili a ladawan
  • {{#invoke:Umuna a Panid|intonobigat|dyk}} - para iti ammom kadi
  • {{#invoke:Umuna a Panid|intonobigat|tfa}} - para iti napili nga artikulo

Idi kalman

  • {{#invoke:Umuna a Panid|idikalman|potd}} - para iti napili a ladawan
  • {{#invoke:Umuna a Panid|idikalman|dyk}} - para iti ammom kadi
  • {{#invoke:Umuna a Panid|idikalman|tfa}} - para iti napili nga artikulo

local p = {}
local lang = mw.getContentLanguage()

-- Prefixes for each type of main page content
-- The key is the parameter to the 'current' function
local prefixes = {
    potd = {prefix ="Plantilia:Napili a ladawan ita nga aldaw/", format = "F j" },
    dyk  = {prefix ="Plantilia:Ammom kadi/", format = "F j" },
    tfa  = {prefix ="Wikipedia:Napili nga artikulo ita nga aldaw/", format = "F j" }
-- otd = {prefix ="Wikipedia:Iti daytoy nga aldaw/", format = "F j" },
-- portal = {prefix = "Portal:No portal/", format="F"},
-- tfl = {prefix = "Wikipedia:Napili a listaan/", format="F"}
}
-- Returns a page for this type and that date if it exists, nil otherwise
-- @param type_name String that is a key in the 'prefixes' table
-- @param date Timestamp (in a format that mw.language:formatDate accepts) to give page for
-- @return a string page title if it exists, nil otherwise
function existing_page_for( type_name, date ) 
    local type_data = prefixes[ type_name ]
    local page_name
    if type( type_data ) == 'table' then
        page_name = type_data['prefix'] .. lang:formatDate( type_data['format'], tostring(date) )
    else
        page_name = type_data .. lang:formatDate( 'F j, Y', tostring(date) )
    end
    local title = mw.title.new( page_name )
    if title.exists then
        return page_name
    else
        return nil
    end
end

-- Returns the expanded text for the current main page featured content specified by the first argument 'type'
-- Checks the page for the current date for the type (using existing_page_for). If it exists, it is 
-- expanded and returned. If not, we keep trying prior dates until we find one that exists, and then
-- expand and return it.
function p.agdama( frame )
    local type = frame.args[1]
    local cur_date = os.date()
    
    local i = 0
    while true do
        cur_date = os.date( nil, os.time() - (i * 24 * 60 * 60) )
        i = i + 1
        page = existing_page_for( type, cur_date )
        if page then
            return frame:expandTemplate{title=page}
        end
    end
end

-- Tomorrows main page featured content.
function p.intonobigat( frame )
    local type = frame.args[1]
    local cur_date = os.date()
    
    local i = 1
    while true do
        cur_date = os.date( nil, os.time() + (i * 24 * 60 * 60) )
        i = i + 1
        page = existing_page_for( type, cur_date )
        if page then
            return frame:expandTemplate{title=page}
        end
    end
end


-- Yesterdays main page featured content.
function p.idikalman( frame )
    local type = frame.args[1]
    local cur_date = os.date()
    
    local i = 1
    while true do
        cur_date = os.date( nil, os.time() - (i * 24 * 60 * 60) )
        i = i - 1
        page = existing_page_for( type, cur_date )
        if page then
            return frame:expandTemplate{title=page}
        end
    end
end

return p