website-xp-phone 2.3.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/blogDirsPlugin.ts +100 -0
- package/package.json +15 -8
- package/public/blog/archive/eighth-post-lost-in-the-sauce.json +36 -0
- package/public/blog/archive/noise/eleventh-post-discussion-java-gist.md +5 -0
- package/public/blog/archive/noise/fifteenth-post-very-rare-windows-funny.md +8 -0
- package/public/blog/archive/noise/fourth-post-meta-blog.md +3 -0
- package/public/blog/archive/noise/sixteenth-post-meta-fantasy-blog.md +4 -0
- package/public/blog/archive/noise/tenth-post-meta-funny-redacted-and-timetravelled.md +3 -0
- package/public/blog/archive/noise/twelfth-post-mixing-phase-technique-audio-music.md +48 -0
- package/public/blog/archive/noise/welcome-back-ramble-meta.md +6 -0
- package/public/blog/archive/noise/welcome-to-my-blog-meta-blog-welcome-to-my-website.md +7 -0
- package/public/blog/archive/seventh-post-lie-theory-na2000.json +22 -0
- package/public/blog/archive/sophus-lie.json +36 -0
- package/public/blog/hlwm_and_herbstutil.md +74 -0
- package/public/blog/writing/hot-action-under-a-cold-moon.json +9 -0
- package/public/checksums.txt +90 -67
- package/public/documents/drift-report.json +13 -1
- package/scripts/refresh-soundcloud.mjs +54 -8
- package/sonar-project.properties +12 -0
- package/src/content/addons.json +2 -2
- package/src/content/blog.json +17 -365
- package/src/content/blogDirs.ts +197 -0
- package/src/content/configs.json +5 -3
- package/src/content/contacts.json +7 -5
- package/src/content/index.ts +155 -57
- package/src/content/music-ext.json +1 -1
- package/src/content/pages.json +2 -1
- package/src/content/projects/development.json +2 -2
- package/src/content/projects/doftiles.json +63 -7
- package/src/content/projects/frontend.json +2 -2
- package/src/content/projects/graphbrowser.json +2 -2
- package/src/content/projects/herbctl.json +213 -0
- package/src/content/projects/herbstutil.json +66 -36
- package/src/content/projects/lightdni-jssas-toggle.json +2 -2
- package/src/content/projects/on-deploy.json +67 -0
- package/src/content/projects/pagerts.json +4 -4
- package/src/content/projects/polyframes.json +83 -0
- package/src/content/projects/rarebert.json +2 -2
- package/src/content/projects/webuser.json +2 -2
- package/src/content/schema.ts +7 -4
- package/src/content/sections.json +20 -13
- package/src/content/soundcloud.json +61 -13
- package/src/lib/clippy.ts +29 -8
- package/src/lib/history.ts +152 -0
- package/src/lib/markdown.tsx +11 -1
- package/src/lib/scrollTo.ts +45 -0
- package/src/lib/signals.tsx +271 -0
- package/src/lib/slashes.ts +20 -0
- package/src/lib/tabNav.ts +192 -0
- package/src/main.tsx +20 -4
- package/src/pages/BlogDirPage.tsx +37 -0
- package/src/pages/BlogPostPage.tsx +78 -3
- package/src/pages/ProjectPage.tsx +9 -3
- package/src/pages/WowPage.tsx +8 -3
- package/src/pages/index.ts +2 -0
- package/src/shell/App.tsx +19 -8
- package/src/shell/Clippy.tsx +13 -3
- package/src/shell/MenuBar.tsx +7 -4
- package/src/shell/resolveRoute.ts +43 -3
- package/src/shell/routerSignals.ts +34 -0
- package/src/styles/extras.css +20 -0
- package/src/styles/layout.css +2 -3
- package/src/styles/menu.css +1 -1
- package/src/styles/window.css +20 -8
- package/src/themes/pageSlide/index.ts +120 -42
- package/src/themes/pageSlide/pageSlide.css +20 -9
- package/src/virtual.d.ts +14 -0
- package/src/window/MaximizedWindow.tsx +100 -64
- package/src/window/OkButton.tsx +42 -25
- package/src/window/PageWindows.tsx +7 -0
- package/src/window/TitleBar.tsx +3 -1
- package/src/window/Window.tsx +132 -87
- package/src/window/closeSounds.ts +27 -0
- package/src/window/model.ts +11 -0
- package/src/window/state.tsx +301 -54
- package/src/window/themes.ts +23 -2
- package/test/content.test.js +15 -10
- package/test/deploy-pipeline.test.js +11 -11
- package/test/markdown-tables.test.js +96 -0
- package/test/soundcloud-refresh.test.js +68 -0
- package/test/tabNav.test.js +137 -0
- package/tsconfig.node.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.config.ts +7 -1
- package/xp.css/dist/98.css +2 -0
- package/xp.css/dist/98.css.map +1 -0
- package/xp.css/dist/GUI.css +2 -0
- package/xp.css/dist/GUI.css.map +1 -0
- package/xp.css/dist/XP.css +2 -0
- package/xp.css/dist/XP.css.map +1 -0
- package/xp.css/dist/fonts/converted/PerfectDOSVGA437Win.woff +0 -0
- package/xp.css/dist/fonts/converted/PerfectDOSVGA437Win.woff2 +0 -0
- package/xp.css/dist/fonts/converted/ms_sans_serif.woff +0 -0
- package/xp.css/dist/fonts/converted/ms_sans_serif.woff2 +0 -0
- package/xp.css/dist/fonts/converted/ms_sans_serif_bold.woff +0 -0
- package/xp.css/dist/fonts/converted/ms_sans_serif_bold.woff2 +0 -0
- package/public/blog/4th.md +0 -28
- package/public/blog/wsl.1.md +0 -40
- package/src/window/hidden.ts +0 -22
- /package/public/blog/{ → archive/noise/}/321/200/321/203/320/275/320/270/321/201/321/207-/320/263/320/273/320/276/321/201/321/201/320/260/321/200/320/270/320/271.md" +0 -0
- /package/src/content/{characters.json → includes/characters.json} +0 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/** Tab navigation — the XP-window metaphor's keyboard traversal.
|
|
2
|
+
*
|
|
3
|
+
* Tab / Shift+Tab cycle:
|
|
4
|
+
* 1. the menu items (the menu bar first),
|
|
5
|
+
* 2. the visible buttons and links of the foreground — when a window
|
|
6
|
+
* is maximized, the cycle stays inside the maximized window's
|
|
7
|
+
* backdrop (the dimmed layer below it and the menu bar are out of
|
|
8
|
+
* reach: focus must not escape below it); otherwise it walks the
|
|
9
|
+
* page's windows.
|
|
10
|
+
* 3. window decorations (title-bar controls, the ride-out clones)
|
|
11
|
+
* are never traversed — the chrome is the mouse's business.
|
|
12
|
+
*
|
|
13
|
+
* The cycle is computed per keypress: the DOM changes under the
|
|
14
|
+
* keyboard (windows open, close, minimize, maximize), so no stale
|
|
15
|
+
* stop list is cached. Typing inside an input keeps the browser's
|
|
16
|
+
* native Tab behaviour.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** The window chrome: title-bar controls are decorations, not content. */
|
|
20
|
+
const isDecoration = (el: HTMLElement) =>
|
|
21
|
+
el.closest(".title-bar, .title-bar-controls") !== null;
|
|
22
|
+
|
|
23
|
+
/** True while the user types in a text field: native Tab belongs to it. */
|
|
24
|
+
export const isTypingTarget = (target: EventTarget | null) =>
|
|
25
|
+
target instanceof HTMLElement &&
|
|
26
|
+
(["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName) ||
|
|
27
|
+
target.isContentEditable);
|
|
28
|
+
|
|
29
|
+
/** A candidate is a tab stop when it is interactive AND visible. */
|
|
30
|
+
function isStop(el: HTMLElement): boolean {
|
|
31
|
+
const tag = el.tagName;
|
|
32
|
+
const interactive =
|
|
33
|
+
tag === "BUTTON" ||
|
|
34
|
+
tag === "A" ||
|
|
35
|
+
tag === "INPUT" ||
|
|
36
|
+
tag === "TEXTAREA" ||
|
|
37
|
+
tag === "SELECT" ||
|
|
38
|
+
(el.getAttribute("tabindex") !== null && el.tabIndex >= 0);
|
|
39
|
+
if (!interactive) return false;
|
|
40
|
+
const input = el as HTMLButtonElement;
|
|
41
|
+
if (input.disabled || input.getAttribute("aria-disabled") === "true")
|
|
42
|
+
return false;
|
|
43
|
+
const style = getComputedStyle(el);
|
|
44
|
+
if (style.display === "none" || style.visibility === "hidden") return false;
|
|
45
|
+
// getClientRects() is empty for display:none subtrees and detached
|
|
46
|
+
// elements; visibility-hidden reports rects, hence the style check above.
|
|
47
|
+
return el.getClientRects().length > 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The maximized windows currently on screen, topmost LAST (DOM order is
|
|
51
|
+
* the stacking order: each maximize pushes its backdrop after the
|
|
52
|
+
* previous ones). Empty when no window is maximized. */
|
|
53
|
+
const maximizedBackdrops = () =>
|
|
54
|
+
[
|
|
55
|
+
...document.querySelectorAll<HTMLElement>(
|
|
56
|
+
".maximized-backdrop[data-window-id]",
|
|
57
|
+
),
|
|
58
|
+
].filter((backdrop) => backdrop.getClientRects().length > 0);
|
|
59
|
+
|
|
60
|
+
/** The traversal scope: the topmost maximized window when one exists,
|
|
61
|
+
* the whole page otherwise. The menu bar is a separate stage BEFORE
|
|
62
|
+
* the page and is excluded from maximized scopes (a maximized window
|
|
63
|
+
* covers the menu — focus must not reach it). */
|
|
64
|
+
function scopes(): HTMLElement[] {
|
|
65
|
+
const backdrops = maximizedBackdrops();
|
|
66
|
+
if (backdrops.length > 0) {
|
|
67
|
+
const topmost = backdrops[backdrops.length - 1];
|
|
68
|
+
return topmost ? [topmost] : [];
|
|
69
|
+
}
|
|
70
|
+
const page = document.querySelector<HTMLElement>("main.page");
|
|
71
|
+
return page ? [page] : [];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** One full cycle: the menu items, then the foreground's stops — in
|
|
75
|
+
* DOM order. Decorations and hidden windows are filtered out. */
|
|
76
|
+
export function tabStops(): HTMLElement[] {
|
|
77
|
+
const menuItems = [
|
|
78
|
+
...document.querySelectorAll<HTMLElement>(".menu-bar a[role='menuitem']"),
|
|
79
|
+
].filter(isStop);
|
|
80
|
+
const menuItemsReachable = maximizedBackdrops().length === 0;
|
|
81
|
+
const stops: HTMLElement[] = [];
|
|
82
|
+
if (menuItemsReachable) stops.push(...menuItems);
|
|
83
|
+
for (const scope of scopes()) {
|
|
84
|
+
for (const el of scope.querySelectorAll<HTMLElement>(
|
|
85
|
+
"button, a, input, textarea, select, [tabindex]",
|
|
86
|
+
)) {
|
|
87
|
+
if (isDecoration(el) || !isStop(el)) continue;
|
|
88
|
+
stops.push(el);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return stops;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The section the cycle last traversed: Tab resumes from the TOP of
|
|
95
|
+
* this section instead of resetting to the menu bar. Set whenever a
|
|
96
|
+
* stop inside a .window is focused; cleared when the window is gone. */
|
|
97
|
+
let lastSection: HTMLElement | null = null;
|
|
98
|
+
|
|
99
|
+
/** The first stop inside a window subtree, or undefined. */
|
|
100
|
+
const firstStopInSection = (stops: HTMLElement[], section: HTMLElement) =>
|
|
101
|
+
stops.find((el) => el.closest(".window") === section);
|
|
102
|
+
|
|
103
|
+
/** The first stop positioned AT or AFTER the section's start (Tab's
|
|
104
|
+
* resume point), and the last stop before it (Shift+Tab's). The
|
|
105
|
+
* section itself may be collapsed (its OK just revealed it), so the
|
|
106
|
+
* boundary is a DOM-position comparison, not a membership test. */
|
|
107
|
+
const sectionBoundary = (
|
|
108
|
+
stops: HTMLElement[],
|
|
109
|
+
section: HTMLElement,
|
|
110
|
+
): { forward: HTMLElement | undefined; backward: HTMLElement | undefined } => {
|
|
111
|
+
const anchor = firstStopInSection(stops, section);
|
|
112
|
+
const start = anchor ?? section;
|
|
113
|
+
const forward =
|
|
114
|
+
anchor ??
|
|
115
|
+
stops.find(
|
|
116
|
+
(el) =>
|
|
117
|
+
(start.compareDocumentPosition(el) &
|
|
118
|
+
Node.DOCUMENT_POSITION_FOLLOWING) !==
|
|
119
|
+
0,
|
|
120
|
+
);
|
|
121
|
+
const backward = [...stops]
|
|
122
|
+
.reverse()
|
|
123
|
+
.find(
|
|
124
|
+
(el) =>
|
|
125
|
+
(start.compareDocumentPosition(el) &
|
|
126
|
+
Node.DOCUMENT_POSITION_FOLLOWING) !==
|
|
127
|
+
0,
|
|
128
|
+
);
|
|
129
|
+
return { forward, backward };
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/** Move focus within the cycle. Returns the element that received it. */
|
|
133
|
+
export function focusNextStops(backwards: boolean): HTMLElement | undefined {
|
|
134
|
+
const stops = tabStops();
|
|
135
|
+
if (stops.length === 0) return undefined;
|
|
136
|
+
const current = document.activeElement;
|
|
137
|
+
const index = stops.findIndex((el) => el === current);
|
|
138
|
+
let nextIndex: number;
|
|
139
|
+
if (index === -1) {
|
|
140
|
+
// Focus fell off the cycle (the just-pressed OK unmounted): resume
|
|
141
|
+
// at the CURRENT section's boundary — the first stop of the
|
|
142
|
+
// revealed section on Tab, the stop before it on Shift+Tab. No
|
|
143
|
+
// section in play (or a stale one): the menu bar leads the cycle.
|
|
144
|
+
const boundary = lastSection?.isConnected
|
|
145
|
+
? sectionBoundary(stops, lastSection)
|
|
146
|
+
: undefined;
|
|
147
|
+
const resume = backwards ? boundary?.backward : boundary?.forward;
|
|
148
|
+
nextIndex = resume ? stops.indexOf(resume) : 0;
|
|
149
|
+
} else {
|
|
150
|
+
lastSection = stops[index]?.closest(".window") ?? null;
|
|
151
|
+
nextIndex = (index + (backwards ? -1 : 1) + stops.length) % stops.length;
|
|
152
|
+
}
|
|
153
|
+
const next = stops[nextIndex];
|
|
154
|
+
if (!next) return undefined;
|
|
155
|
+
next.focus();
|
|
156
|
+
return next;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** The document-level Tab handler: the cycle is this module's business.
|
|
160
|
+
* Typing in a text field keeps the browser's native Tab behaviour. */
|
|
161
|
+
export function onTabKey(event: KeyboardEvent): void {
|
|
162
|
+
if (event.key !== "Tab") return;
|
|
163
|
+
if (event.ctrlKey || event.metaKey || event.altKey) return;
|
|
164
|
+
if (isTypingTarget(event.target)) return;
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
focusNextStops(event.shiftKey);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Track the section the focus currently sits in — from EVERY focus
|
|
170
|
+
* change, not just Tab walks. The OK press that reveals a section is
|
|
171
|
+
* usually a mouse click: without this, the resume anchor would be
|
|
172
|
+
* stale (or null) and the cycle would reset to the menu bar. */
|
|
173
|
+
const noteSection = (event: FocusEvent): void => {
|
|
174
|
+
const el = event.target;
|
|
175
|
+
if (!(el instanceof HTMLElement)) return;
|
|
176
|
+
lastSection = el.closest(".window") ?? null;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/** Test seam: reset the module's section anchor between scenarios. */
|
|
180
|
+
export function resetSectionAnchor(): void {
|
|
181
|
+
lastSection = null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Install the Tab handler on the document. Returns the unmount. */
|
|
185
|
+
export function installTabNavigation(): () => void {
|
|
186
|
+
document.addEventListener("keydown", onTabKey);
|
|
187
|
+
document.addEventListener("focusin", noteSection);
|
|
188
|
+
return () => {
|
|
189
|
+
document.removeEventListener("keydown", onTabKey);
|
|
190
|
+
document.removeEventListener("focusin", noteSection);
|
|
191
|
+
};
|
|
192
|
+
}
|
package/src/main.tsx
CHANGED
|
@@ -5,15 +5,29 @@ import "xp.css/dist/98.css";
|
|
|
5
5
|
import "react-toastify/dist/ReactToastify.css";
|
|
6
6
|
import "./styles/index.css";
|
|
7
7
|
import { App } from "./shell/App";
|
|
8
|
+
import { SignalProvider } from "./lib/signals";
|
|
9
|
+
import { attachHistoryBookmarks } from "./lib/history";
|
|
10
|
+
import { attachRouterSignals } from "./shell/routerSignals";
|
|
11
|
+
import { attachCloseSounds } from "./window/closeSounds";
|
|
8
12
|
import { enablePageSlide } from "./themes/pageSlide";
|
|
9
13
|
|
|
10
14
|
document.body.classList.add("styles-loaded");
|
|
15
|
+
// Attach the shell's signal handlers at boot, next to the theme: the
|
|
16
|
+
// bus carries navigation commands, route-change notices and window
|
|
17
|
+
// events; handlers live here and in lib modules, not in components.
|
|
18
|
+
attachRouterSignals();
|
|
19
|
+
attachCloseSounds();
|
|
20
|
+
// The history bookmarker (maximized-view pushes, hash-free off-site
|
|
21
|
+
// bookmarks, dismissal settles) attaches at boot too: the maximized
|
|
22
|
+
// view's push rides the pageSlide pushState wrapper, so the owner must
|
|
23
|
+
// be live before any window can lift.
|
|
24
|
+
attachHistoryBookmarks();
|
|
11
25
|
// Always install the page-slide theme: its hooks drive window
|
|
12
26
|
// minimisation, navigation choreography and sounds. When the page is
|
|
13
27
|
// loaded directly ONTO a hyperlinked window target (a #hash or ?post=
|
|
14
|
-
// the route
|
|
15
|
-
// — so the entrance
|
|
16
|
-
// the
|
|
28
|
+
// slug the route reveals), the theme starts "parked" — zero slide
|
|
29
|
+
// distance — so the entrance plays from nowhere and disturbs nothing
|
|
30
|
+
// before the reveal scrolls to the linked section. Page loads without a
|
|
17
31
|
// hyperlink target slide in from the top as usual; later navigations
|
|
18
32
|
// apply a real direction and slide as usual.
|
|
19
33
|
enablePageSlide();
|
|
@@ -21,7 +35,9 @@ enablePageSlide();
|
|
|
21
35
|
createRoot(document.getElementById("root")!).render(
|
|
22
36
|
<StrictMode>
|
|
23
37
|
<BrowserRouter>
|
|
24
|
-
<
|
|
38
|
+
<SignalProvider>
|
|
39
|
+
<App />
|
|
40
|
+
</SignalProvider>
|
|
25
41
|
</BrowserRouter>
|
|
26
42
|
</StrictMode>,
|
|
27
43
|
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { blogDirListed, blogDirListing, findBlogDir } from "@/content";
|
|
2
|
+
import { useSignals } from "@/lib/signals";
|
|
3
|
+
import { useLocation } from "react-router-dom";
|
|
4
|
+
import { PageWindows } from "@/window";
|
|
5
|
+
import { stripTrailingSlashes } from "@/lib/slashes";
|
|
6
|
+
|
|
7
|
+
/** A configured directory under /blog/ (src/content/blogDirs.ts): the
|
|
8
|
+
* page is the directory's LISTING — one window naming each shown file,
|
|
9
|
+
* linked to its post page or raw asset. The route exists only for
|
|
10
|
+
* configured directories (resolveRoute), so an unconfigured pathname
|
|
11
|
+
* renders nothing here.
|
|
12
|
+
*
|
|
13
|
+
* The title-bar Minimize and ✕ fold UP a level: the page's onLeave (the
|
|
14
|
+
* depth-0 fold — the same wiring that returns a project page to its
|
|
15
|
+
* index) navigates to the directory above, with the fold animation and
|
|
16
|
+
* the navigating sounds the window system already owns. The parent is
|
|
17
|
+
* the literal parent path; when that parent is a blog subdirectory that
|
|
18
|
+
* does not list (an opted-out shelf), the fold lands on the blog root
|
|
19
|
+
* instead of a dead end. */
|
|
20
|
+
export const BlogDirPage = () => {
|
|
21
|
+
const { pathname } = useLocation();
|
|
22
|
+
const { dispatch } = useSignals();
|
|
23
|
+
const listing = blogDirListing(pathname);
|
|
24
|
+
if (!listing) return null;
|
|
25
|
+
const parent = stripTrailingSlashes(pathname).replace(/\/[^/]*$/, "") || "/";
|
|
26
|
+
const parentLists =
|
|
27
|
+
parent === "/blog" ||
|
|
28
|
+
(Boolean(findBlogDir(parent)) && blogDirListed(parent));
|
|
29
|
+
return (
|
|
30
|
+
<PageWindows
|
|
31
|
+
content={listing}
|
|
32
|
+
onLeave={() =>
|
|
33
|
+
dispatch("app:navigate", { to: parentLists ? parent : "/blog" })
|
|
34
|
+
}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
blogDirListed,
|
|
3
|
+
findBlogDir,
|
|
4
|
+
type Section,
|
|
5
|
+
type ThemeName,
|
|
6
|
+
} from "@/content";
|
|
7
|
+
import { useSignals } from "@/lib/signals";
|
|
8
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
9
|
import { useLocation } from "react-router-dom";
|
|
3
10
|
import { PageWindows } from "@/window";
|
|
11
|
+
import { stripTrailingSlashes } from "@/lib/slashes";
|
|
4
12
|
|
|
5
|
-
/** A markdown file from public/blog/, addressed directly by its URL.
|
|
13
|
+
/** A markdown file from public/blog/, addressed directly by its URL.
|
|
14
|
+
*
|
|
15
|
+
* Posts may also be authored as .json Section trees (the same shape the
|
|
16
|
+
* content JSON files use). The parent directory's generated snapshot
|
|
17
|
+
* (src/content/blogDirs.json) tells the two forms apart: a `<name>.json`
|
|
18
|
+
* entry in the listing means the address renders THAT file — fetched at
|
|
19
|
+
* runtime and mounted through the same PageWindows tree any authored
|
|
20
|
+
* post uses; everything else embeds the markdown `<path>.md`.
|
|
21
|
+
*
|
|
22
|
+
* A post INSIDE a listed blog directory folds UP a level: its title-bar
|
|
23
|
+
* Minimize and ✕ navigate back to the parent directory's listing — the
|
|
24
|
+
* same depth-0 onLeave fold the listing page itself uses. Posts at the
|
|
25
|
+
* /blog root keep the plain page behaviour (their parent is the curated
|
|
26
|
+
* blog page, not a directory listing). */
|
|
6
27
|
export const BlogPostPage = () => {
|
|
7
28
|
const { pathname } = useLocation();
|
|
29
|
+
const { dispatch } = useSignals();
|
|
8
30
|
const content = useMemo(() => {
|
|
9
31
|
const src = decodeURI(pathname);
|
|
10
32
|
return {
|
|
@@ -12,5 +34,58 @@ export const BlogPostPage = () => {
|
|
|
12
34
|
embed: `${pathname}.md`,
|
|
13
35
|
};
|
|
14
36
|
}, [pathname]);
|
|
15
|
-
|
|
37
|
+
const isJson = useMemo(() => {
|
|
38
|
+
const parent =
|
|
39
|
+
stripTrailingSlashes(pathname).replace(/\/[^/]*$/, "") || "/";
|
|
40
|
+
const base = decodeURI(pathname).split("/").pop() ?? "";
|
|
41
|
+
return Boolean(findBlogDir(parent)?.files.includes(`${base}.json`));
|
|
42
|
+
}, [pathname]);
|
|
43
|
+
const [jsonPost, setJsonPost] = useState<Section | null>(null);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!isJson) return;
|
|
46
|
+
let live = true;
|
|
47
|
+
setJsonPost(null);
|
|
48
|
+
fetch(`${pathname}.json`)
|
|
49
|
+
.then((r) => {
|
|
50
|
+
if (!r.ok) throw new Error(`HTTP ${r.status}`);
|
|
51
|
+
return r.json() as Promise<Section>;
|
|
52
|
+
})
|
|
53
|
+
.then((section) => {
|
|
54
|
+
if (live) setJsonPost(section);
|
|
55
|
+
})
|
|
56
|
+
.catch(() => {
|
|
57
|
+
if (live) setJsonPost(null);
|
|
58
|
+
});
|
|
59
|
+
return () => {
|
|
60
|
+
live = false;
|
|
61
|
+
};
|
|
62
|
+
}, [isJson, pathname]);
|
|
63
|
+
const parent = stripTrailingSlashes(pathname).replace(/\/[^/]*$/, "") || "/";
|
|
64
|
+
const parentDir = findBlogDir(parent);
|
|
65
|
+
const foldsUp = Boolean(parentDir) && blogDirListed(parentDir?.path ?? "");
|
|
66
|
+
// A .md post's embed forces its window expanded; a .json post's tree
|
|
67
|
+
// must read the same way — the root window opens (theme "open" merged
|
|
68
|
+
// into whatever the author set) so its children mount, exactly like
|
|
69
|
+
// the authored posts on the blog page itself.
|
|
70
|
+
const post = useMemo(() => {
|
|
71
|
+
if (!isJson) return content;
|
|
72
|
+
if (!jsonPost) return null;
|
|
73
|
+
const themes = jsonPost.theme
|
|
74
|
+
? Array.isArray(jsonPost.theme)
|
|
75
|
+
? jsonPost.theme
|
|
76
|
+
: [jsonPost.theme]
|
|
77
|
+
: [];
|
|
78
|
+
return themes.includes("open")
|
|
79
|
+
? jsonPost
|
|
80
|
+
: { ...jsonPost, theme: [...themes, "open"] as ThemeName[] };
|
|
81
|
+
}, [isJson, jsonPost, content]);
|
|
82
|
+
if (!post) return null;
|
|
83
|
+
return (
|
|
84
|
+
<PageWindows
|
|
85
|
+
content={post}
|
|
86
|
+
onLeave={
|
|
87
|
+
foldsUp ? () => dispatch("app:navigate", { to: parent }) : undefined
|
|
88
|
+
}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
16
91
|
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { useLocation
|
|
1
|
+
import { useLocation } from "react-router-dom";
|
|
2
2
|
import { projectPath, projects, type Item, type Section } from "@/content";
|
|
3
3
|
import { normalizePath } from "@/shell/resolveRoute";
|
|
4
|
+
import { useSignals } from "@/lib/signals";
|
|
4
5
|
import { PageWindows } from "@/window";
|
|
5
6
|
|
|
6
7
|
const toItems = (content: Section["content"]): Item[] =>
|
|
7
8
|
content === undefined ? [] : Array.isArray(content) ? content : [content];
|
|
8
9
|
|
|
9
10
|
export const ProjectPage = () => {
|
|
10
|
-
|
|
11
|
+
// Leaving the page is a command, not a router call — the shell owns
|
|
12
|
+
// the single router-aware "app:navigate" handler.
|
|
13
|
+
const { dispatch } = useSignals();
|
|
11
14
|
const path = normalizePath(useLocation().pathname);
|
|
12
15
|
const project = projects.find((p) => projectPath(p) === path);
|
|
13
16
|
if (!project) return null;
|
|
@@ -17,6 +20,9 @@ export const ProjectPage = () => {
|
|
|
17
20
|
content: toItems(project.content.content),
|
|
18
21
|
};
|
|
19
22
|
return (
|
|
20
|
-
<PageWindows
|
|
23
|
+
<PageWindows
|
|
24
|
+
content={content}
|
|
25
|
+
onLeave={() => dispatch("app:navigate", { to: "/projects" })}
|
|
26
|
+
/>
|
|
21
27
|
);
|
|
22
28
|
};
|
package/src/pages/WowPage.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo, useState, type FormEvent } from "react";
|
|
2
|
-
import { useNavigate } from "react-router-dom";
|
|
3
2
|
import { addons, characters } from "@/content";
|
|
3
|
+
import { useSignals } from "@/lib/signals";
|
|
4
4
|
import { PageWindows } from "@/window";
|
|
5
5
|
|
|
6
6
|
type Feedback = { kind: "error" | "success"; text: string } | null;
|
|
@@ -22,7 +22,9 @@ function download(href: string, name: string) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function DownloadForm() {
|
|
25
|
-
|
|
25
|
+
// Cancelling is a command, not a router call — the shell owns the one
|
|
26
|
+
// router-aware "app:navigate" handler.
|
|
27
|
+
const { dispatch } = useSignals();
|
|
26
28
|
const [username, setUsername] = useState("");
|
|
27
29
|
const [date, setDate] = useState("");
|
|
28
30
|
const [feedback, setFeedback] = useState<Feedback>(null);
|
|
@@ -85,7 +87,10 @@ function DownloadForm() {
|
|
|
85
87
|
</div>
|
|
86
88
|
<div className="form-actions">
|
|
87
89
|
<button type="submit">Verify & Download</button>
|
|
88
|
-
<button
|
|
90
|
+
<button
|
|
91
|
+
type="button"
|
|
92
|
+
onClick={() => dispatch("app:navigate", { to: "/" })}
|
|
93
|
+
>
|
|
89
94
|
Cancel
|
|
90
95
|
</button>
|
|
91
96
|
</div>
|
package/src/pages/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ComponentType } from "react";
|
|
2
2
|
import { AddonsPage } from "./AddonsPage";
|
|
3
|
+
import { BlogDirPage } from "./BlogDirPage";
|
|
3
4
|
import { BlogPage } from "./BlogPage";
|
|
4
5
|
import { BlogPostPage } from "./BlogPostPage";
|
|
5
6
|
import { ContactPage } from "./ContactPage";
|
|
@@ -16,6 +17,7 @@ import { WowPage } from "./WowPage";
|
|
|
16
17
|
/** Maps the `page` names in content/pages.json to components. */
|
|
17
18
|
export const pageRegistry: Record<string, ComponentType> = {
|
|
18
19
|
AddonsPage,
|
|
20
|
+
BlogDirPage,
|
|
19
21
|
BlogPage,
|
|
20
22
|
BlogPostPage,
|
|
21
23
|
ConfigsPage,
|
package/src/shell/App.tsx
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
-
import { Navigate, useLocation } from "react-router-dom";
|
|
2
|
+
import { Navigate, useLocation, useNavigate } from "react-router-dom";
|
|
3
3
|
import { ToastContainer } from "react-toastify";
|
|
4
4
|
import { pageRegistry } from "@/pages";
|
|
5
5
|
import { NotFoundPage } from "@/pages/NotFoundPage";
|
|
6
6
|
import { applyStoredTheme } from "@/lib/theme";
|
|
7
|
+
import { installTabNavigation } from "@/lib/tabNav";
|
|
8
|
+
import { bindNavigate } from "./routerSignals";
|
|
7
9
|
import { Clippy } from "./Clippy";
|
|
8
10
|
import { MenuBar } from "./MenuBar";
|
|
9
11
|
import { resolveRoute } from "./resolveRoute";
|
|
@@ -16,6 +18,13 @@ export function App() {
|
|
|
16
18
|
const { pathname, hash } = useLocation();
|
|
17
19
|
const route = resolveRoute(pathname);
|
|
18
20
|
const Page = pageRegistry[route.page] ?? NotFoundPage;
|
|
21
|
+
const navigate = useNavigate();
|
|
22
|
+
// The shell keeps only the router awareness: the app:navigate handler
|
|
23
|
+
// attached at boot (routerSignals) performs dispatches with THIS
|
|
24
|
+
// navigate, bound here against the router context. Page-load
|
|
25
|
+
// monitoring is the attached handlers' business too — the boot route
|
|
26
|
+
// is announced there, transitions by the pageSlide theme.
|
|
27
|
+
bindNavigate(navigate);
|
|
19
28
|
|
|
20
29
|
const blank = pathname === "/" && hash.toLowerCase() === FEEF69_HASH;
|
|
21
30
|
|
|
@@ -25,6 +34,10 @@ export function App() {
|
|
|
25
34
|
return () => document.body.classList.remove("feef69-page");
|
|
26
35
|
}, [blank]);
|
|
27
36
|
useEffect(applyStoredTheme, []);
|
|
37
|
+
// Tab navigation: menu items first, then the foreground's visible
|
|
38
|
+
// buttons — maximized windows keep focus inside their backdrop and
|
|
39
|
+
// window decorations are never traversed. See lib/tabNav.
|
|
40
|
+
useEffect(installTabNavigation, []);
|
|
28
41
|
|
|
29
42
|
if (blank) return <main className="feef69-page" />;
|
|
30
43
|
|
|
@@ -34,13 +47,11 @@ export function App() {
|
|
|
34
47
|
return (
|
|
35
48
|
<>
|
|
36
49
|
<MenuBar />
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<Page />
|
|
43
|
-
</section>
|
|
50
|
+
{/* main IS the page: one element carries the scroll container and the
|
|
51
|
+
page styling — an extra <section.page> inside it only added a
|
|
52
|
+
nesting level. Pages differ in content, never in shell structure. */}
|
|
53
|
+
<main className="page" key={route.path}>
|
|
54
|
+
<Page />
|
|
44
55
|
</main>
|
|
45
56
|
<Clippy />
|
|
46
57
|
<ToastContainer position="bottom-right" />
|
package/src/shell/Clippy.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
subscribeClippy,
|
|
7
7
|
toggleClippyList,
|
|
8
8
|
} from "@/lib/clippy";
|
|
9
|
-
import {
|
|
9
|
+
import { useSignalValue } from "@/lib/signals";
|
|
10
10
|
|
|
11
11
|
type Corner = "tl" | "tr" | "bl" | "br";
|
|
12
12
|
|
|
@@ -20,11 +20,14 @@ const ARRIVE_MS = 600;
|
|
|
20
20
|
|
|
21
21
|
/** Hidden mascot; summoning logic lives in lib/clippy. Draggable & snappy. */
|
|
22
22
|
export function Clippy() {
|
|
23
|
-
const { visible, bubble, saysNo, listOpen } = useSyncExternalStore(
|
|
23
|
+
const { visible, bubble, saysNo, offering, listOpen } = useSyncExternalStore(
|
|
24
24
|
subscribeClippy,
|
|
25
25
|
getClippyState,
|
|
26
26
|
);
|
|
27
|
-
|
|
27
|
+
// The parked-window roster is a retained signal: Clippy reads its
|
|
28
|
+
// snapshot at render time (the bus keeps the last one) and manages
|
|
29
|
+
// no bridge of its own.
|
|
30
|
+
const hidden = useSignalValue("window:hidden");
|
|
28
31
|
useEffect(attachClippy, []);
|
|
29
32
|
|
|
30
33
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
@@ -199,9 +202,16 @@ export function Clippy() {
|
|
|
199
202
|
</div>
|
|
200
203
|
)}
|
|
201
204
|
{!listOpen && bubble && (
|
|
205
|
+
// ONE bubble at a time, by construction: every lib/clippy state
|
|
206
|
+
// transition clears its sibling flags in the SAME committed set()
|
|
207
|
+
// (offer clears saysNo, the veto clears nothing else, the hint
|
|
208
|
+
// clears offering, the list masks the bubble outright) — so the
|
|
209
|
+
// precedence here never renders two texts side by side.
|
|
202
210
|
<div className="clippy-bubble" role="status">
|
|
203
211
|
{saysNo ? (
|
|
204
212
|
"haha it said no"
|
|
213
|
+
) : offering ? (
|
|
214
|
+
"oh where did that go?.."
|
|
205
215
|
) : (
|
|
206
216
|
<>
|
|
207
217
|
It looks like you're trying to close something. Try clicking one
|
package/src/shell/MenuBar.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useMemo } from "react";
|
|
2
|
-
import { Link, useLocation
|
|
2
|
+
import { Link, useLocation } from "react-router-dom";
|
|
3
3
|
import { getCookie } from "@/lib/cookies";
|
|
4
|
+
import { useSignals } from "@/lib/signals";
|
|
4
5
|
import { visibleMenuItems } from "./menu";
|
|
5
6
|
|
|
6
7
|
const isTyping = (target: EventTarget | null) =>
|
|
@@ -10,7 +11,9 @@ const isTyping = (target: EventTarget | null) =>
|
|
|
10
11
|
|
|
11
12
|
export function MenuBar() {
|
|
12
13
|
const { pathname } = useLocation();
|
|
13
|
-
|
|
14
|
+
// Hotkeys command navigation, so they dispatch: the shell owns the
|
|
15
|
+
// router-aware handler. The <Link> elements below stay real anchors.
|
|
16
|
+
const { dispatch } = useSignals();
|
|
14
17
|
const items = useMemo(
|
|
15
18
|
() => visibleMenuItems(pathname, getCookie("admin") === "akinevz"),
|
|
16
19
|
[pathname],
|
|
@@ -30,11 +33,11 @@ export function MenuBar() {
|
|
|
30
33
|
const item = items.find((i) => i.label[0]?.toLowerCase() === key);
|
|
31
34
|
if (!item) return;
|
|
32
35
|
event.preventDefault();
|
|
33
|
-
navigate
|
|
36
|
+
dispatch("app:navigate", { to: item.href });
|
|
34
37
|
};
|
|
35
38
|
document.addEventListener("keydown", onKey);
|
|
36
39
|
return () => document.removeEventListener("keydown", onKey);
|
|
37
|
-
}, [items,
|
|
40
|
+
}, [items, dispatch]);
|
|
38
41
|
|
|
39
42
|
return (
|
|
40
43
|
<nav className="menu-bar">
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
blogDirFiles,
|
|
3
|
+
blogDirListed,
|
|
4
|
+
findBlogDir,
|
|
5
|
+
routes,
|
|
6
|
+
type Route,
|
|
7
|
+
} from "@/content";
|
|
8
|
+
import { stripEdgeSlashes, stripTrailingSlashes } from "@/lib/slashes";
|
|
2
9
|
|
|
3
10
|
export const NOT_FOUND = routes.find((r) => r.path === "/404") as Route;
|
|
4
11
|
|
|
@@ -11,7 +18,7 @@ export function normalizePath(pathname: string): string {
|
|
|
11
18
|
return pathname;
|
|
12
19
|
}
|
|
13
20
|
path = path.replace(/\/index(\.html)?$/i, "").replace(/\.html$/i, "");
|
|
14
|
-
path = `/${path
|
|
21
|
+
path = `/${stripEdgeSlashes(path)}`;
|
|
15
22
|
const lower = path.toLowerCase();
|
|
16
23
|
return routes.some((r) => r.path === lower) ? lower : path;
|
|
17
24
|
}
|
|
@@ -38,7 +45,40 @@ function blogDocumentRoute(pathname: string): Route {
|
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
export function resolveRoute(pathname: string): Route {
|
|
41
|
-
if (BLOG_PAGE.test(pathname))
|
|
48
|
+
if (BLOG_PAGE.test(pathname)) {
|
|
49
|
+
// Every /blog/** address resolves against the filesystem walk
|
|
50
|
+
// (build/blogDirsPlugin.ts), in order:
|
|
51
|
+
// 1. a directory → its listing page (or 404 when opted out);
|
|
52
|
+
// 2. a file (<base>.md or <base>.json) → its post page;
|
|
53
|
+
// 3. neither → 404. The old fallback embedded "<path>.md" blindly,
|
|
54
|
+
// so removed files AND removed directories rendered whatever the
|
|
55
|
+
// server's SPA fallback handed back — the site inside itself.
|
|
56
|
+
const path = normalizePath(pathname);
|
|
57
|
+
const blogDir = findBlogDir(path);
|
|
58
|
+
if (blogDir) {
|
|
59
|
+
if (!blogDirListed(blogDir.path)) return NOT_FOUND;
|
|
60
|
+
const name =
|
|
61
|
+
blogDir.path.split("/").filter(Boolean).pop() ?? blogDir.path;
|
|
62
|
+
return {
|
|
63
|
+
path: pathname,
|
|
64
|
+
title: `${name} | blog of kine`,
|
|
65
|
+
description: `${name} — the files in this blog directory.`,
|
|
66
|
+
page: "BlogDirPage",
|
|
67
|
+
hidden: true,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const parent = stripTrailingSlashes(path).replace(/\/[^/]*$/, "") || "/";
|
|
71
|
+
const base = path.split("/").pop() ?? "";
|
|
72
|
+
const files = blogDirFiles(parent);
|
|
73
|
+
// The parent of any /blog/** address is /blog or a walk-known
|
|
74
|
+
// subdirectory; an unknown parent means a missing ancestor — 404.
|
|
75
|
+
if (
|
|
76
|
+
!files ||
|
|
77
|
+
(!files.includes(`${base}.md`) && !files.includes(`${base}.json`))
|
|
78
|
+
)
|
|
79
|
+
return NOT_FOUND;
|
|
80
|
+
return blogDocumentRoute(pathname);
|
|
81
|
+
}
|
|
42
82
|
const path = normalizePath(pathname);
|
|
43
83
|
const route = routes.find((r) => r.path === path);
|
|
44
84
|
return route ?? NOT_FOUND;
|