make handles bold.

This commit is contained in:
ed committed 2026-08-25 16:26:52 -04:00
1 parent f577242432
commit 69b87777e5
728 files changed
+3291 -3087

No files matched your search

+7
View File
@@ -78,6 +78,10 @@ BASE_RE: re.Pattern[str] = re.compile(
TITLE_LINK: re.Pattern[str] = re.compile(
r'(<h2[^>]*class="page-title"><a\s+href=")[^"]*(">)'
)
SCRIPT_TAG: str = (
'<script src="/static/threadwell-reader.js" defer></script>'
)
BODY_CLOSE: re.Pattern[str] = re.compile(r"</body>", re.IGNORECASE)
# --- SPA click-handler patch ----------------------------------------------
@@ -200,6 +204,9 @@ def rewrite_html(path: Path) -> str | None:
if out2 != out:
out = out2
actions.append("title")
if SCRIPT_TAG not in out and BODY_CLOSE.search(out):
out = BODY_CLOSE.sub(SCRIPT_TAG + "\n</body>", out, count=1)
actions.append("script")
if out != text:
path.write_text(out, encoding="utf-8")
+53 -2
View File
@@ -2,9 +2,60 @@
.page > #quartz-body {
@media all and ($desktop) {
grid-template-columns: 420px auto 280px;
grid-template-columns: 260px minmax(0, 1fr) 220px;
}
@media all and ($tablet) {
grid-template-columns: 420px auto;
grid-template-columns: 260px minmax(0, 1fr);
}
}
body.threadwell-wide .page > #quartz-body {
@media all and ($desktop) {
grid-template-columns: 0 minmax(0, 1fr) 0;
}
@media all and ($tablet) {
grid-template-columns: 0 minmax(0, 1fr);
}
}
body.threadwell-wide .page > #quartz-body > .left,
body.threadwell-wide .page > #quartz-body > .right {
display: none;
}
article img {
cursor: zoom-in;
max-width: 100%;
height: auto;
}
.threadwell-wide-btn {
position: fixed;
right: 1rem;
bottom: 1rem;
z-index: 40;
padding: 0.4rem 0.7rem;
border: 1px solid var(--gray);
border-radius: 6px;
background: var(--light);
color: var(--dark);
cursor: pointer;
}
.threadwell-zoom {
position: fixed;
inset: 0;
z-index: 80;
display: flex;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.88);
cursor: zoom-out;
}
.threadwell-zoom img {
max-width: 96vw;
max-height: 96vh;
object-fit: contain;
cursor: zoom-out;
}
+5
View File
@@ -8,6 +8,11 @@ if (-not (Test-Path -LiteralPath (Join-Path $site ".git"))) {
Copy-Item -LiteralPath $config -Destination (Join-Path $site "quartz.config.yaml") -Force
Copy-Item -LiteralPath (Join-Path $PSScriptRoot "quartz.custom.scss") -Destination (Join-Path $site "quartz\styles\custom.scss") -Force
$static = Join-Path $site "quartz\static"
if (-not (Test-Path -LiteralPath $static)) {
New-Item -ItemType Directory -Path $static | Out-Null
}
Copy-Item -LiteralPath (Join-Path $PSScriptRoot "threadwell-reader.js") -Destination (Join-Path $static "threadwell-reader.js") -Force
Set-Location -LiteralPath $site
npm ci
npx quartz plugin install --from-config
+86
View File
@@ -0,0 +1,86 @@
(() => {
const WIDE_KEY = "threadwell-wide";
function articleRoot() {
return document.querySelector("article");
}
function setWide(on) {
document.body.classList.toggle("threadwell-wide", on);
try {
localStorage.setItem(WIDE_KEY, on ? "1" : "0");
} catch (_err) {
/* ignore */
}
const btn = document.getElementById("threadwell-wide");
if (btn) {
btn.setAttribute("aria-pressed", on ? "true" : "false");
btn.textContent = on ? "Narrow" : "Wide";
}
}
function addWideButton() {
if (document.getElementById("threadwell-wide")) {
return;
}
const btn = document.createElement("button");
btn.id = "threadwell-wide";
btn.type = "button";
btn.className = "threadwell-wide-btn";
btn.textContent = "Wide";
btn.addEventListener("click", () => {
setWide(!document.body.classList.contains("threadwell-wide"));
});
document.body.appendChild(btn);
try {
if (localStorage.getItem(WIDE_KEY) === "1") {
setWide(true);
}
} catch (_err) {
/* ignore */
}
}
function closeZoom() {
const overlay = document.getElementById("threadwell-zoom");
if (overlay) {
overlay.remove();
}
}
function openZoom(src) {
closeZoom();
const overlay = document.createElement("div");
overlay.id = "threadwell-zoom";
overlay.className = "threadwell-zoom";
const img = document.createElement("img");
img.src = src;
img.alt = "";
overlay.appendChild(img);
overlay.addEventListener("click", closeZoom);
document.body.appendChild(overlay);
}
function onArticleClick(event) {
const target = event.target;
if (!(target instanceof HTMLImageElement)) {
return;
}
if (!articleRoot() || !articleRoot().contains(target)) {
return;
}
if (target.closest("#threadwell-zoom")) {
return;
}
event.preventDefault();
openZoom(target.currentSrc || target.src);
}
document.addEventListener("keydown", (event) => {
if (event.key === "Escape") {
closeZoom();
}
});
document.addEventListener("click", onArticleClick);
addWideButton();
})();