-
-
Save mmd-osm/7ef5f6254d7b84e52473757ad133ddd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- <includeonly> | |
local p = {} | |
function resultsAsTable(events) | |
if (events == nil or events.data == nil) then | |
return | |
end | |
text = '{| class="wikitable" style="font-size:smaller"\n' | |
text = text .. '|+ OSM Events\n' | |
text = text .. '|-\n' | |
text = text .. '! Date\n' | |
text = text .. '! Title\n' | |
text = text .. '! Location\n' | |
text = text .. '! Venue\n' | |
for _, result in ipairs(events.data) do | |
local is_cancelled = ((result.cancelled == nil and false) or result.cancelled) | |
text = text .. '|-' | |
text = text .. '\n| ' .. result.date.human_short | |
text = text .. '\n| ' .. ((is_cancelled and '<s>') or '') .. '[' .. result.url .. ' ' .. mw.text.nowiki(result.name) .. ']' .. ((is_cancelled and '</s>') or '') | |
if result.location == nil then | |
text = text .. '\n| ' | |
text = text .. '\n| ' | |
else | |
text = text .. '\n| ' .. result.location.short | |
text = text .. '\n| ' .. ((result.location.venue == nil and "") or result.location.venue) | |
end | |
text = text .. '\n' | |
end | |
text = text .. '|}\n' | |
return text | |
end | |
function p.Events() | |
local events = mw.ext.externaldata.getWebData { | |
url = 'https://osmcal.org/api/v2/events/' | |
, data = 'data=__json' | |
, format = 'JSON' | |
} | |
return resultsAsTable(events) | |
end | |
return p | |
-- </includeonly> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Embedding: