
Sectie [
Webmaster ,
3 - Over de RGD WWW server ]
Sectie
De hiervoor beschreven Ontwerp uitgangspunten (3.3) werden gerealiseerd met een aantal tools, die alle op het Internet vrij verkrijgbaar zijn. Voor de conversie van WordPerfect documenten (en Word) werd het zeer handige conversie programma Wp2Html gebruikt, dat weliswaar niet public domain is, maar slechts enkele (Engelse) ponden kost. Met dit programma is bv. de voorconversie van het CCCEE document gedaan (oorspronkelijk in Word en via WP 5.1 DOS format geconverteerd).
Verder worden er een aantal zelfgebrouwen scripts gebruikt voor diverse taken. We geven van een aantal daarvan (partiële) listings.
Dit C shell script hernoemt '.htm' files naar '.html':
#!/bin/csh
# htm2html.csh: rename .htm file(s) to .html in current directory.
echo '.htm -> .html'
foreach f ( *.htm )
echo "/bin/mv -f ${f:r}.htm ${f:r}.html"
/bin/mv -f ${f:r}.htm ${f:r}.html
end
Het volgende C shell script vervangt een aantal patronen in html files. Een uitbreiding hierop zou bv. tags in lower case naar upper case kunnen zetten. Overigens is Perl [7] voor dit soort zaken meer geschikt. Perl is echter niet standaard aanwezig op Unix systemen.
#!/bin/csh
# replhtml.sh: replace some patterns in all html file(s) in current directory
# ----------- and below (recurse).
foreach f ( `find . -name '*.htm' -print` )
echo -n " ${f}"
if ( ! -w ${f} ) then
echo error: can not replace ${f}
exit 1
endif
cat < /dev/null > ${f}.$$
if ( ! -f ${f}.$$ ) then
echo error: can not write ${f}.$$
exit 1
endif
sed -e 's/http:\/\/internal.machine.name/http:\/\/www.rgd.nl/g' \
$f > ${f}.$$
/bin/mv -f ${f}.$$ $f
echo ''
end
Dit Bourne shell script converteert een ascii file naar HTML, rekening houdend met bijzondere characters als ">". En passant wordt ook een DOS ascii file geconverteerd. Let op: de ^M en ^Z in dit script moeten de werkelijke control characters zijn!
U kunt ook kiezen voor download ascii2html.sh
#!/bin/sh
#
# ascii2html.sh: Bourne shell script.
# Converts ascii file(s) to HTML.
# ALERT!! Replaces the ascii file with the HTML file.
#
# Features:
# 1. Converts the file to an IETF HTML 2.0 file.
# 2. All ascii text is put in a <PRE> formatted block.
# 3. The special characters '&', '<' and '>' are converted to
# &', '<' and '>' respectively.
# 4. Strip decimal 127 and higher from files by replacing it with a space;
# this is not a bug, we're converting _ascii_, right ;-].
# 5. Replace carriage return and control-Z with nothing (effectively
# converts a DOS file to Unix newline conventions).
#
# All this is done in a special order, so even Dos files turn out right
# under Unix. Tested under Linux 2.0 only.
#
# Eric Maryniak, e.maryniak@rgd.nl
# 1996-10-25
#
# Other users than me should change "webmaster@rgd.nl" to an appropiate
# e-mail address. Btw, a LINK makes weblint happy ;-)
# Hi there !
echo 'Ascii to HTML converter - Eric Maryniak'
# Internal checks.
MV="/bin/mv"
if [ ! -f /bin/mv ]; then
echo 'Help, /bin/mv does not exist !'
exit 1
fi
# If no arguments given, quit.
if [ $# -eq 0 ]; then
echo 'Usage: ascii2html.sh file1 [ file2 ... ]'
exit 1
fi
# Verify existence of files.
for f in $* ; do
if [ ! -f $f ]; then
echo Error: file \`$f\' does not exist.
exit 1
fi
if [ ! -w $f ]; then
echo Error: file \`$f\' is not writable \(cannot convert it\).
exit 1
fi
done
TEMPIE=ascii2html.sh.$$
for f in $* ; do
echo -n "Processing \`$f' ..."
cat <<EOHEAD1 > $TEMPIE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<LINK REV=MADE HREF="mailto:webmaster@rgd.nl">
EOHEAD1
echo "<TITLE>$f: converted from ascii to html</TITLE>" >> $TEMPIE
echo "<!-- On ISO 8601:1988 date/time: `date '+%Y-%m-%d %H:%M:%S'` -->" >> $TEMPIE
echo "<!-- By ascii2html.sh, (c) Eric Maryniak, e.maryniak@rgd.nl -->" >> $TEMPIE
echo "<!-- Conforms to weblint 1.017 and sgmls 1.1.91 -->" >> $TEMPIE
cat <<EOHEAD2 >> $TEMPIE
</HEAD>
<BODY>
<PRE>
EOHEAD2
# En passant convert a DOS type file as well.
# Note that the "^M" and "^Z" are control characters!
# In vi you can insert control characters with ^V (in insert mode).
# Also replace 8-bit characters with a space (_ascii_ to html!).
sed -e 's/^M//' -e 's/^Z//' -e 's/&/&/g' $f | \
sed -e 's/</\</g' -e 's/>/\>/g' | \
tr '\177-\377' ' ' >> $TEMPIE
cat <<EOBODY >> $TEMPIE
</PRE>
</BODY>
</HTML>
EOBODY
if [ ! -f $TEMPIE ]; then
echo Error: cannot write temporary file in current directory.
exit 1
fi
$MV $TEMPIE $f
echo ' done'
done
echo All files done\!
exit 0
Sectie [
Webmaster ,
3 - Over de RGD WWW server ]
Sectie