[m-dev.] for review: generate index files on web site

David Glen JEFFERY dgj at cs.mu.OZ.AU
Mon Jun 26 18:32:55 AEST 2000


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?

===================================================================

Estimated hours taken: 3

Seeing that the departmental www server no longer generates indexes for
directories without an index.html (or whatever), generate suitable index
files for the directories in download/files/

tools/generate_index_html:
	New file that generates index files for a directory and all its
	sub-directories.
tools/test_mercury:
	Execute generate_index_html after all the new beta releases have been
	installed.
tools/run_all_tests_from_cron:
	Check out the new version of generate_index_html


Index: run_all_tests_from_cron
===================================================================
RCS file: /home/staff/zs/imp/mercury/tools/run_all_tests_from_cron,v
retrieving revision 1.17
diff -u -t -r1.17 run_all_tests_from_cron
--- run_all_tests_from_cron	1999/10/26 15:38:10	1.17
+++ run_all_tests_from_cron	2000/06/26 08:26:47
@@ -65,6 +65,8 @@
 cvs checkout mercury/tools/test_mercury
 cp mercury/tools/test_mercury $tmpscript
 
+cvs checkout mercury/tools/generate_index_html
+
 #-----------------------------------------------------------------------------#
 
 echo run_test $HOST
Index: test_mercury
===================================================================
RCS file: /home/staff/zs/imp/mercury/tools/test_mercury,v
retrieving revision 1.109
diff -u -t -r1.109 test_mercury
--- test_mercury	2000/04/19 05:44:28	1.109
+++ test_mercury	2000/06/26 08:25:09
@@ -110,6 +110,7 @@
 BETA_FTPHOST=ftp.mercury.cs.mu.oz.au
 BETA_FTPDIR=/home/ftp/pub/mercury/beta-releases
 BETA_WEBDIR=/home/mercury5/installed_w3/download/files/beta-releases
+BETA_WEBDIR_TOP=/home/mercury5/installed_w3/download/files/
 
 STABLE=$DIR/mercury-latest-stable
 UNSTABLE=$DIR/mercury-latest-unstable
@@ -658,5 +659,12 @@
         exit 1
         ;;
 esac
+
+# Now rebuild the index files on the www site
+(
+export PATH=`pwd`:$PATH
+cd $BETA_WEBDIR_TOP
+generate_index_html
+)
 
 #-----------------------------------------------------------------------------#

New File: 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

    #
    # 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




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