mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-21 06:13:48 +00:00
feat(admin): link email detail to its public entry page
Add a "Public page" link next to the Rendered/Raw toggle in the admin email view, opening the standalone /entries/:feedId/:entryId render. Centralize the entry route shape in a pure entryPath() builder, used by both the admin link and the RSS/Atom/JSON feed generator. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -890,6 +890,39 @@ describe("Admin Routes", () => {
|
||||
expect(body).not.toContain("Attachments");
|
||||
});
|
||||
|
||||
it("links to the public entry page using the feed id and receivedAt", async () => {
|
||||
const authCookie = await loginAndGetCookie();
|
||||
const feedId = "detail-feed";
|
||||
await mockEnv.EMAIL_STORAGE.put(
|
||||
`feed:${feedId}:config`,
|
||||
JSON.stringify({
|
||||
title: "Detail Feed",
|
||||
mailbox_id: "detail.feed.10",
|
||||
language: "en",
|
||||
created_at: 1,
|
||||
}),
|
||||
);
|
||||
const emailKey = `feed:${feedId}:2`;
|
||||
await mockEnv.EMAIL_STORAGE.put(
|
||||
emailKey,
|
||||
JSON.stringify({
|
||||
subject: "Linkable",
|
||||
from: "sender@example.com",
|
||||
content: "<p>hello</p>",
|
||||
receivedAt: 2,
|
||||
headers: {},
|
||||
}),
|
||||
);
|
||||
|
||||
const res = await request(`/admin/emails/${emailKey}`, {
|
||||
headers: { Cookie: authCookie },
|
||||
});
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).toContain(`href="/entries/${feedId}/2"`);
|
||||
});
|
||||
|
||||
it("form-based bulk-delete also removes R2 attachments", async () => {
|
||||
const r2Env = createMockEnv({ withR2: true }) as unknown as Env;
|
||||
const bucket = r2Env.ATTACHMENT_BUCKET as unknown as {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
feedAtomUrl,
|
||||
feedEmailAddress,
|
||||
baseUrl,
|
||||
entryPath,
|
||||
} from "../../infrastructure/urls";
|
||||
import { processEmailContent } from "../../infrastructure/html-processor";
|
||||
import { formatBytes } from "../../domain/format";
|
||||
@@ -604,6 +605,14 @@ emailsRouter.get("/emails/:emailKey", async (c) => {
|
||||
<button id="raw-button" class="toggle-button" onclick="showRaw()">
|
||||
Raw HTML
|
||||
</button>
|
||||
<a
|
||||
class="toggle-view-link"
|
||||
href={entryPath(feedId, emailData.receivedAt)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Public page ↗
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="email-content">
|
||||
|
||||
Reference in New Issue
Block a user