diff --git a/content/_index.md b/content/_index.md index c608acf..a4ae90d 100644 --- a/content/_index.md +++ b/content/_index.md @@ -5,11 +5,7 @@ layout: home hero_image: rose_logo.svg --- -{{< rawhtml >}} -
-Leigh Hackspace is currently -
-{{}} +{{< openstatus >}} | Day | Opening Times | | --------- | ------------- | diff --git a/themes/lhs-retro/layouts/shortcodes/openstatus.html b/themes/lhs-retro/layouts/shortcodes/openstatus.html new file mode 100644 index 0000000..b196369 --- /dev/null +++ b/themes/lhs-retro/layouts/shortcodes/openstatus.html @@ -0,0 +1 @@ +

Leigh Hackspace is currently {{ "" | safeHTML }}

diff --git a/themes/lhs-retro/static/cgi/status.cgi b/themes/lhs-retro/static/cgi/status.cgi new file mode 100644 index 0000000..895ea8a --- /dev/null +++ b/themes/lhs-retro/static/cgi/status.cgi @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# Get the current hackspace status from the SpaceAPI +import requests +import sys + + +def main(output=sys.stdout): + output.write('Content-Type: text/html\n\n') + + try: + resp = requests.get('https://api.leighhack.org/space.json') + if resp.ok: + data = resp.json() + if 'state' in data: + if data['state']['open']: + output.write('Open') + return + except Exception: + pass + + output.write('Closed') + +if __name__ == '__main__': + main() diff --git a/themes/lhs/layouts/shortcodes/openstatus.html b/themes/lhs/layouts/shortcodes/openstatus.html new file mode 100644 index 0000000..2259d99 --- /dev/null +++ b/themes/lhs/layouts/shortcodes/openstatus.html @@ -0,0 +1,3 @@ +
+

Leigh Hackspace is currently

+