Skip to content

Commit e814b27

Browse files
TMHSDigitalclaude
andcommitted
One isListed rule and stats.listed (#257)
shared.mjs exports isListed(entry); build, validate, the exports, llms, freshness, reverify, check-links and app.js use it instead of repeating status !== "deprecated". data.json stats gain listed, which every page's "N sources" line now reads (schema and docs updated). Closes #257 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LpkeXQPaUhxjgqdqnk6BrJ
1 parent 8f8b1c3 commit e814b27

14 files changed

Lines changed: 49 additions & 34 deletions

‎docs/data.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Each entry in `data.json` has these fields. `catalog.csv` has the ones marked CS
4747
| `attributionClass`, `licenseRank` | | Derived sort keys used by the site |
4848
| `maintenance`, `engine_lock`, `ue_versions`, `limits`, `grid_dimensions`, `camera_perspective`, `hardware_tags` | | Present only where they apply; see [the site README](../site/README.md) |
4949

50-
Top-level keys are `generatedAt`, `version`, `site`, `categories`, `guides`, `stacks` (id and title of each starter stack), `featured`, `stats` (counts of total, active, needs-review, deprecated and commercial entries), `filters` (`licenseFamilies` and `formatGroups`, the labels and groups behind the site's filters) and `entries`.
50+
Top-level keys are `generatedAt`, `version`, `site`, `categories`, `guides`, `stacks` (id and title of each starter stack), `featured`, `stats` (counts of total, active, needs-review, deprecated, listed (total less deprecated) and commercial entries), `filters` (`licenseFamilies` and `formatGroups`, the labels and groups behind the site's filters) and `entries`.
5151

5252
Field names are stable, and [`data.schema.json`](https://tmhsdigital.github.io/Free-Game-Dev-Assets/data.schema.json) states them as a JSON Schema the build enforces, so a field cannot be renamed or retyped without the schema changing too. New optional fields may appear, so ignore keys you do not know rather than failing on them (the schema itself rejects unknown keys, which is how the build catches drift).
5353

‎site/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ and tools that want the metadata without scraping the page. The page itself load
4242

4343
- Top-level keys: `generatedAt`, `version` (the calendar tag of the day, `vYYYY.MM.DD`),
4444
`site`, `categories`, `guides`, `stacks` (id and title), `featured`, `stats` (counts: `total`, `active`,
45-
`needsReview`, `deprecated`, `commercialOk`, `commercialVaries`, `categories`), `filters`
45+
`needsReview`, `deprecated`, `listed` (total less deprecated: the "N sources" figure), `commercialOk`, `commercialVaries`, `categories`), `filters`
4646
(`licenseFamilies`, the labels for the Licence filter, and `formatGroups`, the groups behind
4747
the Format filter) and `entries`.
4848
The reader-facing guide to the exports is [`docs/data.md`](../docs/data.md).

‎site/build.mjs‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { execFileSync } from "node:child_process";
1414
import fs from "node:fs";
1515
import path from "node:path";
1616
import { fileURLToPath } from "node:url";
17-
import { baseHeadHtml, BROWSER_MODULES, commercialLabel, headAssetsHtml, esc, latestAllowedDate, OG_CARD_NAME, opensearchLinkHtml, opensearchXml, PAGE_MODULES, PREVIEW_CREDIT_LINE, sponsorButtonHtml } from "./lib/shared.mjs";
17+
import { baseHeadHtml, BROWSER_MODULES, isListed, commercialLabel, headAssetsHtml, esc, latestAllowedDate, OG_CARD_NAME, opensearchLinkHtml, opensearchXml, PAGE_MODULES, PREVIEW_CREDIT_LINE, sponsorButtonHtml } from "./lib/shared.mjs";
1818
import { filmstripHtml, groupedEntriesHtml } from "./lib/cards.mjs";
1919
import { guidePageHtml } from "./lib/guide-page.mjs";
2020
import { renderGuide } from "./lib/guide-render.mjs";
@@ -208,7 +208,7 @@ function headMetaHtml(site, stats, generatedAt, hasCard) {
208208
opensearchLinkHtml(site),
209209
`<meta name="generator" content="site/build.mjs ${esc(generatedAt)}" />`,
210210
`<meta name="catalog:entries" content="${stats.total}" />`,
211-
`<script type="application/ld+json">${scriptJson(homeJsonLd({ site, generatedAt, total: stats.total - stats.deprecated }))}</script>`,
211+
`<script type="application/ld+json">${scriptJson(homeJsonLd({ site, generatedAt, total: stats.listed }))}</script>`,
212212
].join("\n ");
213213
}
214214

@@ -407,7 +407,7 @@ function writeStackPages({ stacks, entries, config, stats, stamp, hasCard, now }
407407
owed: owes(stack.picked),
408408
site: config.site,
409409
stamp,
410-
total: stats.total - stats.deprecated,
410+
total: stats.listed,
411411
hasCard,
412412
now,
413413
});
@@ -433,7 +433,7 @@ function writeEntryPages({ entries, bodies, config, stats, stamp, hasCard, now,
433433
const written = [];
434434
const resolverFor = linkResolvers(entries, config);
435435
// Prev/next follow the homepage's default order: category, then name.
436-
const visible = entries.filter((e) => e.status !== "deprecated");
436+
const visible = entries.filter(isListed);
437437
const neighbours = new Map();
438438
for (const cat of Object.keys(config.categories)) {
439439
const group = visible.filter((e) => e.category === cat);
@@ -459,7 +459,7 @@ function writeEntryPages({ entries, bodies, config, stats, stamp, hasCard, now,
459459
site: config.site,
460460
categoryLabel: config.categories[entry.category]?.label || entry.category,
461461
stamp,
462-
total: stats.total - stats.deprecated,
462+
total: stats.listed,
463463
hasCard,
464464
now,
465465
stacks: usedIn.get(entry.id) || [],
@@ -482,7 +482,7 @@ function writeCategoryPages({ entries, config, stats, stamp, hasCard, now }) {
482482
if (!group.length) continue;
483483
writeOut(
484484
path.join("category", cat, "index.html"),
485-
categoryPageHtml({ cat, meta, entries: group, site: config.site, stamp, total: stats.total - stats.deprecated, hasCard, now })
485+
categoryPageHtml({ cat, meta, entries: group, site: config.site, stamp, total: stats.listed, hasCard, now })
486486
);
487487
written.push(`category/${cat}/index.html`);
488488
}
@@ -525,7 +525,7 @@ function writeGuidePages({ entries, config, stats, stamp, hasCard, modified = ne
525525
// anything else is a bug in the build and stops it, as for entry pages.
526526
try {
527527
const rendered = renderGuide(fs.readFileSync(source, "utf8"), { file: guide.path, resolveLink });
528-
writeOut(path.join("guide", guide.id, "index.html"), guidePageHtml({ guide, rendered, site: config.site, stamp, total: stats.total - stats.deprecated, hasCard, modified: modified.get(guide.path) || null }));
528+
writeOut(path.join("guide", guide.id, "index.html"), guidePageHtml({ guide, rendered, site: config.site, stamp, total: stats.listed, hasCard, modified: modified.get(guide.path) || null }));
529529
written.push(`guide/${guide.id}/index.html`);
530530
} catch (err) {
531531
if (!(err instanceof MarkdownError || err instanceof LinkError)) throw err;
@@ -609,6 +609,8 @@ function main() {
609609
active: entries.filter((e) => e.status === "active").length,
610610
needsReview: entries.filter((e) => e.status === "needs-review").length,
611611
deprecated: entries.filter((e) => e.status === "deprecated").length,
612+
// What every "N sources" line on the site says (#257).
613+
listed: entries.filter(isListed).length,
612614
commercialOk: entries.filter((e) => e.commercial === true).length,
613615
commercialVaries: entries.filter((e) => e.commercial === "varies").length,
614616
categories: Object.keys(config.categories).length,
@@ -676,7 +678,7 @@ function main() {
676678
// catalog whose whole value is that its entries can be found.
677679
const now = Date.now();
678680
const stamp = payload.generatedAt.slice(0, 10);
679-
const visible = entries.filter((e) => e.status !== "deprecated");
681+
const visible = entries.filter(isListed);
680682
const fresh = freshnessStats(entries, now);
681683
// The hero filmstrip draws from the categories that default to cards.
682684
const cardCategories = Object.entries(config.categories)
@@ -697,10 +699,10 @@ function main() {
697699
GUIDE_ROWS: guideRowsHtml(config.guides, repoUrl),
698700
CATALOG_BLURB: `${visible.length} sources &middot; ${stats.active} active &middot; ${stats.commercialOk} commercial-ok &middot; ${stats.commercialVaries} per-file${stats.deprecated ? ` &middot; plus ${stats.deprecated} deprecated, hidden by default` : ""}`,
699701
// Deprecated entries are hidden until their switch is on, so they are not counted until then (app.js does the same).
700-
RESULT_COUNT: `${visible.length} of ${stats.total - stats.deprecated} sources shown`,
702+
RESULT_COUNT: `${visible.length} of ${stats.listed} sources shown`,
701703
SPONSOR_BUTTON: sponsorButtonHtml(),
702704
PREVIEW_CREDIT: PREVIEW_CREDIT_LINE,
703-
FOOTER_STAMP: `Built ${esc(stamp)} from ${stats.total - stats.deprecated} listed sources.`,
705+
FOOTER_STAMP: `Built ${esc(stamp)} from ${stats.listed} listed sources.`,
704706
};
705707
let html = fs.readFileSync(path.join(PUBLIC, "index.html"), "utf8");
706708
const missingMarkers = Object.keys(substitutions).filter((key) => !html.includes(`<!--${key}-->`));
@@ -722,7 +724,7 @@ function main() {
722724
writeOut("robots.txt", robotsTxt(config.site));
723725
writeOut("opensearch.xml", opensearchXml(config.site));
724726
writeOut("404.html", notFoundHtml(config.site));
725-
writeOut(path.join("freshness", "index.html"), freshnessPageHtml({ stats: fresh, site: config.site, stamp, total: stats.total - stats.deprecated, hasCard }));
727+
writeOut(path.join("freshness", "index.html"), freshnessPageHtml({ stats: fresh, site: config.site, stamp, total: stats.listed, hasCard }));
726728

727729
const pages = writeEntryPages({ entries, bodies, config, stats, stamp, hasCard, now, usedIn });
728730
const stackPages = writeStackPages({ stacks, entries, config, stats, stamp, hasCard, now });

‎site/check-links.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { fileURLToPath } from "node:url";
2525
import { maintenanceFromRepo } from "./checks.mjs";
2626
import { readCatalog, usableRecord } from "./lib/entry-files.mjs";
2727
import { safeFetch } from "./lib/safe-fetch.mjs";
28+
import { isListed } from "./lib/shared.mjs";
2829
import { cliArgs } from "./lib/cli.mjs";
2930
import { checkMaintenanceRepos, classify, reportUrl, staleDaysFrom } from "./lib/link-check.mjs";
3031

@@ -103,7 +104,7 @@ if (staleArg.error) {
103104
process.exit(2);
104105
}
105106
const staleDays = staleArg.days;
106-
const entries = loadEntries().filter((e) => e.status !== "deprecated");
107+
const entries = loadEntries().filter(isListed);
107108
const results = await run(entries);
108109
const { mismatches: maintenance, skipped } = await checkMaintenance(entries);
109110
const cutoff = new Date(Date.now() - staleDays * 86400000).toISOString().slice(0, 10);

‎site/data.schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
},
6767
"stats": {
6868
"type": "object",
69-
"required": ["total", "active", "needsReview", "deprecated", "commercialOk", "commercialVaries", "categories"],
69+
"required": ["total", "active", "needsReview", "deprecated", "listed", "commercialOk", "commercialVaries", "categories"],
7070
"additionalProperties": { "type": "integer", "minimum": 0 }
7171
},
7272
"filters": {

‎site/lib/exports.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* for readers and sitemap.xml for crawlers. data.json stays the full
44
* machine-readable catalog.
55
*/
6-
import { esc } from "./shared.mjs";
6+
import { esc, isListed } from "./shared.mjs";
77

88
/**
99
* The folders whose files get a page with a lastmod: catalog entries, stacks
@@ -149,7 +149,7 @@ export function atomFeed({ entries, site, generatedAt, limit = 40, kind = "added
149149
const feedTitle = category ? `${spec.title} in ${category.label}` : spec.title;
150150
const feedId = category ? `${base}/${file}` : `${base}/${kind === "added" ? "" : spec.file}`;
151151
const recent = entries
152-
.filter((e) => (!category || e.category === category.id) && e.status !== "deprecated" && e[kind])
152+
.filter((e) => (!category || e.category === category.id) && isListed(e) && e[kind])
153153
.sort((a, b) => String(b[kind]).localeCompare(String(a[kind])) || a.name.localeCompare(b.name))
154154
.slice(0, limit);
155155
const items = recent.map((e) => {

‎site/lib/freshness.mjs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* Buckets come from verifiedAge, the function the homepage cards use, so the
44
* summary and the cards cannot disagree. Pure: `now` is passed in.
55
*/
6-
import { baseHeadHtml, esc, freshnessPageUrl, VERIFIED_FRESH_DAYS, verifiedAge, siteHeaderHtml, siteFooterHtml } from "./shared.mjs";
6+
import { baseHeadHtml, esc, isListed, freshnessPageUrl, VERIFIED_FRESH_DAYS, verifiedAge, siteHeaderHtml, siteFooterHtml } from "./shared.mjs";
77

88
const RECENT_DAYS = 30;
99
const byName = (a, b) => a.entry.name.localeCompare(b.entry.name);
1010
const dayWord = (n) => `${n} ${n === 1 ? "day" : "days"}`;
1111

1212
export function freshnessStats(entries, now) {
1313
const rows = entries
14-
.filter((e) => e.status !== "deprecated")
14+
.filter(isListed)
1515
.map((entry) => ({ entry, ...verifiedAge(entry.verified, now) }));
1616
const count = (bucket) => rows.filter((r) => r.bucket === bucket).length;
1717
const dated = rows.filter((r) => r.days !== null).sort((a, b) => b.days - a.days || byName(a, b));
@@ -48,7 +48,7 @@ const NEW_DAYS = 30;
4848
export function newEntriesLineHtml(entries, stamp, { named = 5, sortHref = "?sort=added#catalog" } = {}) {
4949
const since = new Date(Date.parse(`${stamp}T00:00:00Z`) - NEW_DAYS * 86400000).toISOString().slice(0, 10);
5050
const fresh = entries
51-
.filter((e) => e.status !== "deprecated" && e.added && e.added >= since)
51+
.filter((e) => isListed(e) && e.added && e.added >= since)
5252
.sort((a, b) => b.added.localeCompare(a.added) || a.name.localeCompare(b.name));
5353
if (!fresh.length) return "";
5454
const links = fresh.slice(0, named).map((e) => `<a href="entry/${esc(e.id)}/">${esc(e.name)}</a>`);

‎site/lib/lib.test.mjs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ eq("search: q from the URL is capped", readState(`?q=${"a".repeat(5000)}`, { q:
15501550
generatedAt: "2026-11-03T00:00:00.000Z", version: "v2026.11.03",
15511551
site: { title: "T", tagline: "t", repo: "r", siteUrl: "s" }, categories: { "2d": { label: "2D", view: "cards" } },
15521552
guides: [{ id: "g", title: "G", path: "docs/g.md" }], featured: [{ ...entry, need: "x" }],
1553-
stats: { total: 1, active: 1, needsReview: 0, deprecated: 0, commercialOk: 1, commercialVaries: 0, categories: 1 },
1553+
stats: { total: 1, active: 1, needsReview: 0, deprecated: 0, listed: 1, commercialOk: 1, commercialVaries: 0, categories: 1 },
15541554
filters: { licenseFamilies: { cc0: "CC0" }, formatGroups: { image: { label: "Images", formats: ["PNG"] } } },
15551555
entries: [entry], ...over,
15561556
});
@@ -2068,6 +2068,14 @@ eq("search: q from the URL is capped", readState(`?q=${"a".repeat(5000)}`, { q:
20682068
eq("coverage: covered in either run counts", cov.uncovered.map((u) => u.name).join(), "g");
20692069
}
20702070

2071+
/* one listed rule (#257) ------------------------------------------------- */
2072+
{
2073+
const { isListed } = await import("./shared.mjs");
2074+
eq("listed: active", isListed({ status: "active" }), true);
2075+
eq("listed: needs-review", isListed({ status: "needs-review" }), true);
2076+
eq("listed: deprecated is not", isListed({ status: "deprecated" }), false);
2077+
}
2078+
20712079
/* report (keep last) ------------------------------------------------------ */
20722080
if (failures.length) {
20732081
console.error(`lib.test failed (${failures.length}):`);

‎site/lib/llms.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** Plain-text indexes of the catalog for AI assistants (llmstxt.org format). */
22
import { LINK_RE, sectionMarkdown, splitEntryBody } from "./markdown.mjs";
3-
import { commercialLabel, entryPageUrl, freshnessPageUrl, stackPageUrl } from "./shared.mjs";
3+
import { commercialLabel, entryPageUrl, freshnessPageUrl, isListed, stackPageUrl } from "./shared.mjs";
44
import { owes } from "./stacks.mjs";
55

66
/** The first paragraph of the body before its first `##`, lines joined. */
@@ -46,7 +46,7 @@ Licence freshness, every entry by check date: ${freshnessPageUrl(site)}
4646

4747
function groups(entries, categories) {
4848
return Object.entries(categories)
49-
.map(([cat, meta]) => ({ label: meta.label || cat, items: entries.filter((e) => e.category === cat && e.status !== "deprecated") }))
49+
.map(([cat, meta]) => ({ label: meta.label || cat, items: entries.filter((e) => e.category === cat && isListed(e)) }))
5050
.filter((g) => g.items.length);
5151
}
5252

‎site/lib/reverify.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* selection rule; site/reverify-batch.mjs does the file I/O.
55
*/
66

7-
import { VERIFIED_FRESH_DAYS } from "./shared.mjs";
7+
import { isListed, VERIFIED_FRESH_DAYS } from "./shared.mjs";
88

99
/**
1010
* Days since a licence check before the entry is due again: 30 days inside
@@ -68,7 +68,7 @@ export function batchSizeNeeded(ages) {
6868
*/
6969
export function pickBatch(entries, { now = Date.now(), dueDays = DUE_DAYS, size } = {}) {
7070
const live = entries
71-
.filter((e) => e.status !== "deprecated")
71+
.filter(isListed)
7272
.map((entry) => ({ entry, age: entry.verified ? ageDays(entry.verified, now) : null }))
7373
.sort((a, b) => (b.age ?? Infinity) - (a.age ?? Infinity) || a.entry.id.localeCompare(b.entry.id));
7474
const picked =

0 commit comments

Comments
 (0)