diff options
| author | Simon Rettberg | 2025-04-01 16:58:43 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2025-04-01 16:58:43 +0200 |
| commit | e7553836fc9e0ce9301fb8c1bb61dfbc1055aa41 (patch) | |
| tree | b3834ba80f0544200601967aef2fd7ee1eb98994 /modules-available/locationinfo/api.inc.php | |
| parent | [syslog] Sanitize input (diff) | |
| download | slx-admin-e7553836fc9e0ce9301fb8c1bb61dfbc1055aa41.tar.gz slx-admin-e7553836fc9e0ce9301fb8c1bb61dfbc1055aa41.tar.xz slx-admin-e7553836fc9e0ce9301fb8c1bb61dfbc1055aa41.zip | |
[locationinfo] Add web application manifest
Diffstat (limited to 'modules-available/locationinfo/api.inc.php')
| -rw-r--r-- | modules-available/locationinfo/api.inc.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index 24919ba1..ef462d83 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -37,6 +37,8 @@ function HandleParameters() } elseif ($get === "calendar") { $locationIds = LocationInfo::getLocationsOr404($uuid); $output = LocationInfo::getCalendar($locationIds); + } elseif ($get === "manifest") { + $output = generateManifest($uuid); } if ($output !== null) { Header('Content-Type: application/json; charset=utf-8'); @@ -152,3 +154,47 @@ function findLocations(array $locations, array $idList): array } return $ret; } + + +/** + * Generates a web application manifest for a panel. + * + * @param string $uuid The UUID of the panel. + * @return array The generated manifest file data. + */ +function generateManifest(string $uuid): array +{ + $row = Database::queryFirst("SELECT panelname FROM locationinfo_panel WHERE paneluuid = :paneluuid", + ['paneluuid' => $uuid]); + if ($row === false) + return ['error' => 'Not found']; + $data = [ + "name" => $row['panelname'], + "short_name" => $row['panelname'], + "start_url" => "/panel/$uuid", + "display_override" => [ + "fullscreen", + "standalone", + "tabbed", + "minimal-ui" + ], + "display" => "fullscreen", + "icons" => [ + [ + "src" => "/panel/style/icon.svg", + "sizes" => "any", + "type" => "image/svg+xml" + ] + ], + ]; + foreach (glob('style/icon*.png', GLOB_NOSORT) as $file) { + if (!preg_match('/icon(\d+)\.png$/', $file, $m)) + continue; + $data['icons'][] = [ + "src" => "/panel/$file", + "sizes" => "${m[1]}x${m[1]}", + "type" => "image/png", + ]; + } + return $data; +}
\ No newline at end of file |
