From aebc14ccb5873cf5f44609c3de84469b78702349 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sun, 12 May 2024 03:36:51 +0200 Subject: [PATCH 1/3] feat: adds spaceapi endpoint --- www/spaceapi.php | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 www/spaceapi.php diff --git a/www/spaceapi.php b/www/spaceapi.php new file mode 100644 index 0000000..0faadbb --- /dev/null +++ b/www/spaceapi.php @@ -0,0 +1,65 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +$door = new \pvv\side\Door($pdo); +$doorEntry = (object)($door->getCurrent()); + +?> +{ + "api_compatibility": ["14"], + "space": "Programvareverkstedet", + "logo": "https://git.pvv.ntnu.no/Drift/pvv-nixos-config/raw/branch/main/assets/logo_blue_regular.png", + "url": "https://www.pvv.ntnu.no/", + "location": { + "address": "Sem Sælands vei 1, 7034 Trondheim, Norway", + "timezone": "Europe/Oslo", + "lon": 10.242, + "lat": 63.250 + }, + "contact": { + "irc": "irc://irc.pvv.ntnu.no/pvv", + "email": "pvv@pvv.ntnu.no", + "ext_discord": "https://discord.gg/8VTBr6Q", + "gopher": "gopher://isvegg.pvv.ntnu.no", + "matrix": "#pvv:pvv.ntnu.no" + }, + "issue_report_channels": ["email"], + "state": { + "open": open ? "true" : "false"); ?>, + "lastchange": time ? $doorEntry->time : 0); ?> + }, + "feeds": { + "wiki": { + "type": "atom", + "url": "https://www.pvv.ntnu.no/w/api.php?hidebots=1&urlversion=1&action=feedrecentchanges&feedformat=atom" + } + }, + "projects": [ + "https://github.com/Programvareverkstedet/", + "https://git.pvv.ntnu.no/", + "https://www.pvv.ntnu.no/prosjekt/" + ], + "links": [ + { + "name": "Events", + "url": "https://www.pvv.ntnu.no/hendelser/", + "description": "Upcoming events at Programvareverkstedet" + }, + { + "name": "YouTube", + "url": "https://www.youtube.com/@pvvntnu5640" + }, + { + "name": "LinkedIn", + "url": "https://www.linkedin.com/company/pvvntnu/" + }, + { + "name": "Facebook", + "url": "https://www.facebook.com/pvvntnu/" + } + ] +} -- 2.44.1 From c6df8e6ae3d4740d00317f33637db02c25b0efd2 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sun, 12 May 2024 10:46:38 +0200 Subject: [PATCH 2/3] nix/module: Specify json mimetype for spaceapi.php --- nix/module.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nix/module.nix b/nix/module.nix index f278ab9..1b4c7bd 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -198,6 +198,10 @@ in fastcgi_pass unix:${config.services.phpfpm.pools."pvv-nettsiden".socket}; ''; + "= /spaceapi.php".extraConfig = '' + add_header Content-Type application/json; + ''; + # based on https://simplesamlphp.org/docs/stable/simplesamlphp-install.html#configuring-nginx "^~ /simplesaml/" = { alias = "${finalPackage}/${finalPackage.passthru.simplesamlphpPath}/public/"; -- 2.44.1 From 0542a10d03fe9689b6a038e2579e7798f4d48a28 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Tue, 14 May 2024 19:53:35 +0200 Subject: [PATCH 3/3] spaceapi: Moves calendar into feeds Co-authored-by: h7x4 --- www/spaceapi.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/www/spaceapi.php b/www/spaceapi.php index 0faadbb..04964a8 100644 --- a/www/spaceapi.php +++ b/www/spaceapi.php @@ -12,9 +12,12 @@ $doorEntry = (object)($door->getCurrent()); { "api_compatibility": ["14"], "space": "Programvareverkstedet", - "logo": "https://git.pvv.ntnu.no/Drift/pvv-nixos-config/raw/branch/main/assets/logo_blue_regular.png", + "logo": "https://git.pvv.ntnu.no/assets/img/logo.png", "url": "https://www.pvv.ntnu.no/", "location": { + "ext_campus": "NTNU Gløshaugen", + "ext_room_name": "Oppredning/Gruvedrift, Floor 2, Room 247", + "ext_mazemap": "https://link.mazemap.com/2n2HWa7H", "address": "Sem Sælands vei 1, 7034 Trondheim, Norway", "timezone": "Europe/Oslo", "lon": 10.242, @@ -30,12 +33,17 @@ $doorEntry = (object)($door->getCurrent()); "issue_report_channels": ["email"], "state": { "open": open ? "true" : "false"); ?>, - "lastchange": time ? $doorEntry->time : 0); ?> + "lastchange": time ? $doorEntry->time : 0); ?>, + "message": "open ? "open for public, members are present" : "closed"); ?>" }, "feeds": { "wiki": { "type": "atom", "url": "https://www.pvv.ntnu.no/w/api.php?hidebots=1&urlversion=1&action=feedrecentchanges&feedformat=atom" + }, + "calendar": { + "type": "html", + "url": "https://www.pvv.ntnu.no/hendelser/" } }, "projects": [ @@ -44,11 +52,6 @@ $doorEntry = (object)($door->getCurrent()); "https://www.pvv.ntnu.no/prosjekt/" ], "links": [ - { - "name": "Events", - "url": "https://www.pvv.ntnu.no/hendelser/", - "description": "Upcoming events at Programvareverkstedet" - }, { "name": "YouTube", "url": "https://www.youtube.com/@pvvntnu5640" -- 2.44.1