Retire the bespoke, chrome-less /.tokens page. It now renders through the shared tables engine — getting the standard header (logo, theme, profile menu) + declarative columns/filters for free — from a server-injected, pre-assembled #table-context built from the user's tokens (Store.List). New, reusable "tables over an API collection" primitive (tables/js/ api-actions.js): when the injected context carries an `apiActions` block, it drives create (a modal form → POST, surfacing the one-time secret) and per-row delete (→ DELETE) against a REST endpoint, and hides the file-model toolbar affordances (+ Add row / Save). It deliberately does NOT touch the file-save/row-ops machinery (ETag/conflict/row-file writes), so the secrets surface stays on the existing tested /.api/tokens endpoints. Server: handler.injectTableContextObj injects an arbitrary pre-assembled context; EmbeddedTablesHTML() exposes the renderer to sibling handlers; ServeTokensPage builds the token context (+ apiActions for /.api/tokens) and serves the tables HTML, falling back to the legacy skeleton only when the store or the tables renderer is unavailable. This is the first dynamic/virtual-record collection rendered by the same declarative engine + chrome as on-disk tables — no bespoke page. Validated end-to-end in a containerized browser (list + create→secret + revoke); tests/tokens.spec.js updated to the new UI; full Go suite green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
116 lines
2.8 KiB
Bash
Executable file
116 lines
2.8 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/tables.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
|
|
|
|
concat_files \
|
|
"../shared/fonts.css" \
|
|
"../shared/base.css" \
|
|
"../shared/toast.css" \
|
|
"../shared/elevation.css" \
|
|
"../shared/profile-menu.css" \
|
|
"../shared/logo.css" \
|
|
"../shared/context-menu.css" \
|
|
"css/table.css" \
|
|
"../form/css/form.css" \
|
|
> "$css_temp"
|
|
|
|
# Single bundle hosts both apps. mode.js runs first to set
|
|
# window.zddcMode based on the URL, then each app's main.js bails
|
|
# early when its mode isn't selected. Form modules live under
|
|
# window.formApp; table modules under window.tablesApp; no namespace
|
|
# collisions.
|
|
concat_files \
|
|
"../shared/vendor/js-yaml.min.js" \
|
|
"../shared/zddc.js" \
|
|
"../shared/zddc-source.js" \
|
|
"../shared/theme.js" \
|
|
"../shared/toast.js" \
|
|
"../shared/logo.js" \
|
|
"../shared/help.js" \
|
|
"../shared/elevation.js" \
|
|
"../shared/profile-menu.js" \
|
|
"../shared/cap.js" \
|
|
"../shared/context-menu.js" \
|
|
"js/mode.js" \
|
|
"js/app.js" \
|
|
"js/context.js" \
|
|
"js/util.js" \
|
|
"js/filters.js" \
|
|
"js/sort.js" \
|
|
"js/editor.js" \
|
|
"js/undo.js" \
|
|
"js/add-row.js" \
|
|
"js/save.js" \
|
|
"js/row-ops.js" \
|
|
"js/clipboard.js" \
|
|
"js/export.js" \
|
|
"js/render.js" \
|
|
"js/api-actions.js" \
|
|
"js/main.js" \
|
|
"../form/js/app.js" \
|
|
"../form/js/context.js" \
|
|
"../form/js/util.js" \
|
|
"../form/js/widgets.js" \
|
|
"../form/js/object.js" \
|
|
"../form/js/array.js" \
|
|
"../form/js/render.js" \
|
|
"../form/js/serialize.js" \
|
|
"../form/js/errors.js" \
|
|
"../form/js/post.js" \
|
|
"../form/js/main.js" \
|
|
> "$js_raw"
|
|
|
|
escape_js_close_tags "$js_raw" "$js_temp"
|
|
|
|
compute_build_label "tables" "${1:-}" "${2:-}"
|
|
|
|
awk -v css_file="$css_temp" -v js_file="$js_temp" -v build_label="$build_label" -v is_red="$is_red" -v favicon_uri="$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
|
|
}
|
|
/\{\{FAVICON\}\}/ {
|
|
gsub(/\{\{FAVICON\}\}/, favicon_uri)
|
|
print
|
|
next
|
|
}
|
|
/<script src="https?:\/\// { next }
|
|
/<link rel="stylesheet" href="https?:\/\// { next }
|
|
{ print }
|
|
' "$src_html" > "$output_html"
|
|
|
|
echo "Wrote $output_html"
|
|
|
|
if [ "$is_release" = "1" ]; then
|
|
promote_release "tables"
|
|
fi
|