Repository navigation
News section and a live highlights section on the landing page - #372
Merged
Merged
Conversation
Pure helpers for slugs, media URLs, categories, dates in NEMAR's time zone, month grouping, NewsArticle JSON-LD, and editor-side validation; a wire client for the public and admin news endpoints (nemar-cli#1551). Unit tested.
An allowImage predicate turns standalone image lines into figures with optional captions, and headingOffset shifts heading levels. READMEs keep the old behavior: without the option, image lines are still stripped. Unit tested.
Three columns under the hero: the latest news, the most cited datasets (linking to the citation dashboard), and the latest datasets. Each fails soft to a missing column. Adds news category marker tokens for both themes. Helpers tested against captured catalog fixtures.
/news lists posts newest first: the newest at full width, the rest on a month timeline. /news/<slug> renders the Markdown body with figures, NewsArticle JSON-LD, and a copy-link action. /news/media/<file> serves post images same-origin (host-neutral) so img-src stays 'self'.
/news/feed.xml carries the 20 newest posts with nemar.org links; a failed list answers 503 rather than an empty feed. Unit tested.
A 1200x630 card per post, rendered at build time like the dataset cards and refreshed by the rebuild cron. /og/news/<slug>.png redirects to the card, or to the post's banner until the next build renders one. Never fails the build.
/admin/news lists every post with its state (draft, scheduled, published) and which ones lead the home page. The editor at /admin/news/new and /admin/news/<id> writes Markdown with a live preview, uploads a banner and inline images (button, drop, or paste), and saves, schedules, or deletes a post.
ORCID sign-in and the streaming viewer (2026-07-29), HED and SCORE annotation (2026-09-02), anonymous deposits (2026-09-16), and the NEMAR Assistant (2026-09-24), each dated by the release that first shipped it to nemar.org. The script uploads banners (as WebP when ImageMagick is present) and creates the posts with an admin API key; it is idempotent.
Deploying nemar-website with
|
| Latest commit: |
472011d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://59c0c4c3.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-371-news.nemar-website.pages.dev |
Crop banners from the top, where an interface screenshot carries its meaning; put each column's link right under its list instead of bottom-aligned across the row; give the news column a one-line note so first rows align.
Biome rewrites a generic arrow's <T,> to <T>, which astro check parses as JSX in .astro frontmatter.
A post body's top heading level now renders as h2 whatever level the author used (newsHeadingOffset, tested), so the outline never skips from h1 to h3. The text measure is in rem so the header and body columns share an edge.
Also crop the index and admin thumbnails from the top.
Also match the preview to the article: normalized headings, rem measure, top crop.
Like the other build scripts, so astro check does not need Bun's types.
6 tasks done
safeUrl denylisted javascript: by prefix, so a leading control character (which browsers strip) slipped a script URL through; it now allowlists http, https, and mailto, reading the scheme with control characters and whitespace removed, and leaves relative URLs alone. This renderer also serves dataset READMEs. Links and code spans are held out before emphasis, which fixes double-escaped query strings, emphasis inside URLs, and a link nested in a link. Captions may contain parentheses. Tested.
Pagination hardcoded /discover for page 1, so page 2 of the news linked back to Discover; it takes a basePath now (Discover's default unchanged), and disabled Previous/Next render without an href so they are no longer focusable. A failed /news list answers 503 instead of a 200 error page.
The OG route checks the post is still public before redirecting to its card, so a deleted or unpublished post stops offering one at once. "Updated" appears only for an edit a day after the post was both written and dated, not on every backdated post. Copy link copies the canonical nemar.org URL, also on app.nemar.org.
In parallel rather than after it, and a sitemap missing its posts because the news list failed is cached for a minute, not an hour.
Uploaded body images get a selected "Describe this image" placeholder instead of the file name, and saving is refused until every image is described (undescribedImages, tested). Toggling Visibility no longer throws (a radio group is not an element). Publishing an old draft warns that it will list below newer posts and offers Now; the date hint names the time zone. The banner error is announced.
Biome's noControlCharactersInRegex rejects a NUL in a regex, which failed CI lint.
The backend ADR was renumbered when dev took 0075.
neuromechanist
added a commit
to nemarOrg/nemar-cli
that referenced
this pull request
Sep 29, 2026
Adds the news_posts table (migration 0087), public GET /news, /news/:slug, /news/media/:file, admin CRUD with a raw image upload stored in the NEWS_MEDIA R2 bucket (nemar-news-media, nemar-news-media-dev), and ADR 0076. Refs #1551; website half nemarOrg/website#372. Tested: news suites 90 pass, tsc clean, migrations:d1-check, and end to end with the website against a local harness.
This was referenced Sep 29, 2026
neuromechanist
added a commit
to nemarOrg/nemar-cli
that referenced
this pull request
Sep 29, 2026
* fix: type news media by name, not metadata GET /news/media/:file now always sends the Content-Type its regex-locked file extension implies, so a bad metadata write on the R2 object can never make the API origin serve text/html. Tested: the media route tests now run the public news routes in workerd through Miniflare, which reaches the 200 branch bun cannot; the new test fails on the old code (text/html) and passes (22 pass). * fix: bound news published_at to 2000-2100 zod accepted 9999-12-31T23:59:59-12:00, which SQLite datetime() turns into NULL (a 500 from the NOT NULL insert), and 0000-01-01T00:00:00+14:00, stored as year -0001. The year as written must now be 2000 through 2100, so both are a 400 naming published_at. Tested: new cases for both extremes on POST and PUT, the years just outside, and the accepted edges; they fail on the old code (500, 201) and pass (70 pass). * feat: audit news post create, update, delete Each admin write now inserts an audit_log row (news_post_created, news_post_updated, news_post_deleted; resource_type news_post, resource_id the post id; details with id, slug, status, published_at and the actor's username) in the same D1 batch as the write, so a failed audit insert fails the request with nothing written. The row is read from the post itself (INSERT ... SELECT) because a create's id does not exist until its INSERT runs; for update and delete this also means a 404 writes no row. Tested on real SQLite migrations: rows for all three writes, none for refused or missed writes, and a trigger-failed audit insert rolls each write back; the 5 new tests fail on the old code (75 pass). * feat: audit news image uploads An upload publishes: the object is readable by anyone with its URL, and the API can neither list nor delete it. POST /admin/news/media now writes a news_media_uploaded row (resource_id the file name; details with url, type, size, already_stored, actor) before the R2 put, so an audit insert that fails leaves nothing stored. Re-uploads of existing bytes are audited too. Tested: rows for a new and a repeated upload, none for every refusal, and a trigger-failed audit insert stores nothing; the 2 new tests fail on the old code (24 pass). * docs: say why the admin news list keeps bodies Trimming GET /admin/news to the summary columns would empty the website's admin list: its parseAdminNewsList (nemarOrg/website#372) drops any row without a string body. The list keeps full posts until the website parses it as summaries; the test now pins the body on every row. Tested: news-routes.test.ts (75 pass). * docs: ADR 0076 recall, cache window, deploy token Adds an Operations section: how to recall a mistaken image (R2 object delete with --remote, the API and website cache purges, the website redeploy), how long a post stays visible after unpublish or delete from the public routes' Cache-Control, and why the deploy token needs R2 (run 36610376353 attempt 1). Also records the new audit rows. Tested: test/adr-index.unit.test.ts.
This was referenced Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #371. Backend: nemarOrg/nemar-cli#1553 (issue nemarOrg/nemar-cli#1551).
Closesdoes not fire onstaging, so close #371 by hand after merge.What changed
Landing page. The two feature cards under the hero ("Assess before you analyze", "Analyze in place or download") are replaced by three live columns:
Each column is fetched in parallel with the hero stats on the decorative deadline and fails soft: a failed or empty column is dropped and the rest widen. A partial render is edge-cached for 60 s instead of 10 min.
"Most cited last month" (a month because citations arrive too slowly for a week) is not possible yet: nothing records when a citation was found, and diffs of the citation repository's history are dominated by pipeline re-runs (nm000275 went from 100 to 636 after a dedupe backfill). The column shows all-time counts until nemarOrg/nemar-citations#247 publishes a real monthly signal.
News section.
/news: the newest post at full width, then a month timeline with the day on the rail. RSS at/news/feed.xml./news/<slug>: title, summary, banner, Markdown body with figures and captions, reading time, copy link, NewsArticle JSON-LD, and three more posts. A body's top heading level always renders ash2, under the title'sh1./news/media/<sha256>.<ext>: post images, streamed from the API's R2 bucket and served same-origin and immutable, so CSPimg-srcstays'self'(ADR 0020). Host-neutral, so the admin editor on app.nemar.org shows them too./og/news/<slug>.pngredirects to the card, or to the post's banner until the next build renders one.Admin. A News tab at
/admin/newslists every post with its state (draft, scheduled, published) and which three lead the home page. The editor writes Markdown with a live preview rendered by the same code the article uses, uploads a banner and inline images (button, drop, or paste), and saves, schedules (a future date), backdates, or deletes. Unlike notices, posts are editable.Markdown renderer. Opt-in
allowImagerenders standalone image lines as figures (only/news/media/paths for news), andheadingOffsetshifts heading levels. README rendering is unchanged.Seed content.
scripts/seed-news.mjscreates the first five posts with an admin API key, dated by the release that first shipped each feature to nemar.org: ORCID sign-in and the streaming viewer (2026-07-29, v0.2.0), HED and SCORE annotation (2026-09-02, v0.2.5), anonymous deposits (2026-09-16, v0.2.14 and nemar-cli 0.10.4), and the NEMAR Assistant (2026-09-24, v0.2.18). Idempotent; banners are converted to WebP when ImageMagick is present.Review round
A Sonnet review found 12 issues; all are fixed in separate commits:
safeUrldenylistedjavascript:by prefix, so a leading control character slipped a script URL through. It now allowlists http, https, and mailto on the scheme read with control characters removed. The same pass fixes double-escaped query strings, emphasis inside URLs, and a link nested in a link./discover; it takes abasePathnow, and disabled Previous/Next are not focusable./newsanswers 503 when the list fails; the OG route checks the post is still public; "Updated" no longer appears on every backdated post; Copy link uses the canonical URL; the sitemap fetches news in parallel and short-caches a partial result.Deploy order
nemar-cli#1553 must reach an environment before this does: without
/news, the landing news column is simply absent, but/newsitself says the news could not load. Create the R2 buckets, promote nemar-cli, seed, then promote this.Test plan
bun run test: 2,603 passed (new: news helpers, heading normalization, Markdown figures, highlights against captured catalog fixtures, RSS, social card, sitemap, llms.txt, host routing, admin tabs)bun run typecheck: 0 errors;bun run lint: cleanastro buildsucceeds;generate:news-ogexits 0 and renders nothing while the API has no/newsseed-news.mjscreated all five posts (banners 94 to 393 KB as WebP) and skipped all five on a re-run/news, an article, the feed, and the OG redirect (to the banner, before a card exists) render; an unknown slug is a 404/news/media/<file>serves 200image/webp, immutable,nosniff; the backend answers 304 toIf-None-Match