/usr/bin/pmlindex is in photoml 0.28-0ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | #! /bin/sh
# This script constructs an HTML index of PhotoML files
# Copyright © 2003-2011 Brendt Wohlberg <photoml@wohlberg.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License at
# http://www.gnu.org/licenses/gpl-2.0.txt.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# Most recent modification: 11 February 2011
# Set up paths to pmltrans and pmlexpand utilities
pmlpath="/usr/share/photoml"
pmltransx="/usr/bin/pmltrans"
pmlexpandx="/usr/bin/pmlexpand"
# Ensure that xsltproc, pmltrans, and pmlexpand are available
if [ ! "`which xsltproc 2>/dev/null`" ]; then
echo "pmlindex: error executing xstlproc" >&2
exit 1
fi
if [ ! -x "$pmltransx" ]; then
echo "pmlindex: error executing pmltrans" >&2
exit 1
fi
if [ ! -x "$pmlexpandx" ]; then
echo "pmlindex: error executing pmlexpand" >&2
exit 1
fi
# Function for displaying usage information
usage()
{
cat <<EOF >&2
usage: pmlindex [-h] [-y] [-s size] (([-e] [-m]) | [-d]) [-p dst-path]
infile [infile] ...
-h Display usage information
-y Group table entries by year
-s size Specify primary font size in points
-e Include exposure detail column when appropriate
-m Include location map when coordinates specified
-d Use detailed rather than summary output
-p dst-path Path to directory into which output should be written
EOF
}
# Parse command line arguments
yflag=''
ygp=''
sflag=''
fsp=''
eflag=''
mflag=''
dflag=''
dstpath='.';
while [ $# -ge 1 ]; do
case $1 in
-y) yflag='-y'; ygp="--stringparam year-group 1" ;;
-s) shift; sflag="-s $1"; fsp="--stringparam font-size $1" ;;
-e) eflag='-e' ;;
-m) mflag='-m' ;;
-d) dflag='-d' ;;
-p) shift; dstpath=$1 ;;
-*) usage; exit 1 ;;
*) break ;;
esac
shift
done
# Display usage information if appropriate
if [ "$1" = '' ]; then
usage; exit 1
fi
# Make destination directory if necessary
mkdir -p $dstpath
# Set up paths to support XSL
xsl0="$pmlpath/xsl/html/preindex.xsl"
xsl1="$pmlpath/xsl/html/index.xsl"
# Set up temporary file paths
tmpidx="/tmp/pmlindex.idx.$$"
tmpexp="/tmp/pmlindex.exp.$$"
# Open root element of XML index source file
echo "<photoindex>" > $tmpidx
# Iterate over all files to be indexed
for src in $@; do
# Generate error if a file could not be read
if [ ! -r "$src" -o ! -f "$src" ]; then
echo "pmlindex: could not read file $src" 1>&2
exit 2
fi
# Set up path variables
srcbase=`basename $src .xml`
dst="$dstpath/$srcbase.html"
# Apply pmltrans (with defaults expansion) if the HTML
# representation of the current PhotoML file does not exist,
# or is out of date with respect to its source
if [ ! -e "$dst" -o "$src" -nt "$dst" ]; then
$pmltransx -x $eflag $mflag $dflag $sflag $src > $dst
if [ ! $? -eq 0 ]; then
echo "pmlindex: error running pmltrans" 1>&2
rm -f $tmpidx $tmpexp
exit 3
fi
fi
if grep -q '<!-- IndexCache:' $dst; then
# If index data cached as a comment in the current HTML file,
# extract and use in the index source file
indexdata=`grep '<!-- IndexCache:' $dst | sed -e 's/<!-- IndexCache: //'\
-e 's/-->.*//' -e 's/\\-/-/g' -e 's/\>/>/g' -e 's/\</</g'`
echo "<file xml=\"$src\" html=\"$srcbase.html\">$indexdata</file>"\
>> $tmpidx
else
# If index data not cached as a comment in the current HTML file,
# expand the defaults in the current PhotoML file and determine
# them. Insert details of the current PhotoML file in the index
# source file, and append the index cache as a comment to the
# current HTML file.
$pmlexpandx $src $tmpexp
if [ ! $? -eq 0 ]; then
echo "pmlindex: error running pmlexpand" 1>&2
rm -f $tmpidx $tmpexp
exit 4
fi
idxsrc=`xsltproc --novalid $xsl0 $tmpexp 2>/dev/null`
rm -f $tmpexp
echo "<file xml=\"$src\" html=\"$srcbase.html\">$idxsrc</file>" >> $tmpidx
indexdata=`echo $idxsrc | tr -d '\n' | sed -e 's/>[ \t]*</></g'\
-e 's/</\</g' -e 's/>/\>/g' -e 's/-/\\-/g'`
echo "<!-- IndexCache: $indexdata -->" >> $dst
fi
done
# Close root element of XML index source file
echo "</photoindex>" >> $tmpidx
# Process XML index source file to generate HTML index
xsltproc $ygp $fsp $ecp $xsl1 $tmpidx > "$dstpath/index.html"
# Clean up
rm -f $tmpidx
exit 0
|