Module:CountdownBanner: Difference between revisions

From 20R1
No edit summary
No edit summary
Line 3: Line 3:
function p.show( frame )
function p.show( frame )
     local currentTime = os.time()
     local currentTime = os.time()
     local query = '{{#ask: [[Category:Events]] [[Event Date::>' .. os.date("!%Y-%m-%d", currentTime) .. ']]'
     local query = '{{#ask: [[Club Name::+]] [[Start Date::>' .. os.date("!%Y-%m-%d", currentTime) .. ']]'
                 .. '|?Event Date'
                 .. '|?Start Date'
                 .. '|?Event Name=Name'
                 .. '|?Event Name=Name'
                 .. '|?Event Location=Location'
                 .. '|?Event Location=Location'
                 .. '|?Event Flyer=Flyer'
                 .. '|?Event Flyer=Flyer'
                 .. '|sort=Event Date'
                 .. '|sort=Start Date'
                 .. '|order=asc'
                 .. '|order=asc'
                 .. '|limit=1'
                 .. '|limit=1'

Revision as of 21:37, 19 November 2025

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

local p = {}

function p.show( frame )
    local currentTime = os.time()
    local query = '{{#ask: [[Club Name::+]] [[Start Date::>' .. os.date("!%Y-%m-%d", currentTime) .. ']]'
                .. '|?Start Date'
                .. '|?Event Name=Name'
                .. '|?Event Location=Location'
                .. '|?Event Flyer=Flyer'
                .. '|sort=Start Date'
                .. '|order=asc'
                .. '|limit=1'
                .. '}}'

    local result = frame:preprocess( query )

    if result == '' or result:match'^%s*$' then
        return '<div style="background:#b22234;color:white;padding:20px;text-align:center;font-size:18px;">No upcoming events scheduled</div>'
    end

    return frame:preprocess( '{{CountdownBannerDisplay|' .. result .. '}}' )
end

return p