~ubuntu-branches/ubuntu/jaunty/luatex/jaunty

« back to all changes in this revision

Viewing changes to src/libs/zziplib/docs/mksite.sh

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2007-09-24 12:56:11 UTC
  • Revision ID: james.westby@ubuntu.com-20070924125611-a8ge689azbptxvla
Tags: upstream-0.11.2
ImportĀ upstreamĀ versionĀ 0.11.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
# this is the sh/sed variant of the mksite script. It is largely
 
3
# derived from snippets that I was using to finish doc pages for 
 
4
# website publishing. For the mksite project the functionaliy has
 
5
# been expanded of course. Still this one does only use simple unix
 
6
# commands like sed, date, and test. And it still works. :-)=)
 
7
#                                               http://zziplib.sf.net/mksite/
 
8
#   THE MKSITE.SH (ZLIB/LIBPNG) LICENSE
 
9
#       Copyright (c) 2004 Guido Draheim <guidod@gmx.de>
 
10
#   This software is provided 'as-is', without any express or implied warranty
 
11
#       In no event will the authors be held liable for any damages arising
 
12
#       from the use of this software.
 
13
#   Permission is granted to anyone to use this software for any purpose, 
 
14
#       including commercial applications, and to alter it and redistribute it 
 
15
#       freely, subject to the following restrictions:
 
16
#    1. The origin of this software must not be misrepresented; you must not
 
17
#       claim that you wrote the original software. If you use this software 
 
18
#       in a product, an acknowledgment in the product documentation would be 
 
19
#       appreciated but is not required.
 
20
#    2. Altered source versions must be plainly marked as such, and must not
 
21
#       be misrepresented as being the original software.
 
22
#    3. This notice may not be removed or altered from any source distribution.
 
23
# $Id: mksite.sh,v 1.4 2005/05/14 15:08:23 guidod Exp $
 
24
 
 
25
# Zsh is not Bourne compatible without the following: (seen in autobook)
 
26
if test -n "$ZSH_VERSION"; then
 
27
  emulate sh
 
28
  NULLCMD=:
 
29
fi
 
30
 
 
31
# initialize some defaults
 
32
test ".$SITEFILE" = "." && test -f "site.htm"  && SITEFILE="site.htm"
 
33
test ".$SITEFILE" = "." && test -f "site.html" && SITEFILE="site.html"
 
34
test ".$SITEFILE" = "." && SITEFILE="site.htm"
 
35
MK="-mksite"     # note the "-" at the start
 
36
SED="sed"
 
37
CAT="cat"        # "sed -e n" would be okay too
 
38
GREP="grep"
 
39
DATE_NOW="date"  # should be available on all posix systems
 
40
DATE_R="date -r" # gnu date has it / solaris date not
 
41
STAT_R="stat"    # gnu linux
 
42
LS_L="ls -l"     # linux uses one less char than solaris
 
43
 
 
44
INFO="~~"     # extension for meta data files
 
45
HEAD="~head~" # extension for head sed script
 
46
BODY="~body~" # extension for body sed script
 
47
FOOT="~foot~" # append to body text (non sed)
 
48
FAST="~move~" # extension for printer friendly sed
 
49
 
 
50
NULL="/dev/null"                             # to divert stdout/stderr
 
51
CATNULL="$CAT $NULL"                         # to create 0-byte files
 
52
SED_LONGSCRIPT="$SED -f"
 
53
 
 
54
LOWER="abcdefghijklmnopqrstuvwxyz"
 
55
UPPER="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
56
az="$LOWER"                                  # some old sed tools can not
 
57
AZ="$UPPER"                                  # use char-ranges in the 
 
58
NN="0123456789"                              # match expressions so that
 
59
AA="_$NN$AZ$az"                              # we use their unrolled
 
60
AX="$AA.+-"                                  # definition here
 
61
if $SED -V 2>$NULL | $GREP "GNU sed" >$NULL ; then
 
62
az="a-z"                                     # but if we have GNU sed
 
63
AZ="A-Z"                                     # then we assume there are
 
64
NN="0-9"                                     # char-ranges available
 
65
AA="_$NN$AZ$az"                              # that makes the resulting
 
66
AX="$AA.+-"                                  # script more readable
 
67
elif uname -s | $GREP HP-UX >$NULL ; then
 
68
SED_LONGSCRIPT="sed_longscript"              # due to 100 sed lines limit
 
69
fi
 
70
 
 
71
LANG="C" ; LANGUAGE="C" ; LC_COLLATE="C"     # these are needed for proper
 
72
export LANG LANGUAGE LC_COLLATE              # lowercasing as some collate
 
73
                                             # treat A-Z to include a-z
 
74
 
 
75
# ==========================================================================
 
76
# reading options from the command line                            GETOPT
 
77
opt_variables="files"
 
78
opt_fileseparator="?"
 
79
opt_files=""
 
80
opt_main_file=""
 
81
opt_formatter="$0"
 
82
opt=""
 
83
for arg in "$@"        # this variant should allow to embed spaces in $arg
 
84
do if test ".$opt" != "." ; then
 
85
      eval "export opt_$opt='$arg'"
 
86
      opt=""
 
87
   else
 
88
      case "$arg" in
 
89
      -*=*) 
 
90
         opt=`echo "$arg" | $SED -e "s/-*\\([$AA][$AA-]*\\).*/\\1/" -e y/-/_/`
 
91
         if test ".$opt" = "." ; then
 
92
            echo "ERROR: invalid option $arg" >&2
 
93
         else
 
94
            arg=`echo "$arg" | $SED -e "s/^[^=]*=//"`
 
95
            eval "export opt_$opt='$arg'"
 
96
            opt_variables="$opt_variables $opt"
 
97
         fi
 
98
         opt="" ;;
 
99
      -*-*)   
 
100
         opt=`echo "$arg" | $SED -e "s/-*\\([$AA][$AA-]*\\).*/\\1/" -e y/-/_/`
 
101
         if test ".$opt" = "." ; then
 
102
            echo "ERROR: invalid option $arg" >&2
 
103
            opt=""
 
104
         else :
 
105
            # keep the option for next round
 
106
         fi ;;
 
107
      -*)  
 
108
         opt=`echo "$arg" | $SED -e "s/^-*\\([$AA][$AA-]*\\).*/\\1/" -e y/-/_/`
 
109
         if test ".$opt" = "." ; then
 
110
            echo "ERROR: invalid option $arg" >&2
 
111
         else
 
112
            arg=`echo "$arg" | $SED -e "s/^[^=]*=//"`
 
113
            eval "export opt_$opt=' '"
 
114
         fi
 
115
         opt="" ;;
 
116
      *) if test ".$opt_main_file" = "." ; then opt_main_file="$arg" ; else
 
117
         test ".$opt_files" != "." && opt_files="$opt_files$opt_fileseparator"
 
118
         opt_files="$opt_files$arg" ; fi
 
119
         opt="" ;;
 
120
      esac
 
121
   fi
 
122
done ; if test ".$opt" != "." ; then
 
123
      eval "export opt_$opt='$arg'"
 
124
      opt=""
 
125
fi
 
126
### env | grep ^opt
 
127
 
 
128
test ".$opt_main_file" != "." && test -f "$opt_main_file" && \
 
129
SITEFILE="$opt_main_file"
 
130
test ".$opt_site_file" != "." && test -f "$opt_site_file" && \
 
131
SITEFILE="$opt_site_file"
 
132
 
 
133
if test ".$opt_help" != "." ; then
 
134
    F="$SITEFILE"
 
135
    echo "$0 [sitefile]";
 
136
    echo "  default sitefile = $F";
 
137
    echo "options:";
 
138
    echo " --filelist : show list of target files as ectracted from $F"
 
139
    echo " --src-dir xx : if source files are not where mksite is executed"
 
140
    echo " --tmp-dir xx : use temp instead of local directory"
 
141
    echo " --tmp : use automatic temp directory in ${TEMP-/tmp}/mksite.*"
 
142
    exit;
 
143
    echo " internal:"
 
144
    echo "--fileseparator=x : for building the internal filelist (default '?')"
 
145
    echo "--files xx : for list of additional files to be processed"
 
146
    echo "--main-file xx : for the main sitefile to take file list from"
 
147
fi
 
148
 
 
149
if test ".$SITEFILE" = "." ; then
 
150
   echo "error: no SITEFILE found (default would be 'site.htm')"
 
151
   exit 1
 
152
else
 
153
   echo "NOTE: sitefile: `ls -s $SITEFILE`"
 
154
fi
 
155
 
 
156
if "${SHELL-/bin/sh}" -c 'foo () { exit 0; }; foo' 2>$NULL ; then : ; else
 
157
echo "!! sorry, this shell '$SHELL' does not support shell functions"; exit 1
 
158
fi
 
159
 
 
160
tmp="." ; if test ".$opt_tmp_dir" != "." ; then tmp="$opt_tmp_dir" ; fi
 
161
if test ".$opt_tmp_dir" = "." && test ".$opt_tmp" != "." ; then
 
162
tmp="${TEMP-/tmp}/mksite.$$" ; fi
 
163
 
 
164
# we use external files to store mappings - kind of relational tables
 
165
MK_TAGS="$tmp/$MK.tags.tmp"
 
166
MK_VARS="$tmp/$MK.vars.tmp"
 
167
MK_META="$tmp/$MK.meta.tmp"
 
168
MK_METT="$tmp/$MK.mett.tmp"
 
169
MK_TEST="$tmp/$MK.test.tmp"
 
170
MK_FAST="$tmp/$MK.fast.tmp"
 
171
MK_GETS="$tmp/$MK.gets.tmp"
 
172
MK_PUTS="$tmp/$MK.puts.tmp"
 
173
MK_OLDS="$tmp/$MK.olds.tmp"
 
174
MK_SITE="$tmp/$MK.site.tmp"
 
175
MK_SECT1="$tmp/$MK.sect1.tmp"
 
176
MK_SECT2="$tmp/$MK.sect2.tmp"
 
177
MK_SECT3="$tmp/$MK.sect3.tmp"
 
178
MK_STYLE="$tmp/$MK.style.tmp"
 
179
MK_INFO="$tmp/$MK.$INFO"
 
180
 
 
181
# ========================================================================
 
182
# ========================================================================
 
183
# ========================================================================
 
184
#                                                             MAGIC VARS
 
185
#                                                            IN $SITEFILE
 
186
printerfriendly=""
 
187
sectionlayout="list"
 
188
sitemaplayout="list"
 
189
simplevars="warn"      # <!--varname-->default
 
190
attribvars=" "         # <x ref="${varname:=default}">
 
191
updatevars=" "         # <!--$varname:=-->default
 
192
expandvars=" "         # <!--$varname-->
 
193
commentvars=" "        # $updatevars && $expandsvars && $simplevars
 
194
sectiontab=" "         # highlight ^<td class=...>...href="$section"
 
195
currenttab=" "         # highlight ^<br>..<a href="$topic">
 
196
headsection="no"
 
197
tailsection="no"
 
198
sectioninfo="no"       # using <h2> title <h2> = info text
 
199
emailfooter="no"
 
200
 
 
201
if $GREP "<!--multi-->"               $SITEFILE >$NULL ; then
 
202
echo \
 
203
"WARNING: do not use <!--multi-->, change to <!--mksite:multi--> " "$SITEFILE"
 
204
echo \
 
205
"warning: or <!--mksite:multisectionlayout--> <!--mksite:multisitemaplayout-->"
 
206
sectionlayout="multi"
 
207
sitemaplayout="multi"
 
208
fi
 
209
if $GREP "<!--mksite:multi-->"               $SITEFILE >$NULL ; then
 
210
sectionlayout="multi"
 
211
sitemaplayout="multi"
 
212
fi
 
213
if $GREP "<!--mksite:multilayout-->"         $SITEFILE >$NULL ; then
 
214
sectionlayout="multi"
 
215
sitemaplayout="multi"
 
216
fi
 
217
 
 
218
mksite_magic_option ()
 
219
{
 
220
    # $1 is word/option to check for
 
221
    INP="$2" ; test ".$INP" = "." && INP="$SITEFILE"
 
222
    $SED \
 
223
      -e "s/\\(<!--mksite:\\)\\($1\\)-->/\\1\\2: -->/g" \
 
224
      -e "s/\\(<!--mksite:\\)\\([$AA][$AA]*\\)\\($1\\)-->/\\1\\3:\\2-->/g" \
 
225
      -e "/<!--mksite:$1:/!d" \
 
226
      -e "s/.*<!--mksite:$1:\\([^<>]*\\)-->.*/\\1/" \
 
227
      -e "s/.*<!--mksite:$1:\\([^-]*\\)-->.*/\\1/" \
 
228
      -e "/<!--mksite:$1:/d" -e q $INP # $++
 
229
}
 
230
 
 
231
x=`mksite_magic_option sectionlayout` ; case "$x" in
 
232
       "list"|"multi") sectionlayout="$x" ;; esac
 
233
x=`mksite_magic_option sitemaplayout` ; case "$x" in
 
234
       "list"|"multi") sitemaplayout="$x" ;; esac
 
235
x=`mksite_magic_option simplevars` ; case "$x" in
 
236
      " "|"no"|"warn") simplevars="$x" ;; esac
 
237
x=`mksite_magic_option attribvars` ; case "$x" in
 
238
      " "|"no"|"warn") attribvars="$x" ;; esac
 
239
x=`mksite_magic_option updatevars` ; case "$x" in
 
240
      " "|"no"|"warn") updatevars="$x" ;; esac
 
241
x=`mksite_magic_option expandvars` ; case "$x" in
 
242
      " "|"no"|"warn") expandvars="$x" ;; esac
 
243
x=`mksite_magic_option commentvars` ; case "$x" in
 
244
      " "|"no"|"warn") commentvars="$x" ;; esac
 
245
x=`mksite_magic_option printerfriendly` ; case "$x" in
 
246
        " "|".*"|"-*") printerfriendly="$x" ;; esac
 
247
x=`mksite_magic_option sectiontab` ; case "$x" in
 
248
      " "|"no"|"warn") sectiontab="$x" ;; esac
 
249
x=`mksite_magic_option currenttab` ; case "$x" in
 
250
      " "|"no"|"warn") currenttab="$x" ;; esac
 
251
x=`mksite_magic_option sectioninfo` ; case "$x" in
 
252
      " "|"no"|"[=:-]") sectioninfo="$x" ;; esac
 
253
x=`mksite_magic_option emailfooter` 
 
254
   test ".$x" != "." && emailfooter="$x"
 
255
 
 
256
test ".$opt_print" != "." && printerfriendly="$opt_print"
 
257
test ".$commentvars"  = ".no" && updatevars="no"   # duplicated into
 
258
test ".$commentvars"  = ".no" && expandvars="no"   # info2vars_sed ()
 
259
test ".$commentvars"  = ".no" && simplevars="no"   # function above
 
260
 
 
261
test -d DEBUG && \
 
262
echo "NOTE: '$sectionlayout'sectionlayout '$sitemaplayout'sitemaplayout"
 
263
test -d DEBUG && \
 
264
echo "NOTE: '$simplevars'simplevars '$printerfriendly'printerfriendly"
 
265
test -d DEBUG && \
 
266
echo "NOTE: '$attribvars'attribvars '$updatevars'updatevars"
 
267
test -d DEBUG && \
 
268
echo "NOTE: '$expandvars'expandvars '$commentvars'commentvars "
 
269
test -d DEBUG && \
 
270
echo "NOTE: '$currenttab'currenttab '$sectiontab'sectiontab"
 
271
test -d DEBUG && \
 
272
echo "NOTE: '$headsection'headsection '$tailsection'tailsection"
 
273
 
 
274
if ($STAT_R "$SITEFILE" >$NULL) 2>$NULL ; then : ; else STAT_R=":" ; fi
 
275
# ==========================================================================
 
276
# init a few global variables
 
277
#                                                                  0. INIT
 
278
 
 
279
mkpathdir () {
 
280
    if test -n "$1"  && test ! -d "$1" ; then
 
281
       echo "!! mkdir '$1'" ; mkdir "$1"
 
282
       test ! -d "$1" || mkdir -p "$1"
 
283
    fi
 
284
}
 
285
 
 
286
mkpathfile () {
 
287
    dirname=`echo "$1" | $SED -e "s:/[^/][^/]*\$::"`
 
288
    if test ".$1" != ".$dirname" && test ".$dirname" != "." ;
 
289
    then mkpathdir "$dirname"; fi
 
290
}
 
291
 
 
292
mknewfile () {
 
293
    mkpathfile "$1"
 
294
    $CATNULL > "$1" 
 
295
}
 
296
 
 
297
tmp_dir_was_created="no"
 
298
if test ! -d "$tmp" ; then mkpathdir "$tmp" ; tmp_dir_was_created="yes" ; fi
 
299
 
 
300
# $MK_TAGS - originally, we would use a lambda execution on each 
 
301
# uppercased html tag to replace <P> with <p class="P">. Here we just
 
302
# walk over all the known html tags and make an sed script that does
 
303
# the very same conversion. There would be a chance to convert a single
 
304
# tag via "h;y;x" or something we do want to convert all the tags on
 
305
# a single line of course.
 
306
mknewfile "$MK_TAGS"
 
307
for P in P H1 H2 H3 H4 H5 H6 DL DD DT UL OL LI PRE CODE TABLE TR TD TH \
 
308
         B U I S Q EM STRONG STRIKE CITE BIG SMALL SUP SUB TT THEAD TBODY \
 
309
         CENTER HR BR NOBR WBR SPAN DIV IMG ADRESS BLOCKQUOTE
 
310
do M=`echo "$P" | $SED -e "y/$UPPER/$LOWER/"`
 
311
  echo "s|<$P>|<$M class=\"$P\">|g"         >> "$MK_TAGS"
 
312
  echo "s|<$P |<$M class=\"$P\" |g"         >> "$MK_TAGS"
 
313
  echo "s|</$P>|</$M>|g"                    >> "$MK_TAGS"
 
314
done
 
315
  echo "s|<>|\\&nbsp\\;|g"                  >> "$MK_TAGS"
 
316
  echo "s|<->|<WBR />\\;|g"                 >> "$MK_TAGS"
 
317
# also make sure that some non-html entries are cleaned away that
 
318
# we are generally using to inject meta information. We want to see
 
319
# that meta ino in the *.htm browser view during editing but they
 
320
# shall not get present in the final html page for publishing.
 
321
DC_VARS="contributor date source language coverage identifier"
 
322
DC_VARS="$DC_VARS rights relation creator subject description"
 
323
DC_VARS="$DC_VARS publisher DCMIType"
 
324
_EQUIVS="refresh expires content-type cache-control"
 
325
_EQUIVS="$_EQUIVS redirect charset" # mapped to refresh / content-type
 
326
_EQUIVS="$_EQUIVS content-language content-script-type content-style-type"
 
327
for P in $DC_VARS $_EQUIVS ; do # dublin core embedded
 
328
   echo "s|<$P>[^<>]*</$P>||g"              >> "$MK_TAGS"
 
329
done
 
330
   echo "s|<!--sect[$AZ$NN]-->||g"          >> "$MK_TAGS"
 
331
   echo "s|<!--[$AX]*[?]-->||g"             >> "$MK_TAGS"
 
332
   echo "s|<!--\\\$[$AX]*[?]:-->||g"        >> "$MK_TAGS"
 
333
   echo "s|<!--\\\$[$AX]*:[?=]-->||g"       >> "$MK_TAGS"
 
334
   echo "s|\\(<[^<>]*\\)\\\${[$AX]*:[?=]\\([^<{}>]*\\)}\\([^<>]*>\\)|\\1\\2\\3|g"        >>$MK_TAGS
 
335
 
 
336
# see overview at www.metatab.de - http-equivs are
 
337
# <refresh>5; url=target</reresh>   or <redirect>target</redirect>
 
338
# <content-type>text/html; charset=koi8-r</content-type> iso-8859-1/UTF-8
 
339
# <content-language>de</content-language>             <charset>UTF-8</charset>
 
340
# <content-script-type>text/javascript</content-script-type> /jscript/vbscript
 
341
# <content-style-type>text/css</content-style-type>
 
342
# <cache-control>no-cache</cache-control>
 
343
 
 
344
trimm ()
 
345
{
 
346
    echo "$1" | $SED -e "s:^ *::" -e "s: *\$::";
 
347
}
 
348
trimmm ()
 
349
{
 
350
    echo "$1" | $SED -e "s:^ *::" -e "s: *\$::" -e "s:[  ][      ]*: :g";
 
351
}
 
352
 
 
353
timezone ()
 
354
{
 
355
    # +%z is an extension while +%Z is supposed to be posix
 
356
    _timezone=`$DATE_NOW +%z`
 
357
    case "$_timezone" in
 
358
        *+*) echo "$_timezone" ;;
 
359
        *-*) echo "$_timezone" ;;
 
360
        *) $DATE_NOW +%Z
 
361
    esac
 
362
}
 
363
timetoday () 
 
364
{
 
365
    $DATE_NOW +%Y-%m-%d
 
366
}
 
367
timetodays ()
 
368
{
 
369
    $DATE_NOW +%Y-%m%d
 
370
}
 
371
    
 
372
# ======================================================================
 
373
#                                                                FUNCS
 
374
 
 
375
sed_longscript ()
 
376
{
 
377
    # hpux sed has a limit of 100 entries per sed script !
 
378
    $SED             -e "100q" "$1" > "$1~1~"
 
379
    $SED -e "1,100d" -e "200q" "$1" > "$1~2~"
 
380
    $SED -e "1,200d" -e "300q" "$1" > "$1~3~"
 
381
    $SED -e "1,300d" -e "400q" "$1" > "$1~4~"
 
382
    $SED -e "1,400d" -e "500q" "$1" > "$1~5~"
 
383
    $SED -e "1,500d" -e "600q" "$1" > "$1~6~"
 
384
    $SED -e "1,600d" -e "700q" "$1" > "$1~7~"
 
385
    $SED -e "1,700d" -e "800q" "$1" > "$1~8~"
 
386
    $SED -e "1,800d" -e "900q" "$1" > "$1~9~"
 
387
    $SED -f "$1~1~"  -f "$1~2~" -f "$1~3~" -f "$1~4~" -f "$1~5~" \
 
388
         -f "$1~6~"  -f "$1~7~" -f "$1~8~" -f "$1~9~" "$2"
 
389
}
 
390
 
 
391
sed_slash_key ()      # helper to escape chars special in /anchor/ regex
 
392
{                     # currently escaping "/" "[" "]" "."
 
393
    echo "$1" | $SED -e "s|[./[-]|\\\\&|g" -e "s|\\]|\\\\&|g"
 
394
}
 
395
sed_piped_key ()      # helper to escape chars special in s|anchor|| regex
 
396
{                     # currently escaping "|" "[" "]" "."
 
397
    echo "$1" | $SED -e "s/[.|[-]/\\\\&/g" -e "s/\\]/\\\\&/g"
 
398
}
 
399
 
 
400
back_path ()          # helper to get the series of "../" for a given path
 
401
{
 
402
    echo "$1" | $SED -e "/\\//!d" -e "s|/[^/]*\$|/|" -e "s|[^/]*/|../|g"
 
403
}
 
404
 
 
405
dir_name ()
 
406
{
 
407
    echo "$1" | $SED -e "s:/[^/][^/]*\$::"
 
408
}
 
409
 
 
410
info2test_sed ()          # cut out all old-style <!--vars--> usages
 
411
{
 
412
  INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$INFO"
 
413
  V8=" *\\([^ ][^ ]*\\) \\(.*\\)"
 
414
  V9=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)"
 
415
   q="\\\$"
 
416
   _x_="WARNING: assumed simplevar <!--\\\\1--> changed to <!--$q\\\\1:=-->"
 
417
   _y_="WARNING: assumed simplevar <!--\\\\1--> changed to <!--$q\\\\1:?-->"
 
418
   _X_="WARNING: assumed tailvar <!--$q\\\\1:--> changed to <!--$q\\\\1:=-->"
 
419
   _Y_="WARNING: assumed tailvar <!--$q\\\\1:--> changed to <!--$q\\\\1:?-->"
 
420
   echo "s/^/ /" # $++
 
421
  $SED -e "/^=....=formatter /d" \
 
422
  -e "/=text=/s%=text=$V9%s|.*<!--\\\\(\\1\\\\)-->.*|$_x_|%" \
 
423
  -e "/=Text=/s%=Text=$V9%s|.*<!--\\\\(\\1\\\\)-->.*|$_x_|%" \
 
424
  -e "/=name=/s%=name=$V9%s|.*<!--\\\\(\\1\\\\)[?]-->.*|$_y_|%" \
 
425
  -e "/=Name=/s%=Name=$V9%s|.*<!--\\\\(\\1\\\\)[?]-->.*|$_y_|%" \
 
426
  -e "/=text=/s%=text=$V8%s|.*<!--\\\\(\\1\\\\)-->.*|$_x_|%" \
 
427
  -e "/=Text=/s%=Text=$V8%s|.*<!--\\\\(\\1\\\\)-->.*|$_x_|%" \
 
428
  -e "/=name=/s%=name=$V8%s|.*<!--\\\\(\\1\\\\)[?]-->.*|$_y_|%" \
 
429
  -e "/=Name=/s%=Name=$V8%s|.*<!--\\\\(\\1\\\\)[?]-->.*|$_y_|%" \
 
430
  -e "/^=/d" -e "s|&|\\\\&|g"  $INP # $++
 
431
  $SED -e "/^=....=formatter /d" \
 
432
  -e "/=text=/s%=text=$V9%s|.*<!--$q\\\\(\\1\\\\):-->.*|$_X_|%" \
 
433
  -e "/=Text=/s%=Text=$V9%s|.*<!--$q\\\\(\\1\\\\):-->.*|$_X_|%" \
 
434
  -e "/=name=/s%=name=$V9%s|.*<!--$q\\\\(\\1\\\\)[?]:-->.*|$_Y_|%" \
 
435
  -e "/=Name=/s%=Name=$V9%s|.*<!--$q\\\\(\\1\\\\)[?]:-->.*|$_Y_|%" \
 
436
  -e "/=text=/s%=text=$V8%s|.*<!--$q\\\\(\\1\\\\):-->.*|$_X_|%" \
 
437
  -e "/=Text=/s%=Text=$V8%s|.*<!--$q\\\\(\\1\\\\):-->.*|$_X_|%" \
 
438
  -e "/=name=/s%=name=$V8%s|.*<!--$q\\\\(\\1\\\\)[?]:-->.*|$_Y_|%" \
 
439
  -e "/=Name=/s%=Name=$V8%s|.*<!--$q\\\\(\\1\\\\)[?]:-->.*|$_Y_|%" \
 
440
  -e "/^=/d" -e "s|&|\\\\&|g"  $INP # $++
 
441
  echo "/^WARNING:/!d" # $++
 
442
}
 
443
 
 
444
info2vars_sed ()          # generate <!--$vars--> substition sed addon script
 
445
{
 
446
  INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$INFO"
 
447
  V8=" *\\([^ ][^ ]*\\) \\(.*\\)"
 
448
  V9=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)"
 
449
  N8=" *\\([^ ][^ ]*\\) \\([$NN].*\\)"
 
450
  N9=" *DC[.]\\([^ ][^ ]*\\) \\([$NN].*\\)"
 
451
  V0="\\\\([<]*\\\\)\\\\\\\$"
 
452
  V1="\\\\([^<>]*\\\\)\\\\\\\$"
 
453
  V2="\\\\([^{<>}]*\\\\)"
 
454
  V3="\\\\([^<>]*\\\\)"
 
455
  SS="<""<>"">" # spacer so value="2004" does not make for s|\(...\)|\12004|
 
456
  test ".$commentvars"  = ".no" && updatevars="no"   # duplicated from
 
457
  test ".$commentvars"  = ".no" && expandvars="no"   # option handling
 
458
  test ".$commentvars"  = ".no" && simplevars="no"   # tests below
 
459
  test ".$expandvars" != ".no" && \
 
460
  $SED -e "/^=....=formatter /d" \
 
461
      -e "/^=name=/s,=name=$V9,s|<!--$V0\\1[?]-->|- \\2|," \
 
462
      -e "/^=Name=/s,=Name=$V9,s|<!--$V0\\1[?]-->|(\\2)|," \
 
463
      -e "/^=name=/s,=name=$V8,s|<!--$V0\\1[?]-->|- \\2|," \
 
464
      -e "/^=Name=/s,=Name=$V8,s|<!--$V0\\1[?]-->|(\\2)|," \
 
465
      -e "/^=/d" -e "s|&|\\\\&|g"  $INP # $++
 
466
  test ".$expandvars" != ".no" && \
 
467
  $SED -e "/^=....=formatter /d" \
 
468
      -e "/^=text=/s,=text=$V9,s|<!--$V1\\1-->|\\\\1$SS\\2|," \
 
469
      -e "/^=Text=/s,=Text=$V9,s|<!--$V1\\1-->|\\\\1$SS\\2|," \
 
470
      -e "/^=name=/s,=name=$V9,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \
 
471
      -e "/^=Name=/s,=Name=$V9,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \
 
472
      -e "/^=text=/s,=text=$V8,s|<!--$V1\\1-->|\\\\1$SS\\2|," \
 
473
      -e "/^=Text=/s,=Text=$V8,s|<!--$V1\\1-->|\\\\1$SS\\2|," \
 
474
      -e "/^=name=/s,=name=$V8,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \
 
475
      -e "/^=Name=/s,=Name=$V8,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \
 
476
      -e "/^=/d" -e "s|&|\\\\&|g"  $INP # $++
 
477
  test ".$simplevars" != ".no" && test ".$updatevars" != ".no" && \
 
478
  $SED -e "/^=....=formatter /d" \
 
479
      -e "/^=text=/s,=text=$V9,s|<!--$V0\\1:-->[$AX]*|\\2|," \
 
480
      -e "/^=Text=/s,=Text=$V9,s|<!--$V0\\1:-->[$AX]*|\\2|," \
 
481
      -e "/^=name=/s,=name=$V9,s|<!--$V0\\1[?]:-->[$AX]*|- \\2|," \
 
482
      -e "/^=Name=/s,=Name=$V9,s|<!--$V0\\1[?]:-->[$AX]*| (\\2) |," \
 
483
      -e "/^=text=/s,=text=$V8,s|<!--$V0\\1:-->[$AX]*|\\2|," \
 
484
      -e "/^=Text=/s,=Text=$V8,s|<!--$V0\\1:-->[$AX]*|\\2|," \
 
485
      -e "/^=name=/s,=name=$V8,s|<!--$V0\\1[?]:-->[$AX]*|- \\2|," \
 
486
      -e "/^=Name=/s,=Name=$V8,s|<!--$V0\\1[?]:-->[$AX]*| (\\2) |," \
 
487
      -e "/^=/d" -e "s|&|\\\\&|g"  $INP # $++
 
488
  test ".$updatevars" != ".no" && \
 
489
  $SED -e "/^=....=formatter /d" \
 
490
      -e "/^=name=/s,=name=$V9,s|<!--$V0\\1:[?]-->[^<>]*|- \\2|," \
 
491
      -e "/^=Name=/s,=Name=$V9,s|<!--$V0\\1:[?]-->[^<>]*| (\\2) |," \
 
492
      -e "/^=name=/s,=name=$V8,s|<!--$V0\\1:[?]-->[^<>]*|- \\2|," \
 
493
      -e "/^=Name=/s,=Name=$V8,s|<!--$V0\\1:[?]-->[^<>]*| (\\2) |," \
 
494
  -e "/^=/d" -e "s|&|\\\\&|g"  $INP # $++
 
495
  test ".$updatevars" != ".no" && \
 
496
  $SED -e "/^=....=formatter /d" \
 
497
      -e "/^=text=/s,=text=$V9,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \
 
498
      -e "/^=Text=/s,=Text=$V9,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \
 
499
      -e "/^=name=/s,=name=$V9,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \
 
500
      -e "/^=Name=/s,=Name=$V9,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \
 
501
      -e "/^=text=/s,=text=$V8,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \
 
502
      -e "/^=Text=/s,=Text=$V8,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \
 
503
      -e "/^=name=/s,=name=$V8,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \
 
504
      -e "/^=Name=/s,=Name=$V8,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \
 
505
      -e "/^=/d" -e "s|&|\\\\&|g"  $INP # $++
 
506
  test ".$attribvars" != ".no" && \
 
507
  $SED -e "/^=....=formatter /d" \
 
508
      -e "/^=text=/s,=text=$V9,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
 
509
      -e "/^=Text=/s,=Text=$V9,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
 
510
      -e "/^=name=/s,=name=$V9,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
 
511
      -e "/^=Name=/s,=Name=$V9,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
 
512
      -e "/^=text=/s,=text=$V8,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
 
513
      -e "/^=Text=/s,=Text=$V8,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
 
514
      -e "/^=name=/s,=name=$V8,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
 
515
      -e "/^=Name=/s,=Name=$V8,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
 
516
      -e "/^=/d" -e "s|&|\\\\&|g"  $INP # $++
 
517
  test ".$simplevars" != ".no" && \
 
518
  $SED -e "/^=....=formatter /d" \
 
519
      -e "/^=text=/s,=text=$V9,s|<!--\\1-->[$AX]*|\\2|," \
 
520
      -e "/^=Text=/s,=Text=$V9,s|<!--\\1-->[$AX]*|\\2|," \
 
521
      -e "/^=name=/s,=name=$V9,s|<!--\\1[?]-->[$AX]*| - \\2|," \
 
522
      -e "/^=Name=/s,=Name=$V9,s|<!--\\1[?]-->[$AX]*| (\\2) |," \
 
523
      -e "/^=text=/s,=text=$V8,s|<!--\\1-->[$AX]*|\\2|," \
 
524
      -e "/^=Text=/s,=Text=$V8,s|<!--\\1-->[$AX]*|\\2|," \
 
525
      -e "/^=name=/s,=name=$V8,s|<!--\\1[?]-->[$AX]*| - \\2|," \
 
526
      -e "/^=Name=/s,=Name=$V8,s|<!--\\1[?]-->[$AX]*| (\\2) |," \
 
527
      -e "/^=/d" -e "s|&|\\\\&|g"  $INP # $++
 
528
  # if value="2004" then generated sed might be "\\12004" which is bad
 
529
  # instead we generate an edited value of "\\1$SS$value" and cut out
 
530
  # the spacer now after expanding the variable values:
 
531
  echo "s|$SS||g" # $++
 
532
}
 
533
 
 
534
info2meta_sed ()         # generate <meta name..> text portion
 
535
{
 
536
  # http://www.metatab.de/meta_tags/DC_type.htm
 
537
  INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$INFO"
 
538
  V6=" *HTTP[.]\\([^ ][^ ]*\\) \\(.*\\)"
 
539
  V7=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)"
 
540
  V8=" *\\([^ ][^ ]*\\) \\(.*\\)"
 
541
  INFO_META_TYPE_SCHEME="name=\"DC.type\" content=\"\\2\" scheme=\"\\1\""
 
542
  INFO_META_DCMI="name=\"\\1\" content=\"\\2\" scheme=\"DCMIType\""
 
543
  INFO_META_NAME_TZ="name=\"\\1\" content=\"\\2 `timezone`\"" 
 
544
  INFO_META_NAME="name=\"\\1\" content=\"\\2\""
 
545
  INFO_META_HTTP="http-equiv=\"\\1\" content=\"\\2\""
 
546
  $SED -e "/=....=today /d" \
 
547
  -e "/=meta=HTTP[.]/s,=meta=$V6, <meta $INFO_META_HTTP />," \
 
548
  -e "/=meta=DC[.]DCMIType /s,=meta=$V7, <meta $INFO_META_TYPE_SCHEME />," \
 
549
  -e "/=meta=DC[.]type Collection$/s,=meta=$V8, <meta $INFO_META_DCMI />," \
 
550
  -e "/=meta=DC[.]type Dataset$/s,=meta=$V8, <meta $INFO_META_DCMI />," \
 
551
  -e "/=meta=DC[.]type Event$/s,=meta=$V8, <meta $INFO_META_DCMI />," \
 
552
  -e "/=meta=DC[.]type Image$/s,=meta=$V8, <meta $INFO_META_DCMI />," \
 
553
  -e "/=meta=DC[.]type Service$/s,=meta=$V8, <meta $INFO_META_DCMI />," \
 
554
  -e "/=meta=DC[.]type Software$/s,=meta=$V8, <meta $INFO_META_DCMI />," \
 
555
  -e "/=meta=DC[.]type Sound$/s,=meta=$V8, <meta $INFO_META_DCMI />," \
 
556
  -e "/=meta=DC[.]type Text$/s,=meta=$V8, <meta $INFO_META_DCMI />," \
 
557
  -e "/=meta=DC[.]date[.].*[+]/s,=meta=$V8, <meta $INFO_META_NAME />," \
 
558
  -e "/=meta=DC[.]date[.].*[:]/s,=meta=$V8, <meta $INFO_META_NAME_TZ />," \
 
559
  -e "/=meta=/s,=meta=$V8, <meta $INFO_META_NAME />," \
 
560
  -e "/<meta name=\"[^\"]*\" content=\"\" /d" \
 
561
  -e "/<meta http-equiv=\"[^\"]*\" content=\"\" /d" \
 
562
  -e "/^=/d" $INP # $++
 
563
}
 
564
 
 
565
info_get_entry () # get the first <!--vars--> value known so far
 
566
{
 
567
  TXT="$1" ; test ".$TXT" = "." && TXT="sect"
 
568
  INP="$2" ; test ".$INP" = "." && INP="$tmp/$F.$INFO"
 
569
  $SED -e "/=text=$TXT /!d" -e "s/=text=$TXT //" -e "q" $INP # $++
 
570
}
 
571
 
 
572
info1grep () # test for a <!--vars--> substition to be already present
 
573
{
 
574
  TXT="$1" ; test ".$TXT" = "." && TXT="sect"
 
575
  INP="$2" ; test ".$INP" = "." && INP="$tmp/$F.$INFO"
 
576
  $GREP "^=text=$TXT " $INP >$NULL
 
577
  return $?
 
578
}
 
579
 
 
580
dx_init()
 
581
{
 
582
    mkpathdir "$tmp"
 
583
    dx_meta formatter `basename $opt_formatter` > "$tmp/$F.$INFO"
 
584
    for opt in $opt_variables ; do case "$opt" in # commandline --def=value
 
585
      *_*) op_=`echo "$opt" | sed -e "y/_/-/"`    # makes for <!--$def-->
 
586
           dx_meta "$op_" `eval echo "\\\$opt_$opt"` ;; 
 
587
      *)   dx_text "$opt" `eval echo "\\\$opt_$opt"` ;;
 
588
    esac ; done
 
589
}
 
590
 
 
591
dx_line ()
 
592
{
 
593
    echo "$1$2 "`trimmm "$3"` >> "$tmp/$F.$INFO"
 
594
}
 
595
 
 
596
DX_line ()
 
597
{
 
598
    dx_val_=`echo "$3" | sed -e "s/<[^<>]*>//g"`
 
599
    dx_line "$1" "$2" "$dx_val_"
 
600
}
 
601
 
 
602
dx_text ()
 
603
{
 
604
    dx_line "=text=" "$1" "$2"
 
605
}
 
606
 
 
607
DX_text ()   # add a <!--vars--> substition includings format variants
 
608
{
 
609
  N=`trimm "$1"` ; T=`trimm "$2"`
 
610
  if test ".$N" != "." ; then
 
611
    if test ".$T" != "." ; then
 
612
      text=`echo "$T" | $SED -e "y/$UPPER/$LOWER/" -e "s/<[^<>]*>//g"`
 
613
      dx_line "=text=" "$N" "$T"
 
614
      dx_line "=name=" "$N" "$text"
 
615
      varname=`echo "$N" | $SED -e 's/.*[.]//'`    # cut out front part
 
616
      if test ".$N" != ".$varname" ; then 
 
617
      text=`echo "$varname $T" | $SED -e "y/$UPPER/$LOWER/" -e "s/<[^<>]*>//g"`
 
618
      dx_line "=Text=" "$varname" "$T"
 
619
      dx_line "=Name=" "$varname" "$text"
 
620
      fi
 
621
    fi
 
622
  fi
 
623
}
 
624
 
 
625
dx_meta ()
 
626
{
 
627
    DX_line "=meta=" "$1" "$2"
 
628
}
 
629
 
 
630
DX_meta ()  # add simple meta entry and its <!--vars--> subsitution
 
631
{
 
632
    DX_line "=meta=" "$1" "$2"
 
633
    DX_text "$1" "$2"
 
634
}
 
635
 
 
636
DC_meta ()   # add new DC.meta entry plus two <!--vars--> substitutions
 
637
{
 
638
    DX_line "=meta=" "DC.$1" "$2"
 
639
    DX_text "DC.$1" "$2"
 
640
    DX_text "$1" "$2"
 
641
}
 
642
 
 
643
HTTP_meta ()   # add new HTTP.meta entry plus two <!--vars--> substitutions
 
644
{
 
645
    DX_line "=meta=" "HTTP.$1" "$2"
 
646
    DX_text "HTTP.$1" "$2"
 
647
    DX_text "$1" "$2"
 
648
}
 
649
 
 
650
DC_VARS_Of () # check DC vars as listed in $DC_VARS global and generate DC_meta
 
651
{             # the results will be added to .meta.tmp and .vars.tmp later
 
652
   FILENAME="$1" ; test ".$FILENAME" = "." && FILENAME="$SOURCEFILE"   
 
653
   for M in $DC_VARS title ; do
 
654
      # scan for a <markup> of this name
 
655
      part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|</$M>.*||" -e q $FILENAME`
 
656
      part=`trimm "$part"`
 
657
      text=`echo  "$part" | $SED -e "s|^[$AA]*:||"`
 
658
      text=`trimm "$text"`
 
659
      test ".$text" = "." && continue
 
660
      # <mark:part> will be <meta name="mark.part">
 
661
      if test ".$text" != ".$part" ; then
 
662
         N=`echo "$part" | $SED -e "s/:.*//"`
 
663
         DC_meta "$M.$N" "$text"
 
664
      elif test ".$M" = ".date" ; then
 
665
         DC_meta "$M.issued" "$text" # "<date>" -> "<date>issued:"
 
666
      else
 
667
         DC_meta "$M" "$text"
 
668
      fi
 
669
   done
 
670
}
 
671
 
 
672
HTTP_VARS_Of () # check HTTP-EQUIVs as listed in $_EQUIV global then
 
673
{               # generate meta tags that are http-equiv= instead of name=
 
674
   FILENAME="$1" ; test ".$FILENAME" = "." && FILENAME="$SOURCEFILE"   
 
675
   for M in $_EQUIVS ; do
 
676
      # scan for a <markup> of this name
 
677
      part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|</$M>.*||" -e q $FILENAME`
 
678
      part=`trimm "$part"`
 
679
      text=`echo  "$part" | $SED -e "s|^[$AA]*:||"`
 
680
      text=`trimm "$text"`
 
681
      test ".$text" = "." && continue
 
682
      if test ".$M" = ".redirect" ; then
 
683
         HTTP_meta "refresh" "5; url=$text" ; DX_text "$M" "$text"
 
684
      elif test ".$M" = ".charset" ; then
 
685
         HTTP_meta "content-type" "text/html; charset=$text" 
 
686
      else
 
687
         HTTP_meta "$M" "$text"
 
688
      fi
 
689
   done
 
690
}
 
691
 
 
692
DC_isFormatOf ()       # make sure there is this DC.relation.isFormatOf tag
 
693
{                      # choose argument for a fallback (usually $SOURCEFILE)
 
694
   NAME="$1" ; test ".$NAME" = "." && NAME="$SOURCEFILE"   
 
695
   info1grep DC.relation.isFormatOf || DC_meta relation.isFormatOf "$NAME"
 
696
}
 
697
 
 
698
DC_publisher ()        # make sure there is this DC.publisher meta tag
 
699
{                      # choose argument for a fallback (often $USER)
 
700
   NAME="$1" ; test ".$NAME" = "." && NAME="$USER"
 
701
   info1grep DC.publisher || DC_meta publisher "$NAME"
 
702
}
 
703
 
 
704
DC_modified ()         # make sure there is a DC.date.modified meta tag
 
705
{                      # maybe choose from filesystem dates if possible
 
706
   Q="$1" # target file
 
707
   if info1grep DC.date.modified ; then :
 
708
   else
 
709
      _42_chars="........................................."
 
710
      cut_42_55="s/^$_42_chars\\(.............\\).*/\\1/" # i.e.`cut -b 42-55`
 
711
      text=`$STAT_R $Q 2>$NULL | $SED -e '/odify:/!d' -e 's|.*fy:||' -e q`
 
712
      text=`echo "$text" | $SED -e "s/:..[.][$NN]*//"`
 
713
      text=`trimm "$text"`
 
714
      test ".$text" = "." && \
 
715
      text=`$DATE_R "$Q" +%Y-%m-%d 2>$NULL`   # GNU sed
 
716
      test ".$text" = "." && 
 
717
      text=`$LS_L "$Q" | $SED -e "$cut_42_55" -e "s/^ *//g" -e "q"`
 
718
      text=`echo "$text" | $SED -e "s/[$NN]*:.*//"` # cut way seconds
 
719
      DC_meta date.modified `trimm "$text"`
 
720
   fi
 
721
}
 
722
 
 
723
DC_date ()             # make sure there is this DC.date meta tag
 
724
{                      # choose from one of the available DC.date.* specials
 
725
   Q="$1" # source file
 
726
   if info1grep DC.date 
 
727
   then DX_text issue "dated `info_get_entry DC.date`"
 
728
        DX_text updated     "`info_get_entry DC.date`"
 
729
   else text=""
 
730
      for kind in available issued modified created ; do
 
731
        text=`info_get_entry DC.date.$kind` 
 
732
      # test ".$text" != "." && echo "$kind = date = $text ($Q)"
 
733
        test ".$text" != "." && break
 
734
      done
 
735
      if test ".$text" = "." ; then
 
736
        M="date"
 
737
        part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|</$M>.*||" -e q $Q`
 
738
        part=`trimm "$part"`
 
739
        text=`echo "$part" | $SED -e "s|^[$AA]*:||"`
 
740
        text=`trimm "$text"`
 
741
      fi
 
742
      if test ".$text" = "." ; then 
 
743
        M="!--date:*=*--" # takeover updateable variable...
 
744
        part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|</.*||" -e q $Q`
 
745
        part=`trimm "$part"`
 
746
        text=`echo "$part" | $SED -e "s|^[$AA]*:||" -e "s|\\&.*||"`
 
747
        text=`trimm "$text"`
 
748
      fi
 
749
      text=`echo "$text" | $SED -e "s/[$NN]*:.*//"` # cut way seconds
 
750
      DX_text updated "$text"
 
751
      text1=`echo "$text" | $SED -e "s|^.* *updated ||"`
 
752
      if test ".$text" != ".$text1" ; then
 
753
        kind="modified" ; text=`echo "$text1" | $SED -e "s|,.*||"`
 
754
      fi
 
755
      text1=`echo "$text" | $SED -e "s|^.* *modified ||"`
 
756
      if test ".$text" != ".$text1" ; then
 
757
        kind="modified" ; text=`echo "$text1" | $SED -e "s|,.*||"`
 
758
      fi
 
759
      text1=`echo "$text" | $SED -e "s|^.* *created ||"`
 
760
      if test ".$text" != ".$text1" ; then
 
761
        kind="created" ; text=`echo "$text1" | $SED -e "s|,.*||"`
 
762
      fi
 
763
      text=`echo "$text" | $SED -e "s/[$NN]*:.*//"` # cut way seconds
 
764
      DC_meta date `trimm "$text"`
 
765
      DX_text issue `trimm "$kind $text"`
 
766
   fi
 
767
}
 
768
 
 
769
DC_title ()
 
770
{
 
771
   # choose a title for the document, either an explicit title-tag
 
772
   # or one of the section headers in the document or fallback to filename
 
773
   Q="$1" # target file
 
774
   if info1grep DC.title ; then :
 
775
   else
 
776
      for M in TITLE title H1 h1 H2 h2 H3 H3 H4 H4 H5 h5 H6 h6 ; do
 
777
        text=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|</$M>.*||" -e q $Q`
 
778
        text=`trimm "$text"` ; test ".$text" != "." && break
 
779
        MM="$M [^<>]*"
 
780
        text=`$SED -e "/<$MM>/!d" -e "s|.*<$MM>||" -e "s|</$M>.*||" -e q $Q`
 
781
        text=`trimm "$text"` ; test ".$text" != "." && break
 
782
      done
 
783
      if test ".text" = "." ; then
 
784
        text=`basename $Q .html`
 
785
        text=`basename $text .htm | $SED -e 'y/_/ /' -e "s/\\$/ info/"`
 
786
      fi
 
787
      term=`echo "$text" | $SED -e 's/.*[(]//' -e 's/[)].*//'`
 
788
      text=`echo "$text" | $SED -e 's/[(][^()]*[)]//'`
 
789
      if test ".$term" = "." || test ".$term" = ".$text" ; then
 
790
         DC_meta title "$text"
 
791
      else
 
792
         DC_meta title "$term - $text"
 
793
      fi
 
794
   fi
 
795
}    
 
796
 
 
797
site_get_section () # return parent section page of given page
 
798
{
 
799
   _F_=`sed_slash_key "$1"`
 
800
   $SED -e "/^=sect=$_F_ /!d" -e "s/^=sect=$_F_ //" -e q "$MK_INFO" # $++
 
801
}
 
802
 
 
803
DC_section () # not really a DC relation (shall we use isPartOf ?) 
 
804
{             # each document should know its section father
 
805
   sectn=`site_get_section "$F"`
 
806
   if test ".$sectn" != "." ; then
 
807
      DC_meta relation.section "$sectn"
 
808
   fi
 
809
}
 
810
 
 
811
info_get_entry_section()
 
812
{
 
813
    info_get_entry DC.relation.section # $++
 
814
}    
 
815
 
 
816
site_get_selected ()  # return section of given page
 
817
{
 
818
   _F_=`sed_slash_key "$1"`
 
819
   $SED -e "/=use.=$_F_ /!d" -e "s/=use.=[^ ]* //" -e q "$MK_INFO" # $++
 
820
}
 
821
 
 
822
DC_selected () # not really a DC title (shall we use alternative ?)
 
823
{
 
824
   # each document might want to highlight the currently selected item
 
825
   short=`site_get_selected "$F"`
 
826
   if test ".$short" != "." ; then
 
827
      DC_meta title.selected "$short"
 
828
   fi
 
829
}
 
830
 
 
831
info_get_entry_selected ()
 
832
{
 
833
    info_get_entry DC.title.selected # $++
 
834
}
 
835
 
 
836
site_get_rootsections () # return all sections from root of nav tree
 
837
{
 
838
   $SED -e "/=use1=/!d" -e "s/=use.=\\([^ ]*\\) .*/\\1/" "$MK_INFO" # $++
 
839
}
 
840
 
 
841
site_get_sectionpages () # return all children pages in the given section
 
842
{
 
843
   _F_=`sed_slash_key "$1"`
 
844
   $SED -e "/^=sect=[^ ]* $_F_\$/!d" -e "s/^=sect=//" \
 
845
        -e "s/ .*//" "$MK_INFO" # $++
 
846
}
 
847
 
 
848
site_get_subpages () # return all page children of given page
 
849
{
 
850
   _F_=`sed_slash_key "$1"`
 
851
   $SED -e "/^=node=[^ ]* $_F_\$/!d" -e "s/^=node=//" -e "s/ .*//" "$MK_INFO"
 
852
   # $++
 
853
}
 
854
 
 
855
site_get_parentpage () # return parent page for given page (".." for sections)
 
856
{
 
857
   _F_=`sed_slash_key "$1"`
 
858
   $SED -e "/^=node=$_F_ /!d" -e "s/^=node=[^ ]* //" -e "q" "$MK_INFO"  # $++
 
859
}
 
860
 
 
861
DX_alternative ()        # detect wether page asks for alternative style
 
862
{                        # which is generally a shortpage variant
 
863
    x=`mksite_magic_option alternative $1 | sed -e "s/^ *//" -e "s/ .*//"`
 
864
    if test ".$x" != "." ; then
 
865
      DX_text alternative "$x"
 
866
    fi
 
867
}
 
868
 
 
869
info2head_sed ()      # append alternative handling script to $HEAD
 
870
{
 
871
    have=`info_get_entry alternative`
 
872
    if test ".$have" != "." ; then
 
873
       echo "/<!--mksite:alternative:$have .*-->/{" # $++
 
874
       echo "s/<!--mksite:alternative:$have\\( .*\\)-->/\\1/" # $++
 
875
       echo "q" # $++ 
 
876
       echo "}" # $++
 
877
    fi
 
878
}
 
879
info2body_sed ()      # append alternative handling script to $BODY
 
880
{
 
881
    have=`info_get_entry alternative`
 
882
    if test ".$have" != "." ; then
 
883
       echo "s/<!--mksite:alternative:$have\\( .*\\)-->/\\1/" # $++
 
884
    fi
 
885
}
 
886
 
 
887
bodymaker_for_sectioninfo ()
 
888
{
 
889
    test ".$sectioninfo" = ".no" && return
 
890
    _x_="<!--mksite:sectioninfo::-->"
 
891
    _q_="\\([^<>]*[$AX][^<>]*\\)"
 
892
    test ".$sectioninfo" != ". " && _q_="[ ][ ]*$sectioninfo\\([ ]\\)" 
 
893
    echo "s|\\(^<[hH][$NN][ >].*</[hH][$NN]>\\)$_q_|\\1$_x_\\2|"       # $++
 
894
    echo "/$_x_/s|^|<table width=\"100%\"><tr valign=\"bottom\"><td>|" # $++
 
895
    echo "/$_x_/s|</[hH][$NN]>|&</td><td align=\"right\"><i>|"         # $++
 
896
    echo "/$_x_/s|\$|</i></td></tr></table>|"                          # $++
 
897
    echo "s|$_x_||"                                                    # $++
 
898
}
 
899
 
 
900
fast_href ()  # args "$FILETOREFERENCE" "$FROMCURRENTFILE:$F"
 
901
{   # prints path to $FILETOREFERENCE href-clickable in $FROMCURRENTFILE
 
902
    # if no subdirectoy then output is the same as input $FILETOREFERENCE
 
903
    R="$2" ; test ".$R" = "." && R="$F"
 
904
    S=`back_path "$R"`
 
905
    if test ".$S" = "." 
 
906
    then echo "$1" # $++
 
907
    else _1_=`echo "$1" | \
 
908
         $SED -e "/^ *\$/d" -e "/^\\//d" -e "/^[.][.]/d" -e "/^[$AA]*:/d" `
 
909
         if test ".$_1_" = "." # don't move any in the pattern above
 
910
         then echo "$1"   # $++
 
911
         else echo "$S$1" # $++  prefixed with backpath
 
912
    fi fi
 
913
}
 
914
 
 
915
make_fast () # experimental - make a FAST file that can be applied
 
916
{            # to htm sourcefiles in a subdirectory of the sitefile.
 
917
#   R="$1" ; test ".$R" = "." && R="$F"
 
918
    S=`back_path "$F"` 
 
919
    if test ".$S" = "" ; then
 
920
       # echo "backpath '$F' = none needed"
 
921
       $CATNULL # $++
 
922
    else
 
923
       # echo "backpath '$F' -> '$S'"
 
924
       $SED -e "/href=\"[^\"]*\"/!d" -e "s/.*href=\"//" -e "s/\".*//" \
 
925
            -e "/^ *\$/d" -e "/^\\//d" -e "/^[.][.]/d" -e "/^[$AA]*:/d" \
 
926
           $SITEFILE $SOURCEFILE | sort | uniq \
 
927
       | $SED -e "s,.*,s|href=\"&\"|href=\"$S&\"|," # $++
 
928
    fi
 
929
}
 
930
 
 
931
# ============================================================== SITE MAP INFO
 
932
# each entry needs atleast a list-title, a long-title, and a list-date
 
933
# these are the basic information to be printed in the sitemap file
 
934
# where it is bound the hierarchy of sect/subsect of the entries.
 
935
 
 
936
site_map_list_title() # $file $text
 
937
{
 
938
    echo "=list=$1 $2" >> "$MK_INFO"
 
939
}
 
940
info_map_list_title() # $file $text
 
941
{
 
942
    echo "=list=$2" >> "$tmp/$1.$INFO"
 
943
}
 
944
site_map_long_title() # $file $text
 
945
{
 
946
    echo "=long=$1 $2" >> "$MK_INFO"
 
947
}
 
948
info_map_long_title() # $file $text
 
949
{
 
950
    echo "=long=$2" >> "$tmp/$1.$INFO"
 
951
}
 
952
site_map_list_date() # $file $text
 
953
{
 
954
    echo "=date=$1 $2" >> "$MK_INFO"
 
955
}
 
956
info_map_list_date() # $file $text
 
957
{
 
958
    echo "=date=$2" >> "$tmp/$1.$INFO"
 
959
}
 
960
 
 
961
siteinfo2sitemap ()  # generate <name><page><date> addon sed scriptlet
 
962
{                    # the resulting script will act on each item/line
 
963
                     # containing <!--"filename"--> and expand any following
 
964
                     # reference of <!--name--> or <!--date--> or <!--long-->
 
965
  INP="$1" ; test ".$INP" = "." && INP="$MK_INFO"
 
966
  _list_="s|<!--\"\\1\"-->.*<!--name-->|\\&<name href=\"\\1\">\\2</name>|"
 
967
  _date_="s|<!--\"\\1\"-->.*<!--date-->|\\&<date>\\2</date>|"
 
968
  _long_="s|<!--\"\\1\"-->.*<!--long-->|\\&<long>\\2</long>|"
 
969
  $SED -e "s:&:\\\\&:g" \
 
970
       -e "s:=list=\\([^ ]*\\) \\(.*\\):$_list_:" \
 
971
       -e "s:=date=\\([^ ]*\\) \\(.*\\):$_date_:" \
 
972
       -e "s:=long=\\([^ ]*\\) \\(.*\\):$_long_:" \
 
973
       -e "/^s|/!d" $INP # $++
 
974
}
 
975
 
 
976
make_multisitemap ()
 
977
{  # each category gets its own column along with the usual entries
 
978
   INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_INFO"
 
979
   siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed
 
980
  _form_="<!--\"\\2\"--><!--use\\1--><!--long--><!--end\\1-->"
 
981
  _form_="$_form_<br><!--name--><!--date-->"
 
982
  _tiny_="small><small><small" ; _tinyX_="small></small></small "
 
983
  _tabb_="<br><$_tiny_> </$_tinyX_>" ; _bigg_="<big> </big>"
 
984
  echo "<table width=\"100%\"><tr><td> " # $++
 
985
  $SED -e "/=use.=/!d" -e "s|=use\\(.\\)=\\([^ ]*\\) .*|$_form_|" \
 
986
       -f "$MK_SITE" -e "/<name/!d" \
 
987
       -e "s|<!--use1-->|</td><td valign=\"top\"><b>|" \
 
988
       -e "s|<!--end1-->|</b>|"  \
 
989
       -e "s|<!--use2-->|<br>|"  \
 
990
       -e "s|<!--use.-->|<br>|" -e "s/<!--[^<>]*-->/ /g" \
 
991
       -e "s|<long>||" -e "s|</long>||" \
 
992
       -e "s|<name |<$_tiny_><a |" -e "s|</name>||" \
 
993
       -e "s|<date>| |" -e "s|</date>|</a><br></$_tinyX_>|" \
 
994
       $INPUTS              # $++
 
995
   echo "</td><tr></table>" # $++
 
996
}
 
997
 
 
998
make_listsitemap ()
 
999
{   # traditional - the body contains a list with date and title extras
 
1000
   INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_INFO"
 
1001
   siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed
 
1002
   _form_="<!--\"\\2\"--><!--use\\1--><!--name--><!--date--><!--long-->"
 
1003
   _tabb_="<td>\\&nbsp\\;</td>" 
 
1004
   echo "<table cellspacing=\"0\" cellpadding=\"0\">" # $++
 
1005
   $SED -e "/=use.=/!d" -e "s|=use\\(.\\)=\\([^ ]*\\) .*|$_form_|" \
 
1006
        -f "$MK_SITE" -e "/<name/!d" \
 
1007
        -e "s|<!--use\\(1\\)-->|<tr class=\"listsitemap\\1\"><td>*</td>|" \
 
1008
        -e "s|<!--use\\(2\\)-->|<tr class=\"listsitemap\\1\"><td>-</td>|" \
 
1009
        -e "s|<!--use\\(.\\)-->|<tr class=\"listsitemap\\1\"><td> </td>|" \
 
1010
        -e  "/<tr.class=\"listsitemap3\">/s|<name [^<>]*>|&- |" \
 
1011
        -e "s|<!--[^<>]*-->| |g" \
 
1012
        -e "s|<name href=\"name:sitemap:|<name href=\"|" \
 
1013
        -e "s|<name |<td><a |" -e "s|</name>|</a></td>$_tabb_|" \
 
1014
        -e "s|<date>|<td><small>|" -e "s|</date>|</small></td>$_tabb_|" \
 
1015
        -e "s|<long>|<td><em>|" -e "s|</long>|</em></td></tr>|" \
 
1016
        $INPUTS             # $++
 
1017
   for xx in `grep "=use.=name:sitemap:" $INPUTS` ; do
 
1018
       xx=`echo $xx | sed -e "s/=use.=name:sitemap://"`
 
1019
       if test -f "$xx" ; then
 
1020
           grep "<tr.class=\"listsitemap[$NN]\">" $xx # $++
 
1021
       fi
 
1022
   done
 
1023
   echo "</table>"          # $++
 
1024
}
 
1025
 
 
1026
print_extension ()
 
1027
{
 
1028
    ARG="$1" ; test ".$ARG" = "." && ARG="$opt_print"
 
1029
    case "$ARG" in
 
1030
      -*|.*) echo "$ARG" ;;   # $++
 
1031
      *)     echo ".print" ;; # $++
 
1032
    esac
 
1033
}
 
1034
    
 
1035
html_sourcefile ()  # generally just cut away the trailing "l" (ell)
 
1036
{                   # making "page.html" argument into "page.htm" return
 
1037
    _SRCFILE_=`echo "$1" | $SED -e "s/l\\$//"`
 
1038
    if test -f "$_SRCFILE_" ; then echo "$_SRCFILE_" # $++
 
1039
    elif test -f "$opt_src_dir/$_SRCFILE_" 
 
1040
    then echo "$opt_src_dir/$_SRCFILE_" # $++
 
1041
    else echo ".//$_SRCFILE_" # $++
 
1042
    fi
 
1043
}
 
1044
html_printerfile_sourcefile () 
 
1045
{                   
 
1046
    if test ".$printerfriendly" = "."
 
1047
    then 
 
1048
    echo "$1" | sed -e "s/l\$//" # $++
 
1049
    else 
 
1050
    _ext_=`print_extension "$printerfriendly"`
 
1051
    _ext_=`sed_slash_key "$_ext_"`
 
1052
    echo "$1" | sed -e "s/l\$//" -e "s/$_ext_\\([.][$AA]*\\)\$/\\1/" # $++
 
1053
    fi
 
1054
}
 
1055
 
 
1056
fast_html_printerfile () {
 
1057
    x=`html_printerfile "$1"` ; basename "$x" # $++
 
1058
#   x=`html_printerfile "$1"` ; fast_href "$x" $2 # $++
 
1059
}
 
1060
 
 
1061
html_printerfile () # generate the printerfile for a given normal output
 
1062
{
 
1063
    _ext_=`print_extension "$printerfriendly" | sed -e "s/&/\\\\&/"`
 
1064
    echo "$1" | sed -e "s/\\([.][$AA]*\\)\$/$_ext_\\1/" # $++
 
1065
}
 
1066
 
 
1067
make_printerfile_fast () # generate s/file.html/file.print.html/ for hrefs
 
1068
{                        # we do that only for the $FILELIST
 
1069
   ALLPAGES="$1" ; # ="$FILELIST"
 
1070
   for p in $ALLPAGES ; do
 
1071
       a=`sed_slash_key "$p"`
 
1072
       b=`html_printerfile "$p"`
 
1073
       if test "$b" != "$p" ; then
 
1074
         b=`html_printerfile "$p" | sed -e "s:&:\\\\&:g" -e "s:/:\\\\\\/:g"`
 
1075
         echo "s/<a href=\"$a\">/<a href=\"$b\">/" # $++
 
1076
         echo "s/<a href=\"$a\" /<a href=\"$b\" /" # $++
 
1077
       fi
 
1078
   done
 
1079
}
 
1080
 
 
1081
echo_printsitefile_style ()
 
1082
{
 
1083
   _bold_="text-decoration : none ; font-weight : bold ; "
 
1084
   echo "   <style>"                                          # $+++
 
1085
   echo "     a:link    { $_bold_ color : #000060 ; }"        # $+++
 
1086
   echo "     a:visited { $_bold_ color : #000040 ; }"        # $+++
 
1087
   echo "     body      { background-color : white ; }"       # $+++
 
1088
   echo "   </style>"                                         # $+++
 
1089
}
 
1090
 
 
1091
make_printsitefile_head() # $sitefile
 
1092
{
 
1093
   echo_printsitefile_style > "$MK_STYLE"
 
1094
   $SED -e "/<title>/p" -e "/<title>/d" \
 
1095
        -e "/<head>/p"   -e "/<head>/d" \
 
1096
        -e "/<\/head>/p"  -e "/<\/head>/d" \
 
1097
        -e "/<body>/p"   -e "/<body>/d" \
 
1098
        -e "/^.*<link [^<>]*rel=\"shortcut icon\"[^<>]*>.*\$/p" \
 
1099
        -e "d" $SITEFILE | $SED -e "/<head>/r $MK_STYLE" # $+++
 
1100
}
 
1101
 
 
1102
 
 
1103
# ------------------------------------------------------------------------
 
1104
# The printsitefile is a long text containing html href markups where
 
1105
# each of the href lines in the file is being prefixed with the section
 
1106
# relation. During a secondary call the printsitefile can grepp'ed for
 
1107
# those lines that match a given output fast-file. The result is a
 
1108
# navigation header with 1...3 lines matching the nesting level
 
1109
 
 
1110
# these alt-texts will be only visible in with a text-mode browser:
 
1111
printsitefile_square="width=\"8\" height=\"8\" border=\"0\""
 
1112
printsitefile_img_1="<img alt=\"|go text:\" $printsitefile_square />"
 
1113
printsitefile_img_2="<img alt=\"||topics:\" $printsitefile_square />"
 
1114
printsitefile_img_3="<img alt=\"|||pages:\" $printsitefile_square />"
 
1115
_SECT="mksite:sect:"
 
1116
 
 
1117
echo_current_line () # $sect $extra
 
1118
{
 
1119
    echo "<!--$_SECT\"$1\"-->$2" # $++
 
1120
}
 
1121
make_current_entry () # $sect $file      ## requires $MK_SITE
 
1122
{
 
1123
  S="$1" ; R="$2"
 
1124
  SSS=`sed_slash_key "$S"`  
 
1125
  sep=" - " ; _left_=" [ " ; _right_=" ] "
 
1126
  echo_current_line "$S" "<a href=\"$R\"><!--\"$R\"--><!--name--></a>$sep" \
 
1127
       | $SED -f "$MK_SITE" -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \
 
1128
        -e "/<a href=\"$SSS\"/s/<a href/$_left_&/" \
 
1129
        -e "/<a href=\"$SSS\"/s/<\\/a>/&$_right_/" \
 
1130
        -e "s/<!--\"[^\"]*\"--><!--name-->//" # $+++
 
1131
}
 
1132
echo_subpage_line () # $sect $extra
 
1133
{
 
1134
    echo "<!--$_SECT*:\"$1\"-->$2" # $++
 
1135
}
 
1136
 
 
1137
make_subpage_entry ()
 
1138
{
 
1139
  S="$1" ; R="$2"
 
1140
  RR=`sed_slash_key "$R"`  
 
1141
  sep=" - " ;
 
1142
  echo_subpage_line "$S" "<a href=\"$R\"><!--\"$R\"--><!--name--></a>$sep" \
 
1143
       | $SED -f "$MK_SITE" -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \
 
1144
        -e "s/<!--\"[^\"]*\"--><!--name-->//" # $+++
 
1145
}
 
1146
 
 
1147
make_printsitefile ()
 
1148
{
 
1149
   # building the printsitefile looks big but its really a loop over sects
 
1150
   INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_INFO"
 
1151
   siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed
 
1152
   make_printsitefile_head $SITEFILE # $++
 
1153
 
 
1154
   sep=" - "
 
1155
   _sect1="<a href=\"#.\" title=\"section\">$printsitefile_img_1</a> ||$sep"
 
1156
   _sect2="<a href=\"#.\" title=\"topics\">$printsitefile_img_2</a> ||$sep"
 
1157
   _sect3="<a href=\"#.\" title=\"pages\">$printsitefile_img_3</a> ||$sep"
 
1158
   site_get_rootsections > "$MK_SECT1"
 
1159
   # round one - for each root section print a current menu
 
1160
   for r in `cat "$MK_SECT1"` ; do
 
1161
       echo_current_line "$r" "<!--mksite:sect1:A--><br>$_sect1" # $++
 
1162
       for s in `cat "$MK_SECT1"` ; do 
 
1163
           make_current_entry "$r" "$s" # $++
 
1164
       done
 
1165
       echo_current_line "$r" "<!--mksite:sect1:Z-->" # $++
 
1166
   done # "$r"
 
1167
 
 
1168
   # round two - for each subsection print a current and subpage menu
 
1169
   for r in `cat "$MK_SECT1"` ; do
 
1170
   site_get_subpages "$r"     > "$MK_SECT2"
 
1171
   for s in `cat "$MK_SECT2"` ; do test "$r" = "$s" && continue
 
1172
       echo_current_line  "$s" "<!--mksite:sect2:A--><br>$_sect2" # $++
 
1173
       for t in `cat "$MK_SECT2"` ; do test "$r" = "$t" && continue
 
1174
           make_current_entry "$s" "$t" # $++
 
1175
       done # "$t"
 
1176
       echo_current_line  "$s" "<!--mksite:sect2:Z-->" # $++
 
1177
   done # "$s"
 
1178
       _have_children_="0"
 
1179
       for t in `cat "$MK_SECT2"` ; do test "$r" = "$t" && continue
 
1180
           test "$_have_children_" = "0" && _have_children_="1" && \
 
1181
       echo_subpage_line  "$r" "<!--mksite:sect2:A--><br>$_sect2" # $++
 
1182
           make_subpage_entry "$r" "$t" # $++
 
1183
       done # "$t"
 
1184
           test "$_have_children_" = "1" && \
 
1185
       echo_subpage_line  "$r" "<!--mksite:sect2:Z-->" # $++
 
1186
   done # "$r"
 
1187
 
 
1188
   # round three - for each subsubsection print a current and subpage menu
 
1189
   for r in `cat "$MK_SECT1"` ; do
 
1190
   site_get_subpages "$r"     > "$MK_SECT2"
 
1191
   for s in `cat "$MK_SECT2"` ; do test "$r" = "$s" && continue
 
1192
   site_get_subpages "$s"     > "$MK_SECT3"
 
1193
   for t in `cat "$MK_SECT3"` ; do test "$s" = "$t" && continue
 
1194
       echo_current_line  "$t" "<!--mksite:sect3:A--><br>$_sect3" # $++
 
1195
       for u in `cat "$MK_SECT3"` ; do test "$s" = "$u" && continue
 
1196
           make_current_entry "$t" "$u" # $++
 
1197
       done # "$u"
 
1198
       echo_current_line  "$t" "<!--mksite:sect3:Z-->" # $++
 
1199
   done # "$t"
 
1200
       _have_children_="0"
 
1201
       for u in `cat "$MK_SECT3"` ; do test "$u" = "$s" && continue
 
1202
           test "$_have_children_" = "0" && _have_children_="1" && \
 
1203
       echo_subpage_line  "$s" "<!--mksite:sect3:A--><br>$_sect3" # $++
 
1204
           make_subpage_entry "$s" "$u" # $++
 
1205
       done # "$u"
 
1206
           test "$_have_children_" = "1" && \
 
1207
       echo_subpage_line  "$s" "<!--mksite:sect3:Z-->" # $++
 
1208
   done # "$s"
 
1209
   done # "$r"
 
1210
   echo "<a name=\".\"></a>" # $++
 
1211
   echo "</body></html>"    # $++
 
1212
}
 
1213
 
 
1214
# create a selector that can grep a printsitefile for the matching entries
 
1215
select_in_printsitefile () # arg = "page" : return to stdout >> $P.$HEAD
 
1216
{
 
1217
   _selected_="$1" ; test ".$_selected_" = "." && _selected_="$F"
 
1218
   _section_=`sed_slash_key "$_selected_"`
 
1219
   echo "s/^<!--$_SECT\"$_section_\"-->//"        # sect3
 
1220
   echo "s/^<!--$_SECT[*]:\"$_section_\"-->//"    # children
 
1221
   _selected_=`site_get_parentpage "$_selected_"` 
 
1222
   _section_=`sed_slash_key "$_selected_"`
 
1223
   echo "s/^<!--$_SECT\"$_section_\"-->//"        # sect2
 
1224
   _selected_=`site_get_parentpage "$_selected_"` 
 
1225
   _section_=`sed_slash_key "$_selected_"`
 
1226
   echo "s/^<!--$_SECT\"$_section_\"-->//"        # sect1
 
1227
   echo "/^<!--$_SECT\"[^\"]*\"-->/d"     
 
1228
   echo "/^<!--$_SECT[*]:\"[^\"]*\"-->/d" 
 
1229
   echo "s/^<!--mksite:sect[$NN]:[$AZ]-->//"
 
1230
}
 
1231
 
 
1232
body_for_emailfooter ()
 
1233
{
 
1234
    test ".$emailfooter" = ".no" && return
 
1235
    _email_=`echo "$emailfooter" | sed -e "s|[?].*||"`
 
1236
    _dated_=`info_get_entry updated`
 
1237
    echo "<hr><table border=\"0\" width=\"100%\"><tr><td>"
 
1238
    echo "<a href=\"mailto:$emailfooter\">$_email_</a>"
 
1239
    echo "</td><td align=\"right\">"
 
1240
    echo "$_dated_</td></tr></table>"
 
1241
}
 
1242
 
 
1243
# ==========================================================================
 
1244
#  
 
1245
#  During processing we will create a series of intermediate files that
 
1246
#  store relations. They all have the same format being
 
1247
#   =relationtype=key value
 
1248
#  where key is usually s filename or an anchor. For mere convenience
 
1249
#  we assume that the source html text does not have lines that start
 
1250
#  off with =xxxx= (btw, ye remember perl section notation...). Of course
 
1251
#  any other format would be usuable as well.
 
1252
#
 
1253
 
 
1254
# we scan the SITEFILE for href references to be converted
 
1255
# - in the new variant we use a ".gets.tmp" sed script that            SECTS
 
1256
# marks all interesting lines so they can be checked later
 
1257
# with an sed anchor of <!--sect[$NN]--> (or <!--sect[$AZ]-->)
 
1258
S="\\&nbsp\\;"
 
1259
# S="[&]nbsp[;]"
 
1260
 
 
1261
# HR and EM style markups must exist in input - BR sometimes left out 
 
1262
# these routines in(ter)ject hardspace before, between, after markups
 
1263
# note that "<br>" is sometimes used with HR - it must exist in input
 
1264
echo_HR_EM_PP ()
 
1265
{
 
1266
    echo "/^$1$2$3*<a href=/s/^/$4/"
 
1267
    echo "/^<>$1$2$3*<a href=/s/^/$4/"
 
1268
    echo "/^$S$1$2$3*<a href=/s/^/$4/"
 
1269
    echo "/^$1<>$2$3*<a href=/s/^/$4/"
 
1270
    echo "/^$1$S$2$3*<a href=/s/^/$4/"
 
1271
    echo "/^$1$2<>$3*<a href=/s/^/$4/"
 
1272
    echo "/^$1$2$S$3*<a href=/s/^/$4/"
 
1273
}
 
1274
 
 
1275
echo_br_EM_PP ()
 
1276
{
 
1277
    echo_HR_EM_PP  "$1" "$2" "$3" "$4"
 
1278
    echo "/^$2$3*<a href=/s/^/$4/"
 
1279
    echo "/^<>$2$3*<a href=/s/^/$4/"
 
1280
    echo "/^$S$2$3*<a href=/s/^/$4/"
 
1281
    echo "/^$2<>$3*<a href=/s/^/$4/"
 
1282
    echo "/^$2$S$3*<a href=/s/^/$4/"
 
1283
}    
 
1284
 
 
1285
echo_HR_PP ()
 
1286
{
 
1287
    echo "/^$1$2*<a href=/s/^/$3/"
 
1288
    echo "/^<>$1$2*<a href=/s/^/$3/"
 
1289
    echo "/^$S$1$2*<a href=/s/^/$3/"
 
1290
    echo "/^$1<>$2*<a href=/s/^/$3/"
 
1291
    echo "/^$1$S$2*<a href=/s/^/$3/"
 
1292
}
 
1293
echo_br_PP ()
 
1294
{
 
1295
    echo_HR_PP "$1" "$2" "$3"
 
1296
    echo "/^$2*<a href=/s/^/$3/"
 
1297
    echo "/^<>$2*<a href=/s/^/$3/"
 
1298
    echo "/^$S$2*<a href=/s/^/$3/"
 
1299
}
 
1300
echo_sp_PP ()
 
1301
{
 
1302
    echo "/^<>$1*<a href=/s/^/$2/"
 
1303
    echo "/^$S$1*<a href=/s/^/$2/"
 
1304
    echo "/^<><>$1*<a href=/s/^/$2/"
 
1305
    echo "/^$S$S$1*<a href=/s/^/$2/"
 
1306
    echo "/^<>$1<>*<a href=/s/^/$2/"
 
1307
    echo "/^$S$1$S*<a href=/s/^/$2/"
 
1308
    echo "/^$1<><>*<a href=/s/^/$2/"
 
1309
    echo "/^$1$S$S*<a href=/s/^/$2/"
 
1310
    echo "/^$1<>*<a href=/s/^/$2/"
 
1311
    echo "/^$1$S*<a href=/s/^/$2/"
 
1312
}
 
1313
 
 
1314
echo_sp_sp ()
 
1315
{
 
1316
    echo "/^$1*<a name=/s/^/$2/"
 
1317
    echo "/^<>$1*<a name=/s/^/$2/"
 
1318
    echo "/^$S$1*<a name=/s/^/$2/"
 
1319
    echo "/^<><>$1*<a name=/s/^/$2/"
 
1320
    echo "/^$S$S$1*<a name=/s/^/$2/"
 
1321
    echo "/^<>$1<>*<a name=/s/^/$2/"
 
1322
    echo "/^$S$1$S*<a name=/s/^/$2/"
 
1323
    echo "/^$1<><>*<a name=/s/^/$2/"
 
1324
    echo "/^$1$S$S*<a name=/s/^/$2/"
 
1325
    echo "/^$1<>*<a name=/s/^/$2/"
 
1326
    echo "/^$1$S*<a name=/s/^/$2/"
 
1327
}
 
1328
 
 
1329
make_sitemap_init()
 
1330
{
 
1331
    # build a list of detectors that map site.htm entries to a section table
 
1332
    # note that the resulting .gets.tmp / .puts.tmp are real sed-script
 
1333
    h1="[-|[]"
 
1334
    b1="[*=]"
 
1335
    b2="[-|[]"
 
1336
    b3="[\\/:]"
 
1337
    q3="[\\/:,[]"
 
1338
    echo_HR_PP    "<hr>"            "$h1"    "<!--sect1-->"      > "$MK_GETS"
 
1339
    echo_HR_EM_PP "<hr>" "<em>"     "$h1"    "<!--sect1-->"     >> "$MK_GETS"
 
1340
    echo_HR_EM_PP "<hr>" "<strong>" "$h1"    "<!--sect1-->"     >> "$MK_GETS"
 
1341
    echo_HR_PP    "<br>"            "$b1$b1" "<!--sect1-->"     >> "$MK_GETS"
 
1342
    echo_HR_PP    "<br>"            "$b2$b2" "<!--sect2-->"     >> "$MK_GETS"
 
1343
    echo_HR_PP    "<br>"            "$b3$b3" "<!--sect3-->"     >> "$MK_GETS"
 
1344
    echo_br_PP    "<br>"            "$b2$b2" "<!--sect2-->"     >> "$MK_GETS"
 
1345
    echo_br_PP    "<br>"            "$b3$b3" "<!--sect3-->"     >> "$MK_GETS"
 
1346
    echo_br_EM_PP "<br>" "<small>"  "$q3"    "<!--sect3-->"     >> "$MK_GETS"
 
1347
    echo_br_EM_PP "<br>" "<em>"     "$q3"    "<!--sect3-->"     >> "$MK_GETS"
 
1348
    echo_br_EM_PP "<br>" "<u>"      "$q3"    "<!--sect3-->"     >> "$MK_GETS"
 
1349
    echo_HR_PP    "<br>"            "$q3"    "<!--sect3-->"     >> "$MK_GETS"
 
1350
    echo_sp_PP                      "$q3"    "<!--sect3-->"     >> "$MK_GETS"
 
1351
    echo_sp_sp                      "$q3"    "<!--sect9-->"     >> "$MK_GETS"
 
1352
    $SED -e "s/\\(>\\)\\(\\[\\)/\\1 *\\2/" "$MK_GETS" > "$MK_PUTS"
 
1353
    # the .puts.tmp variant is used to <b><a href=..></b> some hrefs which
 
1354
    # shall not be used otherwise for being generated - this is nice for
 
1355
    # some quicklinks somewhere. The difference: a whitspace "<hr> <a...>"
 
1356
}
 
1357
 
 
1358
_uses_="=use\\1=\\2 \\3" ; _name_="=use\\1=name:\\2 \\3" ; 
 
1359
_getW_="<!--sect\\([$NN]\\)-->"
 
1360
_getX_="<!--sect\\([$NN]\\)--><[^<>]*>[^<>]*"
 
1361
_getY_="<!--sect\\([$NN]\\)--><[^<>]*>[^<>]*<[^<>]*>[^<>]*"
 
1362
 
 
1363
make_sitemap_list()
 
1364
{
 
1365
    # scan sitefile for references pages - store as "=use+=href+ anchortext"
 
1366
    $SED -f $MK_GETS           -e "/^<!--sect[$NN]-->/!d" \
 
1367
        -e "s|^$_getX_<a href=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*|$_uses_|" \
 
1368
        -e "s|^$_getY_<a href=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*|$_uses_|" \
 
1369
        -e "s|^$_getW_<a name=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*|$_name_|" \
 
1370
        -e "s|^$_getX_<a name=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*|$_name_|" \
 
1371
        -e "s|^$_getY_<a name=\"\\([^\"]*\\)\"[^<>]*>\\(.*\\)</a>.*|$_name_|" \
 
1372
        -e "/^=....=/!d"    "$SITEFILE" > "$MK_INFO"
 
1373
}
 
1374
 
 
1375
make_sitemap_sect() 
 
1376
{
 
1377
    # scan used pages and store prime section group relation =sect= and =node=
 
1378
    # (A) each "use1" creates "=sect=href+ href1" for all following non-"use1"
 
1379
    # (B) each "use1" creates "=node=href2 href1" for all following "use2"
 
1380
    $SED -e "/=use.=/!d" \
 
1381
        -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \
 
1382
        -e "s/=use.=\\([^ ]*\\) .*/=sect=\\1/" \
 
1383
        -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO"
 
1384
    $SED -e "/=use.=/!d" \
 
1385
        -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \
 
1386
        -e "/=use[13456789]=/d" \
 
1387
        -e "s/=use.=\\([^ ]*\\) .*/=node=\\1/" \
 
1388
        -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO"
 
1389
}
 
1390
 
 
1391
make_sitemap_page()
 
1392
{
 
1393
    # scan used pages and store secondary group relation =page= and =node=
 
1394
    # the parenting =node= for use3 is usually a use2 (or use1 if none there)
 
1395
    $SED -e "/=use.=/!d" \
 
1396
        -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \
 
1397
        -e "/=use2=/{" -e "h" -e "s:=use2=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \
 
1398
        -e "/=use[1]=/d" \
 
1399
        -e "s/=use.=\\([^ ]*\\) .*/=page=\\1/" \
 
1400
        -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO"
 
1401
    $SED -e "/=use.=/!d" \
 
1402
        -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \
 
1403
        -e "/=use2=/{" -e "h" -e "s:=use2=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \
 
1404
        -e "/=use[12456789]=/d" \
 
1405
        -e "s/=use.=\\([^ ]*\\) .*/=node=\\1/" \
 
1406
        -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO"
 
1407
    # and for the root sections we register ".." as the parenting group
 
1408
    $SED -e "/=use1=/!d" \
 
1409
        -e "s/=use.=\\([^ ]*\\) .*/=node=\\1 ../"  "$MK_INFO" >> "$MK_INFO"
 
1410
}
 
1411
echo_site_filelist()
 
1412
{
 
1413
    $SED -e "/=use.=/!d" -e "s/=use.=//" -e "s/ .*//" "$MK_INFO"
 
1414
}
 
1415
 
 
1416
# ==========================================================================
 
1417
# originally this was a one-pass compiler but the more information
 
1418
# we were scanning out the more slower the system ran - since we
 
1419
# were rescanning files for things like section information. Now
 
1420
# we scan the files first for global information.
 
1421
#                                                                    1.PASS
 
1422
 
 
1423
scan_sitefile () # $F
 
1424
{
 
1425
 SOURCEFILE=`html_sourcefile "$F"`
 
1426
 if test "$SOURCEFILE" != "$F" ; then
 
1427
   dx_init "$F"
 
1428
   dx_text today "`timetoday`"
 
1429
   short=`echo "$F" | $SED -e "s:.*/::" -e "s:[.].*::"` # basename for all exts
 
1430
   short="$short ~"
 
1431
   DC_meta title "$short"
 
1432
   DC_meta date.available "`timetoday`"
 
1433
   DC_meta subject sitemap
 
1434
   DC_meta DCMIType Collection
 
1435
   DC_VARS_Of "$SOURCEFILE"  ; HTTP_VARS_Of "$SOURCEFILE"
 
1436
   DC_modified "$SOURCEFILE" ; DC_date "$SOURCEFILE"
 
1437
   DC_section "$F"
 
1438
   DX_text date.formatted `timetoday`
 
1439
   test ".$printerfriendly" != "." && \
 
1440
   DX_text "printerfriendly" `fast_html_printerfile "$F"`
 
1441
   test ".$USER" != "." && DC_publisher "$USER"
 
1442
   echo "'$SOURCEFILE': $short (sitemap)"
 
1443
   site_map_list_title "$F" "$short"
 
1444
   site_map_long_title "$F" "generated sitemap index"
 
1445
   site_map_list_date  "$F" "`timetoday`"
 
1446
 fi
 
1447
}
 
1448
 
 
1449
scan_htmlfile() # "$F"
 
1450
{
 
1451
 SOURCEFILE=`html_sourcefile "$F"`                                    # SCAN :
 
1452
 if test "$SOURCEFILE" != "$F" ; then :                               # HTML :
 
1453
 if test -f "$SOURCEFILE" ; then make_fast "$F" > "$tmp/$F.$FAST"
 
1454
   dx_init "$F"
 
1455
   dx_text today "`timetoday`"
 
1456
   dx_text todays "`timetodays`"
 
1457
   DC_VARS_Of "$SOURCEFILE" ; HTTP_VARS_Of "$SOURCEFILE"
 
1458
   DC_title "$SOURCEFILE"
 
1459
   DC_isFormatOf "$SOURCEFILE" 
 
1460
   DC_modified "$SOURCEFILE" ; DC_date "$SOURCEFILE" ; DC_date "$SITEFILE"
 
1461
   DC_section "$F" ;  DC_selected "$F" ;  DX_alternative "$SOURCEFILE"
 
1462
   test ".$USER" != "." && DC_publisher "$USER"
 
1463
   DX_text date.formatted "`timetoday`"
 
1464
   test ".$printerfriendly" != "." && \
 
1465
   DX_text "printerfriendly" `fast_html_printerfile "$F"`
 
1466
   sectn=`info_get_entry DC.relation.section`
 
1467
   short=`info_get_entry DC.title.selected`
 
1468
   site_map_list_title "$F" "$short"
 
1469
   info_map_list_title "$F" "$short"
 
1470
   title=`info_get_entry DC.title`
 
1471
   site_map_long_title "$F" "$title"
 
1472
   info_map_long_title "$F" "$title"
 
1473
   edate=`info_get_entry DC.date`
 
1474
   issue=`info_get_entry issue`
 
1475
   site_map_list_date "$F" "$edate"
 
1476
   info_map_list_date "$F" "$edate"
 
1477
   echo "'$SOURCEFILE':  '$title' ('$short') @ '$issue' ('$sectn')"
 
1478
 else
 
1479
   echo "'$SOURCEFILE': does not exist"
 
1480
   site_map_list_title "$F" "$F"
 
1481
   site_map_long_title "$F" "$F (no source)"
 
1482
 fi ; else
 
1483
   echo "<$F> - skipped"
 
1484
 fi
 
1485
}
 
1486
 
 
1487
scan_namespec ()
 
1488
{
 
1489
    # nothing so far
 
1490
    case "$1" in
 
1491
        name:sitemap:*)
 
1492
            short=`echo "$F" | $SED -e "s:.*/::" -e "s:[.].*::"` 
 
1493
            short=`echo "$short ~" | $SED -e "s/name:sitemap://"` 
 
1494
            site_map_list_title "$F" "$short"
 
1495
            site_map_long_title "$F" "external sitemap index"
 
1496
            site_map_list_date  "$F" "`timetoday`"
 
1497
            echo "'$F' external sitemap index$n" 
 
1498
            ;;
 
1499
    esac
 
1500
}
 
1501
scan_httpspec ()
 
1502
{
 
1503
    # nothing so far
 
1504
    return;
 
1505
}
 
1506
 
 
1507
skip_namespec ()
 
1508
{
 
1509
    # nothing so far
 
1510
    return;
 
1511
}
 
1512
skip_httpspec ()
 
1513
{
 
1514
    # nothing so far
 
1515
    return;
 
1516
}
 
1517
 
 
1518
# ==========================================================================
 
1519
# and now generate the output pages
 
1520
#                                                                   2.PASS
 
1521
 
 
1522
head_sed_sitemap() # $filename $section
 
1523
{
 
1524
   FF="$1"
 
1525
   SECTION=`sed_slash_key "$2"`
 
1526
   SECTS="<!--sect[$NN$AZ]-->" ; SECTN="<!--sect[$NN]-->" # lines with hrefs
 
1527
   echo "/^$SECTS.*<a href=\"$FF\">/s|</a>|</a></b>|"          # $++
 
1528
   echo "/^$SECTS.*<a href=\"$FF\">/s|<a href=|<b><a href=|"   # $++
 
1529
   test ".$sectiontab" != ".no" && \
 
1530
   echo "/ href=\"$SECTION\"/s|^<td class=\"[^\"]*\"|<td |"    # $++
 
1531
}
 
1532
 
 
1533
head_sed_listsection() # $filename $section
 
1534
{
 
1535
   # traditional.... the sitefile is the full navigation bar
 
1536
   FF=`sed_slash_key "$1"`
 
1537
   SECTION=`sed_slash_key "$2"`
 
1538
   SECTS="<!--sect[$NN$AZ]-->" ; SECTN="<!--sect[$NN]-->" # lines with hrefs
 
1539
   echo "/^$SECTS.*<a href=\"$FF\">/s|</a>|</a></b>|"          # $++
 
1540
   echo "/^$SECTS.*<a href=\"$FF\">/s|<a href=|<b><a href=|"   # $++
 
1541
   test ".$sectiontab" != ".no" && \
 
1542
   echo "/ href=\"$SECTION\"/s|^<td class=\"[^\"]*\"|<td |"    # $++
 
1543
}
 
1544
 
 
1545
head_sed_multisection() # $filename $section
 
1546
{
 
1547
   # sitefile navigation bar is split into sections
 
1548
   FF=`sed_slash_key "$1"`
 
1549
   SECTION=`sed_slash_key "$2"`
 
1550
   SECTS="<!--sect[$NN$AZ]-->" ; SECTN="<!--sect[$NN]-->" # lines with hrefs
 
1551
   # grep all pages with a =sect= relation to current $SECTION and
 
1552
   # build foreach an sed line "s|$SECTS\(<a href=$F>\)|<!--sectX-->\1|"
 
1553
   # after that all the (still) numeric SECTNs are deactivated / killed.
 
1554
   for section in $SECTION $headsection $tailsection ; do
 
1555
       test ".$section" = ".no" && continue
 
1556
   $SED -e "/^=sect=[^ ]* $section/!d" \
 
1557
        -e "s, .*,\"\\\\)|<!--sectX-->\\\\1|,"  \
 
1558
        -e "s,^=sect=,s|^$SECTS\\\\(.*<a href=\"," "$MK_INFO"  # $++
 
1559
   done
 
1560
   echo "s|^$SECTN[^ ]*\\(<a href=[^<>]*>\\).*|<!-- \\1 -->|"  # $++
 
1561
   echo "/^$SECTS.*<a href=\"$FF\">/s|</a>|</a></b>|"          # $++
 
1562
   echo "/^$SECTS.*<a href=\"$FF\">/s|<a href=|<b><a href=|"   # $++
 
1563
   test ".$sectiontab" != ".no" && \
 
1564
   echo "/ href=\"$SECTION\"/s|^<td class=\"[^\"]*\"|<td |"    # $++
 
1565
}
 
1566
 
 
1567
make_sitefile () # "$F"
 
1568
{
 
1569
 SOURCEFILE=`html_sourcefile "$F"`
 
1570
 if test "$SOURCEFILE" != "$F" ; then
 
1571
 if test -f "$SOURCEFILE" ; then 
 
1572
   # remember that in this case "${SITEFILE}l" = "$F" = "${SOURCEFILE}l"
 
1573
   info2vars_sed > $MK_VARS           # have <!--title--> vars substituted
 
1574
   info2meta_sed > $MK_META           # add <meta name="DC.title"> values
 
1575
   if test ".$simplevars" = ".warn" ; then
 
1576
   info2test_sed > $MK_TEST           # check <!--title--> vars old-style
 
1577
   $SED_LONGSCRIPT "$MK_TEST" "$SOURCEFILE" | tee -a "$MK_OLDS" ; fi
 
1578
   F_HEAD="$tmp/$F.$HEAD" ; F_FOOT="$tmp/$F.$FOOT"
 
1579
   $CAT "$MK_PUTS"                                    > "$F_HEAD"
 
1580
   head_sed_sitemap "$F" "`info_get_entry_section`"  >> "$F_HEAD"
 
1581
   echo "/<head>/r $MK_META"                         >> "$F_HEAD"
 
1582
   $CAT "$MK_VARS" "$MK_TAGS"                        >> "$F_HEAD"
 
1583
   echo "/<\\/body>/d"                               >> "$F_HEAD"
 
1584
   case "$sitemaplayout" in
 
1585
   multi) make_multisitemap > "$F_FOOT" ;;       # here we use ~foot~ to
 
1586
   *)     make_listsitemap  > "$F_FOOT" ;;       # hold the main text
 
1587
   esac
 
1588
 
 
1589
   mkpathfile "$F"
 
1590
   $SED_LONGSCRIPT "$F_HEAD"               "$SITEFILE"  > $F   # ~head~
 
1591
   $CAT            "$F_FOOT"                           >> $F   # ~body~
 
1592
   $SED -e "/<\\/body>/!d" -f "$MK_VARS"   "$SITEFILE" >> $F   #</body>
 
1593
   echo "'$SOURCEFILE': " `ls -s $SOURCEFILE` ">->" `ls -s $F` "(sitemap)"
 
1594
 else
 
1595
   echo "'$SOURCEFILE': does not exist"
 
1596
 fi fi
 
1597
}
 
1598
 
 
1599
make_htmlfile() # "$F"
 
1600
{
 
1601
 SOURCEFILE=`html_sourcefile "$F"`                      #     2.PASS
 
1602
 if test "$SOURCEFILE" != "$F" ; then
 
1603
 if test -f "$SOURCEFILE" ; then
 
1604
   if grep '<meta name="formatter"' "$SOURCEFILE" >/dev/null ; then
 
1605
     echo "$SOURCEFILE: SKIP, this sourcefile looks like a formatted file"
 
1606
     echo "$SOURCEFILE:  (may be a sourcefile in place of a targetfile?)"
 
1607
     return
 
1608
   fi
 
1609
   info2vars_sed > $MK_VARS           # have <!--$title--> vars substituted
 
1610
   info2meta_sed > $MK_META           # add <meta name="DC.title"> values
 
1611
   if test ".$simplevars" = ".warn" ; then
 
1612
   info2test_sed > $MK_TEST           # check <!--title--> vars old-style
 
1613
   $SED_LONGSCRIPT "$MK_TEST" "$SOURCEFILE" | tee -a "$MK_OLDS" ; fi
 
1614
   F_HEAD="$tmp/$F.$HEAD" ; F_BODY="$tmp/$F.$BODY" ; F_FOOT="$tmp/$F.$FOOT"
 
1615
   $CAT "$MK_PUTS"                        > "$F_HEAD"
 
1616
   case "$sectionlayout" in
 
1617
   multi) head_sed_multisection "$F" "`info_get_entry_section`" >> "$F_HEAD" ;;
 
1618
       *) head_sed_listsection  "$F" "`info_get_entry_section`" >> "$F_HEAD" ;;
 
1619
   esac
 
1620
      $CAT "$MK_VARS" "$MK_TAGS"            >> "$F_HEAD" #tag and vars
 
1621
      echo "/<\\/body>/d"                   >> "$F_HEAD" #cut lastline
 
1622
      echo "/<head>/r $MK_META"             >> "$F_HEAD" #add metatags
 
1623
      echo "/<title>/d"                      > "$F_BODY" #not that line
 
1624
      $CAT "$MK_VARS" "$MK_TAGS"            >> "$F_BODY" #tag and vars
 
1625
      bodymaker_for_sectioninfo             >> "$F_BODY" #if sectioninfo
 
1626
      info2body_sed                         >> "$F_BODY" #cut early
 
1627
      info2head_sed                         >> "$F_HEAD"
 
1628
      $CAT "$tmp/$F.$FAST"                  >> "$F_HEAD"
 
1629
      test ".$emailfooter" != ".no" && \
 
1630
      body_for_emailfooter                   > "$F_FOOT"
 
1631
 
 
1632
      mkpathfile "$F"
 
1633
      $SED_LONGSCRIPT "$F_HEAD" $SITEFILE                > $F # ~head~
 
1634
      $SED_LONGSCRIPT "$F_BODY" $SOURCEFILE             >> $F # ~body~
 
1635
      test -f "$F_FOOT" && $CAT "$F_FOOT"               >> $F # ~foot~
 
1636
      $SED -e "/<\\/body>/!d" -f "$MK_VARS" "$SITEFILE" >> $F #</body>
 
1637
   echo "'$SOURCEFILE': " `ls -s $SOURCEFILE` "->" `ls -s $F`
 
1638
 else # test -f $SOURDEFILE
 
1639
   echo "'$SOURCEFILE': does not exist"
 
1640
 fi ; else
 
1641
   echo "<$F> - skipped"
 
1642
 fi
 
1643
}
 
1644
 
 
1645
make_printerfriendly () # "$F"
 
1646
{                                                                 # PRINTER
 
1647
  printsitefile="0"                                               # FRIENDLY
 
1648
  P=`html_printerfile "$F"`
 
1649
  F_FAST="$tmp/$F.$FAST"
 
1650
  P_HEAD="$tmp/$P.$HEAD"
 
1651
  P_BODY="$tmp/$P.$BODY"
 
1652
  case "$F" in
 
1653
  ${SITEFILE}|${SITEFILE}l) make_fast "$F" > "$F_FAST"
 
1654
          printsitefile=">=>" ; BODY_TXT="$tmp/$F.$FOOT"  ;;
 
1655
  *.html) printsitefile="=>" ;  BODY_TXT="$SOURCEFILE" ;;
 
1656
  esac
 
1657
  if grep '<meta name="formatter"' "$BODY_TXT" >/dev/null ; then return; fi
 
1658
  if test ".$printsitefile" != ".0" && test -f "$SOURCEFILE" ; then
 
1659
      make_printerfile_fast "$FILELIST" > ./$MK_FAST
 
1660
      $CAT "$MK_VARS" "$MK_TAGS" "$MK_FAST" > "$P_HEAD"
 
1661
      $SED -e "/DC.relation.isFormatOf/s|content=\"[^\"]*\"|content=\"$F\"|" \
 
1662
           "$MK_META" > "$MK_METT"
 
1663
      echo "/<head>/r $MK_METT"                       >> "$P_HEAD" # meta
 
1664
      echo "/<\\/body>/d"                             >> "$P_HEAD"
 
1665
      select_in_printsitefile "$F"                    >> "$P_HEAD"
 
1666
      _ext_=`print_extension "$printerfriendly"`                     # head-
 
1667
      $SED -e "s/[.]html\"|/$_ext_&/g" "$F_FAST"      >> "$P_HEAD" # hrefs
 
1668
      # line_=`sed_slash_key "$printsitefile_img_2"`                   # back-
 
1669
      echo "/||topics:/s| href=\"[#][.]\"| href=\"$F\"|" >> "$P_HEAD"
 
1670
      echo "/|||pages:/s| href=\"[#][.]\"| href=\"$F\"|" >> "$P_HEAD"
 
1671
      $CAT                             "$F_FAST"      >> "$P_HEAD" # subdir
 
1672
      $CAT "$MK_VARS" "$MK_TAGS" "$MK_FAST"            > "$P_BODY"
 
1673
      $SED -e "s/[.]html\"|/$_ext_&/g" "$F_FAST"      >> "$P_BODY" # body-
 
1674
      $CAT                             "$F_FAST"      >> "$P_BODY" # hrefs
 
1675
 
 
1676
      mkpathfile "$P"
 
1677
      $SED_LONGSCRIPT "$P_HEAD"              $PRINTSITEFILE  > $P # ~head~
 
1678
      $SED_LONGSCRIPT "$P_BODY"                   $BODY_TXT >> $P # ~body~
 
1679
      $SED -e "/<\\/body>/!d" -f $MK_VARS $PRINTSITEFILE >> $P #</body>
 
1680
   echo "'$SOURCEFILE': " `ls -s $SOURCEFILE` "$printsitefile" `ls -s $P`
 
1681
   fi 
 
1682
}
 
1683
 
 
1684
 
 
1685
# ========================================================================
 
1686
# ========================================================================
 
1687
# ========================================================================
 
1688
 
 
1689
# ========================================================================
 
1690
#                                                          #### 0. INIT
 
1691
make_sitemap_init
 
1692
make_sitemap_list
 
1693
make_sitemap_sect
 
1694
make_sitemap_page
 
1695
 
 
1696
FILELIST=`echo_site_filelist`
 
1697
if test ".$opt_filelist" != "." || test ".$opt_list" = ".file"; then
 
1698
   for F in $FILELIST; do echo "$F" ; done ; exit # --filelist
 
1699
fi
 
1700
if test ".$opt_files" != "." ; then FILELIST="$opt_files" ; fi # --files
 
1701
if test ".$FILELIST" = "."; then echo "nothing to do" >&2 ; fi
 
1702
if test ".$FILELIST" = ".SITEFILE" ; then echo "only '$SITEFILE'?!" >&2 ; fi
 
1703
 
 
1704
for F in $FILELIST ; do case "$F" in                       #### 1. PASS
 
1705
name:*)                   scan_namespec "$F" ;;
 
1706
http:*|*://*)             scan_httpspec "$F" ;;
 
1707
${SITEFILE}|${SITEFILE}l) scan_sitefile "$F" ;;   # ........... SCAN SITE
 
1708
../*) 
 
1709
   echo "!! -> '$F' (skipping topdir build)"
 
1710
   ;;
 
1711
# */*.html) 
 
1712
#    make_fast  > $F.$FAST # try for later subdir build
 
1713
#    echo "!! -> '$F' (skipping subdir build)"
 
1714
#    ;;
 
1715
# */*/*/|*/*/|*/|*/index.htm|*/index.html) 
 
1716
#    echo "!! -> '$F' (skipping subdir index.html)"
 
1717
#    ;;
 
1718
*.html) scan_htmlfile "$F" ;;                      # ........... SCAN HTML
 
1719
*/) echo "'$F' : directory - skipped"
 
1720
   site_map_list_title "$F" "`sed_slash_key $F`"
 
1721
   site_map_long_title "$F" "(directory)"
 
1722
   ;;
 
1723
*) echo "?? -> '$F'"
 
1724
   ;;
 
1725
esac done
 
1726
 
 
1727
if test ".$printerfriendly" != "." ; then           # .......... PRINT VERSION
 
1728
  _ext_=`print_extension "$printerfriendly" | sed -e "s/&/\\\\&/"`
 
1729
  PRINTSITEFILE=`echo "$SITEFILE" | sed -e "s/\\.[$AA]*\$/$_ext_&/"`
 
1730
  echo "NOTE: going to create printer-friendly sitefile $PRINTSITEFILE"
 
1731
  make_printsitefile > "$PRINTSITEFILE"
 
1732
fi
 
1733
 
 
1734
if test ".$simplevars" = ". " ; then
 
1735
mknewfile $MK_OLDS 
 
1736
fi
 
1737
 
 
1738
for F in $FILELIST ; do case "$F" in                        #### 2. PASS
 
1739
name:*)                    skip_namespec "$F" ;; 
 
1740
http:*|*://*)              skip_httpspec "$F" ;;
 
1741
${SITEFILE}|${SITEFILE}l)  make_sitefile "$F"           # ........ SITE FILE
 
1742
    if test ".$printerfriendly" != "." ; then make_printerfriendly "$F" ; fi ;;
 
1743
../*) 
 
1744
    echo "!! -> '$F' (skipping topdir build)"
 
1745
    ;;
 
1746
# */*.html) 
 
1747
#   echo "!! -> '$F' (skipping subdir build)"
 
1748
#   ;;
 
1749
# */*/*/|*/*/|*/|*/index.htm|*/index.html) 
 
1750
#   echo "!! -> '$F' (skipping subdir index.html)"
 
1751
#   ;;
 
1752
*.html)  make_htmlfile "$F"                  # .................. HTML FILES
 
1753
    if test ".$printerfriendly" != "." ; then make_printerfriendly "$F" ; fi ;;
 
1754
*/) echo "'$F' : directory - skipped"
 
1755
    ;;
 
1756
*)  echo "?? -> '$F'"
 
1757
    ;;
 
1758
esac
 
1759
# .............. debug ....................
 
1760
   if test -d DEBUG && test -f "./$F" ; then
 
1761
      FFFF=`echo "$F" | sed -e s,/,:,g`
 
1762
      cp "$tmp/$F.$INFO" DEBUG/$FFFF.info.TMP
 
1763
      for P in tags vars meta page date list html sect info ; do
 
1764
      test -f $tmp/$MK.$P.tmp && cp $tmp/$MK.$P.tmp DEBUG/$FFFF.$P.tmp
 
1765
      test -f $tmp/$MK.$P.TMP && cp $tmp/$MK.$P.TMP DEBUG/$FFFF.$P.TMP
 
1766
      done
 
1767
   fi
 
1768
done
 
1769
 
 
1770
if test ".$simplevars" = ".warn" ; then if test -f "$MK_OLDS" ; then
 
1771
oldvars=`cat "$MK_OLDS" | wc -l | $SED -e "s/ *//g"`
 
1772
if test "$oldvars" = "0" ; then
 
1773
echo "HINT: you have no simplevars in your htm sources, so you may want to"
 
1774
echo "hint: set the magic <!--mksite:nosimplevars--> in your $SITEFILE"
 
1775
echo "hint: which makes execution _faster_ actually in the 2. pass"
 
1776
echo "note: simplevars expansion was the oldstyle way of variable expansion"
 
1777
else
 
1778
echo "HINT: there were $oldvars simplevars found in your htm sources."
 
1779
echo "hint: This style of variable expansion will be disabled in the near"
 
1780
echo "hint: future. If you do not want change then add the $SITEFILE magic"
 
1781
echo "hint: <!--mksite:simplevars--> somewhere to suppress this warning"
 
1782
echo "note: simplevars expansion will be an explicit option in the future."
 
1783
echo "note: errornous simplevar detection can be suppressed with a magic"
 
1784
echo "note: hint of <!--mksite:nosimplevars--> in the $SITEFILE for now."
 
1785
fi fi fi
 
1786
 
 
1787
rm $tmp/$MK.*.tmp
 
1788
if test ".$tmp_dir_was_created" != ".no" ; then rm $tmp/* ; rmdir $tmp ; fi
 
1789
exit 0