Module:CountdownBanner: Difference between revisions
From 20R1
m Alex moved page Module:CountdownTimer to Module:CountdownBanner without leaving a redirect: This was suggested and created by grok 4.1 |
No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.show(frame) | function p.show( frame ) | ||
local currentTime = os.time() | local currentTime = os.time() | ||
-- Use the normal DPL-style SMW query instead of mw.smw.ask | |||
local query = '{{#ask: [[Category:Events]] [[Event Date::>' .. os.date("!%Y-%m-%d", currentTime) .. ']]' | |||
.. '|?Event Date' | |||
.. '|?Event Name=Name' | |||
.. '|?Event Location=Location' | |||
.. '|?Event Flyer=Flyer' | |||
.. '|sort=Event Date' | |||
.. '|order=asc' | |||
.. '|limit=1' | |||
.. '|format=template' | |||
.. '|template=CountdownBannerHelper' | |||
.. '}}' | |||
local result = frame:preprocess( query ) | |||
-- If nothing returned, show friendly message | |||
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 result | |||
end | end | ||
return p | return p | ||
Revision as of 20:57, 19 November 2025
Documentation for this module may be created at Module:CountdownBanner/doc
local p = {}
function p.show( frame )
local currentTime = os.time()
-- Use the normal DPL-style SMW query instead of mw.smw.ask
local query = '{{#ask: [[Category:Events]] [[Event Date::>' .. os.date("!%Y-%m-%d", currentTime) .. ']]'
.. '|?Event Date'
.. '|?Event Name=Name'
.. '|?Event Location=Location'
.. '|?Event Flyer=Flyer'
.. '|sort=Event Date'
.. '|order=asc'
.. '|limit=1'
.. '|format=template'
.. '|template=CountdownBannerHelper'
.. '}}'
local result = frame:preprocess( query )
-- If nothing returned, show friendly message
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 result
end
return p
