Rev 14816 | Rev 17871 | 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 |
15581 | bpr | 51 | class_header=$wims_doc |
52 | def=$class_header |
||
53 | src=$class_header/src |
||
54 | fi |
||
7240 | bpr | 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 |
||
15581 | bpr | 61 | dd=${i%.def} |
62 | if [ ! -f $2/$dd ]; then |
||
63 | echo Removing $def/$i. |
||
64 | rm -f $1/$i >/dev/null; |
||
65 | fi |
||
7240 | bpr | 66 | done |
67 | } |
||
20 | reyssat | 68 | |
11402 | bpr | 69 | clean_src ( ) { |
70 | rm -f $1/.src/* >/dev/null; |
||
11672 | bpr | 71 | rmdir $1/.src 2>/dev/null; |
11402 | bpr | 72 | } |
73 | |||
7240 | bpr | 74 | ## generation des .def |
75 | gen_doc ( ) { |
||
76 | def=$1 |
||
77 | src=$2 |
||
78 | srcf=`cd $src; ls 2>/dev/null | grep -v '.hd$'` |
||
79 | for i in $srcf |
||
80 | do |
||
15581 | bpr | 81 | dd=$i.def |
82 | dh=$i.hd |
||
83 | if [ ! -f $src/$dh ]; then |
||
84 | awk '/^!if/ {exit}; {print}' $def/$dd >$src/$dh 2>/dev/null |
||
85 | fi |
||
86 | if [ ! -f $def/$dd ] || [ $src/$i -nt $def/$dd ]; then |
||
87 | rm -f $def/$dd 2>/dev/null |
||
88 | $wims_home/bin/msg2wims $src/$i tmp |
||
89 | cat $src/$dh >$def/$dd 2>/dev/null |
||
7240 | bpr | 90 | ## make here some perl conversions on the file tmp |
91 | ## as s:</li>\s*<p>\s*<li>:\n</li><li>\n:g; |
||
15581 | bpr | 92 | $wims_home/public_html/scripts/docu/conversion.pl tmp |
93 | cat <<@ >>$def/$dd |
||
20 | reyssat | 94 | !if \$wims_read_parm!=\$empty |
14816 | bpr | 95 | !goto \$wims_read_parm |
20 | reyssat | 96 | !endif |
97 | !exit |
||
98 | |||
99 | :content |
||
100 | @ |
||
7240 | bpr | 101 | cat tmp >>$def/$dd |
102 | fi |
||
103 | done |
||
104 | rm -f tmp |
||
105 | } |
||
20 | reyssat | 106 | |
7240 | bpr | 107 | index_file () { |
15581 | bpr | 108 | cd $1 |
109 | filelist=`ls *.def 2>/dev/null` |
||
110 | echo >.index |
||
111 | for f in $filelist |
||
112 | do |
||
113 | fs=${f%.def} |
||
114 | tit=`awk -F= '/titb.*=/ {print $2; exit}' $f` |
||
115 | if [ -n "$tit" ]; then |
||
116 | echo ":$fs |
||
20 | reyssat | 117 | $tit" >>.index |
15581 | bpr | 118 | fi |
119 | done |
||
7240 | bpr | 120 | } |
7248 | bpr | 121 | |
122 | latex2wims ( ) { |
||
15581 | bpr | 123 | perl $wims_home/public_html/modules/adm/latex2wims/latex2wims.pl --subdir=$1 --docdir=$lastdir --embed=document $2.tex |
7248 | bpr | 124 | } |
125 | |||
7240 | bpr | 126 | ## on cherche les parametres $def $src |
20 | reyssat | 127 | |
7248 | bpr | 128 | mk_doc ( ) { |
15581 | bpr | 129 | cd $lastdir |
130 | doc_type $1 |
||
131 | if [ ! -d $def ]; then |
||
132 | echo Directory $def not found. |
||
133 | def=. |
||
134 | src=$def/src |
||
135 | ##exit; |
||
136 | fi |
||
7240 | bpr | 137 | if [ ! -d $src ]; then |
138 | echo Directory $src not found. |
||
139 | exit; |
||
140 | fi |
||
7248 | bpr | 141 | ##latex2wims |
7260 | bpr | 142 | if [ -f "$lastdir/doc/srctex/0index" ]; then |
15581 | bpr | 143 | cd "$lastdir/doc/srctex" |
144 | cat 0index | while read dd |
||
145 | do |
||
146 | if [ ! -z "${dd}" ] ; then latex2wims ${dd}; fi |
||
147 | done |
||
148 | fi |
||
149 | cd $lastdir |
||
150 | ## cleaning file.def where file has been deleted |
||
151 | clean_doc $def $src |
||
152 | ## cleaning .src if it exists |
||
153 | clean_src $def |
||
154 | ## generated file *.def |
||
7240 | bpr | 155 | gen_doc $def $src |
15581 | bpr | 156 | ##definition files |
7240 | bpr | 157 | index_file $def |
158 | } |
||
159 | |||
160 | ## main program ! |
||
161 | |||
162 | if [ -f $lastdir/doc/.def ] ; then |
||
15581 | bpr | 163 | doclist=`awk -F'=' '$1=="doclist" {print $2}' $lastdir/var.proc` |
7240 | bpr | 164 | fi |
165 | if [ -z "$doclist" ]; then doclist="1" ; fi |
||
7622 | bpr | 166 | for l in $doclist; do mk_doc $l; echo "" ; echo "$l done"; done |
7240 | bpr | 167 | |
168 | ### in case of a class, the parameter of doc () do not mind ! |
||
169 | ### many global variables yet |