#!/bin/sh # stand-alone server for the java application that annotates diagrams # # At the centre it has a triggering role on a set of stick-e notes, # but it also assumes rules are needed to convert between the caller's # world and the stick-e rule; on the way in these rules convert the # setting of the present convert, and on the way out they convert # the output from triggering # This converted output is the final result # # "-x" as first argument means extract contexts (for drawing points on map) # # SERVER FOR ANNOTATED GRAPHS # has 4 parameters: # 1: a setting of the present context e.g. 199834..36 # 2: the name of the notesfile (relative to pjb webpages directory) # example: annotations/psion.notes # Alternatively this can be a URL # In the file case, the file can be a "driver file" whose content # gives the files to be used; this is assumed to be the case when # the content begins with -f; example content: -f file1 -f file2 # 3: the rules for mapping contexts from the world of the application # (as given by the first parameter) to the world of the notes, # if rules are null, the two worlds are the same; # again this can be a file or a URL # 4: (optional) extra argument for the triggerring stage (e.g. recipe and/or activeTags) # In addition, if the switch "-x" is on the front, mapping is applied # both to input to SetRigger and to the triggered notes; default is not to # do the latter; -x is used for extracting the area to draw on the map; # it is not used for triggered notes, since the user wants to see these # in their original form. # # to test this outside an applet use ~pjb/java/sem*/rpsion # echo "Content-type: text/html" echo if test ! -z "$5"; then echo "" fi # # the old version used $1 etc; this decodes $QUERY_STRING #echo "QUERY_STRING is $QUERY_STRING" PATH=.:/home/pjbrown/bin:/usr/java/bin:/usr/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/jdk/bin:/usr/X11R6/bin:/usr/local/jdk/bin:$PATH cd /home/pjbrown # all files are addressed relative to this Q=`echo $QUERY_STRING | sed "s/+/ /g"` echo "" set -- $Q echo "" SWITCH=$1 #KOPTION=-ki # -ki means apply rules to input #TOPTION="-et -t" # -et means switch off automatic setting of timw, -t means trigger if test X"$1" = "X-x"; then # KOPTION=-kio # TOPTION="-et -e0 -tm" # -e0 means suppress explanation, -tm means return the field(s) that match the present context (eg match and ) # SEPARATOR="-----" shift fi echo "" # this is a magic command that redirects all subsequent errors to stdout exec 2>&1 # do URL decodings (NB these may be in upper or lower case: eg %3A or %3a) # actually the conversion below have already been done SETTINGS=`echo $1 | sed "$SED_COMMANDS s/%20/ /g s/%2C/,/g s/%2c/,/g s/%2F/\//g s/%2f/\//g s/%3B/;/g s/%3b/;/g s/%3C//g s/%3e/>/g "` echo "" EXTRAS=`echo $4 | sed "$SED_COMMANDS s/%20/ /g s/%2C/,/g s/%2c/,/g s/%2F/\//g s/%2f/\//g s/%3B/;/g s/%3b/;/g s/%3C//g s/%3e/>/g "` echo "" # remove encoded / from filename FILE=`echo $2 | sed "s/%2F/\//g s/%2f/\//g s/%3A/:/g s/%3a/:/g "` # remove : and / from URL RULES=`echo $3 | sed "s/%2F/\//g s/%2f/\//g s/%3A/:/g s/%3a/:/g "` echo "" # # FILE itself may itself contain a list of files, with -f on the front # if so set FILE to the content of FILE #FILE="$FILE.notes" if test -r "$FILE"; then set -- `head -1 $FILE` if test "$1" = "-f"; then FILE=`cat $FILE` fi fi echo "" if test -f oldcode; then # This just calls the SeTrigger module (which has the name "combined") # SeTrigger may in turn use SeMapper to apply the conversion rules # sometimes rm does not work because it cannot chain back from the current directory # hence the line below (which ensures that a new /tmp/entities.sgml is used): (cd / && rm -f /tmp/entities.sgml) # ask "combined" to output tags in the form: # was:START_TAG_TEMPLATE="|NB||EXPLAIN||*|<%s>|" export START_TAG_TEMPLATE SEPARATOR="" # separator of notes triggered by SeTrigger export SEPARATOR START_OF_OUTPUT_USERTAG=" " export END_OF_OUTPUT_USERTAG START_TAG_TEMPLATE="|*|<%s>|" export START_TAG_TEMPLATE END_TAG_TEMPLATE="" export END_TAG_TEMPLATE echo " " bin/combined -f $FILE $KOPTION "$RULES" -M "$SETTINGS" $TOPTION #./combined -f $FILE $KOPTION "$RULES" -M "$SETTINGS" -t -E present (cd / && rm -f /tmp/entities.sgml) else MATCHER=java/semapper/matcher if test "$SWITCH" = -x; then # extract the bounds $MATCHER "$RULES" "EXTRACT" -a -d "$SETTINGS" else # here we do 3 things: apply the rules to convert the present context; trigger; convert back again # assume $SETTINGS may be a literal or a file or a URL RESULT1=`$MATCHER "$RULES" -d "$SETTINGS"` #echo "" #echo "Calling $MATCHER -a $FILE -d $EXTRAS -l $RESULT1" RESULT2=`$MATCHER -a $FILE -d "$EXTRAS" -l "$RESULT1"` #echo "" $MATCHER -r "$RULES" -l "$RESULT2" fi fi