More audit cleanup: shared route cache helper, url columns, tab keys
- One CACHE and json() in shape.js for the seven public route files - A url column type: link fields (13 of them) refuse javascript:, data: and any other scheme on save, not only when drawn - The chapter map's logo uses the shared Logo component - Schedule tabs take Home and End as well as the arrows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1c94ffb281
commit
d1a6332a45
12 changed files with 66 additions and 75 deletions
|
|
@ -24,16 +24,11 @@
|
|||
|
||||
import { Hono } from "hono";
|
||||
|
||||
import { asBool, loadBlocks, marks, loadFeaturedCards, paragraphs } from "../shape.js";
|
||||
import { asBool, json, loadBlocks, loadFeaturedCards, marks, paragraphs } from "../shape.js";
|
||||
import { readFeeds } from "../feeds.js";
|
||||
|
||||
const blog = new Hono();
|
||||
|
||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
||||
|
||||
const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
|
||||
|
||||
|
||||
const PAGE_ID = "community";
|
||||
|
||||
const splitTags = (tags) =>
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import { Hono } from "hono";
|
|||
|
||||
import {
|
||||
asBool,
|
||||
json,
|
||||
loadBlocks,
|
||||
loadLinks,
|
||||
marks,
|
||||
|
|
@ -67,13 +68,9 @@ const content = new Hono();
|
|||
// Content changes weekly at most, and a stale minute costs nobody
|
||||
// anything. stale-while-revalidate keeps the page instant while the
|
||||
// refresh happens behind it.
|
||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
||||
|
||||
const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
|
||||
|
||||
const ORG_KINDS = ["national", "region", "chapter", "partner"];
|
||||
|
||||
|
||||
/* ── Loaders ───────────────────────────────────────────────── */
|
||||
|
||||
/* Hosts for a batch of events, keyed by event id, in the order
|
||||
|
|
@ -484,7 +481,6 @@ content.get("/events", (c) => {
|
|||
return json(c, { scopes, events });
|
||||
});
|
||||
|
||||
|
||||
/* One event, for its own page. */
|
||||
content.get("/events/:id", (c) => {
|
||||
const db = c.get("db");
|
||||
|
|
@ -541,7 +537,6 @@ content.get("/events/:id", (c) => {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
/* ── Organizations ─────────────────────────────────────────────
|
||||
GET /organizations every published, listed org
|
||||
GET /organizations?kind=region one kind
|
||||
|
|
@ -596,7 +591,6 @@ content.get("/organizations", (c) => {
|
|||
return json(c, { organizations });
|
||||
});
|
||||
|
||||
|
||||
/* One organization's page: region, chapter, partner or NGU. */
|
||||
content.get("/organizations/:id", (c) => {
|
||||
const db = c.get("db");
|
||||
|
|
@ -640,7 +634,6 @@ content.get("/organizations/:id", (c) => {
|
|||
return json(c, { organization });
|
||||
});
|
||||
|
||||
|
||||
/* ── Teams ─────────────────────────────────────────────────────
|
||||
GET /teams every published, listed team
|
||||
GET /teams?org=mid-atlantic one organization's teams
|
||||
|
|
@ -676,7 +669,6 @@ content.get("/teams", (c) => {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
content.get("/teams/:id", (c) => {
|
||||
const db = c.get("db");
|
||||
const id = c.req.param("id");
|
||||
|
|
@ -699,7 +691,6 @@ content.get("/teams/:id", (c) => {
|
|||
return json(c, { team: { ...shapeTeam(row, links, cards), blocks: body } });
|
||||
});
|
||||
|
||||
|
||||
/* ── Awards ────────────────────────────────────────────────────
|
||||
GET /awards every award
|
||||
GET /awards?org=ngu awards a given organization gives
|
||||
|
|
@ -738,7 +729,6 @@ content.get("/awards", (c) => {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
content.get("/awards/:id", (c) => {
|
||||
const db = c.get("db");
|
||||
const id = c.req.param("id");
|
||||
|
|
|
|||
|
|
@ -28,11 +28,10 @@
|
|||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { Hono } from "hono";
|
||||
import { CACHE } from "../shape.js";
|
||||
|
||||
const directory = new Hono();
|
||||
|
||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
||||
|
||||
directory.get("/directory", (c) => {
|
||||
const db = c.get("db");
|
||||
const all = (sql) => db.prepare(sql).all();
|
||||
|
|
|
|||
|
|
@ -31,15 +31,10 @@
|
|||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { Hono } from "hono";
|
||||
import { marks } from "../shape.js";
|
||||
import { json, marks } from "../shape.js";
|
||||
|
||||
const history = new Hono();
|
||||
|
||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
||||
|
||||
const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
|
||||
|
||||
|
||||
/* 'YYYY' → year, 'YYYY-MM' → month, 'YYYY-MM-DD' → day. */
|
||||
function precisionOfString(date) {
|
||||
const parts = String(date).split("-");
|
||||
|
|
|
|||
|
|
@ -48,14 +48,10 @@
|
|||
|
||||
import { Hono } from "hono";
|
||||
|
||||
import { asBool, loadFeaturedCards, loadLinks, shapeSeries, splitLinks } from "../shape.js";
|
||||
import { asBool, json, loadFeaturedCards, loadLinks, shapeSeries, splitLinks } from "../shape.js";
|
||||
|
||||
const home = new Hono();
|
||||
|
||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
||||
|
||||
const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
|
||||
|
||||
const PAGE_ID = "home";
|
||||
|
||||
const STAT_QUERIES = {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import { fileURLToPath } from "node:url";
|
|||
import { Hono } from "hono";
|
||||
|
||||
import { metaFor, renderPage, robotsTxt, siteFor, sitemap } from "../pageMeta.js";
|
||||
import { CACHE } from "../shape.js";
|
||||
|
||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
|
|
@ -43,8 +44,6 @@ export const SITE_INDEX = path.resolve(
|
|||
process.env.SITE_INDEX ?? path.join(here, "../../../dist/index.html"),
|
||||
);
|
||||
|
||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
||||
|
||||
let cached = { mtime: 0, html: null };
|
||||
|
||||
function indexHtml() {
|
||||
|
|
|
|||
|
|
@ -21,15 +21,10 @@
|
|||
|
||||
import { Hono } from "hono";
|
||||
|
||||
import { asBool, loadBlocks, loadLinks, marks, paragraphs, splitLinks } from "../shape.js";
|
||||
import { asBool, json, loadBlocks, loadLinks, marks, paragraphs, splitLinks } from "../shape.js";
|
||||
|
||||
const people = new Hono();
|
||||
|
||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
||||
|
||||
const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
|
||||
|
||||
|
||||
/* How many slugs one request may name. Keeps the URL sane. */
|
||||
const MAX_IDS = 50;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue