mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-20 22:03:48 +00:00
refactor(admin): migrate feeds.ts to feeds.tsx with JSX rendering
Convert the edit feed GET route from hono/html tagged template literals to typed JSX using the <Layout> component. All CRUD routes and business logic are preserved unchanged. textarea placeholder special characters are now handled via JSX attribute escaping rather than entities. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
import { html } from "hono/html";
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { Env, FeedConfig, FeedMetadata, EmailData } from "../../types";
|
import { Env, FeedConfig, FeedMetadata, EmailData } from "../../types";
|
||||||
import { generateFeedId } from "../../utils/id-generator";
|
import { generateFeedId } from "../../utils/id-generator";
|
||||||
import { waitUntilSafe } from "../../utils/worker";
|
import { waitUntilSafe } from "../../utils/worker";
|
||||||
import { logger } from "../../lib/logger";
|
import { logger } from "../../lib/logger";
|
||||||
import { layout } from "./ui";
|
import { Layout } from "./ui";
|
||||||
import {
|
import {
|
||||||
addFeedToList,
|
addFeedToList,
|
||||||
updateFeedInList,
|
updateFeedInList,
|
||||||
@@ -246,68 +245,66 @@ feedsRouter.get("/:feedId/edit", async (c) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return c.html(
|
return c.html(
|
||||||
layout(
|
<Layout title="Edit Feed">
|
||||||
"Edit Feed",
|
<div class="container fade-in">
|
||||||
html`
|
<div class="header-with-actions">
|
||||||
<div class="container fade-in">
|
<div class="header-title">
|
||||||
<div class="header-with-actions">
|
<h1>{feedConfig.title} - Edit Feed</h1>
|
||||||
<div class="header-title">
|
|
||||||
<h1>${feedConfig.title} - Edit Feed</h1>
|
|
||||||
</div>
|
|
||||||
<div class="header-actions">
|
|
||||||
<a href="/admin" class="button button-secondary button-back"
|
|
||||||
>Back to Dashboard</a
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="header-actions">
|
||||||
<div class="card">
|
<a href="/admin" class="button button-secondary button-back">
|
||||||
<form action="/admin/feeds/${feedId}/edit" method="post">
|
Back to Dashboard
|
||||||
<div class="form-group">
|
</a>
|
||||||
<label for="title">Feed Title</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="title"
|
|
||||||
name="title"
|
|
||||||
value="${feedConfig.title}"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="description">Description</label>
|
|
||||||
<textarea id="description" name="description" rows="3">
|
|
||||||
${feedConfig.description || ""}</textarea
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="allowed_senders"
|
|
||||||
>Allowed senders (optional, one email or domain per
|
|
||||||
line)</label
|
|
||||||
>
|
|
||||||
<textarea
|
|
||||||
id="allowed_senders"
|
|
||||||
name="allowed_senders"
|
|
||||||
rows="3"
|
|
||||||
placeholder="newsletter@example.com techmeme.com"
|
|
||||||
>
|
|
||||||
${(feedConfig.allowed_senders || []).join("\n")}</textarea
|
|
||||||
>
|
|
||||||
<small
|
|
||||||
>When set, inbound emails are only accepted from these
|
|
||||||
senders/domains.</small
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" id="language" name="language" value="en" />
|
|
||||||
|
|
||||||
<button type="submit" class="button">Update Feed</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`,
|
|
||||||
),
|
<div class="card">
|
||||||
|
<form action={`/admin/feeds/${feedId}/edit`} method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="title">Feed Title</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="title"
|
||||||
|
name="title"
|
||||||
|
value={feedConfig.title}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="description">Description</label>
|
||||||
|
<textarea id="description" name="description" rows={3}>
|
||||||
|
{feedConfig.description || ""}
|
||||||
|
</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="allowed_senders">
|
||||||
|
Allowed senders (optional, one email or domain per line)
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
id="allowed_senders"
|
||||||
|
name="allowed_senders"
|
||||||
|
rows={3}
|
||||||
|
placeholder={"newsletter@example.com\ntechmeme.com"}
|
||||||
|
>
|
||||||
|
{(feedConfig.allowed_senders || []).join("\n")}
|
||||||
|
</textarea>
|
||||||
|
<small>
|
||||||
|
When set, inbound emails are only accepted from these
|
||||||
|
senders/domains.
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="hidden" id="language" name="language" value="en" />
|
||||||
|
|
||||||
|
<button type="submit" class="button">
|
||||||
|
Update Feed
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Layout>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
Reference in New Issue
Block a user