New shared/zip-source.js: a ZipDirectoryHandle / ZipFileHandle pair that exposes a JSZip instance behind the File-System-Access surface (values/entries/keys, getDirectoryHandle/getFileHandle, getFile) — read-only, with a zip-slip guard. Mirrors shared/zddc-source.js's HTTP polyfill. Wired into archive's and browse's build.sh (both already bundle JSZip). archive: a .zip whose name minus ".zip" parses as a transmittal-folder name is now scanned as that transmittal folder. Offline, the zip is opened in the browser (ZipDirectoryHandle) and its members enumerated exactly like an uncompressed folder's files — table/export/hash paths are unchanged (they go through file.handle.getFile()). Online, the scanner recurses into the server's "<…>.zip/" virtual-directory listing, so members come back as "<…>.zip/<member>" URLs the server extracts on demand — no whole-zip download. browse: the offline (file://) zip path is migrated onto the shared adapter — expanding a .zip now opens it as a ZipDirectoryHandle and its members become ordinary dir/file nodes handled by the normal fetchFsChildren path (nested zips fall out by recursion). The bespoke flat-entry walker (loadZipChildren / setZipDirChildren / zipEntries / zipParentId / zipPath / _zipSyntheticDir) is gone — one zip implementation repo-wide. Markdown members inside a zip are flagged read-only (the ZipFileHandle refuses createWritable; server "<…>.zip/" URLs 405 on PUT). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
104 lines
3.1 KiB
Bash
Executable file
104 lines
3.1 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. Toast UI's CSS
|
|
# is bundled because the markdown plugin uses Toast UI inside the
|
|
# preview pane (.md files render as a full editor).
|
|
concat_files \
|
|
"../shared/fonts.css" \
|
|
"../shared/base.css" \
|
|
"../shared/toast.css" \
|
|
"../shared/nav.css" \
|
|
"../shared/logo.css" \
|
|
"../shared/vendor/toastui-editor.min.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. JSZip is vendored (rather than CDN-loaded) so ZIP
|
|
# expansion in the tree works under restrictive networks / CSPs and
|
|
# without an external HTTP dependency.
|
|
concat_files \
|
|
"../shared/vendor/jszip.min.js" \
|
|
"../shared/vendor/utif.min.js" \
|
|
"../shared/vendor/toastui-editor-all.min.js" \
|
|
"../shared/zddc.js" \
|
|
"../shared/zddc-filter.js" \
|
|
"../shared/zip-source.js" \
|
|
"../shared/theme.js" \
|
|
"../shared/toast.js" \
|
|
"../shared/nav.js" \
|
|
"../shared/logo.js" \
|
|
"../shared/help.js" \
|
|
"../shared/preview-lib.js" \
|
|
"js/init.js" \
|
|
"js/loader.js" \
|
|
"js/tree.js" \
|
|
"js/preview.js" \
|
|
"js/preview-markdown.js" \
|
|
"js/grid.js" \
|
|
"js/upload.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.
|
|
# Non-stable build labels (alpha/beta/dev-dirty) are wrapped in a red
|
|
# span — same convention as every other tool (compute_build_label
|
|
# sets $is_red=1 for non-stable cuts). Keeps the visual cue
|
|
# consistent across tool headers.
|
|
awk -v css_file="$css_temp" -v js_file="$js_temp" \
|
|
-v build_label="$build_label" -v is_red="$is_red" \
|
|
-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
|
|
}
|
|
/\{\{BUILD_LABEL\}\}/ {
|
|
if (is_red == "1") {
|
|
gsub(/\{\{BUILD_LABEL\}\}/, "<span style=\"color:red;font-weight:bold\">" build_label "</span>")
|
|
} else {
|
|
gsub(/\{\{BUILD_LABEL\}\}/, build_label)
|
|
}
|
|
print; next
|
|
}
|
|
{
|
|
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"
|