#! /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). This script takes care of those files. # Unwanted code is tagged thus: # # ... HTML code ... # # ... unsuitable code ... # # ... more HTML CODE ... # # The lines between the two tags will be deleted. # Similarly, we might want to add text to the bulk download file # (e.g., "Internet connection required."). # This script looks for BULK_ADD tags, as in: # # ... HTML code ... # # ... HTML code ... # # The text between the two tags will be un-commented. # # In both cases, the tags may be in-line or on different lines. # # jtb 020126: fixed bug that prevented files containing only ADD # text from being filtered. set me=$0:t # the name of this program goto Start ###################################################################### Usage: echo "bulkfix got: $*" echo "Usage: $me version time name file1 [file2 ...]" echo "Fixes html files going into the bulk file, and applies the" echo " version number and bulk time stamps where needed" echo echo " version a quoted string to insert as the bulk version number" echo " time a quoted string to insert as the bulk time stamp" echo " name a quoted string to insert as the bulk file name" echo exit Start: if ($# < 4) then goto Usage endif set theVersion="$1" set theTime="$2" set theName="$3" shift; shift;shift; set addTag = "_BULK_ADD_" set cutTag = "_BULK_CUT_" set stampTag = "_BULKVERSION_" # jtb 050525: Embedded the sed script stuff here # so we don't need a separate (and very ugly) sed command file. #--------------------------------- # Create a stream-editor (sed) command file set sedFile="/tmp/${me}.sed" cat << END_INPUT > $sedFile # This is a sed script to edit an ATI html file for off-line use # by stripping the BULK_CUT and BULK_ADD tags # # # jtb 050129: I removed this chunk: # s/\[\[//g # from the block below that begins # /_BULK_ADD_END_-->/{ # because we don't need it anymore. BBEdit's "Comment" and "Uncomment" # commands no longer convert < and > to [[ and ]]. # # s/.*//g //{ :top N //!b top } //d //!b top2 } /${addTag}END_-->/{ s/~~/--/g } s///g END_INPUT #--------------------------------- foreach x ($*) # echo "${me} trying ${x}..." if (-e $x && $x:e == html) then # if it exists and is an .html file... grep -q $addTag $x # then look for the tag set addStatus = $status # save the results of the test grep -q $cutTag $x # look for the tag in the file set cutStatus = $status # save the results of the test grep -q $stampTag $x # look for the tag in the file set stampStatus = $status # save the results of the test if (! $addStatus || ! $cutStatus) then#if either tag was found, then... sed -f $sedFile $x > $x.tmp # ... filter the file mv $x.tmp $x chmod a+r $x set modified # and make a note that the file was modified endif if (! $stampStatus) then # if the BULKVERSION tag was found... stamp_bulk "$theVersion" "$theTime" "$theName" $x #...then stamp version info set modified # and make a note that the file was modified endif if (${?modified}) then # if the files was modified, then... stamp_rev-date $x # ...stamp the revision date else echo "${me}: no tags found in file ${x} (${addTag}, ${cutTag}, ${stampTag})." endif else echo "Can't find file '$x' or not an .html file." endif end rm $sedFile