Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve usability of PWAs in Dev Containers #3576

Merged
merged 61 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
369be4e
Add WIP icons
ruffsl May 12, 2023
187753d
Add WIP icons for gzweb
ruffsl May 14, 2023
dde6a84
Add WIP icons for glances
ruffsl May 14, 2023
5d38954
Set cross origin to use credentials
ruffsl May 14, 2023
33cb661
Use ReqHost variable in templates
ruffsl May 14, 2023
e1b53ca
Delete duplicate manifest
ruffsl May 14, 2023
5097323
Set id property in app manifests
ruffsl May 14, 2023
dd7ecd8
Ensure apps are uniquely identifies
ruffsl May 15, 2023
c9e861b
Refactor root landing page into nav2 app
ruffsl May 15, 2023
26a8bb2
Fix https detection for Caddy reverse proxies
ruffsl May 15, 2023
693e7e4
Remove unnecessary files
ruffsl May 16, 2023
b54f258
Prune smaller images
ruffsl May 16, 2023
5710401
Prune duplicate icon
ruffsl May 16, 2023
921d966
Clean up html tags
ruffsl May 16, 2023
cf25c0d
Update manifest icons
ruffsl May 16, 2023
552c8a8
Rename icons
ruffsl May 16, 2023
4488539
Revert "Prune duplicate icon"
ruffsl May 16, 2023
02efb7e
Add back favicon for shortcut
ruffsl May 16, 2023
d4a1e72
Add self index for completeness and bookmarking
ruffsl May 16, 2023
6b3a9ac
Simplify icon linking
ruffsl May 16, 2023
71142d3
Delete binary files
ruffsl May 16, 2023
d210698
Fix hyperlink path
ruffsl May 16, 2023
5f846c4
Include image files using gitattributes
ruffsl May 16, 2023
4ece5ac
Add icons using git lfs
ruffsl May 16, 2023
856361f
Standardized all icon paths
ruffsl May 16, 2023
701403b
Use external links for icons
ruffsl May 16, 2023
152b477
Stage any and maskable icons
ruffsl May 17, 2023
5847eee
Use any and masked icons
ruffsl May 17, 2023
dc8c131
Set colors to match maskable icon colors
ruffsl May 17, 2023
0e8907c
Update icon
ruffsl May 17, 2023
b421507
Use lossless compression
ruffsl May 18, 2023
ed0836b
Use WebP instead of PNG
ruffsl May 18, 2023
ed866cd
Move icons into icons folder
ruffsl May 18, 2023
f4bf919
Use _SRV environment variables for service paths
ruffsl May 18, 2023
7f5dff3
Download media files from github
ruffsl May 18, 2023
0975972
Delete media icons from git repo
ruffsl May 18, 2023
6695978
Add comments
ruffsl May 18, 2023
ba6f5bb
Enable file browsing for non app paths
ruffsl May 18, 2023
15be7a1
Consolidate assets into single folder
ruffsl May 18, 2023
ed52a6b
Add links for file browser paths
ruffsl May 18, 2023
cb8e12d
Delete unused symlink
ruffsl May 18, 2023
923cfa9
Update landing page to match manifest
ruffsl May 18, 2023
929bd8e
Patch gzweb to disable modelList
ruffsl May 18, 2023
25724d5
Update comments
ruffsl May 19, 2023
b4a5602
Simplify Caddyfile by reverting to symlinking
ruffsl May 19, 2023
7ca3081
Loop over nav2 srv folders when symlinking
ruffsl May 19, 2023
16da7b2
Add matcher for file browsing root directory
ruffsl May 19, 2023
1f513d2
Use placeholders for root variable
ruffsl May 19, 2023
5baf315
Promote file browser in Nav2 app shortcuts
ruffsl May 19, 2023
e1223b8
Fix and update SRV envs
ruffsl May 19, 2023
afeed53
Postpone symlinking for Nav2 web app
ruffsl May 19, 2023
7096bc2
Add guard to check if srv folder exists
ruffsl May 19, 2023
5e2a483
Add refresh rate shortcuts to glances
ruffsl May 19, 2023
3ec82a3
Add file browser shortcut to nav2
ruffsl May 19, 2023
300a138
Set scope for nav2 PWA to root
ruffsl May 19, 2023
2ae8d13
Display child apps in fullscreen mode by default
ruffsl May 19, 2023
5dd0469
Update shortcuts and landing page
ruffsl May 19, 2023
0ac4d5c
Document PWA scope and installation order
ruffsl May 19, 2023
85c9d44
Revert setting scope for nav2 PWA to root path
ruffsl May 19, 2023
ee622b6
Update server diagnostics for troubleshooting
ruffsl May 19, 2023
971384b
Verify checksum of archive before extraction
ruffsl May 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 33 additions & 23 deletions .devcontainer/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Matcher for http request scheme. E.g. "http" or "https"
@http_scheme {
expression {http.request.scheme}=="https" || {header.X-Forwarded-Scheme}=="https"
expression {http.request.scheme}=="https" || {header.X-Forwarded-Scheme}=="https" || {header.X-Forwarded-Proto}=="https"
}
# If any http scheme is "https", then use "wss"
vars @http_scheme WsScheme "wss"
Expand All @@ -19,9 +19,9 @@
header X-Forwarded-Host *
}
# If http headers exists, then use them
vars @host_forwarded WsHost {header.X-Forwarded-Host}
vars @host_forwarded ReqHost {header.X-Forwarded-Host}
# Else default to host in request
vars WsHost {http.request.hostport}
vars ReqHost {http.request.hostport}

# Matcher for websocket connection upgrade requests
@websockets {
Expand All @@ -37,8 +37,8 @@
# E.g auto redirect websocket URL to match request scheme
(redirect) {
# Configure redirect to match request scheme
vars LayoutUrl "/assets/nav2_foxglove_layout.json"
vars DataSourceUrl "{vars.WsScheme}://{vars.WsHost}{args.0}/"
vars LayoutUrl "/assets/foxglove/nav2_layout.json"
vars DataSourceUrl "{vars.WsScheme}://{vars.ReqHost}{args.0}/"
redir /autoconnect "{args.0}/?ds=foxglove-websocket&ds.url={vars.DataSourceUrl}"
redir /autolayout "{args.0}/?ds=foxglove-websocket&ds.url={vars.DataSourceUrl}&layoutUrl={vars.LayoutUrl}"
}
Expand All @@ -55,30 +55,26 @@
route / {
# Inject link to manifest just after <head> tag
# https://developer.mozilla.org/docs/Web/Manifest
replace `<head>` `<head><link rel="manifest" href="manifest.json" />`
replace `<head>` `<head><link rel="manifest" href="manifest.json" crossorigin="use-credentials"/>`
}
# Redirect relative handle_path'ed manifest.json to /manifests directory
redir /manifest.json /manifests{http.request.orig_uri.path.dir}manifest.json
redir /manifest.json /assets{http.request.orig_uri.path.dir}manifest.json
}

# Snippet for hosted web app using websockets
# to serve static files and reverse proxying connections
# E.g. for serving GzWeb and Foxglove web apps
(app) {
# Redirect implicit directory requests twards index.html
redir {args.0} {args.0}/
# handle and strip path prefix from redirect
handle_path {args.0}/* {
# Set root directory for static files
root * {args.1}
# Serve static files
file_server
root * {http.vars.root}{args.0}
# Enable mobile web app features
import mobile
# Reverse proxy websockets to backend address
reverse_proxy @websockets {args.2}
reverse_proxy @websockets {args.1}
# Import custom snippets
import {args.3} {args.0}
import {args.2} {args.0}
}
}

Expand All @@ -88,24 +84,38 @@
:8080 {
# Include global matchers and variables
import globals
root * {$ROOT_SRV:/srv}
file_server browse

# Handle main landing page
# Handle root content
# I.e. assets internal to workspace
handle /* {
# Use relative path for root directory
root * srv
file_server
import mobile
# Render markdown files as html
templates
# Template manifest.json files
templates */manifest.json {
mime application/json
}
}

# Handle nav2 web app
# I.e. main landing page
handle_path /nav2/* {
root * {http.vars.root}/nav2
import mobile
# Render markdown files as html
templates
}

# Matcher for requests without browse query
@no_browse {
path /
not query browse=true
}
# Redirect to nav2 web app by default
redir @no_browse /nav2/

# Import app snippets for web apps
import app "/gzweb" "{$GZWEB_WS}/http/client" "localhost:9090" "dummy"
import app "/foxglove" "{$FOXGLOVE_WS}" "localhost:8765" "redirect"
import app "/gzweb" "localhost:9090" "dummy"
import app "/foxglove" "localhost:8765" "redirect"

# Handle glances web app
redir /glances /glances/
Expand Down
40 changes: 40 additions & 0 deletions .devcontainer/caddy/srv/assets/foxglove/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "Foxglove: {{placeholder "http.vars.ReqHost"}}",
"short_name": "Foxglove: {{placeholder "http.vars.ReqHost"}}",
"icons": [
{
"src": "/media/icons/foxglove/any_icon_x512.webp",
"sizes": "512x512",
"type": "image/webp",
"purpose": "any"
},
{
"src": "/media/icons/foxglove/maskable_icon_x512.webp",
"sizes": "512x512",
"type": "image/webp",
"purpose": "maskable"
}
],
"id": "/foxglove/",
"start_url": "/foxglove/autoconnect",
"theme_color": "#6F3BE8",
"background_color": "#6F3BE8",
"display": "fullscreen",
"shortcuts" : [
{
"name": "Auto Connect",
"url": "/foxglove/autoconnect",
"description": "Auto connect to default data source"
},
{
"name": "Auto Layout",
"url": "/foxglove/autolayout",
"description": "Auto connect using default layout"
},
{
"name": "Manual Connect",
"url": "/foxglove/",
"description": "Manually connect to data source"
}
]
}
40 changes: 40 additions & 0 deletions .devcontainer/caddy/srv/assets/glances/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "Glances: {{placeholder "http.vars.ReqHost"}}",
"short_name": "Glances: {{placeholder "http.vars.ReqHost"}}",
"icons": [
{
"src": "/media/icons/glances/any_icon_x512.webp",
"sizes": "512x512",
"type": "image/webp",
"purpose": "any"
},
{
"src": "/media/icons/glances/maskable_icon_x512.webp",
"sizes": "512x512",
"type": "image/webp",
"purpose": "maskable"
}
],
"id": "/glances/",
"start_url": "/glances/",
"theme_color": "#2C363F",
"background_color": "#2C363F",
"display": "fullscreen",
"shortcuts" : [
{
"name": "Refresh 1sec",
"url": "/glances/1",
"description": "Refresh page every 1 second"
},
{
"name": "Refresh 5sec",
"url": "/glances/5",
"description": "Refresh page every 5 seconds"
},
{
"name": "Refresh 10sec",
"url": "/glances/10",
"description": "Refresh page every 10 seconds"
}
]
}
23 changes: 23 additions & 0 deletions .devcontainer/caddy/srv/assets/gzweb/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "Gzweb: {{placeholder "http.vars.ReqHost"}}",
"short_name": "Gzweb: {{placeholder "http.vars.ReqHost"}}",
"icons": [
{
"src": "/media/icons/gzweb/any_icon_x512.webp",
"sizes": "512x512",
"type": "image/webp",
"purpose": "any"
},
{
"src": "/media/icons/gzweb/maskable_icon_x512.webp",
"sizes": "512x512",
"type": "image/webp",
"purpose": "maskable"
}
],
"id": "/gzweb/",
"start_url": "/gzweb/",
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "fullscreen"
}
23 changes: 23 additions & 0 deletions .devcontainer/caddy/srv/assets/nav2/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "Nav2: {{placeholder "http.vars.ReqHost"}}",
"short_name": "Nav2: {{placeholder "http.vars.ReqHost"}}",
"icons": [
{
"src": "/media/icons/nav2/any_icon_x512.webp",
"sizes": "512x512",
"type": "image/webp",
"purpose": "any"
},
{
"src": "/media/icons/nav2/maskable_icon_x512.webp",
"sizes": "512x512",
"type": "image/webp",
"purpose": "maskable"
}
],
"id": "/nav2/",
"start_url": "/nav2/",
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
48 changes: 0 additions & 48 deletions .devcontainer/caddy/srv/index.md

This file was deleted.

32 changes: 0 additions & 32 deletions .devcontainer/caddy/srv/manifests/foxglove/manifest.json

This file was deleted.

15 changes: 0 additions & 15 deletions .devcontainer/caddy/srv/manifests/glances/manifest.json

This file was deleted.

15 changes: 0 additions & 15 deletions .devcontainer/caddy/srv/manifests/gzweb/manifest.json

This file was deleted.

8 changes: 0 additions & 8 deletions .devcontainer/caddy/srv/manifests/manifest.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<title>{{$title}}</title>
<meta name="color-scheme" content="light dark">
<link rel="stylesheet" href="github-markdown.css">
<link rel="icon" type="image/webp" href="/media/icons/nav2/any_icon_x512.webp">

<style>
body {
box-sizing: border-box;
Expand Down
Loading