-
+
---
@@ -62,7 +62,7 @@ npx lighthouse https://reader.boringcode.dev --view
- source filters
- real source icons in filters, dialog rows, and card metadata
- RSS-based app icon/favicon branding
- - dark/light mode
+ - seven themes — Auto (follows the device), Ink, Paper, Sepia, Terminal, Glacier, and Ember — with a visual swatch picker
- inline expanding search
- reader settings dialog for theme, density, and source visibility
- iPhone landscape safe-area handling so content stays clear of the notch and Dynamic Island
@@ -335,12 +335,15 @@ Presentation-layer note:
- `Reading` — Article preview, bookmarks, and AI personalization
- `Sources` — visible sources
- tabs support click, arrow keys, Home, and End; validation jumps to `Sources` or `Reading` when that tab needs attention
-- theme and density options are shown in a 2-column layout to reduce dialog height
+- themes are shown as a 2-column swatch grid; density options sit below in a 2-column row
+- the selected theme is applied when the dialog is saved, and the settings form scrolls internally on short screens
- clicking the dialog backdrop closes it
- background page scrolling is locked while the dialog is open
- selected sources are stored in `localStorage` under `feedreader.sources`
- selected density is stored in `localStorage` under `feedreader.uiDensity`
-- selected theme is stored in `localStorage` under `feedreader.theme`
+- selected theme is stored in `localStorage` under `feedreader.theme`; valid values are `system` (default), `dark`, `light`, `sepia`, `terminal`, `glacier`, and `ember`
+- `system` resolves to the device's current light/dark preference and follows changes live; existing `dark`/`light` preferences keep working
+- an inline pre-paint theme init script applies the stored preference before the stylesheet loads, avoiding a light/dark flash
- article preview is off by default and stored in `localStorage` under `feedreader.articlePreviewEnabled`
- bookmark controls are off by default and stored in `localStorage` under `feedreader.bookmarksEnabled`; enabling them shows the bookmark controls and Saved filter, and disabling them hides those controls without deleting saved items
- source-specific filters render as **real icon-only buttons**
@@ -360,6 +363,8 @@ Presentation-layer note:
- when enabled in Reader settings, clicking any card (including its title) loads a reader view in a right-hand panel instead of opening a new tab
- `Cmd`/`Ctrl`/`Shift`-clicking a title still opens the article in a new tab
- the panel shows the extracted title, byline, publication date/reading time, rich text with validated inline links/emphasis/inline code, image blocks with captions and intrinsic dimensions, and semantic tables; images load directly from the source with lazy loading and no referrer; `Open source` opens the original page
+- consecutive list items render as one list and prose uses the full preview width; figures are capped in height so a single image cannot dominate the panel
+- previews are source-aware: GitHub README previews drop the `GitHub - ` title prefix and decorative SVG/badge images, while Hugging Face paper previews render the abstract, authors, arXiv/PDF/project/GitHub links, and citing model, dataset, space, and collection lists instead of community comment chrome
- Hacker News items also show a **Comments** action inside the preview and card `…` dialogs; other sources omit it
- each card’s `…` dialog includes an **Open source** action that opens the article directly without opening the preview
- **Share** uses the device/browser share sheet when available and falls back to copying the article link; it is available in both the card and preview `…` dialogs
@@ -421,6 +426,8 @@ npm run db:migrate:local
- CI runs on pull requests and `main` pushes.
- CI checks type safety, unit tests, and a local D1 migration smoke run.
+- Pull requests get a Cloudflare version preview commented on the PR.
+- Non-`main` branch pushes get an automatic per-branch preview alias in the Actions run summary; branches with an open PR defer to the PR preview.
- Deploy runs on `main` pushes and manual dispatch.
- Deploy validates Cloudflare credentials, re-runs verification, applies remote D1 migrations, and deploys the Worker.
diff --git a/core/preview.ts b/core/preview.ts
index f076659..7c8f009 100644
--- a/core/preview.ts
+++ b/core/preview.ts
@@ -214,7 +214,7 @@ export function extractArticlePreview(
): ArticlePreview {
const document = parseHtmlDocument(html);
- const title = firstNonEmpty(
+ const rawTitle = firstNonEmpty(
metaContent(document, [
'meta[property="og:title"]',
'meta[name="twitter:title"]',
@@ -222,6 +222,8 @@ export function extractArticlePreview(
normalizeText(document.querySelector("h1")?.textContent),
normalizeText(document.querySelector("title")?.textContent),
);
+ const title = sanitizePreviewTitle(rawTitle, pageUrl);
+ const isPaperPage = isHuggingFacePaperPage(pageUrl);
const siteName =
metaContent(document, ['meta[property="og:site_name"]']) ||
hostLabel(pageUrl);
@@ -233,9 +235,18 @@ export function extractArticlePreview(
]),
normalizeText(document.querySelector('[rel="author"]')?.textContent),
normalizeText(document.querySelector('[class*="byline"]')?.textContent),
+ isPaperPage ? extractHuggingFacePaperByline(document) : "",
),
);
const publishedAt = extractPublishedAt(document);
+ // Read paper resources and citation lists before nav/header cleanup drops
+ // the containers they live in.
+ const paperLinks = isPaperPage
+ ? extractHuggingFacePaperLinks(document, pageUrl)
+ : [];
+ const paperCitations = isPaperPage
+ ? extractHuggingFacePaperCitations(document, pageUrl)
+ : [];
for (const selector of NOISE_SELECTORS) {
document.querySelectorAll(selector).forEach((element) => {
@@ -243,8 +254,17 @@ export function extractArticlePreview(
});
}
- const root = pickContentRoot(document);
+ const root = isPaperPage
+ ? (pickHuggingFacePaperRoot(document) ?? pickContentRoot(document))
+ : pickContentRoot(document);
const blocks = root ? extractBlocks(root, title, pageUrl) : [];
+ if (paperLinks.length > 0) {
+ blocks.push({
+ type: "paragraph",
+ segments: [{ text: "Read the full paper: " }, ...paperLinks],
+ });
+ }
+ blocks.push(...paperCitations);
if (blocks.length === 0) {
const description = normalizeText(
metaContent(document, [
@@ -444,6 +464,11 @@ function collectInlineSegments(
}
}
+/**
+ * Resolves relative links and returns only public http(s) URLs.
+ * `normalizePreviewUrl` rejects javascript:, data:, credentials, non-standard
+ * ports, and private/link-local hosts, so callers never see unsafe schemes.
+ */
function resolveInlineHref(raw: string | null, pageUrl: string): string {
const trimmed = (raw ?? "").trim();
if (trimmed === "") return "";
@@ -569,6 +594,7 @@ function extractImageBlock(
}
if (resolved === "") return null;
if (isAvatarImageSrc(resolved)) return null;
+ if (isDecorativeImageSrc(resolved)) return null;
const caption = normalizeText(
image.closest("figure")?.querySelector("figcaption")?.textContent,
@@ -652,6 +678,26 @@ function isAvatarImageSrc(rawUrl: string): boolean {
return false;
}
+/**
+ * README badges and wordmarks dominate a reader view when they are stretched
+ * to the panel width. They are interface chrome, not article figures.
+ */
+function isDecorativeImageSrc(rawUrl: string): boolean {
+ let url: URL;
+ try {
+ url = new URL(rawUrl);
+ } catch {
+ return false;
+ }
+ if (/\.svgz?$/i.test(url.pathname)) return true;
+ const host = url.hostname.toLowerCase().replace(/^www\./, "");
+ return (
+ host === "img.shields.io" ||
+ host === "badgen.net" ||
+ host === "badge.fury.io"
+ );
+}
+
function resolveSrcsetUrl(srcset: string | null, pageUrl: string): string {
const raw = (srcset ?? "").trim();
if (raw === "") return "";
@@ -682,6 +728,149 @@ function parseImageDimension(raw: string | null): number | undefined {
return parsed;
}
+/**
+ * Source pages often prefix the article title with their own site chrome
+ * ("GitHub - ", "Paper page - "). Strip only on the matching host so a real
+ * article title that happens to start with those words is left alone.
+ */
+function sanitizePreviewTitle(rawTitle: string, pageUrl: string): string {
+ const title = rawTitle.trim();
+ let url: URL;
+ try {
+ url = new URL(pageUrl);
+ } catch {
+ return title;
+ }
+ const host = url.hostname.toLowerCase().replace(/^www\./, "");
+ let cleaned = title;
+ if (host === "github.com") {
+ cleaned = cleaned.replace(/^GitHub\s*[-–—]\s*/i, "");
+ } else if (host === "huggingface.co" && url.pathname.startsWith("/papers/")) {
+ cleaned = cleaned.replace(/^Paper page\s*[-–—]\s*/i, "");
+ }
+ return cleaned.trim() || title;
+}
+
+function isHuggingFacePaperPage(pageUrl: string): boolean {
+ try {
+ const url = new URL(pageUrl);
+ return (
+ url.hostname.toLowerCase().replace(/^www\./, "") === "huggingface.co" &&
+ url.pathname.startsWith("/papers/")
+ );
+ } catch {
+ return false;
+ }
+}
+
+/**
+ * Paper pages mix the abstract with a community thread and citation cards in
+ * one document. Start at the "Abstract" section so the reader view keeps the
+ * paper itself instead of the surrounding discussion chrome.
+ */
+function extractHuggingFacePaperByline(document: Document): string {
+ const nodes = Array.from(document.querySelectorAll(".author, h2"));
+ const abstractIndex = nodes.findIndex(
+ (element) =>
+ element.tagName === "H2" &&
+ normalizeText(element.textContent).toLowerCase() === "abstract",
+ );
+ const stop = abstractIndex === -1 ? nodes.length : abstractIndex;
+ const names: string[] = [];
+ for (const node of nodes.slice(0, stop)) {
+ if (!node.classList.contains("author")) continue;
+ const name = normalizeText(node.textContent).replace(/\s*,\s*$/, "");
+ if (name !== "" && !names.includes(name)) names.push(name);
+ }
+ if (names.length === 0) return "";
+ return names.length <= 3
+ ? names.join(", ")
+ : `${names.slice(0, 3).join(", ")}, et al.`;
+}
+
+function extractHuggingFacePaperLinks(
+ document: Document,
+ pageUrl: string,
+): PreviewSegment[] {
+ const heading = findHuggingFaceAbstractHeading(document);
+ const container = heading?.parentElement?.nextElementSibling;
+ const anchors = container
+ ? Array.from(container.querySelectorAll("a[href]"))
+ : [];
+ const parts: PreviewSegment[] = [];
+ for (const anchor of anchors) {
+ const label = normalizeText(anchor.textContent);
+ // resolveInlineHref only emits public http(s) URLs.
+ const href = resolveInlineHref(anchor.getAttribute("href"), pageUrl);
+ if (href === "") continue;
+ let text = "";
+ if (/^View arXiv page/i.test(label)) text = "arXiv abstract";
+ else if (/^View PDF/i.test(label)) text = "PDF";
+ else if (/^Project page/i.test(label)) text = "Project page";
+ else if (/^GitHub\b/i.test(label)) text = "GitHub";
+ if (text === "") continue;
+ if (parts.length > 0) parts.push({ text: " · " });
+ parts.push({ text, href });
+ }
+ return parts;
+}
+
+function extractHuggingFacePaperCitations(
+ document: Document,
+ pageUrl: string,
+): PreviewBlock[] {
+ const blocks: PreviewBlock[] = [];
+ const headings = Array.from(document.querySelectorAll("h2, h3")).filter(
+ (element) => {
+ const text = normalizeText(element.textContent);
+ return (
+ /^(Models|Datasets|Spaces) citing this paper/i.test(text) ||
+ /^Collections including this paper/i.test(text)
+ );
+ },
+ );
+ for (const heading of headings) {
+ const title = normalizeText(heading.textContent);
+ const container = heading.nextElementSibling;
+ if (!container) continue;
+ const items: PreviewSegment[] = [];
+ for (const anchor of Array.from(container.querySelectorAll("a[href]"))) {
+ // resolveInlineHref only emits public http(s) URLs.
+ const href = resolveInlineHref(anchor.getAttribute("href"), pageUrl);
+ if (href === "") continue;
+ const label = normalizeText(
+ anchor.querySelector("h4")?.textContent ?? anchor.textContent,
+ );
+ if (label === "") continue;
+ items.push({ text: label, href });
+ }
+ if (items.length === 0) continue;
+ blocks.push({ type: "heading", text: title });
+ for (const item of items) {
+ blocks.push({ type: "list", segments: [item] });
+ }
+ }
+ return blocks;
+}
+
+function findHuggingFaceAbstractHeading(document: Document): Element | null {
+ return (
+ Array.from(document.querySelectorAll("h2")).find(
+ (element) =>
+ normalizeText(element.textContent).toLowerCase() === "abstract",
+ ) ?? null
+ );
+}
+
+function pickHuggingFacePaperRoot(document: Document): Element | null {
+ const heading = findHuggingFaceAbstractHeading(document);
+ const parent = heading?.parentElement ?? null;
+ if (!parent || parent === document.body || parent.tagName === "MAIN") {
+ return null;
+ }
+ return parent;
+}
+
function pickContentRoot(document: Document): Element | null {
const articles = Array.from(document.querySelectorAll("article"));
let bestArticle: Element | null = null;
diff --git a/core/render.ts b/core/render.ts
index 304f783..55b9d48 100644
--- a/core/render.ts
+++ b/core/render.ts
@@ -65,6 +65,45 @@ function renderErrorBanner(error: ErrorView): string {
return `