feat(about): the #about tab, manifest version, and outbound links

Completes docs/06 §3.5: identity, tagline, GitHub/issues/changelog links, the
"Third-party dependencies: None" statement, all five donate handles from
.github/FUNDING.yml (docs/14 §5), and the four legal documents. The
acceptance-date line follows in the Legal Gate commit, which owns that store.

The displayed version now comes from the manifest, as docs/06 §3.5 requires.
It was hardcoded as "0.1.0" in THREE places -- the Manager footer, run-export
and run-import -- so a release bump had three chances to leave a stale number
in a footer users quote in bug reports, and two chances to write a lying
`generator` field into an exported backup. getAppVersion() returns '' rather
than a plausible fallback, and every render site hides the line instead.

Static links are <a target="_blank" rel="noopener noreferrer">. docs/09 T3
bans <a href> for *imported* bookmark URLs, which is untrusted data and keeps
using tabs.create in #edit; these are compile-time literals in one module.
Using tabs.create here would add an awaited call that can reject, for nothing.

Changelog points at /releases: CHANGELOG.md is Phase 5 work, and a 404 opened
from a legal-adjacent surface is worse than an empty releases page. A test
pins it, and another asserts every legal URL resolves to a file that actually
exists in legal/ -- a rename would otherwise ship four dead links inside the
legal gate with nothing else noticing.

Also drops common.comingSoon now that no route falls through to a placeholder.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
poli0981andClaude Opus 5 committed 2026-07-26 12:54:47 +07:00
1 parent f897a711bd
commit 2c2d8347ae
11 files changed
+336 -19

No files matched your search

+9 -7
View File
@@ -1,5 +1,7 @@
<script lang="ts">
import { onMount } from 'svelte';
import { getAppVersion } from '@/lib/browser/app-info';
import AboutTab from '@/lib/components/AboutTab.svelte';
import EditTab from '@/lib/components/EditTab.svelte';
import ExportTab from '@/lib/components/ExportTab.svelte';
import ImportTab from '@/lib/components/ImportTab.svelte';
@@ -10,12 +12,14 @@
import Toast from '@/lib/components/Toast.svelte';
import { t } from '@/lib/i18n/index.svelte';
import { isWriting } from '@/lib/stores/import-session.svelte';
import { REPO_URL } from '@/lib/links';
import { getRoute, navigate, startRouting } from '@/lib/stores/route.svelte';
import { flushSettings, getSettings, updateSettings } from '@/lib/stores/settings.svelte';
import { pushToast } from '@/lib/stores/toast.svelte';
// Settings are loaded and awaited in main.ts, before this ever mounts.
const settings = $derived(getSettings());
const version = getAppVersion();
onMount(() => {
const stopRouting = startRouting();
@@ -74,13 +78,15 @@
{:else if getRoute() === 'settings'}
<SettingsTab />
{:else}
<!-- Phase 4's About tab lands in the next commit. -->
<p class="placeholder">{t('common.comingSoon', { tab: t(`common.${getRoute()}`) })}</p>
<AboutTab />
{/if}
</main>
<footer>
<span>v0.1.0 · GPL-3.0</span>
<span>
{#if version !== ''}v{version} · {/if}GPL-3.0 ·
<a href={REPO_URL} target="_blank" rel="noopener noreferrer">GitHub ↗</a>
</span>
<nav>
<!-- Gated like TabBar's tabs: navigating away mid-write unmounts ImportTab
and strands the attestation resolver, deadlocking the import
@@ -147,10 +153,6 @@
min-height: 60vh;
}
.placeholder {
color: var(--fg-muted);
}
footer nav {
display: flex;
gap: var(--sp-3);
+42 -3
View File
@@ -1,10 +1,12 @@
<script lang="ts">
import { onMount } from 'svelte';
import { getAppVersion } from '@/lib/browser/app-info';
import { getRootChildren } from '@/lib/browser/bookmarks';
import { openManager } from '@/lib/browser/open-manager';
import { num, t } from '@/lib/i18n/index.svelte';
let counts = $state<{ bookmarks: number; folders: number } | undefined>();
const version = getAppVersion();
// Settings are loaded and awaited in main.ts, before this ever mounts.
onMount(() => {
@@ -38,6 +40,7 @@
<header>
<span class="mark" aria-hidden="true">◆</span>
<strong>{t('common.appName')}</strong>
{#if version !== ''}<span class="version">v{version}</span>{/if}
</header>
<div class="actions">
@@ -47,9 +50,19 @@
</div>
<footer>
{#if counts !== undefined}
{t('popup.counts', { bookmarks: num(counts.bookmarks), folders: num(counts.folders) })}
{/if}
<span>
{#if counts !== undefined}
{t('popup.counts', { bookmarks: num(counts.bookmarks), folders: num(counts.folders) })}
{/if}
</span>
<button
class="settings"
aria-label={t('common.settings')}
title={t('common.settings')}
onclick={() => void openManager('#settings')}
>
⚙
</button>
</footer>
</main>
@@ -94,10 +107,36 @@
}
footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--sp-2);
padding-top: var(--sp-2);
border-top: 1px solid var(--border);
color: var(--fg-muted);
font-size: var(--fs-0);
min-height: 1.5em;
}
.version {
margin-left: auto;
color: var(--fg-muted);
font-size: var(--fs-0);
font-variant-numeric: tabular-nums;
}
.settings {
font: inherit;
flex-shrink: 0;
padding: 0 var(--sp-1);
border: none;
background: none;
color: var(--fg-muted);
cursor: pointer;
font-size: var(--fs-2);
}
.settings:hover {
color: var(--accent);
}
</style>
+26
View File
@@ -0,0 +1,26 @@
/**
* Runtime metadata about the built extension.
*
* Purpose: the ONE place the displayed version comes from (docs/06 §3.5). It
* used to be hardcoded in three files, which is three chances to ship a
* number that disagrees with the manifest.
* Inputs: none — reads the packaged manifest.
* Guarantees: synchronous, so there is no version race and no loading state;
* never throws.
*/
import { browser } from 'wxt/browser';
/**
* The manifest version, or `''` when it cannot be read.
*
* Empty rather than a plausible fallback like `'0.0.0'`: callers hide the line
* entirely, and no version at all is better than a wrong one in a footer users
* quote in bug reports.
*/
export function getAppVersion(): string {
try {
return browser.runtime.getManifest().version;
} catch {
return '';
}
}
+106
View File
@@ -0,0 +1,106 @@
<script lang="ts">
import { getAppVersion } from '../browser/app-info';
import { t } from '../i18n/index.svelte';
import { CHANGELOG_URL, DONATE_LINKS, ISSUES_URL, LEGAL_URLS, REPO_URL } from '../links';
const version = getAppVersion();
</script>
<section aria-label={t('common.about')}>
<header>
<img src="/icon/48.png" alt="" width="48" height="48" />
<div>
<strong>{t('common.appName')}</strong>
{#if version !== ''}<span class="version">{t('about.version', { version })}</span>{/if}
</div>
</header>
<p class="tagline">{t('about.tagline')}</p>
<h2>{t('about.links')}</h2>
<ul class="links">
<li><a href={REPO_URL} target="_blank" rel="noopener noreferrer">{t('about.repo')} ↗</a></li>
<li><a href={ISSUES_URL} target="_blank" rel="noopener noreferrer">{t('about.issues')} ↗</a></li>
<li>
<a href={CHANGELOG_URL} target="_blank" rel="noopener noreferrer">
{t('about.changelog')} ↗
</a>
</li>
</ul>
<h2>{t('about.thirdParty')}</h2>
<p class="muted">{t('about.thirdPartyNote')}</p>
<h2>{t('about.donate')}</h2>
<p class="muted">{t('about.donateNote')}</p>
<ul class="links">
{#each DONATE_LINKS as link (link.url)}
<li><a href={link.url} target="_blank" rel="noopener noreferrer">{link.label} ↗</a></li>
{/each}
</ul>
<h2>{t('about.legal')}</h2>
<ul class="links">
{#each LEGAL_URLS as link (link.url)}
<li>
<a href={link.url} target="_blank" rel="noopener noreferrer">{t(link.labelKey)} ↗</a>
</li>
{/each}
</ul>
<p class="muted">{t('legal.englishNote')}</p>
</section>
<style>
section {
max-width: 640px;
}
header {
display: flex;
align-items: center;
gap: var(--sp-3);
padding-bottom: var(--sp-3);
border-bottom: 1px solid var(--border);
}
header div {
display: flex;
flex-direction: column;
}
header strong {
font-size: var(--fs-3);
}
.version {
font-size: var(--fs-0);
color: var(--fg-muted);
font-variant-numeric: tabular-nums;
}
.tagline {
color: var(--fg-muted);
font-size: var(--fs-1);
}
h2 {
margin: var(--sp-5) 0 var(--sp-2);
font-size: var(--fs-2);
}
.muted {
margin: 0;
color: var(--fg-muted);
font-size: var(--fs-1);
}
.links {
display: flex;
flex-wrap: wrap;
gap: var(--sp-2) var(--sp-4);
margin: var(--sp-2) 0 0;
padding: 0;
list-style: none;
font-size: var(--fs-1);
}
</style>
+3 -3
View File
@@ -6,6 +6,8 @@
* anchor path is enough here — unlike the Replace backup, a failed export
* loses nothing).
*/
import { getAppVersion } from '../browser/app-info';
import { getRootChildren, getRoots, type LiveNode, toBookmarkNodes } from '../browser/bookmarks';
import { sanitizeFilename, timestampSuffix, triggerDownload } from '../browser/download';
import type { ExportFormat } from '../browser/storage';
@@ -15,8 +17,6 @@ import { type CsvDelimiter, serializeCsv } from '../core/serialize/csv';
import { type MarkdownStyle, serializeMarkdown } from '../core/serialize/markdown';
import { serializeNetscapeHtml } from '../core/serialize/netscape-html';
const APP_VERSION = '0.1.0';
export const FORMAT_META: Record<
ExportFormat,
{ extension: string; mimeType: string; importable: boolean }
@@ -117,7 +117,7 @@ function serialize(nodes: ReturnType<typeof toBookmarkNodes>, options: ExportOpt
return serializeNetscapeHtml(nodes);
case 'bm-json':
return serializeBmJson(nodes, {
version: APP_VERSION,
version: getAppVersion(),
exportedAt: options.now.toISOString(),
});
case 'csv':
-1
View File
@@ -21,7 +21,6 @@ const dict = {
about: 'About',
busy: 'An import is in progress',
cancel: 'Cancel',
comingSoon: '{tab} arrives in a later build.',
},
popup: {
import: 'Import bookmarks…',
-1
View File
@@ -14,7 +14,6 @@ export default {
about: '概要',
busy: 'インポートを実行中です',
cancel: 'キャンセル',
comingSoon: '{tab}は今後のビルドで利用できます。',
},
popup: {
import: 'ブックマークをインポート…',
-1
View File
@@ -11,7 +11,6 @@ export default {
about: 'Giới thiệu',
busy: 'Đang có tiến trình nhập',
cancel: 'Hủy',
comingSoon: '{tab} sẽ có ở bản sau.',
},
popup: {
import: 'Nhập bookmark…',
+5 -3
View File
@@ -8,6 +8,7 @@
* picker resolving, or by the user explicitly confirming the fallback
* download (docs/03 §1 step 6b).
*/
import { getAppVersion } from '../browser/app-info';
import { clearRoots, getRootChildren, getRoots, toBookmarkNodes } from '../browser/bookmarks';
import {
isPickerAvailable,
@@ -37,8 +38,6 @@ const PARSERS = {
csv: parseCsv,
} as const;
const APP_VERSION = '0.1.0';
export interface PreparedImport {
result: ParseResult;
/** Bookmarks in the file whose URL already exists in the browser. */
@@ -160,7 +159,10 @@ export async function proveBackup(
): Promise<void> {
let content: string;
try {
content = serializeBmJson(snapshot, { version: APP_VERSION, exportedAt: now.toISOString() });
content = serializeBmJson(snapshot, {
version: getAppVersion(),
exportedAt: now.toISOString(),
});
} catch (cause) {
throw new BmBackupError(
'BACKUP_SERIALIZE_FAILED',
+58
View File
@@ -0,0 +1,58 @@
/**
* Every outbound URL the product shows — docs/14 §4, docs/06 §3.5.
*
* Purpose: one place for the repo, legal and donate links, so the About tab and
* the Legal Gate cannot drift apart.
* Inputs: none — compile-time literals.
* Guarantees: no requests are made from here. These are hrefs the user chooses
* to follow; the extension itself stays offline (docs/09 §1).
*
* They are rendered as `<a target="_blank" rel="noopener noreferrer">`, unlike
* bookmark URLs, which docs/09 T3 forbids putting in an href and which #edit
* opens through `tabs.create` instead. Two mechanisms for two trust classes:
* these are literals in this file, those are untrusted data from a user's
* import file. Do not "harmonize" them.
*/
export const REPO_URL = 'https://github.com/poli0981/bookmarkmagic';
export const ISSUES_URL = `${REPO_URL}/issues`;
/**
* Releases, not `blob/main/CHANGELOG.md` — the changelog is authored in Phase 5
* and the file does not exist yet. A releases page renders as a valid (empty)
* page; a missing blob is a 404 shown from inside a legal-adjacent surface.
*/
export const CHANGELOG_URL = `${REPO_URL}/releases`;
export interface LabelledLink {
labelKey: string;
url: string;
}
/**
* The four documents the gate and About link to (docs/14 §2).
*
* `blob/main/` and not a pinned tag on purpose: the gate asks the user to
* accept the *current* documents, and LEGAL_VERSION is the re-consent
* mechanism. Pinning would show terms that are no longer the ones in force.
*/
export const LEGAL_URLS: readonly LabelledLink[] = [
{ labelKey: 'legal.eula', url: `${REPO_URL}/blob/main/legal/EULA.md` },
{ labelKey: 'legal.license', url: `${REPO_URL}/blob/main/LICENSE` },
{ labelKey: 'legal.disclaimer', url: `${REPO_URL}/blob/main/legal/DISCLAIMER.md` },
{ labelKey: 'legal.privacy', url: `${REPO_URL}/blob/main/legal/PRIVACY.md` },
];
/**
* Donation platforms, from `.github/FUNDING.yml` (docs/14 §5).
*
* Labels are literals rather than i18n keys: these are brand names, which
* docs/07 §4 leaves untranslated. Only the section heading is localized.
*/
export const DONATE_LINKS: readonly { label: string; url: string }[] = [
{ label: 'GitHub Sponsors', url: 'https://github.com/sponsors/poli0981' },
{ label: 'Ko-fi', url: 'https://ko-fi.com/skullmute' },
{ label: 'Buy Me a Coffee', url: 'https://www.buymeacoffee.com/skullmute' },
{ label: 'Patreon', url: 'https://www.patreon.com/skullmute' },
{ label: 'PayPal', url: 'https://paypal.me/DungDang212' },
];
+87
View File
@@ -0,0 +1,87 @@
import { existsSync } from 'node:fs';
import { basename, join } from 'node:path';
import { afterEach, describe, expect, it } from 'vitest';
import { getAppVersion } from '@/lib/browser/app-info';
import { setLocale, t } from '@/lib/i18n/index.svelte';
import type { Locale } from '@/lib/i18n/resolve-locale';
import { CHANGELOG_URL, DONATE_LINKS, ISSUES_URL, LEGAL_URLS, REPO_URL } from '@/lib/links';
const LOCALES: Locale[] = ['en', 'vi', 'ja'];
/** Vitest runs with cwd at the project root, which is where `legal/` lives. */
const REPO_ROOT = process.cwd();
afterEach(() => {
setLocale('en');
});
describe('outbound links', () => {
it('are all absolute https URLs', () => {
const urls = [
REPO_URL,
ISSUES_URL,
CHANGELOG_URL,
...LEGAL_URLS.map((link) => link.url),
...DONATE_LINKS.map((link) => link.url),
];
for (const url of urls) {
expect(() => new URL(url)).not.toThrow();
expect(new URL(url).protocol).toBe('https:');
}
});
it('points every legal link at a file that exists in the repo', () => {
// A rename would otherwise ship four dead links from inside a legal gate,
// and nothing else in the build would notice.
for (const link of LEGAL_URLS) {
const path = new URL(link.url).pathname.replace('/poli0981/bookmarkmagic/blob/main/', '');
expect(existsSync(join(REPO_ROOT, path)), `missing ${path}`).toBe(true);
expect(basename(path)).not.toBe('');
}
});
it('labels every legal link in all three locales', () => {
const missing: string[] = [];
for (const locale of LOCALES) {
setLocale(locale);
for (const link of LEGAL_URLS) {
if (t(link.labelKey) === link.labelKey) missing.push(`${locale}: ${link.labelKey}`);
}
}
expect(missing).toEqual([]);
});
it('lists exactly the four documents docs/14 §2 requires', () => {
expect(LEGAL_URLS.map((link) => link.labelKey)).toEqual([
'legal.eula',
'legal.license',
'legal.disclaimer',
'legal.privacy',
]);
});
it('lists all five funding handles from .github/FUNDING.yml (docs/14 §5)', () => {
expect(DONATE_LINKS).toHaveLength(5);
expect(DONATE_LINKS.map((link) => link.label)).toEqual([
'GitHub Sponsors',
'Ko-fi',
'Buy Me a Coffee',
'Patreon',
'PayPal',
]);
});
it('avoids linking a CHANGELOG.md that does not exist yet', () => {
// Phase 5 authors it; until then the releases page is the honest target.
expect(CHANGELOG_URL.endsWith('/releases')).toBe(true);
});
});
describe('getAppVersion', () => {
it('returns an empty string rather than throwing when the manifest is unreadable', () => {
// fakeBrowser has no packaged manifest, so this exercises the fallback.
// A wrong-but-plausible version in a footer users quote in bug reports is
// worse than no version at all.
expect(() => getAppVersion()).not.toThrow();
expect(typeof getAppVersion()).toBe('string');
});
});