Skip to content

Commit b74191b

Browse files
committed
Fix registry dates and load timestamp
1 parent d354c43 commit b74191b

8 files changed

Lines changed: 64 additions & 9 deletions

File tree

generated/registry-index.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"schema_version": 2,
3-
"generated_at": "2026-05-14T23:42:53+08:00",
3+
"generated_at": "2026-05-14T23:49:22+08:00",
44
"registry_id": "cardputerzero-appstore",
55
"device_targets": [
66
"CardputerZero"
@@ -29,6 +29,8 @@
2929
],
3030
"author": {},
3131
"version": "0.1.0",
32+
"published_at": "2026-05-14T23:49:22+08:00",
33+
"updated_at": "2026-05-14T23:49:22+08:00",
3234
"license": "MIT",
3335
"source_repo": "https://github.com/CardputerZero/2048",
3436
"download": {
@@ -107,6 +109,8 @@
107109
],
108110
"author": {},
109111
"version": "0.1.3",
112+
"published_at": "2026-05-14T23:49:22+08:00",
113+
"updated_at": "2026-05-14T23:49:22+08:00",
110114
"license": "MIT",
111115
"source_repo": "https://github.com/CardputerZero/Calendar",
112116
"download": {
@@ -193,6 +197,8 @@
193197
"display_name": "vicliu624"
194198
},
195199
"version": "0.2.0-1~lofibox23",
200+
"published_at": "2026-05-14T23:49:22+08:00",
201+
"updated_at": "2026-05-14T23:49:22+08:00",
196202
"license": "GPL-3.0",
197203
"source_repo": "https://github.com/vicliu624/LoFiBox-Zero",
198204
"download": {
@@ -281,6 +287,8 @@
281287
"display_name": "eggfly"
282288
},
283289
"version": "1.0.3",
290+
"published_at": "2026-05-14T23:49:22+08:00",
291+
"updated_at": "2026-05-14T23:49:22+08:00",
284292
"license": "MIT",
285293
"source_repo": "https://github.com/eggfly/CardputerZero-NC2000",
286294
"download": {

generated/registry.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"schema_version": 2,
3-
"generated_at": "2026-05-14T23:42:53+08:00",
3+
"generated_at": "2026-05-14T23:49:22+08:00",
44
"registry_id": "cardputerzero-appstore",
55
"device_targets": [
66
"CardputerZero"
@@ -29,6 +29,8 @@
2929
],
3030
"author": {},
3131
"version": "0.1.0",
32+
"published_at": "2026-05-14T23:49:22+08:00",
33+
"updated_at": "2026-05-14T23:49:22+08:00",
3234
"license": "MIT",
3335
"source_repo": "https://github.com/CardputerZero/2048",
3436
"download": {
@@ -107,6 +109,8 @@
107109
],
108110
"author": {},
109111
"version": "0.1.3",
112+
"published_at": "2026-05-14T23:49:22+08:00",
113+
"updated_at": "2026-05-14T23:49:22+08:00",
110114
"license": "MIT",
111115
"source_repo": "https://github.com/CardputerZero/Calendar",
112116
"download": {
@@ -193,6 +197,8 @@
193197
"display_name": "vicliu624"
194198
},
195199
"version": "0.2.0-1~lofibox23",
200+
"published_at": "2026-05-14T23:49:22+08:00",
201+
"updated_at": "2026-05-14T23:49:22+08:00",
196202
"license": "GPL-3.0",
197203
"source_repo": "https://github.com/vicliu624/LoFiBox-Zero",
198204
"download": {
@@ -281,6 +287,8 @@
281287
"display_name": "eggfly"
282288
},
283289
"version": "1.0.3",
290+
"published_at": "2026-05-14T23:49:22+08:00",
291+
"updated_at": "2026-05-14T23:49:22+08:00",
284292
"license": "MIT",
285293
"source_repo": "https://github.com/eggfly/CardputerZero-NC2000",
286294
"download": {

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ <h3></h3>
7070
</article>
7171
</template>
7272

73-
<script src="site/app.js?v=20260513-dev-guide" defer></script>
73+
<script src="site/app.js?v=20260514-date-load-time" defer></script>
7474
</body>
7575
</html>

scripts/generate_registry.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def normalize_assets(pkg_name: str, meta: dict[str, Any]) -> dict[str, Any]:
9595
}
9696

9797

98-
def build_app(pkg_name: str, pkg_info: dict[str, str], meta: dict[str, Any]) -> dict[str, Any]:
98+
def build_app(pkg_name: str, pkg_info: dict[str, str], meta: dict[str, Any], generated_at: str) -> dict[str, Any]:
9999
sha256 = pkg_info.get("SHA256", "")
100100
filename = pkg_info.get("Filename", "")
101101
assets = normalize_assets(pkg_name, meta)
@@ -105,6 +105,8 @@ def build_app(pkg_name: str, pkg_info: dict[str, str], meta: dict[str, Any]) ->
105105
locales = i18n
106106
if not i18n and locales:
107107
i18n = locales
108+
published_at = str(meta.get("published_at") or meta.get("created_at") or generated_at)
109+
updated_at = str(meta.get("updated_at") or meta.get("published_at") or meta.get("created_at") or generated_at)
108110

109111
app = {
110112
"uuid": str(meta.get("uuid") or make_uuid(pkg_name, sha256)),
@@ -117,6 +119,8 @@ def build_app(pkg_name: str, pkg_info: dict[str, str], meta: dict[str, Any]) ->
117119
"categories": list_value(meta.get("categories")),
118120
"author": meta.get("author") if isinstance(meta.get("author"), dict) else {},
119121
"version": pkg_info.get("Version", ""),
122+
"published_at": published_at,
123+
"updated_at": updated_at,
120124
"license": str(meta.get("license") or ""),
121125
"source_repo": str(meta.get("source_repo") or ""),
122126
"download": {
@@ -139,6 +143,7 @@ def build_app(pkg_name: str, pkg_info: dict[str, str], meta: dict[str, Any]) ->
139143
def build_registry(packages_path: Path, meta_dir: Path, overrides_path: Path) -> dict[str, Any]:
140144
packages = parse_packages(packages_path)
141145
overrides = read_json(overrides_path, {})
146+
generated_at = now_iso()
142147
apps = []
143148
for pkg_name, pkg_info in sorted(packages.items()):
144149
meta_path = meta_dir / f"{pkg_name}.json"
@@ -150,11 +155,11 @@ def build_registry(packages_path: Path, meta_dir: Path, overrides_path: Path) ->
150155
override = overrides.get(pkg_name, {}) if isinstance(overrides, dict) else {}
151156
if isinstance(override, dict):
152157
meta = deep_merge(meta, override)
153-
apps.append(build_app(pkg_name, pkg_info, meta))
158+
apps.append(build_app(pkg_name, pkg_info, meta, generated_at))
154159

155160
return {
156161
"schema_version": 2,
157-
"generated_at": now_iso(),
162+
"generated_at": generated_at,
158163
"registry_id": "cardputerzero-appstore",
159164
"device_targets": ["CardputerZero"],
160165
"i18n": {

site/app.js

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const REGISTRY_URL = "generated/registry.json";
22
const PAGE_SIZE = 6;
33
const SUPPORTED_LOCALES = ["zh-CN", "en", "ja"];
4+
const APP_LOADED_AT = new Date();
45
const GISCUS_CONFIG = {
56
repo: "CardputerZero/cardputerzero.github.io",
67
repoId: "R_kgDOSWq5Vw",
@@ -158,6 +159,9 @@ async function fetchJson(url) {
158159
}
159160

160161
function normalizeApp(app) {
162+
const registryGeneratedAt = state.registry?.generated_at || "";
163+
const publishedAt = app.published_at || app.updated_at || registryGeneratedAt;
164+
const updatedAt = app.updated_at || app.published_at || registryGeneratedAt;
161165
const source = app.source || {
162166
openness: app.source_openness || "unknown",
163167
repository: app.source_repo || ""
@@ -170,6 +174,8 @@ function normalizeApp(app) {
170174
...app,
171175
categories: app.categories || [],
172176
locales: app.locales || app.i18n || {},
177+
published_at: publishedAt,
178+
updated_at: updatedAt,
173179
source,
174180
review,
175181
download: app.download || {},
@@ -349,6 +355,10 @@ function renderRegistryPanel() {
349355
<span class="status-label">${t("registry.updated")}</span>
350356
<span class="status-value">${formatDate(registry.generated_at)}</span>
351357
</div>
358+
<div class="status-item">
359+
<span class="status-label">${t("registry.loaded")}</span>
360+
<span class="status-value">${formatDateTime(APP_LOADED_AT)}</span>
361+
</div>
352362
<div class="status-item">
353363
<span class="status-label">${t("registry.schema")}</span>
354364
<span class="status-value">v${registry.schema_version}</span>
@@ -587,10 +597,10 @@ function getFilteredApps() {
587597
}
588598

589599
function sortApps(a, b) {
590-
if (state.sort === "published") return new Date(b.published_at) - new Date(a.published_at);
600+
if (state.sort === "published") return dateTimeValue(b.published_at) - dateTimeValue(a.published_at);
591601
if (state.sort === "name") return localized(a, "title").localeCompare(localized(b, "title"), state.locale);
592602
if (state.sort === "review") return a.review.status.localeCompare(b.review.status);
593-
return new Date(b.updated_at) - new Date(a.updated_at);
603+
return dateTimeValue(b.updated_at) - dateTimeValue(a.updated_at);
594604
}
595605

596606
function renderAppCard(app) {
@@ -1316,7 +1326,28 @@ function getPath(source, path) {
13161326
}
13171327

13181328
function formatDate(value) {
1319-
return new Intl.DateTimeFormat(state.locale, { dateStyle: "medium" }).format(new Date(value));
1329+
const date = parseDate(value);
1330+
if (!date) return "—";
1331+
return new Intl.DateTimeFormat(state.locale, { dateStyle: "medium" }).format(date);
1332+
}
1333+
1334+
function formatDateTime(value) {
1335+
const date = parseDate(value);
1336+
if (!date) return "—";
1337+
return new Intl.DateTimeFormat(state.locale, {
1338+
dateStyle: "medium",
1339+
timeStyle: "medium"
1340+
}).format(date);
1341+
}
1342+
1343+
function parseDate(value) {
1344+
if (!value) return null;
1345+
const date = value instanceof Date ? value : new Date(value);
1346+
return Number.isNaN(date.getTime()) ? null : date;
1347+
}
1348+
1349+
function dateTimeValue(value) {
1350+
return parseDate(value)?.getTime() || 0;
13201351
}
13211352

13221353
function bindCopyButtons() {

site/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
"apps": "Apps",
218218
"eyebrow": "REGISTRY FILES",
219219
"files": "Static files",
220+
"loaded": "Page loaded",
220221
"open": "Open registry",
221222
"pageLead": "The Web UI reads the JSON registry. YAML is kept for maintainer review and device tooling.",
222223
"pageTitle": "Registry data source",

site/i18n/ja.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
"apps": "アプリ数",
218218
"eyebrow": "REGISTRY FILES",
219219
"files": "静的ファイル",
220+
"loaded": "ページ読み込み",
220221
"open": "registry を開く",
221222
"pageLead": "Web UI は JSON registry を読み込みます。YAML はメンテナーのレビューとデバイスツール向けに保持します。",
222223
"pageTitle": "Registry データソース",

site/i18n/zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
"apps": "应用数量",
218218
"eyebrow": "REGISTRY FILES",
219219
"files": "静态文件",
220+
"loaded": "页面加载",
220221
"open": "查看 registry",
221222
"pageLead": "Web UI 使用 JSON registry;YAML 文件供维护者 review 和真机工具链对接。",
222223
"pageTitle": "Registry 数据源",

0 commit comments

Comments
 (0)