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