1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
#! /bin/sh
## global variable
thisdir=`pwd`
lastdir=$thisdir
if [ -z "$wims_home" ]; then wims_home=$1; fi;
if [ -z "$wims_home" ]; then wims_home=$w_wims_home; fi
## use in bin/mkindex
if [ -z "$w_wims_class" ] ; then wims_doc=$2 ; fi
while [ -z "$wims_home" ] && [ "$lastdir" != "/" ]
do
wims_home=`cat $lastdir/.wimshome 2>/dev/null`
lastdir=`dirname $lastdir`
done
if [ -z "$wims_home" ]; then
echo WIMS home directory not found.
exit;
fi
w_msg2wims_primitives=`grep msgprim $wims_home/public_html/scripts/primitives/allmsgprim | awk -F "=" '{print $2}'`
export w_msg2wims_primitives
### macro : structure of the document : define $def and $src
### the parameter is the name of the directory in doc (not used in a class)
doc_type () {
test=
if [ ! -z "$w_wims_class" ]; then
test=`echo $thisdir | grep '/classes/..$'`
fi
if [ ! -z "$test" ] && [ -d $wims_home/log/classes/$w_wims_class ]; then
class_header=$wims_home/log/classes/$w_wims_class
ntest=`awk -F'=' '$1=="sharing_doc" {print $2}' $class_header/neighbors`
if [ ! -z "$ntest" ] && [ -d "$wims_home/log/classes/$ntest/src" ]; then
class_header=$wims_home/log/classes/$ntest
fi
### no document like that - come from oef ?
def=$class_header/def
src=$class_header/src
mkdir -p $def
else
class_header=
def=doc/$1
src=$def/src
fi
if [ -z "$class_header" ] && [ ! -z "$wims_doc" ]
then
class_header=$wims_doc
def=$class_header
src=$class_header/src
fi
}
clean_doc ( ) {
deff=`cd $1; ls *.def 2>/dev/null`
for i in $deff
do
dd=${i%.def}
if [ ! -f $2/$dd ]; then
echo Removing $def/$i.
rm -f $1/$i >/dev/null;
fi
done
}
clean_src ( ) {
rm -f $1/.src/* >/dev/null;
rmdir $1/.src 2>/dev/null;
}
## generation des .def
gen_doc ( ) {
def=$1
src=$2
srcf=`cd $src; ls 2>/dev/null | grep -v '.hd$'`
for i in $srcf
do
dd=$i.def
dh=$i.hd
if [ ! -f $src/$dh ]; then
awk '/^!if/ {exit}; {print}' $def/$dd >$src/$dh 2>/dev/null
fi
if [ ! -f $def/$dd ] || [ $src/$i -nt $def/$dd ]; then
rm -f $def/$dd 2>/dev/null
$wims_home/bin/msg2wims $src/$i tmp
cat $src/$dh >$def/$dd 2>/dev/null
## make here some perl conversions on the file tmp
## as s:</li>\s*<p>\s*<li>:\n</li><li>\n:g;
$wims_home/public_html/scripts/docu/conversion.pl tmp
cat <<@ >>$def/$dd
!if \$wims_read_parm!=\$empty
!goto \$wims_read_parm
!endif
!exit
:content
@
cat tmp >>$def/$dd
fi
done
rm -f tmp
}
index_file () {
cd $1
filelist=`ls *.def 2>/dev/null`
echo >.index
for f in $filelist
do
fs=${f%.def}
tit=`awk -F= '/titb.*=/ {print $2; exit}' $f`
if [ -n "$tit" ]; then
echo ":$fs
$tit" >>.index
fi
done
}
latex2wims ( ) {
perl $wims_home/public_html/modules/adm/latex2wims/latex2wims.pl --subdir=$1 --docdir=$lastdir --embed=document $2.tex
}
## on cherche les parametres $def $src
mk_doc ( ) {
cd $lastdir
doc_type $1
if [ ! -d $def ]; then
echo Directory $def not found.
def=.
src=$def/src
##exit;
fi
if [ ! -d $src ]; then
echo Directory $src not found.
exit;
fi
##latex2wims
if [ -f "$lastdir/doc/srctex/0index" ]; then
cd "$lastdir/doc/srctex"
cat 0index | while read dd
do
if [ ! -z "${dd}" ] ; then latex2wims ${dd}; fi
done
fi
cd $lastdir
## cleaning file.def where file has been deleted
clean_doc $def $src
## cleaning .src if it exists
clean_src $def
## generated file *.def
gen_doc $def $src
##definition files
index_file $def
}
## main program !
if [ -f $lastdir/doc/.def ] ; then
doclist=`awk -F'=' '$1=="doclist" {print $2}' $lastdir/var.proc`
fi
if [ -z "$doclist" ]; then doclist="1" ; fi
for l in $doclist; do mk_doc $l; echo "" ; echo "$l done"; done
### in case of a class, the parameter of doc () do not mind !
### many global variables yet
|