Skip to content
Merged
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
1 change: 1 addition & 0 deletions site/assets/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<meta name="referrer" content="no-referrer">
<title>Your account — readm3</title>
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="manifest" href="/manifest.webmanifest">
<link rel="stylesheet" href="__ACCOUNT_STYLES__">
<script type="module" src="__ACCOUNT_SCRIPT__"></script>
<script defer src="__PROFILE_SCRIPT__"></script>
Expand Down
2 changes: 1 addition & 1 deletion site/assets/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex,nofollow"><meta name="referrer" content="no-referrer">
<title>Your Markdown workspace — readm3</title>
<link rel="icon" href="/favicon.svg"><link rel="stylesheet" href="__STYLES__"><link rel="stylesheet" href="__VIEWER_STYLES__"><link rel="stylesheet" href="__ADMIN_STYLES__">
<link rel="icon" href="/favicon.svg"><link rel="manifest" href="/manifest.webmanifest"><link rel="stylesheet" href="__STYLES__"><link rel="stylesheet" href="__VIEWER_STYLES__"><link rel="stylesheet" href="__ADMIN_STYLES__">
<script type="module" src="__ADMIN_SCRIPT__"></script>
</head>
<body class="reader-app admin-app">
Expand Down
10 changes: 10 additions & 0 deletions site/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ function shell(options: { title: string; description: string; path: string; main
<meta name="description" content="${escape(options.description)}">
<link rel="canonical" href="${canonical}">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="manifest" href="/manifest.webmanifest">
<meta name="theme-color" content="#05070a">
<link rel="stylesheet" href="/styles.css">
<meta property="og:type" content="website">
<meta property="og:title" content="${escape(options.title)}">
Expand Down Expand Up @@ -725,6 +727,14 @@ write("viewer.webmanifest", JSON.stringify({
launch_type: "single-client",
}],
}));
// The site-wide manifest: every page but the editor links it, so readm3.com installs from its homepage.
write("manifest.webmanifest", JSON.stringify({
id: "/", name: "readm3", short_name: "readm3",
description: "Markdown editing and sharing for people and teams.",
start_url: "/", scope: "/", display: "standalone",
background_color: "#05070a", theme_color: "#05070a", lang: "en",
icons: [192, 512].flatMap((size) => ["any", "maskable"].map((purpose) => ({ src: `/viewer-assets/icon-${size}.png`, sizes: `${size}x${size}`, type: "image/png", purpose }))),
}));
const precache = ["/viewer", script, ...chunks, viewerCss, sharedCss, adminCss, seed, "/viewer.webmanifest", "/favicon.svg", "/viewer-assets/icon-192.png", "/viewer-assets/icon-512.png"];
const cacheVersion = createHash("sha256").update(viewerHtml + precache.join("|")).digest("hex").slice(0, 16);
write("viewer-sw.js", readFileSync(join(here, "assets/viewer-sw.js"), "utf8")
Expand Down
14 changes: 14 additions & 0 deletions site/test/viewer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,20 @@ test("still renders a Markdown paste as a document", async ({ page, request }) =
await expect(page.locator("#raw-link")).toBeVisible();
});

test("the homepage links an installable site manifest", async ({ request }) => {
expect(await (await request.get("/")).text()).toContain('<link rel="manifest" href="/manifest.webmanifest">');
const response = await request.get("/manifest.webmanifest");
expect(response.headers()["content-type"]).toContain("manifest+json");
const manifest = await response.json();
expect(manifest).toMatchObject({ name: "readm3", start_url: "/", scope: "/", display: "standalone" });
for (const size of ["192x192", "512x512"]) expect(manifest.icons.some((icon: { sizes: string }) => icon.sizes === size)).toBe(true);
for (const icon of manifest.icons) {
const image = await request.get(icon.src);
expect(image.ok()).toBe(true);
expect(image.headers()["content-type"]).toBe("image/png");
}
});

test("installs a complete offline shell and restores edited documents after an offline reload", async ({ page, context, request }) => {
const manifestResponse = await request.get("/viewer.webmanifest");
expect(manifestResponse.headers()["content-type"]).toContain("manifest+json");
Expand Down
Loading