The homepage now renders itself from the repository list: a live stat strip (repository count, language count, newest commit), a card grid for every public non-empty repository with its own description, language dot, last-commit age, latest release tag and links, plus client-side filter and sort, a language breakdown, and a single case-study link row. Nothing on the page is pinned to a fixed project set, so a repository added to publish-bot appears on next load.
102 lines
14 KiB
Python
102 lines
14 KiB
Python
"""Generate the public portfolio and its Gitea homepage from reviewed content.
|
|
|
|
Standard library only. This tool never reads application profiles or credentials.
|
|
"""
|
|
from pathlib import Path
|
|
import html
|
|
import json
|
|
import shutil
|
|
import textwrap
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
DATA = json.loads((ROOT / "content.json").read_text(encoding="utf-8"))
|
|
OUT = ROOT / "dist"
|
|
ASSETS = OUT / "assets" / "portfolio"
|
|
DEPLOY = ROOT / "deploy"
|
|
CASES = ROOT / "case-studies"
|
|
BASE = "/assets/portfolio"
|
|
REPO = "https://code.knickqueue.win/publish-bot/portfolio"
|
|
VERSION = "20261203-2"
|
|
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>'
|
|
def case_url(project): return f"{BASE}/case-studies/{project['id']}.html"
|
|
def link(url, label, css=""): return f'<a class="{css}" href="{esc(url)}">{esc(label)}</a>'
|
|
|
|
for folder in (ASSETS / "images", ASSETS / "diagrams", ASSETS / "case-studies", DEPLOY, CASES):
|
|
folder.mkdir(parents=True, exist_ok=True)
|
|
for file in ("portfolio.css", "portfolio.js", "showcase.css", "showcase.js"):
|
|
shutil.copy2(ROOT / "site" / file, ASSETS / file)
|
|
for file in (ROOT / "assets" / "images").glob("*"):
|
|
shutil.copy2(file, ASSETS / "images" / file.name)
|
|
|
|
DIAGRAMS = {
|
|
"centra-tab": ("Encrypted cross-device clipboard", ["Desktop / Android", "Encrypted outbox", "Private hub", "Peer history"], ["Capture locally", "Persist through outages", "Store ciphertext", "Reconcile generations"], "Workspace keys stay on clients · stable identity through recovery"),
|
|
"repo-relay": ("Reviewed publication boundary", ["Private snapshot", "Immutable review", "Public commit", "Verified release"], ["Pinned source revision", "Profile + file hashes", "Separate public history", "Anonymous clone + hashes"], "Approval expires when bytes or policy change · durable worker state"),
|
|
"remoraid": ("Session-bound actions and response receipts", ["Authenticated client", "Session / relay", "Target action", "Result journal"], ["Request identity", "Lease + capability checks", "Fresh foreground / screen", "Persist before delivery"], "Lost delivery ≠ permission to repeat a mutation"),
|
|
"nfcauth": ("Windows authentication and recovery boundaries", ["Signed authority", "SYSTEM service", "Credential provider", "User companion"], ["Issue approved grants", "Validate local policy", "Windows sign-in boundary", "Interactive session status"], "Protected local communication · SCM and companion supervision")
|
|
}
|
|
def diagram(key):
|
|
title, names, detail, note = DIAGRAMS[key]
|
|
blocks = []
|
|
for i, (name, sub) in enumerate(zip(names, detail)):
|
|
x,y = [(25,90),(320,90),(320,205),(25,205)][i]
|
|
blocks.append(f'<rect x="{x}" y="{y}" width="255" height="95" rx="7" fill="#1a2b36" stroke="#55717d"/><text x="{x+15}" y="{y+23}" fill="#9ae4f0" font-size="12">0{i+1}</text><text x="{x+15}" y="{y+51}" fill="#edf4f8" font-size="18">{esc(name)}</text><text x="{x+15}" y="{y+76}" fill="#a2b1bc" font-size="13">{esc(sub)}</text>')
|
|
arrows='<path d="M286 137h25m-6-6 6 6-6 6M447 191v8m-5-5 5 5 5-5M311 252h-25m6-6-6 6 6 6" stroke="#9ae4f0" stroke-width="2" fill="none"/>'
|
|
note_lines=''.join(f'<text x="25" y="{328+i*18}" fill="#a2b1bc" font-size="12">{esc(line)}</text>' for i,line in enumerate(textwrap.wrap(note,width=83)))
|
|
return f'<svg xmlns="http://www.w3.org/2000/svg" width="600" height="365" viewBox="0 0 600 365" role="img" aria-labelledby="title desc"><title id="title">{esc(title)}</title><desc id="desc">{esc(" → ".join(names)+". "+note)}</desc><rect width="600" height="365" fill="#13202a"/><g font-family="Segoe UI,Arial,sans-serif"><text x="25" y="31" fill="#9ae4f0" font-size="10" letter-spacing="2">SYSTEM OVERVIEW</text><text x="25" y="61" fill="#edf4f8" font-size="20">{esc(title)}</text>{"".join(blocks)}{arrows}{note_lines}</g></svg>'
|
|
for project in DATA["projects"]:
|
|
(ASSETS / "diagrams" / project["diagram"]).write_text(diagram(project["id"]), encoding="utf-8", newline="\n")
|
|
|
|
def masthead(home=False):
|
|
prefix = "" if home else "/"
|
|
return f'''<div class="wrap"><header class="masthead"><a class="identity" href="/" aria-label="Nicholas Quandt home"><span class="monogram" aria-hidden="true">NQ</span><span><strong>Nicholas Quandt</strong><small>Software & systems engineering</small></span></a><nav aria-label="Site"><a href="{prefix}#repos">Repositories</a><a href="{prefix}#languages">Languages</a><a href="{prefix}#case-studies">Case studies</a><a class="nav-contact" href="mailto:{DATA['email']}">Get in touch ↗</a></nav></header></div>'''
|
|
def footer():
|
|
return f'''<div class="wrap"><footer><span>© 2026 Nicholas Quandt · Built and operated on my own infrastructure.</span><span>{link(REPO,'Portfolio source')} · {link(DATA['github'],'GitHub')} · {link(DATA['linkedin'],'LinkedIn')}</span></footer></div>'''
|
|
def document(title, description, body, canonical):
|
|
return f'''<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>{esc(title)} · Nicholas Quandt</title><meta name="description" content="{esc(description)}"><meta name="author" content="Nicholas Quandt"><link rel="canonical" href="{esc(canonical)}"><meta property="og:title" content="{esc(title)} · Nicholas Quandt"><meta property="og:description" content="{esc(description)}"><meta property="og:type" content="website"><meta property="og:url" content="{esc(canonical)}"><meta property="og:image" content="https://code.knickqueue.win{BASE}/images/social.png"><meta name="twitter:card" content="summary_large_image"><link rel="icon" href="{BASE}/images/mark.svg" type="image/svg+xml"><link rel="stylesheet" href="{BASE}/portfolio.css?v={VERSION}"><script src="{BASE}/portfolio.js?v={VERSION}" defer></script></head><body class="portfolio"><a class="skip" href="#main">Skip to content</a>{body}</body></html>'''
|
|
|
|
rows = []
|
|
for i, project in enumerate(DATA["projects"], 1):
|
|
rows.append(f'''<article class="project-row"><span class="project-number">0{i}</span><div><p class="project-category">{esc(project['category'])}</p><h3>{link(case_url(project),project['name'])}</h3><p class="project-headline">{esc(project['headline'])}</p><p class="project-description">{esc(project['summary'])}</p><span class="status-tag">{esc(project['status'])}</span>{tags(project['technologies'])}{link(case_url(project),'Read the case study →','project-link')}</div><a class="diagram-frame" href="{case_url(project)}" aria-label="Read the {esc(project['name'])} case study"><img src="{BASE}/diagrams/{project['diagram']}" alt="{esc(DIAGRAMS[project['id']][0])}" width="600" height="365" loading="lazy"></a></article>''')
|
|
tools = ''.join(f'''<article class="tool"><h3>{esc(item['name'])}</h3><span class="status-tag">{esc(item['status'])}</span><p>{esc(item['description'])}</p><span class="tagline">{esc(item['tag'])}</span>{link(item['url'],'Source & releases ↗','project-link')}</article>''' for item in DATA['tools'])
|
|
lab = ''.join(f'''<article class="lab"><h3>{esc(item['name'])}</h3><span class="status-tag">{esc(item['status'])}</span><p>{esc(item['description'])}</p>{link(item['url'],'Explore the source ↗','project-link') if item.get('url') else ''}</article>''' for item in DATA['lab'])
|
|
case_links = ''.join(f'<a href="/assets/portfolio/case-studies/{esc(p["id"])}.html">{esc(p["name"])}<span>{esc(p["category"])}</span></a>' for p in DATA["projects"])
|
|
HOME = ((ROOT / "site" / "home.html").read_text(encoding="utf-8")
|
|
.replace("{{MASTHEAD}}", masthead(True))
|
|
.replace("{{FOOTER}}", footer())
|
|
.replace("{{CASE_LINKS}}", case_links)
|
|
.replace("{{EMAIL}}", esc(DATA["email"])))
|
|
(OUT / "index.html").write_text(document("Software & systems engineering", "Nicholas Quandt's selected software and systems work: encrypted desktop sync, release infrastructure, device control and Windows authentication.", HOME, "https://code.knickqueue.win/"), encoding="utf-8", newline="\n")
|
|
(DEPLOY / "home.tmpl").write_text(
|
|
'{{template "base/head" .}}\n'
|
|
'<link rel="stylesheet" href="' + BASE + '/portfolio.css?v=' + VERSION + '">\n'
|
|
'<link rel="stylesheet" href="' + BASE + '/showcase.css?v=' + VERSION + '">\n'
|
|
'<div class="portfolio"><a class="skip" href="#main">Skip to repository content</a>' + HOME + '</div>\n'
|
|
'<script src="' + BASE + '/showcase.js?v=' + VERSION + '" defer></script>\n'
|
|
'{{template "base/footer" .}}\n',
|
|
encoding="utf-8", newline="\n")
|
|
|
|
def markdown(project):
|
|
text = f"# {project['name']}\n\n**{project['headline']}**\n\n{project['summary']}\n\nStatus: {project['status']}. Evidence reviewed {DATA['reviewed']}.\n\n[Read the illustrated case study](https://code.knickqueue.win{case_url(project)})\n\n## My contribution\n\n{project['contribution']}\n\n## The problem\n\n" + '\n\n'.join(project['problem']) + '\n\n## Engineering decisions\n\n'
|
|
for decision in project['decisions']: text += f"### {decision['title']}\n\n{decision['text']}\n\n"
|
|
text += f"## A failure that shaped the design\n\n{project['failure']}\n\n## Evidence and scope\n\n"
|
|
for evidence in project['evidence']: text += f"- **{evidence['label']}:** {evidence['result']} Scope: {evidence['scope']}\n"
|
|
text += '\nThese are reviewed recorded results, unless explicitly described as current public-access verification. Application tests and physical-device checks were not rerun for this portfolio.\n\n## Remaining limits\n\n' + '\n'.join('- '+item for item in project['limits']) + '\n\n## Evidence references\n\n' + '\n'.join('- '+item for item in project['references']) + f"\n\nRevision: `{project['revision']}`\n\n{project['sourceStatus']}\n"
|
|
for item in project['links']: text += f"\n[{item['label']}]({item['url']})\n"
|
|
return text
|
|
|
|
for index, project in enumerate(DATA['projects']):
|
|
sections = ['problem','contribution','decisions','failure','evidence','walkthrough','limits','references']
|
|
labels = ['The problem','My contribution','Engineering decisions','A useful failure','Evidence','Recovery walkthrough','Remaining limits','References']
|
|
toc = ''.join(f'<a href="#{key}">{label}</a>' for key,label in zip(sections,labels))
|
|
evidence = ''.join(f'<tr><td><strong>{esc(item["label"])}</strong></td><td>{esc(item["result"])}</td><td>{esc(item["scope"])}</td></tr>' for item in project['evidence'])
|
|
decisions = ''.join(f'<h3>{esc(item["title"])}</h3><p>{esc(item["text"])}</p>' for item in project['decisions'])
|
|
walkthrough = ''.join(f'<li><span class="step-number">0{i+1}</span><h3>{esc(item["title"])}</h3><p>{esc(item["text"])}</p></li>' for i,item in enumerate(project['walkthrough']))
|
|
next_project = DATA['projects'][(index+1)%len(DATA['projects'])]
|
|
body = f'''{masthead()}<main id="main" class="wrap"><header class="case-hero"><p class="breadcrumb">{link('/#work','Selected work')} / {esc(project['name'])}</p><p class="eyebrow">{esc(project['category'])}</p><h1>{esc(project['headline'])}</h1><p class="intro">{esc(project['summary'])}</p><div class="case-meta"><span>{esc(project['status'])}</span><span>Evidence reviewed {DATA['reviewed']}</span></div>{tags(project['technologies'])}</header><div class="case-overview diagram-frame"><img src="{BASE}/diagrams/{project['diagram']}" width="600" height="365" alt="{esc(DIAGRAMS[project['id']][0])}"></div><div class="case-layout"><nav class="case-toc" aria-label="Case study sections">{toc}</nav><article class="article"><section id="problem"><h2>The problem</h2>{paragraphs(project['problem'])}</section><section id="contribution"><h2>My contribution</h2><p>{esc(project['contribution'])}</p></section><section id="decisions"><h2>Engineering decisions</h2>{decisions}</section><section id="failure"><h2>A failure that shaped the design</h2><p>{esc(project['failure'])}</p></section><section id="evidence"><h2>Evidence and scope</h2><p class="scope-note">These are reviewed recorded results unless explicitly described as current public-access verification. Application tests and physical-device checks were not rerun for this portfolio.</p><table class="evidence-table"><thead><tr><th>Check</th><th>Recorded result</th><th>Conditions & limits</th></tr></thead><tbody>{evidence}</tbody></table></section><section id="walkthrough"><h2>Walk through the recovery path</h2><p class="scope-note">An illustrated explanation of the design. This is not a live application or a recording of a device trial.</p><div data-walkthrough><ol class="walkthrough">{walkthrough}</ol><button class="button" type="button" hidden>Start walkthrough →</button><div class="walk-status" role="status" aria-live="polite"></div></div></section><section id="limits"><h2>Remaining limits</h2><ul>{''.join('<li>'+esc(item)+'</li>' for item in project['limits'])}</ul></section><section id="references"><h2>Evidence references</h2><p class="scope-note">These filenames identify the source and acceptance records used to prepare this write-up. Private application files are not published as part of the portfolio.</p><ul class="references">{''.join('<li>'+esc(item)+'</li>' for item in project['references'])}</ul><p class="project-revision">Revision: {esc(project['revision'])}</p><p class="source-note">{esc(project['sourceStatus'])}</p><div class="actions">{''.join(link(item['url'],item['label']+' ↗','button') for item in project['links'])}{link(REPO+'/src/branch/main/case-studies/'+project['id']+'.md','Markdown version ↗','text-link')}</div></section><div class="case-end">{link('/#work','← All selected work')}{link(case_url(next_project),'Next: '+next_project['name']+' →')}</div></article></div></main>{footer()}'''
|
|
(ASSETS / "case-studies" / (project['id']+'.html')).write_text(document(project['name'],project['summary'],body,'https://code.knickqueue.win'+case_url(project)),encoding="utf-8",newline="\n")
|
|
(CASES / (project['id']+'.md')).write_text(markdown(project),encoding="utf-8",newline="\n")
|
|
|
|
print(f"Built homepage, {len(DATA['projects'])} case studies and {len(DIAGRAMS)} diagrams in {OUT}")
|