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 | |
| 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')
3 files changed, 52 insertions, 4 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 diff --git a/modules-available/locationinfo/templates/frontend-default.html b/modules-available/locationinfo/templates/frontend-default.html index cc62075e..5f52182d 100755 --- a/modules-available/locationinfo/templates/frontend-default.html +++ b/modules-available/locationinfo/templates/frontend-default.html @@ -23,11 +23,12 @@ optional: --> <html lang="{{language}}"> -<meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8"> <head> + <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8"> <title>DoorSign</title> - <link rel='stylesheet' type='text/css' href='modules/js_jqueryui/style.css'/> - <link rel='stylesheet' type='text/css' href='modules/js_weekcalendar/style.css'/> + <link rel='stylesheet' type='text/css' href='modules/js_jqueryui/style.css'> + <link rel='stylesheet' type='text/css' href='modules/js_weekcalendar/style.css'> + <link rel="manifest" type="application/json" href="api/get=manifest&uuid={{uuid}}"> <style type="text/css"> diff --git a/modules-available/locationinfo/templates/frontend-summary.html b/modules-available/locationinfo/templates/frontend-summary.html index 136ac3a5..d9851783 100644 --- a/modules-available/locationinfo/templates/frontend-summary.html +++ b/modules-available/locationinfo/templates/frontend-summary.html @@ -1,9 +1,10 @@ <!DOCTYPE html> <html lang="{{language}}"> -<meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8"> <head> + <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8"> <script type='text/javascript' src='script/jquery.js'></script> <script type='text/javascript' src='modules/locationinfo/frontend/frontendscript.js'></script> + <link rel="manifest" type="application/json" href="api/get=manifest&uuid={{uuid}}"> <style type='text/css'> |
