#!/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/classifier.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 to concatenate in order concat_files \ "../shared/fonts.css" \ "../shared/base.css" \ "../shared/toast.css" \ "../shared/nav.css" \ "../shared/logo.css" \ "css/base.css" \ "css/layout.css" \ "css/spreadsheet.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 tag. Required for any tool with template literals. escape_js_close_tags "$js_raw" "$js_temp" compute_build_label "classifier" "${1:-}" "${2:-}" # Process template: inject CSS/JS, substitute build label, strip CDN refs. 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\}\}/, "" build_label "") } else { gsub(/\{\{BUILD_LABEL\}\}/, build_label) } print next } /\{\{FAVICON\}\}/ { gsub(/\{\{FAVICON\}\}/, favicon_uri) print next } /