Subversion Repositories wimsdev

Rev

Rev 13392 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/bin/sh

#line 1: <img src= address>
#line 2: graphviz/number_of_image
#line 3: size in pixels width,height
#line 4 and following: plain output (for the coordinates)

if [ "$wims_exec_parm" = "" ] || [ "$s2_dir" = "" ] || [ ! -d "$s2_dir" ]; then
    exit
fi

tstamp=`date '+%s'`

if [ "$wims_exec_parm" = "about" ]; then
    dd=`./bin/ch..root dot -V 2>&1| head -1` ;
    echo "<a href=\"http://www.graphviz.org\">Graphviz</a> ($dd)" ;
 exit;
fi

if [ -z "$w_graphviz_charset" ]; then w_graphviz_charset="iso-8859-1"; fi
if [ -z "$w_graphviz_output" ]; then w_graphviz_output='png' ;  fi
if [ -z "$w_graphviz_format" ]; then w_graphviz_format="dot"; fi ;
if [ "$w_graphviz_format" != 'dot' -a "$w_graphviz_format" != 'neato'  -a "$w_graphviz_format" != 'circo' -a "$w_graphviz_format" != 'fdp' -a "$w_graphviz_format" != 'twopi' ];  then w_graphviz_format='dot'; fi
mkdir -p $s2_dir/graphviz
i=1 ;
lsout=`ls $s2_dir/graphviz/*.$w_graphviz_output 2>/dev/null`
for file in $lsout
do
  num=`basename $file .$w_graphviz_output`
  if [ $i -le $num ]; then i=$(( $num+1 )) ; fi
done

parm="-T$w_graphviz_output -o $tmp_dir/graphviz.$w_graphviz_output -Tplain -Gcharset=$w_graphviz_charset"
cat <<@ >$tmp_dir/graphviz
$wims_exec_parm
@

./bin/ch..root $w_graphviz_format $parm $tmp_dir/graphviz > $tmp_dir/graphviz.plain
if [ -f "../chroot/tmp/sessions/.chroot" ]; then
  chroot=1;
else
  chroot=0;
fi;

cp $tmp_dir/graphviz.$w_graphviz_output $s2_dir/graphviz/$i.$w_graphviz_output
if [ -f "$s2_dir/graphviz/$i.$w_graphviz_output" ]; then
  if [ "$w_graphviz_output" = "svg" ]; then
    cat "$s2_dir/graphviz/$i.$w_graphviz_output"
    echo "plain"
    cat "$tmp_dir/graphviz.plain"
  else
    echo "wims.cgi?session=$w_session&+cmd=getins&+special_parm=graphviz/$i.$w_graphviz_output&+modif=$tstamp"
    if [ "$chroot" = "0" ] ; then
      identify -format \%w,\%h $s2_dir/graphviz/$i.$w_graphviz_output
    else
      ./bin/ch..root identify -format \%w,\%h $tmp_dir/graphviz.$w_graphviz_output
    fi;
    echo ""
    cat $tmp_dir/graphviz.plain
  fi
fi
rm $tmp_dir/graphviz.$w_graphviz_output
exit