Files
anonymous_github/public/script/template-state.js
T
Thomas DurieuxandClaude Opus 5.5 579ce970c7 feat(ui): redesign the viewer, landing, author and admin screens
Viewer: full-height app bar with a Help menu, search + ZIP sidebar, one
toolbar for README and code, reading mode with a scroll-tracking outline,
docked find for Markdown and code, and redaction slots (a blank stone slot
holding the term number) in prose, headings, code, the tree and the path.

Landing and FAQ: live redaction demo, serif display headings, teal accent.

Author screens: My work table with copy/open/edit actions, a usage meter,
a single-container New anonymization flow with a sticky submit bar, themed
form controls, and consistent GitHub connection cards.

Admin: underline tabs, severity-first errors chart and list, error tiles
that filter (older pages load until matches appear), queue and overview
health states, and shared toolbar heights and borders.

Fixes: guarded localStorage access, failed README images render a
placeholder, phone hover states no longer stick, and UI tests updated for
the new copy and markup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:52:10 +00:00

64 lines
3.2 KiB
JavaScript

import { computed } from "vue";
// Local state formerly initialized by templates; list aliases are computed.
export function initializeTemplate(name, state) {
if (name === "partials/explorer.htm") {
state.sidebarCollapsed = window.matchMedia?.("(max-width: 767px)").matches || false;
state.sidebarHidden = false;
state.dirExpanded = false;
state.moreOpen = false;
state.mdFindOpen = false;
state.mdFindQuery = "";
state.mdFindTotal = 0;
state.mdFindIndex = 0;
state.mdFindCase = false;
state.accountOpen = false;
state.helpOpen = false;
state.sidebarWidth = Math.min(520, Math.max(220, Number(localStorage.getItem("sidebarWidth")) || 280));
// Shared with the app bar so the brand column lines up with the file tree.
document.documentElement.style.setProperty("--sidebar-w", state.sidebarWidth + "px");
state.startSidebarResize = (event) => {
event.preventDefault();
const startX = event.clientX;
const startWidth = state.sidebarWidth;
const move = (e) => {
state.sidebarWidth = Math.min(520, Math.max(220, startWidth + e.clientX - startX));
document.documentElement.style.setProperty("--sidebar-w", state.sidebarWidth + "px");
};
const up = () => {
window.removeEventListener("pointermove", move);
window.removeEventListener("pointerup", up);
document.body.classList.remove("is-resizing");
localStorage.setItem("sidebarWidth", String(state.sidebarWidth));
};
document.body.classList.add("is-resizing");
window.addEventListener("pointermove", move);
window.addEventListener("pointerup", up);
};
}
if (name === "partials/anonymize.htm") {
state.prTabState = { active: state.options.diff ? "diff" : "comments" };
state.watchGroup(["options.diff", "options.comments"], () => {
if (!state.options[state.prTabState.active]) state.prTabState.active = state.options.diff ? "diff" : state.options.comments ? "comments" : null;
});
}
if (name === "partials/gist.htm") state.tabState = { active: state.details?.files ? "files" : "comments" };
if (["partials/conferences.htm", "partials/conference.htm"].includes(name)) {
state.statusLabels = { ready: "Ready", expired: "Expired", removed: "Removed" };
}
const lists = {
"partials/dashboard.htm": ["filteredItems", () => state.items, "itemFilter"],
"partials/conferences.htm": ["filteredConferences", () => state.conferences, "conferenceFilter"],
"partials/conference.htm": ["filteredRepositories", () => state.conference?.repositories, "repoFiler"],
"partials/admin/repositories.htm": ["filteredRepositories", () => state.repositories, "repoFiler"],
"partials/admin/user.htm": ["filteredRepositories", () => state.repositories, "repoFiler"],
"partials/admin/users.htm": ["filteredUsers", () => state.users, "userFiler"],
"partials/admin/conferences.htm": ["filteredConferences", () => state.conferences],
};
const list = lists[name];
if (list) {
const value = computed(() => state.fmt.orderBy(state.fmt.filter(list[1](), state[list[2]]), state.orderBy));
Object.defineProperty(state, list[0], { configurable: true, get: () => value.value });
}
}