Compare commits

...

4 Commits

Author SHA1 Message Date
Oystein Kristoffer Tveit 9d8b14a08b
nix/module: fix spaceapi endpoint 2024-05-18 20:54:05 +02:00
Felix Albrigtsen 0542a10d03
spaceapi: Moves calendar into feeds
Co-authored-by: h7x4 <h7x4@nani.wtf>
2024-05-18 20:03:20 +02:00
Felix Albrigtsen c6df8e6ae3 nix/module: Specify json mimetype for spaceapi.php 2024-05-14 19:29:51 +02:00
Felix Albrigtsen aebc14ccb5 feat: adds spaceapi endpoint 2024-05-14 19:29:51 +02:00
2 changed files with 71 additions and 0 deletions

View File

@ -196,6 +196,9 @@ in
include ${pkgs.nginx}/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME ${finalPackage}/share/php/pvv-nettsiden/www$fastcgi_script_name;
fastcgi_pass unix:${config.services.phpfpm.pools."pvv-nettsiden".socket};
location = /spaceapi.php {
add_header Content-Type application/json;
}
'';
# based on https://simplesamlphp.org/docs/stable/simplesamlphp-install.html#configuring-nginx

68
www/spaceapi.php Normal file
View File

@ -0,0 +1,68 @@
<?php
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
$pdo->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/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,
"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": <?php echo($doorEntry->open ? "true" : "false"); ?>,
"lastchange": <?php echo($doorEntry->time ? $doorEntry->time : 0); ?>,
"message": "<?php echo($doorEntry->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": [
"https://github.com/Programvareverkstedet/",
"https://git.pvv.ntnu.no/",
"https://www.pvv.ntnu.no/prosjekt/"
],
"links": [
{
"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/"
}
]
}