Bundles Phase 2 polish + the user-requested header/breadcrumb work:
- Breadcrumbs replacing the plain currentPath span. Server mode
renders linkified ancestor segments (each <a> navigates to that
directory; the browser fetches browse.html, the new instance
auto-loads the listing). FS-API mode renders the rootHandle name
as a non-link (no ancestor handles to navigate). Both prefix the
path with a 🏠 root icon. Trailing slash + bold-current segment
match common file-explorer conventions.
- Subdued 'Select Directory' button in server mode. Once browse is
serving a real directory listing, the local-folder switcher is
available but visually quiet (btn--subtle: transparent, muted
color). FS-API mode keeps the primary styling (it's how the user
got there). New btn--subtle CSS class added to browse's tree.css.
A refresh button (⟳) appears next to it in both modes; clicking
it re-fetches the current root listing.
- Header consistency: browse now matches archive's header layout
(refresh + help buttons in addition to theme on the right). Help
is a placeholder for future help dialog wiring.
- File preview popup. Click a file row → opens a popup window with
the file rendered. Plain types (PDF, HTML, image) load in
iframes; TIFF + ZIP listings via shared/preview-lib.js's
renderTiff / renderZipListing helpers; text via <pre>; unknown
types → 'click Download' placeholder. Modifier-click (ctrl/cmd/
shift) and middle-click still open the file in a new tab via the
underlying <a target=_blank>. Single popup window is reused
across multiple file clicks (matches archive's UX).
- ZIP inline expansion. .zip files have a chevron and act like
folders in the tree. First expand fetches the zip bytes
(server URL or FS handle or parent-zip read), parses with JSZip
(auto-loaded from CDN), and synthesizes the entry tree. Nested
directories within the zip lazy-expand on demand by re-walking
the cached entry list at the right path prefix. Click on a
zip-entry file opens the preview popup with bytes read from
JSZip. Recursive expand-all skips zip archives by design — they
can be very large, and explicit click-to-expand is safer.
- Extension multi-select filter. Toolbar now has a <select
multiple> populated with extensions present in the current
view. Filter is OR-of-selected; combined with the name filter
it's AND-of-both. Folders pass through (so expanding a folder
whose name doesn't match the ext filter still shows its file
children that do match).
71 lines
1.9 KiB
Bash
Executable file
71 lines
1.9 KiB
Bash
Executable file
#!/bin/sh
|
|
set -eu
|
|
|
|
root_dir=$(cd "$(dirname "$0")" && pwd)
|
|
. "$root_dir/../shared/build-lib.sh"
|
|
|
|
src_html="$root_dir/template.html"
|
|
output_dir="$root_dir/dist"
|
|
output_html="$output_dir/browse.html"
|
|
|
|
mkdir -p "$output_dir"
|
|
ensure_exists "$src_html"
|
|
|
|
css_temp=$(mktemp)
|
|
js_raw=$(mktemp)
|
|
js_temp=$(mktemp)
|
|
cleanup() { rm -f "$css_temp" "$js_raw" "$js_temp"; }
|
|
trap cleanup EXIT
|
|
|
|
# CSS files: shared base first, then browse-specific.
|
|
concat_files \
|
|
"../shared/base.css" \
|
|
"css/base.css" \
|
|
"css/tree.css" \
|
|
> "$css_temp"
|
|
|
|
# JS files: shared canonical helpers, then browse modules.
|
|
# init.js must come first so window.app exists when later modules
|
|
# attach to it.
|
|
concat_files \
|
|
"../shared/zddc.js" \
|
|
"../shared/theme.js" \
|
|
"../shared/preview-lib.js" \
|
|
"js/init.js" \
|
|
"js/loader.js" \
|
|
"js/tree.js" \
|
|
"js/preview.js" \
|
|
"js/events.js" \
|
|
"js/app.js" \
|
|
> "$js_raw"
|
|
|
|
# Escape any literal `</` inside JS string/template literals so the
|
|
# inlined <script> block doesn't get terminated prematurely.
|
|
escape_js_close_tags "$js_raw" "$js_temp"
|
|
|
|
tool=browse
|
|
compute_build_label "$tool" "$@"
|
|
|
|
# Replace template placeholders with concatenated CSS/JS + label.
|
|
awk -v css_file="$css_temp" -v js_file="$js_temp" \
|
|
-v build_label="$build_label" -v favicon="$favicon_data_uri" '
|
|
/\{\{CSS_PLACEHOLDER\}\}/ {
|
|
while ((getline line < css_file) > 0) print line
|
|
close(css_file); next
|
|
}
|
|
/\{\{JS_PLACEHOLDER\}\}/ {
|
|
while ((getline line < js_file) > 0) print line
|
|
close(js_file); next
|
|
}
|
|
{
|
|
gsub(/\{\{BUILD_LABEL\}\}/, build_label)
|
|
gsub(/\{\{FAVICON\}\}/, favicon)
|
|
print
|
|
}
|
|
' "$src_html" > "$output_html"
|
|
|
|
echo "Wrote $output_html"
|
|
|
|
# Promote AFTER the dist file exists so promote_release can copy from
|
|
# $output_html. (The order matters — _promote_stable does cp $output_html ...)
|
|
promote_release "$tool"
|