#!/bin/csh -f # make_html_for_image_and_caption # ------------------------------------------------------------------------- # Shell script to create an HTML fragment to show an image and its caption. # ------------------------------------------------------------------------- # Revision History: # $Log$ # ------------------------------------------------------------------------- # Collect command line options set option_thumbs = "false" while ($#argv > 0) if ("$1" == "-h" || "$1" == "--help") then echo "Usage: $0:t [options] image_file caption_file > fragment.htm" echo "Options:" echo " -h = Show this help text" echo " --help = Show this help text" echo ' --thumbs = Show the same-named image file from the "thumbs"' echo ' subdirectory with a clickable link to the image' exit 1 else if ($1:q == "--thumbs") then shift set option_thumbs = "true" else if ("-" == "`echo $1:q | cut -c 1`") then echo "Error: Invalid option: $1:q" $0 --help exit 1 else # Not a recognized option. Assume it's the first argument break endif end # Collect command line arguments # Note: Do not check for the existence and readability if ($#argv != 2) then $0 --help exit 1 else if ("${option_thumbs}" == "false" && ! -e $1:t:q) then # Strip incoming "../" from image name via :t when doing slides, not thumbs echo "Error: File $1:t:q does not exist." exit 1 else if ("${option_thumbs}" == "true" && ! -e $1:q) then echo "Error: File $1:q does not exist." exit 1 else if ("${option_thumbs}" == "false" && ! -r $1:t:q) then # Strip incoming "../" from image name via :t when doing slides, not thumbs echo "Error: File $1:t:q is not readable." exit 1 else if ("${option_thumbs}" == "true" && ! -r $1:q) then echo "Error: File $1:q is not readable." exit 1 else if (! -e $2:q) then # No problem. Caption file is allowed to not exist. Captions are optional. # echo "Error: File $2:q does not exist." # exit 1 else if (! -r $2:q) then echo "Error: File $2:q is not readable." exit 1 endif set image_file = $1:q set caption_file = $2:q #?? It's sloppy to re-compute this here, as well as in makeslides. #?? Should pass in as a parameter. #?? Also, now we're blurring the distinction between generating an album only #?? or also a slideshow (-s option of make_and_pub_index_htm_from_jpgs). #?? We're relying on the slideshow folder existing, even without the -s #?? option. Should fix to either get rid of -s option entirely and always #?? do a slideshow as well as the album, or to have 2 modes here: one #?? where slide_file is the image and the other where it is the HTM file. set slide_file = "slideshow/${image_file:r}.htm" if ("${option_thumbs}" == "true") then # Nothing to do. Don't need to load these JS libraries at each thumbnail # in the album. They're already loaded once at the top of the album page. # They need to be loaded only in the standalone slides. else # Echo the following lines while expanding dollar sign vars # ?? Add below: cat < EOF endif if ("${option_thumbs}" == "true") then echo " " else echo "
" endif if ("${option_thumbs}" == "true") then # Nothing to do. Don't need a return link at each thumbnail in the # album. They're needed only in the standalone slides. else # Echo the following lines w/o expanding dollar sign vars, or anything # Seems to be the only way to generate the onClick line where we use both # single and double quotes, so we can't also quote the entire string as # a param to echo. The following did not work. Reported: Unmatched '. #??echo "onClick='com.bristle.jslib.Presentation.returnToParentPage(\"../index.htm\")'" cat <<"EOF" "EOF" endif echo " " # Do NOT use valign='top' on this TD. It's not necessary since the IMG # will always fill the height of the TD anyhow. And it causes problems # when we dynamically rotate images via JavaScript code that sets the CSS # transform property. Rotating images does not change the width or height # properties of the IMG, so when the TD uses the height property of the # IMG to decide how to position it within the TD to cause the vertical # alignment to the top of the TD, it gets the wrong value -- the old # un-rotated height value. Dynamic image rotation is most commonly used # for pictures taken in portrait mode by turning a camera vertical, so # that the image is lot lying on it's side. The un-rotated width is # usually more than the un-rotated height. So, when the TD uses the # un-rotated height for its calcuation, it gets a smaller value than the # rotated heights, so it positions the IMG too close to the top of the # TD, and overflows the TD, perhaps even being clipped by the top of the # browser window. # echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo "
Album
" echo " " # TODO: This doesn't work if the filename contains an apostrophe. # End up with invalid href (broken link) and invalid src # (broken image). if ("${option_thumbs}" == "true") then # Echo the following lines while expanding dollar sign vars cat < EOF else # Echo the following lines while expanding dollar sign vars cat < . symlink to main album folder. --> EOF endif echo "
" if ("${option_thumbs}" == "true") then echo " " echo " $image_file:t" echo " " else # Don't make the image filename clickable either. echo " " echo " $image_file:t" echo " " endif echo "
" echo " " if ("${option_thumbs}" == "true") then # Nothing to do. Don't make captions in albums bigger. Looks too # clunky with small thumbnails. else # Make captions bigger for slideshow. Looks better, especially on # small screens like mobile devices (tablets, phones, etc.) echo " " endif echo " " if (-e $caption_file:q) then cat $caption_file:q endif echo " " if ("${option_thumbs}" == "true") then # Insert a blank line at the end of the caption to cause tables in album # to be spaced slightly vertically. #?? Note: Better to do this via margin-botton of table, so any border #?? around the entire table would not contain this blank line? echo "

" else echo "
" endif echo "
" echo "
" if ("${option_thumbs}" == "true") then # Nothing to do. else echo " " echo "" endif