diff --git a/layouts/page/calendar.html b/layouts/page/calendar.html index cc76b27..73b86e6 100644 --- a/layouts/page/calendar.html +++ b/layouts/page/calendar.html @@ -44,4 +44,5 @@ {{ define "content" }}
+{{ "" | safeHTML }} {{ end }} \ No newline at end of file diff --git a/themes/lhs-retro/static/cgi/events.cgi b/themes/lhs-retro/static/cgi/events.cgi new file mode 100644 index 0000000..e0b6d55 --- /dev/null +++ b/themes/lhs-retro/static/cgi/events.cgi @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# Get the current upcoming events from the Hackspace API +import requests +import sys +import arrow + + +def main(output=sys.stdout): + output.write("Content-Type: text/html\n\n") + + try: + resp = requests.get("https://api.leighhack.org/events", timeout=5) + if resp.ok: + data = resp.json() + + for event in data[:5]: + start = arrow.get(event["start"]["dateTime"]) + end = arrow.get(event["end"]["dateTime"]) + output.write( + f"

{start.format('YYYY-MM-DD')} - {event['summary']} - {start.format('HH:mm')} -> {end.format('HH:mm')}

" + ) + output.write(f"

{event['description']}

") + + return + except Exception: + pass + + output.write("Oops, something wen't wrong grabbing the upcoming events.") + + +if __name__ == "__main__": + main()