/[MITgcm]/manual/tools/figchange.sh
ViewVC logotype

Annotation of /manual/tools/figchange.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download) (as text)
Thu Feb 28 19:30:25 2002 UTC (22 years, 2 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint57l_post, checkpoint01, HEAD
File MIME type: application/x-sh
Adding extra online manual customisation tools

1 cnh 1.1 #!/bin/csh -f
2     set flist = ( `find figsub -name '*.html' -maxdepth 1 ` )
3    
4     # Work through all the figsub .html subdirectories
5     foreach f ( $flist )
6     set fnode = `echo $f | sed s'/figsub\/\([^\/]*\).*/\1/'`
7     set fdir = ( figsub/$fnode )
8     echo Doing figures for node $fnode using directory $fdir
9    
10     # Work through all the subs for each node
11     # Must work in reverse numeric order to allow ed edits
12     # at the end.
13     echo $fdir/sub* | sed s'/[^ ]*\/sub\([0-9]*\)/\1/g' \
14     | tr ' ' '\n' | sort -n -r > figsub/temp-slist.$$
15     set slist = `cat figsub/temp-slist.$$`
16     \rm figsub/temp-slist.$$
17     foreach sn ( $slist )
18     set s = ( ${fdir}/sub${sn} )
19     set snum = `echo $s | sed s'/.*sub\(.*\)/\1/'`
20     set sline = `cat $s/startline`
21     set eline = `cat $s/endline`
22     echo " "substitution number $snum from line $sline to $eline
23     set newfigdir = `head -1 $s/extracted_html | awk '{print $2}'`
24     echo " "substitute figure directory is ../on-line-figs/$newfigdir
25    
26     #
27     # o Look for substitute figure directory (named according to word after MITGCM_INSERT_.... )
28     # under the directory ../on-line-figs
29     #
30     if ( ! -d ../on-line-figs/$newfigdir ) then
31     echo " **"directory ../on-line-figs/$newfigdir not found, skipping substitution
32     echo " "
33     break
34     endif
35    
36     #
37     # o Look for substitute img part of the html. This is in file img.html within
38     # the substitute figure directory. If its not found we used the original
39     # extract in extracted_html_img. Substituting full img part can be
40     # used to replace static image with animated gif or an applet.
41     #
42     if ( -f ../on-line-figs/$newfigdir/img.html ) then
43     echo " "substitute image html ../on-line-figs/$newfigdir/img.html wll be used
44     set subimfile = ../on-line-figs/$newfigdir/img.html
45     else
46     echo " "no substitute img, original img html $s/extracted_html_img will be used
47     set subimfile = $s/extracted_html_img
48     endif
49    
50     #
51     # o Look for substitute caption part of the html. This is in file caption.html within
52     # the substitute figure directory. If its not found we used the original
53     # extract in extracted_html_caption. Substituting full caption can be used to
54     # create totally different cption for on-line doc.
55     #
56     if ( -f ../on-line-figs/$newfigdir/caption.html ) then
57     echo " "substitute caption html ../on-line-figs/$newfigdir/caption.html wll be used
58     set subcapfile = ../on-line-figs/$newfigdir/caption.html
59     else
60     echo " "no substitute caption, original caption html $s/extracted_html_caption will be used
61     set subcapfile = $s/extracted_html_caption
62     endif
63    
64     #
65     # o Look for simple URL insert. This is used if we just want figure
66     # to be a hyperlink and leave evrything else unchanged.
67     # Note - having a scheme for putting the URL in the source latex
68     # would be nice but, many URLs (especially ingrid ones) contains
69     # embedded % characters. These are taken as comments and discarded
70     # even within a rawhtml block. So instead we opt to put the
71     # URL in a file.
72     #
73     if ( -f ../on-line-figs/$newfigdir/URL ) then
74     set imgurl = `cat ../on-line-figs/$newfigdir/URL`
75     else
76     set imgurl = ""
77     endif
78    
79     # Insert replacement into node
80     # Insert puts in original labels, modified or original caption and
81     # img. The fignum from the original is always used. If a modified caption
82     # is used then it needs to contain a dummy figure number block that
83     # will be substituted.
84     set fnum = `cat $s/extracted_html_fignum`
85     set stnum = `cat $s/startline`
86     set fnnum = `cat $s/endline`
87     echo ${stnum},${fnnum}c > temp-figchange.$$
88     echo '<!--- 'MITGCM_INSERT_FIGURE_BEGIN ${newfigdir}' -->' >> temp-figchange.$$
89     echo '<P></P>' >> temp-figchange.$$
90     cat $s/extracted_html_labels >> temp-figchange.$$
91     echo '<TABLE>' >> temp-figchange.$$
92     cat $subcapfile | \
93     sed s'/Figure [^:]*:/'"$fnum"'/' \
94     >> temp-figchange.$$
95     cat $subimfile >> temp-figchange.$$
96     echo '</TABLE>' >> temp-figchange.$$
97     echo '</DIV><P></P>' >> temp-figchange.$$
98     echo '<!--- 'MITGCM_INSERT_FIGURE_END' -->' >> temp-figchange.$$
99     echo '.' >> temp-figchange.$$
100     echo w >> temp-figchange.$$
101     echo q >> temp-figchange.$$
102     cp temp-figchange.$$ figsub/temp-figchange
103     \rm temp-figchange.$$
104     # Insert the img url if there is one.
105     if ( "$imgurl[1]" != "" ) then
106     echo '/\/CAPTION/' > figsub/ed2
107     echo '/TD/' >> figsub/ed2
108     echo 's/TD>/TD>\' >> figsub/ed2
109     echo '/' >> figsub/ed2
110     echo 'i' >> figsub/ed2
111     echo '<A href='"$imgurl"'>' >> figsub/ed2
112     echo '.' >> figsub/ed2
113     echo '/TD/' >> figsub/ed2
114     echo 's/<\/TD>/\' >> figsub/ed2
115     echo '<\/TD>/' >> figsub/ed2
116     echo i >> figsub/ed2
117     echo '</A>' >> figsub/ed2
118     echo '.' >> figsub/ed2
119     echo 'w' >> figsub/ed2
120     echo 'q' >> figsub/ed2
121     cat figsub/ed2 | ed figsub/temp-figchange
122     endif
123     cat figsub/temp-figchange | ed $fnode
124     end
125    
126     end

  ViewVC Help
Powered by ViewVC 1.1.22