Subversion Repositories wimsdev

Rev

Rev 7622 | Rev 7790 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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