The /incoming/ path regex in browse/js/grid.js was the second-most
visible client-side hardcode of the canonical convention. Migrating
it to the cascade:
Header surface:
X-ZDDC-Default-Tool: <name> The cascade-resolved default tool
for the listing's directory. Empty
header = no default declared.
Client wiring:
loader.fetchServerChildren reads the header into
state.scopeDefaultTool on every listing fetch (initial mount,
rescope on dblclick, popstate). grid.classifierAvailableHere
now returns scopeDefaultTool === 'classifier' instead of
regex-matching the URL.
Effect:
Grid mode auto-activates wherever the cascade picks classifier
as the default — currently archive/<party>/incoming per
defaults.zddc.yaml. An operator who sets default_tool: classifier
on a custom directory gets grid mode there too, no code change.
An operator who removes the default at incoming sees grid mode
stop auto-activating there.
Bootstrap timing fix:
The initial events.init() runs applyResolvedViewMode before the
detection fetch completes, so state.scopeDefaultTool is empty
at that point and grid never auto-activates on first paint.
app.js bootstrap now re-applies the resolved view mode after
autoDetectServerMode returns, so a fresh /incoming URL lands
on grid mode immediately.
The /incoming/ regex is gone. Two client hardcodes remaining
(archive source heuristics, shared/nav stage strip) — Phase 4c/d.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
63 lines
2.4 KiB
JavaScript
63 lines
2.4 KiB
JavaScript
// Bootstrap window.app for the browse tool. Mirrors the convention
|
|
// used by every other ZDDC tool — ./build's CSS/JS concat order means
|
|
// this file runs FIRST inside the IIFE-of-IIFEs.
|
|
(function () {
|
|
'use strict';
|
|
|
|
if (!window.app) {
|
|
window.app = { modules: {}, state: {} };
|
|
}
|
|
|
|
window.app.state = {
|
|
// Source: 'server' | 'fs' | null. Determines how the loader
|
|
// resolves entries.
|
|
source: null,
|
|
|
|
// For server-source: the URL path of the directory currently
|
|
// being viewed. Always starts with '/' and ends with '/'.
|
|
// For fs-source: the displayed path string (no semantic
|
|
// meaning — just for the toolbar).
|
|
currentPath: '/',
|
|
|
|
// FileSystemAccessAPI root handle (null in server mode).
|
|
rootHandle: null,
|
|
|
|
// Sort state. key: 'name' | 'size' | 'ext' | 'date'. dir: 1 or -1.
|
|
sort: { key: 'name', dir: 1 },
|
|
|
|
// Currently-selected tree node id (for highlight + pop-out).
|
|
selectedId: null,
|
|
lastPreviewedNodeId: null,
|
|
|
|
// View mode: 'browse' (tree + preview, default) | 'grid' (classifier).
|
|
viewMode: 'browse',
|
|
|
|
// The tree's in-memory representation. Each node:
|
|
// { id, name, isDir, size, modTime, ext, url, depth,
|
|
// parentId, expanded, loaded, childIds, isZip, zipFile,
|
|
// zipPath }
|
|
// - isZip: set when the node IS a .zip file we know how to
|
|
// expand inline (server file or FS handle).
|
|
// - zipFile: cached JSZip instance for this archive (set
|
|
// after first expand).
|
|
// - zipPath: relative path WITHIN a zip (set on virtual
|
|
// children of an expanded zip; null otherwise).
|
|
// Stored flat in a Map keyed by id; render order derived
|
|
// from a depth-first walk.
|
|
nodes: new Map(),
|
|
rootIds: [],
|
|
nextId: 1,
|
|
|
|
// Single shared popup window for file preview (across
|
|
// multiple file clicks). Same pattern as archive's preview.
|
|
previewWindow: null,
|
|
|
|
// Cascade-resolved scope flags, refreshed on each listing
|
|
// fetch from response headers.
|
|
// scopeDropTarget: cascade's drop_target at currentPath
|
|
// scopeDefaultTool: cascade's default_tool at currentPath
|
|
// (empty when no default declared)
|
|
scopeDropTarget: false,
|
|
scopeDefaultTool: ''
|
|
};
|
|
})();
|