[MLton-commit] r4069

Stephen Weeks MLton@mlton.org
Mon, 5 Sep 2005 21:17:49 -0700


Added a script to grab the wiki and create a reasonably self-contained
set of web pages, intended to be shipped as documentation with
packages.


----------------------------------------------------------------------

A   mlton/trunk/bin/grab-wiki

----------------------------------------------------------------------

Added: mlton/trunk/bin/grab-wiki
===================================================================
--- mlton/trunk/bin/grab-wiki	2005-09-05 21:33:10 UTC (rev 4068)
+++ mlton/trunk/bin/grab-wiki	2005-09-06 04:17:48 UTC (rev 4069)
@@ -0,0 +1,99 @@
+#!/bin/bash
+
+set -e
+set -x
+
+name=`basename $0`
+dir=`dirname $0`
+src=`cd $dir/.. && pwd`
+
+die () {
+        echo >&2 "$1"
+        exit 1
+}
+
+usage () {
+        die "usage: $name"
+}
+
+case "$#" in
+0)
+;;
+*)
+	usage
+;;
+esac
+
+TIMEFORMAT='  Took %lR.'
+
+base='http://mlton.org'
+version=`date +%Y%m%d`
+
+index='.index'
+script='.script'
+tmp='.tmp'
+
+cd "$src/doc/guide"
+
+rm -f *
+
+drop='\(Download\|.*MoinEditorBackup\|OldPages\|Preferences\|RecentChanges\|TemporaryBugExamples\|TemporaryUpload\|WikiSandBox\)'
+
+echo "Getting index:" 
+lynx -dump "$base/Index?action=titleindex" | \
+    grep -v >$index -e '^$' -e "^$drop$"
+
+echo "Getting pages:" 
+wget -B $base -c -nv -i $index
+ 
+echo "Getting CSS:"
+for f in common screen print; do
+	wget -c $base/wiki/mlton/css/$f.css
+done
+
+echo "Getting images:"
+for f in bottom email ftp top www; do
+	wget -c $base/wiki/mlton/img/moin-$f.png
+done
+
+echo "Fixing pages:" 
+
+# Eliminate ungrabbed pages from Index.
+grep -v "$drop" Index >$tmp
+mv $tmp Index
+
+# Write sed script to file.
+cat >$script <<EOF
+# Delete search box.
+/<form .* action = "http:\/\/www.google.com\/custom">/,+6d
+# Replace highlight actions with no-op.
+s;"\([^"]*\).action=highlight[^"]*";"\1";g
+# Delete Index actions.
+/<a href *= *"Index?.*"/d
+# Delete unused link rel.
+/<link rel="\(Glossary\|Help\|Index\|Search\)"/d
+# Delete <a> and <link> actions.
+s;<a[^>]* href *= *"[^"]*?action[^"]*">.*</a>;;g
+s;<link[^>]* href *= *"[^"]*?action[^"]*">;;g
+# Add version stamp in upper left.
+s;<a class = mltona\(.*\)>MLton</a>;<a class = mltona\1>MLton $version</a>;
+# Fix wiki hrefs and srcs
+s; \(href\|src\) *= *"\(/pages/[^"]*\)"; \1="$base\2";g
+s; \(href\|src\) *= *"/\([^"]\+\)"; \1="\2";g
+s; href *= *"/"; href="Home";g
+s; href *= *"$drop"; href="$base/\1";g
+s; \(href\|src\) *= *"wiki/mlton/[^/]\+/\([^"]*\)"; \1="\2";g
+EOF
+
+for f in $(cat $index); do
+	echo $f
+	head -n -19 <$f >$tmp
+	(
+		sed -f $script <$tmp
+		echo '</body></html>'
+	) >$f
+done
+
+rm -f $tmp $index $script 
+
+cp Home index.html


Property changes on: mlton/trunk/bin/grab-wiki
___________________________________________________________________
Name: svn:executable
   + *