-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_branded_html.sh
More file actions
executable file
·30 lines (25 loc) · 1.14 KB
/
create_branded_html.sh
File metadata and controls
executable file
·30 lines (25 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Script to create a branded HTML document from TEI XML
# Usage: ./create_branded_html.sh input.xml [site_title] [brand_name]
TEI_FILE="$1"
SITE_TITLE="${2:-UC Press E-Books Collection, 1982-2004}"
BRAND_NAME="${3:-UC Press E-Books Collection, 1982-2004}"
if [ -z "$TEI_FILE" ]; then
echo "Usage: $0 <tei_file.xml> [site_title] [brand_name]"
exit 1
fi
# Convert TEI to HTML fragment
TEI_CONTENT=$(docker run --rm -v "$(dirname "$(realpath "$TEI_FILE")"):/data" ucpec_static:latest exe/ucpec_static t 2h "/data/$(basename "$TEI_FILE")")
# Render the shared layout template, CSS is read from files inside Ruby
export SITE_TITLE BRAND_NAME
ruby -r erb -e "
include ERB::Util
SITE_TITLE = ENV['SITE_TITLE']
BRAND_NAME = ENV['BRAND_NAME']
base_css = File.read('templates/base.css') rescue ''
page_css = File.read('templates/styles.css') rescue ''
page_title = nil
tei_content = STDIN.read
page_content = %(<main class=\"document-content\">\n <div class=\"container\">\n #{tei_content}\n </div>\n </main>)
print ERB.new(File.read('templates/_layout.html.erb'), trim_mode: '-').result(binding)
" <<< "$TEI_CONTENT"