#! /bin/csh -f
# jtb 010617
# Some files in the "bulk download" file must be edited before
# being stored in bulk.zip. These include files that have HTML
# code for features that are only implemented online (e.g., the 
# search engine, etc.). This script takes care of those files.
# Unsuitable code is tagged thus:
#
#	... HTML code ...
#	<!--BULK_CUT_START-->
#	... unsuitable code ...
#	<!--BULK_CUT_END-->
#	... more HTML CODE ...
#
# The lines between the two tags will be deleted.
#

set sedFile="~/bin/bulkfix.sed"

foreach x ($*)

echo -n filtering `basename $x`...
if (-e $x && $x:e == html) then
	# The following is a kludgey test. We shouldn't have
	# the tag embedded both in this code and in the sed script.
	grep -q BULK_CUT $x # see if the file contains the tag
	if (! $status) then # if it does, then...
		sed -f $sedFile $x > $x.tmp # make a filtered version
		mv $x.tmp $x
		chmod a+r $x
	endif
else
	echo Can\'t find file \'$x\' or not an .html file\!
	exit
endif
	echo "done. "
end
