Subversion Repositories wimsdev

Rev

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