2021-02-23
------------------------------------------------------------------

Since I am not very smart with code, I like to keep stuff
extremely modular. If something doesn't work, I can usually find
it faster than if it was all in one file.

I created a few scripts to create an html version of my
gopherhole. You can check it out at http://undo.freak.net

Here's a script to change the gophermap links into html:
------------------------------------------------------------------

workdir=$HOME/html-script
echo "Parsing links from gophermap"
cat $HOME/gopher/gophermap | grep ^0 | rev | cut -s -f1 | rev | \
sed 's/^/<a href="\.\//' | sed 's/$/\"/'> $workdir/links
cat $HOME/gopher/gophermap | grep ^0 | sed 's/^0.* - //' | \
cut -s -f1 | sed 's/$/<\/a><br>/' > $workdir/names
paste -d">" $workdir/links $workdir/names > $workdir/listoflinks
rm $workdir/links $workdir/names

This one combines two html-fragments to the list of links:
------------------------------------------------------------------

workdir=$HOME/html-script
cat pagestart > $workdir/index.html
cat listoflinks >> $workdir/index.html
cat pageend >> $workdir/index.html

This one copies the text files:
------------------------------------------------------------------

workdir=$HOME/html-script
echo "Copying j, t, q, c and b"
cp $HOME/gopher/j* $HOME/html/
cp $HOME/gopher/t* $HOME/html/
cp $HOME/gopher/q* $HOME/html/
cp $HOME/gopher/c* $HOME/html/
cp $HOME/gopher/b* $HOME/html/

This one runs the above scripts and changes the permission:
------------------------------------------------------------------

/goptolinks.sh
/createpage.sh
/gopcopy.sh
echo "Copying index"
cp index.html $HOME/html
echo "Setting permissions"
mkhomepg -p
echo "Done"