#! /usr/bin/gawk -f # Last edited on 2008-02-04 18:24:53 by stolfi BEGIN{ usage = ( ARGV[0] " [ -v title=STRING ] < INDEXFILE > INDEXPAGE" ); abort = -1; # Reads from stdin a list of lines of the form KEY IMGDIR, # sorted by KEY. Assigns an integer page number PAGE to each # distinct KEY. Then writes to stdout a master HTML index with # all keys, and creates two files for each PAGE: # # "htitle/PAGE" with the corresponding KEY, and # "entries/PAGE" with the corresponding IMGDIRs, one per line. # # In the "htitle/PAGE" file, the KEY has its braces removed, # "_" replaced by " ", and the characters <"'> quoted as in HTML. if (title == "") { title = "Image index"; } else { title = iso_to_html(title); } pg = 0; okey = ""; # Print header: printf "\n"; printf "\n"; printf "%s", title; printf "\n"; printf "\n"; printf "\n"; printf "

%s

", title; printf "\n"; printf "\n"; printf "\n"; printf "\n"; close("/dev/stdout"); } function iso_to_html(str) { gsub(/&/, "\\&", str); # "\\&#;" gsub(/"/, "\\"", str); # "\\&#;" gsub(//, "\\>", str); # "\\&#;" return str; } function data_error(f,n,msg) { printf "line %d: %s\n", FNR, msg > "/dev/stderr"; abort = 1; exit 1 }