All checks were successful
Notify chart dev on beta cut / notify-chart-dev (push) Successful in 5s
A new HTML tool — browse — that lists the contents of any directory.
Designed for ZDDC archives but no ZDDC-specific filtering; just a
straight folder browser with expand/collapse, sort, and name filter.
Modes (auto-detected at page load):
- Online: when served by zddc-server at a folder URL, queries
the same URL with Accept: application/json to load the listing
and renders it. Auto-served as the default at any directory
under ZDDC_ROOT without an index.html (replacing the previous
minimal-HTML stub from directory.go).
- Local: 'Select Directory' button uses FileSystemAccessAPI to
pick any folder on disk; works in Chromium-based browsers.
Features (Phase 1 — what's in this commit):
- Tree view with lazy-loaded folders (children fetched on first
expand).
- Sort by name / size / extension / date (column header click).
- Filter by name substring (toolbar input).
- File click opens in a new tab — for server-backed pages,
routes through zddc-server's normal handler so .archive
redirects + apps cascade overrides + ACL all apply.
Phase 2 deferred:
- ZIP files inline expansion (treat archive entries as virtual
children).
- File preview popup (reuse shared/preview-lib.js).
- Extension multi-select filter.
Wiring:
- browse/ added to top-level ./build's per-tool list, embed
block, versions.txt, and the lockstep release commit + tag set.
All seven tools (archive, transmittal, classifier, mdedit,
landing, form, browse) advance together on stable cuts.
- shared/build-lib.sh: browse added to ZDDC_RELEASE_TOOLS and
verify_channel_links's per-tool loop.
- zddc/internal/apps/embed.go: //go:embed browse.html +
EmbeddedBytes("browse") case.
- zddc/internal/apps/availability.go: browse available at every
directory (same as archive).
- zddc/internal/apps/handler.go: MatchAppHTML routes
/<dir>/browse.html → 'browse'.
- zddc/internal/handler/directory.go: when a directory request
arrives with Accept: text/html and no index.html exists,
serve the embedded browse.html bytes (with a JSON-fallback
if the embedded slot is empty during bootstrap).
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package apps
|
|
|
|
import _ "embed"
|
|
|
|
// Embedded fallback: the five tool HTMLs from the time the binary was
|
|
// built. Used as a last-resort served-bytes when (cache miss) AND
|
|
// (upstream unreachable) AND (no operator override) — see handler.go.
|
|
//
|
|
// The files are populated by the top-level build.sh, which copies the
|
|
// freshly-built dist/<tool>.html into ./embedded/ before `go build` runs.
|
|
// Empty placeholder files are checked in so the package compiles when no
|
|
// build has been run yet (CI bootstrap, fresh clone, etc.); at runtime an
|
|
// empty embedded body is treated as "no embedded fallback available."
|
|
|
|
//go:embed embedded/archive.html
|
|
var embeddedArchive []byte
|
|
|
|
//go:embed embedded/transmittal.html
|
|
var embeddedTransmittal []byte
|
|
|
|
//go:embed embedded/classifier.html
|
|
var embeddedClassifier []byte
|
|
|
|
//go:embed embedded/mdedit.html
|
|
var embeddedMdedit []byte
|
|
|
|
//go:embed embedded/index.html
|
|
var embeddedLanding []byte
|
|
|
|
//go:embed embedded/browse.html
|
|
var embeddedBrowse []byte
|
|
|
|
// EmbeddedBytes returns the embedded HTML for app, or nil if either app is
|
|
// not one of the canonical names or the embedded slot is empty (no build
|
|
// has populated it).
|
|
func EmbeddedBytes(app string) []byte {
|
|
var b []byte
|
|
switch app {
|
|
case "archive":
|
|
b = embeddedArchive
|
|
case "transmittal":
|
|
b = embeddedTransmittal
|
|
case "classifier":
|
|
b = embeddedClassifier
|
|
case "mdedit":
|
|
b = embeddedMdedit
|
|
case "landing":
|
|
b = embeddedLanding
|
|
case "browse":
|
|
b = embeddedBrowse
|
|
default:
|
|
return nil
|
|
}
|
|
if len(b) == 0 {
|
|
return nil
|
|
}
|
|
return b
|
|
}
|