[m-dev.] for review: generate index files on web site
David Glen JEFFERY
dgj at cs.mu.OZ.AU
Mon Jun 26 18:53:29 AEST 2000
On 26-Jun-2000, Peter Ross <petdr at cs.mu.OZ.AU> wrote:
> On Mon, Jun 26, 2000 at 06:32:55PM +1000, David Glen JEFFERY wrote:
> > We'll try again. Note that the solution implemented here will potentially
> > cause problems if the different machines invoke generate_index_html at
> > the same time. Is this worth worrying about?
> >
> Maybe the best thing to do would be to output to index.html.$$ and then
> move it to index.html at the end.
Jolly good idea, but I'll make it index.html.$HOST instead.
Here's the new generate_index_html:
#!/bin/sh
#
# generate_index_html
#
# Generates index.html files with a link to each file in the directory, and
# recursively for its sub-directories.
#
# Note: This script recursively calls itself, so it had better be in its
# own path!
#
INDEX=index.html.$HOST
trap 'rm -f $INDEX; exit 1' 1 2 3 13 15
#
# These are the standard locations for apache's icons
#
img_txt="<img src=/icons/text.gif>"
img_dir="<img src=/icons/folder.gif>"
img_bak="<img src=/icons/back.gif>"
echo "<H1>Directory listing</H1>" > $INDEX
echo "<hr>" >> $INDEX
echo "$img_bak <a href=../>Parent Directory</a><br>" >> $INDEX
for file in *
do
if [ $file != index.html ] && [ $file != README ]
then
if [ -d $file ]
then
(cd $file && generate_index_html)
echo "$img_dir <a href=$file/>$file/</a><br>" >> $INDEX
else
size=`ls -l $file | awk '{ print $5; }'`
sizekb=`expr $size / 1024`
echo "$img_txt <a href=$file>$file</a> ($sizekb kilobytes)<br>" >> $INDEX
fi
fi
done
echo "<hr>" >> $INDEX
if [ -f README ]
then
echo "<pre>" >> $INDEX
cat README >> $INDEX
echo "</pre>" >> $INDEX
fi
chmod a+r,g+w $INDEX
chgrp mercury $INDEX
mv $INDEX index.html
dgj
--
David Jeffery (dgj at cs.mu.oz.au) | If your thesis is utterly vacuous
PhD student, | Use first-order predicate calculus.
Dept. of Comp. Sci. & Soft. Eng.| With sufficient formality
The University of Melbourne | The sheerist banality
Australia | Will be hailed by the critics: "Miraculous!"
| -- Anon.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list