Polish pass after the big refactor in 2d114fc.
== Header elevation slot propagated ==
shared/elevation.{js,css} surface a header checkbox for admins.
30-minute sudo-style cookie window (Max-Age=1800, SameSite=Lax).
Only renders when /.profile/access reports can_elevate=true; quiet
for non-admins. Slot added to all 7 tool templates and concat'd
into all 7 build.sh files; admin in any tool now sees the toggle.
Three text-rename ride-alongs in archive/classifier/transmittal
templates: "Add Local Directory" → "Use Local Directory" (the same
rename that landed in browse earlier in this branch).
== Docs ==
- CLAUDE.md gets an "Admin elevation is sudo-style" paragraph in
the "Things that bite if you forget" section.
- AGENTS.md gets a dedicated "Admin elevation (sudo-style)" section
alongside "Bearer tokens" — same depth as the existing auth docs.
== Helper file splits ==
The retired form editor's shared helpers got bundled into a single
zddc_admin.go in the cleanup; that name is now misleading. Split by
concern:
- admin_helpers.go: hasAnyAdminScope (the only admin-specific helper)
- paths.go: resolvePath, urlPathOf, chainDirs (URL ↔ filesystem path
math — used by several profile / zddc-file handlers)
- profile_assets.go (renamed from zddc_admin_assets.go): custom CSS
pipeline. URL renamed from /.profile/zddc/assets/ → /.profile/assets/
since /.profile/zddc/ no longer hosts an editor.
- treeEntry moves to profilehandler.go (alongside AccessView, its
only consumer).
- writeError moves to profileprojects.go (its only consumer).
== Smell cleanup ==
- zddc.HasAnyAdminGrant(fsRoot, email) — new elevation-independent
primitive that walks the cascade and reports whether email is named
in any admin: list anywhere. Replaces the synthetic-elevated probe
hack in enumerateAccess (`Principal{Email, Elevated: true}` was
"lying" to the elevation gate to ask what it would say). The handler's
hasAnyAdminScope collapses to a 4-line wrapper that gates on
p.Elevated and delegates.
- Access-log middleware records `elevated` per request, so forensics
can distinguish "admin acting as user" from "admin exercising power."
- browse/js/app.js's ?file= deep link walks multi-segment paths. Each
intermediate segment is matched + expanded; the leaf gets
selected/previewed. Auto-shows hidden when any segment starts with
. or _. Silently no-ops on unresolved segments.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
193 lines
4.7 KiB
Bash
Executable file
193 lines
4.7 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/transmittal.html"
|
|
|
|
mkdir -p "$output_dir"
|
|
ensure_exists "$src_html"
|
|
readme_file="$root_dir/README.md"
|
|
ensure_exists "$readme_file"
|
|
|
|
css_temp=$(mktemp)
|
|
js_raw=$(mktemp)
|
|
js_temp=$(mktemp)
|
|
md_temp=$(mktemp)
|
|
cleanup() { rm -f "$css_temp" "$js_raw" "$js_temp" "$md_temp"; }
|
|
trap cleanup EXIT
|
|
|
|
# CSS files to concatenate in order
|
|
concat_files \
|
|
"../shared/fonts.css" \
|
|
"../shared/base.css" \
|
|
"../shared/toast.css" \
|
|
"../shared/elevation.css" \
|
|
"../shared/nav.css" \
|
|
"../shared/logo.css" \
|
|
"css/base.css" \
|
|
"css/layout.css" \
|
|
"css/forms.css" \
|
|
"css/table.css" \
|
|
"css/remarks.css" \
|
|
"css/markdown.css" \
|
|
"css/markdown-editor.css" \
|
|
"css/filter.css" \
|
|
"css/modal.css" \
|
|
"css/utilities.css" \
|
|
"css/print.css" \
|
|
> "$css_temp"
|
|
|
|
# JavaScript files to concatenate in order. Vendored libraries first
|
|
# (jszip, docx-preview) so window.JSZip + window.docx are defined before
|
|
# any tool code runs — replaces the previous CDN loadLibrary() calls
|
|
# scattered through files-preview.js. xlsx stays CDN-loaded on demand.
|
|
concat_files \
|
|
"../shared/vendor/jszip.min.js" \
|
|
"../shared/vendor/docx-preview.min.js" \
|
|
"../shared/vendor/xlsx.full.min.js" \
|
|
"../shared/vendor/utif.min.js" \
|
|
"../shared/zddc.js" \
|
|
"../shared/hash.js" \
|
|
"../shared/zddc-source.js" \
|
|
"../shared/theme.js" \
|
|
"../shared/toast.js" \
|
|
"../shared/nav.js" \
|
|
"../shared/logo.js" \
|
|
"../shared/preview-lib.js" \
|
|
"js/app.js" \
|
|
"js/reactive.js" \
|
|
"js/dom.js" \
|
|
"js/util.js" \
|
|
"js/json.js" \
|
|
"js/hydrate.js" \
|
|
"js/state.js" \
|
|
"js/mode.js" \
|
|
"js/visibility.js" \
|
|
"js/live-digest.js" \
|
|
"js/files.js" \
|
|
"js/files-archive.js" \
|
|
"js/files-render.js" \
|
|
"js/files-preview.js" \
|
|
"../shared/zddc-filter.js" \
|
|
"js/filters.js" \
|
|
"js/markdown.js" \
|
|
"js/markdown-editor.js" \
|
|
"js/email-tags.js" \
|
|
"js/validation.js" \
|
|
"js/security.js" \
|
|
"js/verification.js" \
|
|
"js/data.js" \
|
|
"js/publish.js" \
|
|
"js/reset.js" \
|
|
"js/publish-modal.js" \
|
|
"js/logos.js" \
|
|
"js/drop-zones.js" \
|
|
"js/focus.js" \
|
|
"../shared/help.js" \
|
|
"../shared/elevation.js" \
|
|
"js/main.js" \
|
|
> "$js_raw"
|
|
|
|
# Escape '</' in JS and the inlined README so neither can prematurely close
|
|
# the inline <script> blocks they get embedded in.
|
|
escape_js_close_tags "$js_raw" "$js_temp"
|
|
escape_js_close_tags "$readme_file" "$md_temp"
|
|
|
|
compute_build_label "transmittal" "${1:-}" "${2:-}"
|
|
|
|
awk -v css_file="$css_temp" -v js_file="$js_temp" -v md_file="$md_temp" -v build_label="$build_label" -v is_red="$is_red" -v favicon_uri="$favicon_data_uri" '
|
|
BEGIN {
|
|
css_inserted = 0
|
|
js_inserted = 0
|
|
help_inserted = 0
|
|
in_help = 0
|
|
}
|
|
/<link rel="stylesheet" href="css\// { next }
|
|
/<link rel="stylesheet" href="tailwind-lite\.css"/ { next }
|
|
/<script src="js\// { next }
|
|
/<script src="\.\.\// { next }
|
|
/<script id="help-markdown" type="application\/markdown">/ {
|
|
in_help = 1
|
|
next
|
|
}
|
|
in_help {
|
|
if ($0 ~ /<\/script>/) {
|
|
in_help = 0
|
|
}
|
|
next
|
|
}
|
|
/<head>/ {
|
|
print
|
|
if (!css_inserted) {
|
|
print "<style>"
|
|
while ((getline line < css_file) > 0) print line
|
|
close(css_file)
|
|
print "</style>"
|
|
css_inserted = 1
|
|
}
|
|
next
|
|
}
|
|
/<\/body>/ {
|
|
if (!js_inserted) {
|
|
print "<script>"
|
|
while ((getline line < js_file) > 0) print line
|
|
close(js_file)
|
|
print "</script>"
|
|
js_inserted = 1
|
|
}
|
|
if (!help_inserted) {
|
|
print "<script id=\"help-markdown\" type=\"application/markdown\">"
|
|
while ((getline line < md_file) > 0) print line
|
|
close(md_file)
|
|
print "</script>"
|
|
help_inserted = 1
|
|
}
|
|
print
|
|
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
|
|
}
|
|
/\{\{FAVICON\}\}/ {
|
|
gsub(/\{\{FAVICON\}\}/, favicon_uri)
|
|
print
|
|
next
|
|
}
|
|
{ print }
|
|
END {
|
|
if (!css_inserted) {
|
|
print "<style>"
|
|
while ((getline line < css_file) > 0) print line
|
|
close(css_file)
|
|
print "</style>"
|
|
}
|
|
if (!js_inserted) {
|
|
print "<script>"
|
|
while ((getline line < js_file) > 0) print line
|
|
close(js_file)
|
|
print "</script>"
|
|
}
|
|
if (!help_inserted) {
|
|
print "<script id=\"help-markdown\" type=\"application/markdown\">"
|
|
while ((getline line < md_file) > 0) print line
|
|
close(md_file)
|
|
print "</script>"
|
|
}
|
|
}
|
|
' "$src_html" > "$output_html"
|
|
|
|
echo "Wrote $output_html"
|
|
|
|
if [ "$is_release" = "1" ]; then
|
|
promote_release "transmittal"
|
|
fi
|