Compare commits

..

1 Commits

Author SHA1 Message Date
sulthan af07314bb6 Cinder pass across /admin, the login gate, and the library's a11y floor
Uncommitted work from three design runs on this branch, against one design
system: docs/design-system.md is updated to match the CSS, not the reverse.

Library (Reader-facing):
- .chrome sticks at top: 0. Search and the tab row were unreachable three
  screens into a 300-item library, which is exactly where they earn their
  keep; everything above them still scrolls away on purpose.
- One :focus-visible ring (2px --paper) on the nine controls that defined
  none and fell back to the UA blue. .searchbar keeps its border recolour as
  a resting cue but no longer stands in for a ring.
- Mono labels lift 10px -> 11px everywhere. The brief names night reading and
  glare as the usage scene; 10px small-caps was where taste overrode it.
- A card in flight past 2s says "Saving..." and carries aria-busy. htmx sets
  neither, so the wait up to its 15s timeout was silent in both channels.
- Titles clamp at 3 lines; .is-new .title takes width: fit-content, or
  -webkit-box stretches the ember underline past the text it sizes to.

/admin:
- Overview routes into Lanes when a lane is unhealthy, prefixes each figure
  with its column word on the phone layout that drops the thead, labels state
  cells for a screen reader, and has an empty state where the sites table
  assumed rows.
- The admin shell picks up the library's chrome: htmx 15s timeout, the shared
  #notice slot, #sr-announce, filter.js. admin.css follows the same pass.
- admin_render_test.go and card_render_test.go render the templates directly,
  so markup regressions in either surface fail without a browser.

Login:
- DISCORD_GUILD_NAME (optional) names the community on the login screen and
  in the refusal message, so a stranger knows which Discord to ask for an
  invite. Unset degrades to a generic label; neither form names the guild id.

Handlers:
- maxChapterNum (9999) bounds both typed-chapter paths. uiChapter and
  adminSeriesCorrectLatest each parsed a float64 with no ceiling, so a
  hand-rolled POST stored 1e308 and every later reader of that row inherited
  it. Matches the max on the card's chapter input.

go test ./... green.
2026-08-27 23:05:40 +07:00
4 changed files with 9 additions and 47 deletions
-4
View File
@@ -145,10 +145,6 @@ func (f *TLSCoverFetcher) Fetch(ctx context.Context, sourceURL string) ([]byte,
if err != nil {
return nil, "", fmt.Errorf("build cover request: %w", err)
}
// cdn.asurascans.com answers Go's default User-Agent with a Cloudflare
// challenge (403, cf-mitigated) and a Chrome one with the image; measured
// 2026-12-04. No TLS fingerprint needed — the UA alone flips it.
req.Header.Set("User-Agent", chromeUA)
resp, err := f.client.Do(req)
if err != nil {
return nil, "", fmt.Errorf("fetch cover: %w", err)
@@ -228,24 +228,6 @@ func TestCoverFetcherRejectsNonImage(t *testing.T) {
}
}
// cdn.asurascans.com challenges Go's default User-Agent (measured 2026-12-04),
// so every cover from it failed until the fetcher sent a browser one.
func TestCoverFetcherSendsBrowserUserAgent(t *testing.T) {
client := &http.Client{Transport: roundTripFunc(func(r *http.Request) (*http.Response, error) {
if r.UserAgent() != chromeUA {
return coverResponse(http.StatusForbidden, "text/html", "", []byte("Just a moment...")), nil
}
return coverResponse(http.StatusOK, "image/webp", "", []byte("cover-bytes")), nil
})}
fetcher := newCoverFetcher(client, func(context.Context, string) ([]netip.Addr, error) {
return []netip.Addr{netip.MustParseAddr("198.51.100.10")}, nil
})
if _, _, err := fetcher.Fetch(context.Background(), "https://cdn.asurascans.com/asura-images/covers/x.webp"); err != nil {
t.Fatalf("Fetch: %v", err)
}
}
// comix labels its covers "image/jpg", which is not a registered type but is
// what the Site actually answers with; the bytes are stored under the real
// name so one image cannot land under two spellings.
+2 -16
View File
@@ -341,27 +341,13 @@ func comixCoverURL(seriesURL, body string) string {
return publishedCoverURL(entry.Poster.Medium)
}
// ogImageCover reads the og:image metadata shared by demonic and
// ogImageCover reads the og:image metadata shared by asura, demonic and
// lightnovelworld.
func ogImageCover(_, body string) (string, bool) {
cover := metaContent(body, "property", "og:image")
return cover, cover != ""
}
// asuraCoverRe reads coverUrl from the astro-island props, in both quote forms
// asuraStatusRe accepts. asura's og:image stopped being the cover (seen
// 2026-12-04): it is now a 1200x630 social card on asurascans.com itself,
// which also challenges every fetch without a Chrome TLS fingerprint.
var asuraCoverRe = regexp.MustCompile(`(?:"|")coverUrl(?:"|"):\[0,(?:"|")(https://[^&"]+)`)
func asuraCover(_, body string) (string, bool) {
m := asuraCoverRe.FindStringSubmatch(body)
if m == nil {
return "", false
}
return m[1], true
}
func novelfullCoverEntry(_, body string) (string, bool) {
cover := metaContent(body, "name", "image")
return cover, cover != ""
@@ -555,7 +541,7 @@ var sites = map[string]site{
"asura": {
Host: "asurascans.com",
LatestChapter: asuraLatestChapter,
Cover: asuraCover,
Cover: ogImageCover,
Completed: asuraCompleted,
Rest: defaultRest,
Gap: defaultGap,
+7 -9
View File
@@ -286,11 +286,9 @@ const lnwOngoingFixture = `<script type="application/ld+json">{
"creativeWorkStatus": "https://schema.org/ActiveActionStatus"
}</script>`
// Trimmed from https://asurascans.com/comics/chronicles-of-the-demon-faction-ce13e3a9
// on 2026-12-04. og:image is a social card, not the cover; the cover is the
// astro-island coverUrl prop.
const asuraCoverFixture = `<meta property="og:image" content="https://asurascans.com/og/comics/chronicles-of-the-demon-faction.jpg">` +
`<astro-island props="{&quot;seriesTitle&quot;:[0,&quot;Chronicles of the Demon Faction&quot;],&quot;coverUrl&quot;:[0,&quot;https://cdn.asurascans.com/asura-images/covers/chronicles-of-the-demon-faction.d4dcb8.webp&quot;]}"></astro-island>`
// Trimmed from https://asurascans.com/comics/chronicles-of-the-demon-faction-f886a8af
// (redirected to ...-00dcbf97) on 2026-08-10.
const asuraCoverFixture = `<meta property="og:image" content="https://cdn.asurascans.com/asura-images/covers/chronicles-of-the-demon-faction.d4dcb8.webp">`
// Trimmed from https://demonicscans.org/manga/Catastrophic-Necromancer on 2026-08-10.
// The source publishes the raw space in this URL.
@@ -323,7 +321,7 @@ func TestCoverFrom(t *testing.T) {
wantCover string
}{
{
name: "asura reads coverUrl prop, not og social card",
name: "asura uses published metadata URL",
site: "asura", body: asuraCoverFixture, wantOK: true,
wantCover: "https://cdn.asurascans.com/asura-images/covers/chronicles-of-the-demon-faction.d4dcb8.webp",
},
@@ -354,10 +352,10 @@ func TestCoverFrom(t *testing.T) {
},
{
name: "later metadata cover survives empty match",
site: "demonic",
body: `<meta property="og:image" content="">` + demonicCoverFixture,
site: "asura",
body: `<meta property="og:image" content="">` + asuraCoverFixture,
wantOK: true,
wantCover: "https://readermc.org/images/thumbnails/Catastrophic%20Necromancer.webp",
wantCover: "https://cdn.asurascans.com/asura-images/covers/chronicles-of-the-demon-faction.d4dcb8.webp",
},
{
name: "page without cover is empty",