Render every active public repository in the public code list
The homepage list was pinned to four repository names, so a project published to publish-bot after the last build never appeared. The list is now rebuilt at page load from the public API: every non-private, non-empty, non-archived repo in updated order, with language and last-updated date. The static anchors stay as the no-JavaScript fallback.
This commit is contained in:
+2
-2
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+40
-22
@@ -15,33 +15,51 @@
|
||||
});
|
||||
const list = document.querySelector("[data-public-source]");
|
||||
if (!list) return;
|
||||
// The featured projects and source links are already HTML. This is optional enrichment.
|
||||
// The static links in the homepage are the no-JavaScript fallback. When the public API
|
||||
// answers, the list is rebuilt from the repository list itself, so a project published to
|
||||
// publish-bot appears here on the next page load with no rebuild or deploy.
|
||||
const LABELS = { portfolio: "Portfolio source", "ats-native-fsd": "ATS native simulator controller" };
|
||||
const PAGE = 50, MAX_PAGES = 4;
|
||||
const sameOriginUrl = value => {
|
||||
try { const url = new URL(value, location.origin); return url.origin === location.origin && url.protocol === "https:" ? url.href : null; }
|
||||
catch { return null; }
|
||||
};
|
||||
const stamp = value => {
|
||||
const date = new Date(value);
|
||||
return Number.isNaN(date.valueOf()) ? "" : date.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
|
||||
};
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 8000);
|
||||
fetch("/api/v1/users/publish-bot/repos?limit=50&sort=updated", {credentials:"omit",headers:{Accept:"application/json"},signal:controller.signal})
|
||||
.then(response => { if (!response.ok) throw new Error("Public listing unavailable"); return response.json(); })
|
||||
.then(repos => {
|
||||
if (!Array.isArray(repos)) return;
|
||||
const known = new Set([...list.querySelectorAll("a")].map(a => a.dataset.repo));
|
||||
const featured = new Set(["portfolio", "UniClik", "WindowsVolumeSteps", "ats-native-fsd"]);
|
||||
for (const repo of repos) {
|
||||
if (repo.private !== false || repo.empty || !featured.has(repo.name) || known.has(repo.name)) continue;
|
||||
const url = sameOriginUrl(repo.html_url);
|
||||
if (!url) continue;
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.dataset.repo = repo.name;
|
||||
link.append(document.createTextNode(repo.name));
|
||||
const meta = document.createElement("span");
|
||||
meta.textContent = repo.language || "Public repository";
|
||||
link.append(meta);
|
||||
list.append(link);
|
||||
}
|
||||
})
|
||||
.catch(() => { /* Existing source links remain useful when the API is unavailable. */ })
|
||||
const fetchPage = page => fetch(`/api/v1/users/publish-bot/repos?limit=${PAGE}&page=${page}&sort=updated`, { credentials: "omit", headers: { Accept: "application/json" }, signal: controller.signal })
|
||||
.then(response => { if (!response.ok) throw new Error("Public listing unavailable"); return response.json(); });
|
||||
(async () => {
|
||||
const repos = [];
|
||||
for (let page = 1; page <= MAX_PAGES; page++) {
|
||||
const batch = await fetchPage(page);
|
||||
if (!Array.isArray(batch) || batch.length === 0) break;
|
||||
repos.push(...batch);
|
||||
if (batch.length < PAGE) break;
|
||||
}
|
||||
const active = repos
|
||||
.filter(repo => repo.private === false && !repo.empty && !repo.archived)
|
||||
.sort((a, b) => String(b.updated_at).localeCompare(String(a.updated_at)));
|
||||
if (!active.length) return;
|
||||
const rows = document.createDocumentFragment();
|
||||
for (const repo of active) {
|
||||
const url = sameOriginUrl(repo.html_url);
|
||||
if (!url) continue;
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.dataset.repo = repo.name;
|
||||
if (repo.description) link.title = repo.description;
|
||||
link.append(document.createTextNode(LABELS[repo.name] || repo.name));
|
||||
const meta = document.createElement("span");
|
||||
const updated = stamp(repo.updated_at);
|
||||
meta.textContent = [repo.language || "Public repository", updated && `updated ${updated}`].filter(Boolean).join(" · ");
|
||||
link.append(meta);
|
||||
rows.append(link);
|
||||
}
|
||||
if (rows.childElementCount) list.replaceChildren(rows);
|
||||
})().catch(() => { /* Existing source links remain useful when the API is unavailable. */ })
|
||||
.finally(() => clearTimeout(timeout));
|
||||
})();
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+40
-22
@@ -15,33 +15,51 @@
|
||||
});
|
||||
const list = document.querySelector("[data-public-source]");
|
||||
if (!list) return;
|
||||
// The featured projects and source links are already HTML. This is optional enrichment.
|
||||
// The static links in the homepage are the no-JavaScript fallback. When the public API
|
||||
// answers, the list is rebuilt from the repository list itself, so a project published to
|
||||
// publish-bot appears here on the next page load with no rebuild or deploy.
|
||||
const LABELS = { portfolio: "Portfolio source", "ats-native-fsd": "ATS native simulator controller" };
|
||||
const PAGE = 50, MAX_PAGES = 4;
|
||||
const sameOriginUrl = value => {
|
||||
try { const url = new URL(value, location.origin); return url.origin === location.origin && url.protocol === "https:" ? url.href : null; }
|
||||
catch { return null; }
|
||||
};
|
||||
const stamp = value => {
|
||||
const date = new Date(value);
|
||||
return Number.isNaN(date.valueOf()) ? "" : date.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
|
||||
};
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 8000);
|
||||
fetch("/api/v1/users/publish-bot/repos?limit=50&sort=updated", {credentials:"omit",headers:{Accept:"application/json"},signal:controller.signal})
|
||||
.then(response => { if (!response.ok) throw new Error("Public listing unavailable"); return response.json(); })
|
||||
.then(repos => {
|
||||
if (!Array.isArray(repos)) return;
|
||||
const known = new Set([...list.querySelectorAll("a")].map(a => a.dataset.repo));
|
||||
const featured = new Set(["portfolio", "UniClik", "WindowsVolumeSteps", "ats-native-fsd"]);
|
||||
for (const repo of repos) {
|
||||
if (repo.private !== false || repo.empty || !featured.has(repo.name) || known.has(repo.name)) continue;
|
||||
const url = sameOriginUrl(repo.html_url);
|
||||
if (!url) continue;
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.dataset.repo = repo.name;
|
||||
link.append(document.createTextNode(repo.name));
|
||||
const meta = document.createElement("span");
|
||||
meta.textContent = repo.language || "Public repository";
|
||||
link.append(meta);
|
||||
list.append(link);
|
||||
}
|
||||
})
|
||||
.catch(() => { /* Existing source links remain useful when the API is unavailable. */ })
|
||||
const fetchPage = page => fetch(`/api/v1/users/publish-bot/repos?limit=${PAGE}&page=${page}&sort=updated`, { credentials: "omit", headers: { Accept: "application/json" }, signal: controller.signal })
|
||||
.then(response => { if (!response.ok) throw new Error("Public listing unavailable"); return response.json(); });
|
||||
(async () => {
|
||||
const repos = [];
|
||||
for (let page = 1; page <= MAX_PAGES; page++) {
|
||||
const batch = await fetchPage(page);
|
||||
if (!Array.isArray(batch) || batch.length === 0) break;
|
||||
repos.push(...batch);
|
||||
if (batch.length < PAGE) break;
|
||||
}
|
||||
const active = repos
|
||||
.filter(repo => repo.private === false && !repo.empty && !repo.archived)
|
||||
.sort((a, b) => String(b.updated_at).localeCompare(String(a.updated_at)));
|
||||
if (!active.length) return;
|
||||
const rows = document.createDocumentFragment();
|
||||
for (const repo of active) {
|
||||
const url = sameOriginUrl(repo.html_url);
|
||||
if (!url) continue;
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.dataset.repo = repo.name;
|
||||
if (repo.description) link.title = repo.description;
|
||||
link.append(document.createTextNode(LABELS[repo.name] || repo.name));
|
||||
const meta = document.createElement("span");
|
||||
const updated = stamp(repo.updated_at);
|
||||
meta.textContent = [repo.language || "Public repository", updated && `updated ${updated}`].filter(Boolean).join(" · ");
|
||||
link.append(meta);
|
||||
rows.append(link);
|
||||
}
|
||||
if (rows.childElementCount) list.replaceChildren(rows);
|
||||
})().catch(() => { /* Existing source links remain useful when the API is unavailable. */ })
|
||||
.finally(() => clearTimeout(timeout));
|
||||
})();
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ DEPLOY = ROOT / "deploy"
|
||||
CASES = ROOT / "case-studies"
|
||||
BASE = "/assets/portfolio"
|
||||
REPO = "https://code.knickqueue.win/publish-bot/portfolio"
|
||||
VERSION = "20261016-1"
|
||||
VERSION = "20261203-1"
|
||||
def esc(value): return html.escape(str(value), quote=True)
|
||||
def paragraphs(values): return "".join(f"<p>{esc(value)}</p>" for value in values)
|
||||
def tags(values): return '<div class="tags">' + ''.join(f'<span>{esc(value)}</span>' for value in values) + '</div>'
|
||||
|
||||
Reference in New Issue
Block a user