[m-rev.] for review: improve web site download index

Simon Taylor stayl at cs.mu.OZ.AU
Mon Aug 19 14:58:22 AEST 2002


I've attached some sample output, note that the file sizes are mostly
zero because I only copied the file names, not the files themselves.

Simon.


Estimated hours taken: 3

tools/generate_index_html:
	Improve the index.html files generated for the download
	area of the web site so that the files are grouped by
	release with proper descriptions on the links, rather than
	just listed in alphabetical order.

Index: generate_index_html
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/generate_index_html,v
retrieving revision 1.4
diff -u -u -r1.4 generate_index_html
--- generate_index_html	4 Jul 2000 02:28:59 -0000	1.4
+++ generate_index_html	19 Aug 2002 04:47:37 -0000
@@ -10,6 +10,7 @@
 #
 
 INDEX=index.html.$HOST
+handled_files=
 
 trap 'rm -f $INDEX; exit 1' 1 2 3 13 15
 
@@ -29,29 +30,208 @@
 echo "<BODY>" >> $INDEX
 echo "<H1>Directory listing</H1>" >> $INDEX
 echo "<hr>" >> $INDEX
+
+# link_to_file prefix filename description.
+#
+# Generate a line with the prefix followed by a link to the given file.
+# Record that the file has been handled.
+link_to_file () {
+	prefix=$1
+	this_file=$2
+	this_file_descr=$3
+	this_file_size=`ls -l $this_file | awk '{ print $5; }'`
+	this_file_sizekb=`expr $this_file_size / 1024`
+	handled_files="$this_file $handled_files"
+	echo "$prefix <a href=$this_file>$this_file_descr</a> ($this_file_sizekb kilobytes)" >> $INDEX 
+}
+
+# link_to_file filename description
+#
+# Generate a link to a file if it exists.
+# This should be called within a `<ul>' element.
+link_to_existing_file () {
+	if [ -f $1 ]; then
+		link_to_file "<li> " $1 "$2"
+	fi
+}
+
+# handle_release release_file
+#
+# Given the name of a source or binary distribution file in a release,
+# generate an entry describing all the files in the release.
+handle_release () {
+	file=$1
+	if [ -f $file ]
+	then
+		case "$handled_files" in
+		*$file*)	;;
+		*)		do_handle_release $file ;;
+		esac
+	fi
+}
+
+do_handle_release () {
+	file=$1
+	date=`echo $file | \
+		sed -e's/.*\([0-9]\{4\}-[0-9][0-9]-[0-9][0-9]\).*/\1/'`
+
+	case $file in
+	    *-rotd*-unstable*)
+		release_name="Unstable snapshot $date"
+		release_id="rotd-$date-unstable"
+		;;
+	    *-rotd*)
+		release_name="Stable snapshot $date"
+		release_id="rotd-$date"
+		;;
+	    *-0.10.2-beta*-unstable*)
+		release_name="Unstable 0.10.2 beta $date"
+		release_id="0.10.2-beta-$date-unstable"
+		;;
+	    *-0.10.2-beta*)
+		release_name="Stable 0.10.2 beta $date"
+		release_id="0.10.2-beta-$date"
+		;;
+	    *-0.10.1*)
+		release_name="Release 0.10.1"
+		release_id="0.10.1"
+		;;
+	    *-0.10*)
+		release_name="Release 0.10"
+		release_id="0.10"
+		;;
+	    *)
+		# Unknown release, this will be put in the list of
+		# other files after all known releases.
+		return 0
+		;;
+	esac
+
+	echo "<li> $release_name" >> $INDEX
+	echo '<ul>' >> $INDEX
+	link_to_existing_file NEWS-$release_id "NEWS"
+	link_to_existing_file INSTALL-$release_id "Installation instructions"
+	link_to_existing_file mercury-compiler-$release_id.tar.gz \
+		"Source distribution"
+	link_to_existing_file mercury-compiler-$release_id-1.src.rpm \
+		"Source RPM"
+	link_to_existing_file mercury-compiler-$release_id-1.i386.rpm \
+		"RPM (x86)"
+	link_to_existing_file mercury_$release_id-1_i386.deb "Debian (x86)"
+	bindists=`echo mercury-$release_id.[a-z]*.tar.gz`
+	case "$bindists" in
+	    *'*'.tar.gz)
+		;;
+	    *)
+		echo "<li> Binary distributions" >> $INDEX
+		echo "<ul>" >> $INDEX
+		for bindist in $bindists
+		do
+			bindist_name=`echo $bindist | \
+			    sed -e"s/mercury-$release_id.\(.*\).tar.gz/\1/"`
+			link_to_file "<li> " $bindist $bindist_name	
+		done
+		echo "</ul>" >> $INDEX
+		;;
+	esac
+	link_to_existing_file mercury-extras-$release_id.tar.gz "Extras"
+	link_to_existing_file mercury-tests-$release_id.tar.gz "Test suite"
+	link_to_existing_file test-failures-$release_id "Test failures"
+	echo '</ul><p>' >> $INDEX
+}
+
 echo "$img_bak <a href=../>Parent Directory</a><br>" >> $INDEX
 
-for file in * 
+#
+# Directories.
+#
+for file in *
 do
-        #
-	# Don't include the README or any of the index files
-	#
-    case $file in
-        README|index.html*) 
-	    ;;
+	if [ -d $file ]
+	then
+		(cd $file && generate_index_html)
+		echo "$img_dir <a href=$file/>$file/</a><br>" >> $INDEX
+	fi
+done
+
+
+echo "<p>" >> $INDEX
+echo "<ul>" >> $INDEX
+
+#
+# Handle releases. Note that handle_release checks for files
+# which have been handled before, so the cases below need not
+# be mutually exclusive.
+#
+
+#
+# Current release.
+#
+handle_release mercury-compiler-0.10.1.tar.gz
+
+#
+# Stable beta for current release + bug fixes.
+# There may be an unstable beta, but there's no point using it.
+#
+for file in mercury-compiler-0.10.2-beta*.tar.gz mercury-0.10.2-beta*.tar.gz
+do
+	case $file in
+		*-unstable*) ;;
+		*)	handle_release $file ;;
+	esac
+done
+
+#
+# Stable release-of-the-day.
+#
+for file in mercury-compiler-rotd*.tar.gz mercury-rotd-*
+do
+	case $file in
+		*-unstable*) ;;
+		*)	handle_release $file ;;
+	esac
+done
+
+#
+# Unstable release-of-the-day
+#
+for file in mercury-compiler-rotd-*-unstable.tar.gz
+do
+	handle_release $file
+done
+
+#
+# Other assorted releases.
+#
+for file in mercury-compiler-* mercury-rotd-*
+do
+	handle_release $file
+done
 
-	*)  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
-	    ;;
+#
+# Other stuff.
+#
+for file in *
+do
+    case $file in
+		#
+		# Don't include the README or any of the index files
+		#
+	README|index.html*)
+		;;
+	*)
+		if [ ! -d $file ]
+		then
+			case $handled_files in
+				*$file*) ;;
+				*)	link_to_file "<li> " $file $file ;;
+			esac
+		fi
+    		;;
     esac
 done
+
+echo "</ul>" >> $INDEX
 
 echo "<hr>" >> $INDEX
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20020819/1cd47ae7/attachment.html>


More information about the reviews mailing list