Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions apps/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<meta name="ontime" content="ontime - time keeping for live events" />
<link rel="apple-touch-icon" href="/ontime-logo.png" />
<link rel="icon" type="image/png" href="/ontime-logo.png" />
<link rel="manifest" href="/site.webmanifest" />
<link rel="manifest" href="/manifest.json" />
<link rel="manifest" href="/manifest.webmanifest" />
<meta name="robots" content="noindex" />
<title>ontime</title>
<style>
Expand Down
19 changes: 0 additions & 19 deletions apps/client/public/manifest.json

This file was deleted.

15 changes: 15 additions & 0 deletions apps/client/public/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "ontime",
"short_name": "ontime",
"icons": [
{
"src": "/ontime-logo.png",
"sizes": "295x295",
"type": "image/png"
}
],
"scope": "/",
"display": "standalone",
"theme_color": "#2B5ABC",
"background_color": "#101010"
}
10 changes: 0 additions & 10 deletions apps/client/public/site.webmanifest

This file was deleted.

19 changes: 19 additions & 0 deletions apps/server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import serverTiming from 'server-timing';
import cookieParser from 'cookie-parser';

// import utils
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { publicDir, srcDir } from './setup/index.js';
import { environment, isProduction } from './setup/environment.js';
import { updateRouterPrefix } from './externals.js';
Expand Down Expand Up @@ -98,6 +100,23 @@ app.use(`${prefix}/user`, express.static(publicDir.userDir, { etag: false, lastM

// Base route for static files
app.use(`${prefix}`, authenticateAndRedirect, compressedStatic);

app.get(`${prefix}/manifest.webmanifest`, (req, res) => {
// get the referer, if it doesnt exist, we send the default manifest
const referer = req.headers.referer || '/';

// read the manifest file
const manifest = JSON.parse(
readFileSync(join(publicDir.root, 'manifest.webmanifest'), 'utf-8'),
);

// set the start_url to the referer
manifest.start_url = referer;

// send the manifest
res.json(manifest);
});

app.use(`${prefix}/*splat`, authenticateAndRedirect, compressedStatic);

// Implement catch all
Expand Down
37 changes: 37 additions & 0 deletions e2e/tests/features/214-pwa-install.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { test, expect } from '@playwright/test';

test('manifest start_url is correct for cuesheet', async ({ page }) => {
await page.goto('/cuesheet');
const manifestUrl = await page.evaluate(() => {
const link = document.querySelector('link[rel="manifest"]');
if (!link) {
return null;
}
return (link as HTMLLinkElement).href;
});

expect(manifestUrl).not.toBeNull();

const response = await page.request.get(manifestUrl!);
const manifest = await response.json();

expect(manifest.start_url).toContain('/cuesheet');
});

test('manifest start_url is correct for op', async ({ page }) => {
await page.goto('/op');
const manifestUrl = await page.evaluate(() => {
const link = document.querySelector('link[rel="manifest"]');
if (!link) {
return null;
}
return (link as HTMLLinkElement).href;
});

expect(manifestUrl).not.toBeNull();

const response = await page.request.get(manifestUrl!);
const manifest = await response.json();

expect(manifest.start_url).toContain('/op');
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@
"turbo": "^2.3.3",
"typescript": "catalog:"
},
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977",
"dependencies": {
"tsx": "^4.20.3"
}
}
4 changes: 4 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.