/frameworks/trunk/zziplib/libzziplib/docs/mksite.sh
Shell | 1689 lines | 1457 code | 107 blank | 125 comment | 200 complexity | 1e4d2b0ec0665e789ed105fb2186902f MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, BSD-3-Clause, GPL-3.0, LGPL-3.0, MPL-2.0-no-copyleft-exception, Zlib, GPL-2.0
Large files files are truncated, but you can click here to view the full file
- #! /bin/sh
- # this is the sh/sed variant of the mksite script. It is largely
- # derived from snippets that I was using to finish doc pages for
- # website publishing. For the mksite project the functionaliy has
- # been expanded of course. Still this one does only use simple unix
- # commands like sed, date, and test. And it still works. :-)=)
- # http://zziplib.sf.net/mksite/
- # THE MKSITE.SH (ZLIB/LIBPNG) LICENSE
- # Copyright (c) 2004 Guido U. Draheim <guidod@gmx.de>
- # This software is provided 'as-is', without any express or implied warranty
- # In no event will the authors be held liable for any damages arising
- # from the use of this software.
- # Permission is granted to anyone to use this software for any purpose,
- # including commercial applications, and to alter it and redistribute it
- # freely, subject to the following restrictions:
- # 1. The origin of this software must not be misrepresented; you must not
- # claim that you wrote the original software. If you use this software
- # in a product, an acknowledgment in the product documentation would be
- # appreciated but is not required.
- # 2. Altered source versions must be plainly marked as such, and must not
- # be misrepresented as being the original software.
- # 3. This notice may not be removed or altered from any source distribution.
- # $Id: mksite.sh,v 1.5 2006-09-22 00:33:22 guidod Exp $
- # Zsh is not Bourne compatible without the following: (seen in autobook)
- if test -n "$ZSH_VERSION"; then
- emulate sh
- NULLCMD=:
- fi
- # initialize some defaults
- test ".$SITEFILE" = "." && test -f "site.htm" && SITEFILE="site.htm"
- test ".$SITEFILE" = "." && test -f "site.html" && SITEFILE="site.html"
- test ".$SITEFILE" = "." && SITEFILE="site.htm"
- MK="-mksite" # note the "-" at the start
- SED="sed"
- CAT="cat" # "sed -e n" would be okay too
- GREP="grep"
- DATE_NOW="date" # should be available on all posix systems
- DATE_R="date -r" # gnu date has it / solaris date not
- STAT_R="stat" # gnu linux
- LS_L="ls -l" # linux uses one less char than solaris
- DATA="~~" # extension for meta data files
- HEAD="~head~" # extension for head sed script
- BODY="~body~" # extension for body sed script
- FOOT="~foot~" # append to body text (non sed)
- NULL="/dev/null" # to divert stdout/stderr
- CATNULL="$CAT $NULL" # to create 0-byte files
- SED_LONGSCRIPT="$SED -f"
- Q='q class='
- QX='/q'
- LOWER="abcdefghijklmnopqrstuvwxyz"
- UPPER="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- az="$LOWER" # some old sed tools can not
- AZ="$UPPER" # use char-ranges in the
- NN="0123456789" # match expressions so that
- AA="_$NN$AZ$az" # we use their unrolled
- AX="$AA.+-" # definition here
- AP="|" # (pipe symbol in char-range)
- AK="[" # (open range in char-range)
- LANG="C" ; LANGUAGE="C" ; LC_COLLATE="C" # these are needed for proper
- export LANG LANGUAGE LC_COLLATE # lowercasing as some collate
- # treat A-Z to include a-z
- HTMLTAGS=" a p h1 h2 h3 h4 h5 h6 dl dd dt ul ol li pre code table tr td th"
- HTMLTAGS=" $HTMLTAGS b u i s q em strong strike cite big small sup sub tt"
- HTMLTAGS=" $HTMLTAGS thead tbody center hr br nobr wbr"
- HTMLTAGS=" $HTMLTAGS span div img adress blockquote"
- HTMLTAGS2=" html head body title meta http-equiv style link"
- # ==========================================================================
- if "${SHELL-/bin/sh}" -c 'foo () { exit 0; }; foo' 2>$NULL ; then : ; else
- echo "!! sorry, this shell '$SHELL' does not support shell functions" ; exit 1
- fi
- error ()
- {
- echo "ERROR:" "$@" 1>&2
- }
- warn ()
- {
- echo "WARN:" "$@" 1>&2
- }
- note ()
- {
- echo "NOTE:" "$@" 1>&2
- }
- hint=":"
- init ()
- {
- if test -d DEBUG
- then hint="note"
- fi
- if test "$SED" = "sed" ; then
- if gsed --version 2>$NULL | $GREP "GNU sed" >$NULL ; then
- SED="gsed"
- $hint "using 'gsed' as SED"
- fi
- fi
- if $SED --version 2>$NULL | $GREP "GNU sed" >$NULL ; then
- az="a-z" # but if we have GNU sed
- AZ="A-Z" # then we assume there are
- NN="0-9" # char-ranges available
- AA="_$NN$AZ$az" # that makes the resulting
- AX="$AA.+-" # script more readable
- $hint "found GNU sed - good"
- elif uname -s | $GREP HP-UX >$NULL ; then
- SED_LONGSCRIPT="sed_longscript" # due to 100 sed lines limit
- $hint "weird sed - hpux sed has a limit of 100 lines" \
- "- using sed_longscript mode"
- fi
- if echo "TEST" | sed -e "s%[:[]*TEST%OK%" | grep OK 2>&1 > $NULL
- then :
- elif echo "TEST" | sed -e "s%[:\\[]*TEST%OK%" | grep OK 2>&1 > $NULL
- then AK="\\[" ; $hint "AK=\\["
- else AK="" ; warn "buggy sed - disabled [ in char-ranges / fileref-tests"
- fi
- if echo "TEST" | sed -e "s%[:|]*TEST%OK%" | grep OK 2>&1 > $NULL
- then :
- elif echo "TEST" | sed -e "s%[:\\|]*TEST%OK%" | grep OK 2>&1 > $NULL
- then AP="\\[" ; $hint "AP=\\|"
- else AP="" ; warn "buggy sed - disabled | in char-ranges / fileref-tests"
- fi
- }
- init "NOW!!!"
- sed_debug ()
- {
- $note "sed" "$@" >&2
- sed "$@"
- }
- # ==========================================================================
- # reading options from the command line GETOPT
- opt_variables="files"
- opt_fileseparator="?"
- opt_files=""
- opt_main_file=""
- opt_formatter="$0"
- opt=""
- for arg in "$@" # this variant should allow to embed spaces in $arg
- do if test ".$opt" != "." ; then
- eval "export opt_$opt='$arg'"
- opt=""
- else
- case "$arg" in
- -*=*)
- opt=`echo "$arg" | $SED -e "s/-*\\([$AA][$AA-]*\\).*/\\1/" -e y/-/_/`
- if test ".$opt" = "." ; then
- error "invalid option $arg"
- else
- arg=`echo "$arg" | $SED -e "s/^[^=]*=//"`
- eval "export opt_$opt='$arg'"
- opt_variables="$opt_variables $opt"
- fi
- opt="" ;;
- -*?-*) : an option with an argument --main-file=x or --main-file x
- opt=`echo "$arg" | $SED -e "s/-*\\([$AA][$AA-]*\\).*/\\1/" -e y/-/_/`
- if test ".$opt" = "." ; then
- error "invalid option $arg"
- opt=""
- else :
- # keep the option for next round
- fi ;;
- -*) : a simple option --filelist or --debug or --verbose
- opt=`echo "$arg" | $SED -e "s/^-*\\([$AA][$AA-]*\\).*/\\1/" -e y/-/_/`
- if test ".$opt" = "." ; then
- error "invalid option $arg"
- else
- arg=`echo "$arg" | $SED -e "s/^[^=]*=//"`
- eval "export opt_$opt=' '"
- fi
- opt="" ;;
- *) $hint "<$arg>"
- if test ".$opt_main_file" = "." ; then opt_main_file="$arg" ; else
- test ".$opt_files" != "." && opt_files="$opt_files$opt_fileseparator"
- opt_files="$opt_files$arg" ; fi
- opt="" ;;
- esac
- fi
- done ; if test ".$opt" != "." ; then
- eval "export opt_$opt='$arg'"
- opt=""
- fi
- ### env | grep ^opt
- test ".$opt_main_file" != "." && test -f "$opt_main_file" && \
- SITEFILE="$opt_main_file"
- test ".$opt_site_file" != "." && test -f "$opt_site_file" && \
- SITEFILE="$opt_site_file"
- test "$opt_debug" && \
- hint="note"
- if test ".$opt_help" != "." ; then
- F="$SITEFILE"
- echo "$0 [sitefile]";
- echo " default sitefile = $F";
- echo "options:";
- echo " --filelist : show list of target files as ectracted from $F"
- echo " --src-dir xx : if source files are not where mksite is executed"
- echo " --tmp-dir xx : use temp instead of local directory"
- echo " --tmp : use automatic temp directory in ${TEMP-/tmp}/mksite.*"
- exit;
- echo " internal:"
- echo "--fileseparator=x : for building the internal filelist (default '?')"
- echo "--files xx : for list of additional files to be processed"
- echo "--main-file xx : for the main sitefile to take file list from"
- fi
- if test ".$SITEFILE" = "." ; then
- error "no SITEFILE found (default would be 'site.htm')"
- exit 1
- else
- $hint "sitefile:" `ls -s $SITEFILE`
- fi
- tmp="." ; if test ".$opt_tmp_dir" != "." ; then tmp="$opt_tmp_dir" ; fi
- if test ".$opt_tmp_dir" = "." && test ".$opt_tmp" != "." ; then
- tmp="${TEMP-/tmp}/mksite.$$" ; fi
- # we use external files to store mappings - kind of relational tables
- MK_TAGS="$tmp/$MK.tags.tmp.sed"
- MK_VARS="$tmp/$MK.vars.tmp.sed"
- MK_SPAN="$tmp/$MK.span.tmp.sed"
- MK_META="$tmp/$MK.meta.tmp.htm"
- MK_METT="$tmp/$MK.mett.tmp.htm"
- MK_TEST="$tmp/$MK.test.tmp.htm"
- MK_FAST="$tmp/$MK.fast.tmp.sed"
- MK_GETS="$tmp/$MK.gets.tmp.sed"
- MK_PUTS="$tmp/$MK.puts.tmp.sed"
- MK_SITE="$tmp/$MK.site.tmp.sed"
- MK_SECT1="$tmp/$MK.sect1.tmp.sed"
- MK_SECT2="$tmp/$MK.sect2.tmp.sed"
- MK_SECT3="$tmp/$MK.sect3.tmp.sed"
- MK_STYLE="$tmp/$MK.style.tmp.sed"
- MK_DATA="$tmp/$MK.$DATA.tmp.htm"
- # ========================================================================
- # ========================================================================
- # ========================================================================
- # MAGIC VARS
- # IN $SITEFILE
- printerfriendly=""
- sectionlayout="list"
- sitemaplayout="list"
- attribvars=" " # <x ref="${varname:=default}">
- updatevars=" " # <!--$varname:=-->default
- expandvars=" " # <!--$varname-->
- commentvars=" " # $updatevars && $expandsvars
- sectiontab=" " # highlight ^<td class=...>...href="$section"
- currenttab=" " # highlight ^<br>..<a href="$topic">
- headsection="no"
- tailsection="no"
- sectioninfo="no" # using <h2> title <h2> = info text
- emailfooter="no"
- if $GREP "<!--multi-->" $SITEFILE >$NULL ; then
- echo \
- "WARNING: do not use <!--multi-->, change to <!--mksite:multi--> " "$SITEFILE"
- echo \
- "warning: or <!--mksite:multisectionlayout--> <!--mksite:multisitemaplayout-->"
- sectionlayout="multi"
- sitemaplayout="multi"
- fi
- if $GREP "<!--mksite:multi-->" $SITEFILE >$NULL ; then
- sectionlayout="multi"
- sitemaplayout="multi"
- fi
- if $GREP "<!--mksite:multilayout-->" $SITEFILE >$NULL ; then
- sectionlayout="multi"
- sitemaplayout="multi"
- fi
- mksite_magic_option ()
- {
- # $1 is word/option to check for
- INP="$2" ; test ".$INP" = "." && INP="$SITEFILE"
- $SED \
- -e "s/\\(<!--mksite:\\)\\($1\\)-->/\\1\\2: -->/g" \
- -e "s/\\(<!--mksite:\\)\\([$AA][$AA]*\\)\\($1\\)-->/\\1\\3:\\2-->/g" \
- -e "/<!--mksite:$1:/!d" \
- -e "s/.*<!--mksite:$1:\\([^<>]*\\)-->.*/\\1/" \
- -e "s/.*<!--mksite:$1:\\([^-]*\\)-->.*/\\1/" \
- -e "/<!--mksite:$1:/d" -e q $INP # $++
- }
- x=`mksite_magic_option sectionlayout` ; case "$x" in
- "list"|"multi") sectionlayout="$x" ;; esac
- x=`mksite_magic_option sitemaplayout` ; case "$x" in
- "list"|"multi") sitemaplayout="$x" ;; esac
- x=`mksite_magic_option attribvars` ; case "$x" in
- " "|"no"|"warn") attribvars="$x" ;; esac
- x=`mksite_magic_option updatevars` ; case "$x" in
- " "|"no"|"warn") updatevars="$x" ;; esac
- x=`mksite_magic_option expandvars` ; case "$x" in
- " "|"no"|"warn") expandvars="$x" ;; esac
- x=`mksite_magic_option commentvars` ; case "$x" in
- " "|"no"|"warn") commentvars="$x" ;; esac
- x=`mksite_magic_option printerfriendly` ; case "$x" in
- " "|".*"|"-*") printerfriendly="$x" ;; esac
- x=`mksite_magic_option sectiontab` ; case "$x" in
- " "|"no"|"warn") sectiontab="$x" ;; esac
- x=`mksite_magic_option currenttab` ; case "$x" in
- " "|"no"|"warn") currenttab="$x" ;; esac
- x=`mksite_magic_option sectioninfo` ; case "$x" in
- " "|"no"|"[=:-]") sectioninfo="$x" ;; esac
- x=`mksite_magic_option emailfooter`
- test ".$x" != "." && emailfooter="$x"
- test ".$opt_print" != "." && printerfriendly="$opt_print"
- test ".$commentvars" = ".no" && updatevars="no" # duplicated into
- test ".$commentvars" = ".no" && expandvars="no" # info2vars_sed ()
- $hint "'$sectionlayout'sectionlayout '$sitemaplayout'sitemaplayout"
- $hint "'$attribvars'attribvars '$updatevars'updatevars"
- $hint "'$expandvars'expandvars '$commentvars'commentvars "
- $hint "'$currenttab'currenttab '$sectiontab'sectiontab"
- $hint "'$headsection'headsection '$tailsection'tailsection"
- if ($STAT_R "$SITEFILE" >$NULL) 2>$NULL ; then : ; else STAT_R=":" ; fi
- # ==========================================================================
- # init a few global variables
- # 0. INIT
- mkpathdir () {
- if test -n "$1" && test ! -d "$1" ; then
- echo "!! mkdir '$1'" ; mkdir "$1"
- test ! -d "$1" || mkdir -p "$1"
- fi
- }
- mkpathfile () {
- dirname=`echo "$1" | $SED -e "s:/[^/][^/]*\$::"`
- if test ".$1" != ".$dirname" && test ".$dirname" != "." ;
- then mkpathdir "$dirname"; fi
- }
- mknewfile () {
- mkpathfile "$1"
- $CATNULL > "$1"
- }
- tmp_dir_was_created="no"
- if test ! -d "$tmp" ; then mkpathdir "$tmp" ; tmp_dir_was_created="yes" ; fi
- # $MK_TAGS - originally, we would use a lambda execution on each
- # uppercased html tag to replace <P> with <p class="P">. Here we just
- # walk over all the known html tags and make an sed script that does
- # the very same conversion. There would be a chance to convert a single
- # tag via "h;y;x" or something we do want to convert all the tags on
- # a single line of course.
- mknewfile "$MK_TAGS"
- for M in `echo $HTMLTAGS`
- do P=`echo "$M" | $SED -e "y/$LOWER/$UPPER/"`
- echo "s|<$P>|<$M class=\"$P\">|g" >> "$MK_TAGS"
- echo "s|<$P |<$M class=\"$P\" |g" >> "$MK_TAGS"
- echo "s|</$P>|</$M>|g" >> "$MK_TAGS"
- done
- echo "s|<>|\\ \\;|g" >> "$MK_TAGS"
- echo "s|<->|<WBR />|g" >> "$MK_TAGS"
- echo "s|<c>|<code>|g" >> "$MK_TAGS"
- echo "s|</c>|</code>|g" >> "$MK_TAGS"
- echo "s|<section>||g" >> "$MK_TAGS"
- echo "s|</section>||g" >> "$MK_TAGS"
- echo "s|<\\(a [^<>]*\\) />|<\\1></a>|g" >> "$MK_TAGS"
- _ulink_="<a href=\"\\1\" remap=\"url\">\\1</a>"
- echo "s|<a>\\([$az$AZ][$az$AZ]*://[^<>]*\\)</a>|$_ulink_|g" >> "$MK_TAGS"
- # also make sure that some non-html entries are cleaned away that
- # we are generally using to inject meta information. We want to see
- # that meta ino in the *.htm browser view during editing but they
- # shall not get present in the final html page for publishing.
- DC_VARS="contributor date source language coverage identifier"
- DC_VARS="$DC_VARS rights relation creator subject description"
- DC_VARS="$DC_VARS publisher DCMIType"
- _EQUIVS="refresh expires content-type cache-control"
- _EQUIVS="$_EQUIVS redirect charset" # mapped to refresh / content-type
- _EQUIVS="$_EQUIVS content-language content-script-type content-style-type"
- for P in $DC_VARS $_EQUIVS ; do # dublin core embedded
- echo "s|<$P>[^<>]*</$P>||g" >> "$MK_TAGS"
- done
- test ".$opt_keepsect" = "." && \
- echo "s|<a sect=\"[$AZ$NN]\"|<a|g" >> "$MK_TAGS"
- echo "s|<!--[$AX]*[?]-->||g" >> "$MK_TAGS"
- echo "s|<!--\\\$[$AX]*[?]:-->||g" >> "$MK_TAGS"
- echo "s|<!--\\\$[$AX]*:[?=]-->||g" >> "$MK_TAGS"
- echo "s|\\(<[^<>]*\\)\\\${[$AX]*:[?=]\\([^<{}>]*\\)}\\([^<>]*>\\)|\\1\\2\\3|g" >>$MK_TAGS
- # see overview at www.metatab.de - http-equivs are
- # <refresh>5; url=target</reresh> or <redirect>target</redirect>
- # <content-type>text/html; charset=koi8-r</content-type> iso-8859-1/UTF-8
- # <content-language>de</content-language> <charset>UTF-8</charset>
- # <content-script-type>text/javascript</content-script-type> /jscript/vbscript
- # <content-style-type>text/css</content-style-type>
- # <cache-control>no-cache</cache-control>
- trimm ()
- {
- echo "$1" | $SED -e "s:^ *::" -e "s: *\$::";
- }
- trimmm ()
- {
- echo "$1" | $SED -e "s:^ *::" -e "s: *\$::" -e "s:[ ][ ]*: :g";
- }
- timezone ()
- {
- # +%z is an extension while +%Z is supposed to be posix
- _timezone=`$DATE_NOW +%z`
- case "$_timezone" in
- *+*) echo "$_timezone" ;;
- *-*) echo "$_timezone" ;;
- *) $DATE_NOW +%Z
- esac
- }
- timetoday ()
- {
- $DATE_NOW +%Y-%m-%d
- }
- timetodays ()
- {
- $DATE_NOW +%Y-%m%d
- }
-
- # ======================================================================
- # FUNCS
- sed_longscript ()
- {
- # hpux sed has a limit of 100 entries per sed script !
- $SED -e "100q" "$1" > "$1~1~"
- $SED -e "1,100d" -e "200q" "$1" > "$1~2~"
- $SED -e "1,200d" -e "300q" "$1" > "$1~3~"
- $SED -e "1,300d" -e "400q" "$1" > "$1~4~"
- $SED -e "1,400d" -e "500q" "$1" > "$1~5~"
- $SED -e "1,500d" -e "600q" "$1" > "$1~6~"
- $SED -e "1,600d" -e "700q" "$1" > "$1~7~"
- $SED -e "1,700d" -e "800q" "$1" > "$1~8~"
- $SED -e "1,800d" -e "900q" "$1" > "$1~9~"
- $SED -f "$1~1~" -f "$1~2~" -f "$1~3~" -f "$1~4~" -f "$1~5~" \
- -f "$1~6~" -f "$1~7~" -f "$1~8~" -f "$1~9~" "$2"
- }
- sed_escape_key ()
- {
- $SED -e "s|\\.|\\\\&|g" -e "s|\\[|\\\\&|g" -e "s|\\]|\\\\&|g" "$@"
- }
- sed_slash_key () # helper to escape chars special in /anchor/ regex
- { # currently escaping "/" "[" "]" "."
- echo "$1" | sed_escape_key -e "s|/|\\\\&|g"
- }
- sed_piped_key () # helper to escape chars special in s|anchor|| regex
- { # currently escaping "|" "[" "]" "."
- echo "$1" | sed_escape_key -e "s/|/\\\\&/g"
- }
- back_path () # helper to get the series of "../" for a given path
- {
- echo "$1" | $SED -e "/\\//!d" -e "s|/[^/]*\$|/|" -e "s|[^/]*/|../|g"
- }
- dir_name ()
- {
- echo "$1" | $SED -e "s:/[^/][^/]*\$::"
- }
- piped_value="s/|/\\\\|/g"
- amp_value="s|&|\\\\&|g"
- info2vars_sed () # generate <!--$vars--> substition sed addon script
- {
- INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$DATA"
- V8=" *\\([^ ][^ ]*\\) \\(.*\\)<$QX>"
- V9=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)<$QX>"
- N8=" *\\([^ ][^ ]*\\) \\([$NN].*\\)<$QX>"
- N9=" *DC[.]\\([^ ][^ ]*\\) \\([$NN].*\\)<$QX>"
- V0="\\\\([<]*\\\\)\\\\\\\$"
- V1="\\\\([^<>]*\\\\)\\\\\\\$"
- V2="\\\\([^{<>}]*\\\\)"
- V3="\\\\([^<>]*\\\\)"
- SS="<""<>"">" # spacer so value="2004" does not make for s|\(...\)|\12004|
- test ".$commentvars" = ".no" && updatevars="no" # duplicated from
- test ".$commentvars" = ".no" && expandvars="no" # option handling
- test ".$expandvars" != ".no" && \
- $SED -e "/^=....=formatter /d" -e "$piped_value" \
- -e "/^<$Q'name'>/s,<$Q'name'>$V9,s|<!--$V0\\1[?]-->|- \\2|," \
- -e "/^<$Q'Name'>/s,<$Q'Name'>$V9,s|<!--$V0\\1[?]-->|(\\2)|," \
- -e "/^<$Q'name'>/s,<$Q'name'>$V8,s|<!--$V0\\1[?]-->|- \\2|," \
- -e "/^<$Q'Name'>/s,<$Q'Name'>$V8,s|<!--$V0\\1[?]-->|(\\2)|," \
- -e "/^<$Q/d" -e "/^<!/d" -e "$amp_value" $INP # $++
- test ".$expandvars" != ".no" && \
- $SED -e "/^=....=formatter /d" -e "$piped_value" \
- -e "/^<$Q'text'>/s,<$Q'text'>$V9,s|<!--$V1\\1-->|\\\\1$SS\\2|," \
- -e "/^<$Q'Text'>/s,<$Q'Text'>$V9,s|<!--$V1\\1-->|\\\\1$SS\\2|," \
- -e "/^<$Q'name'>/s,<$Q'name'>$V9,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \
- -e "/^<$Q'Name'>/s,<$Q'Name'>$V9,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \
- -e "/^<$Q'text'>/s,<$Q'text'>$V8,s|<!--$V1\\1-->|\\\\1$SS\\2|," \
- -e "/^<$Q'Text'>/s,<$Q'Text'>$V8,s|<!--$V1\\1-->|\\\\1$SS\\2|," \
- -e "/^<$Q'name'>/s,<$Q'name'>$V8,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \
- -e "/^<$Q'Name'>/s,<$Q'Name'>$V8,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \
- -e "/^<$Q/d" -e "/^<!/d" -e "$amp_value" $INP # $++
- test ".$updatevars" != ".no" && \
- $SED -e "/^=....=formatter /d" -e "$piped_value" \
- -e "/^<$Q'name'>/s,<$Q'name'>$V9,s|<!--$V0\\1:[?]-->[^<>]*|- \\2|," \
- -e "/^<$Q'Name'>/s,<$Q'Name'>$V9,s|<!--$V0\\1:[?]-->[^<>]*|(\\2)|," \
- -e "/^<$Q'name'>/s,<$Q'name'>$V8,s|<!--$V0\\1:[?]-->[^<>]*|- \\2|," \
- -e "/^<$Q'Name'>/s,<$Q'Name'>$V8,s|<!--$V0\\1:[?]-->[^<>]*|(\\2)|," \
- -e "/^<$Q/d" -e "/^<!/d" -e "$amp_value" $INP # $++
- test ".$updatevars" != ".no" && \
- $SED -e "/^=....=formatter /d" -e "$piped_value" \
- -e "/^<$Q'text'>/s,<$Q'text'>$V9,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \
- -e "/^<$Q'Text'>/s,<$Q'Text'>$V9,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \
- -e "/^<$Q'name'>/s,<$Q'name'>$V9,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \
- -e "/^<$Q'Name'>/s,<$Q'Name'>$V9,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \
- -e "/^<$Q'text'>/s,<$Q'text'>$V8,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \
- -e "/^<$Q'Text'>/s,<$Q'Text'>$V8,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \
- -e "/^<$Q'name'>/s,<$Q'name'>$V8,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \
- -e "/^<$Q'Name'>/s,<$Q'Name'>$V8,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \
- -e "/^<$Q/d" -e "/^<!/d" -e "$amp_value" $INP # $++
- test ".$attribvars" != ".no" && \
- $SED -e "/^=....=formatter /d" -e "$piped_value" \
- -e "/^<$Q'text'>/s,<$Q'text'>$V9,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
- -e "/^<$Q'Text'>/s,<$Q'Text'>$V9,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
- -e "/^<$Q'name'>/s,<$Q'name'>$V9,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
- -e "/^<$Q'Name'>/s,<$Q'Name'>$V9,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
- -e "/^<$Q'text'>/s,<$Q'text'>$V8,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
- -e "/^<$Q'Text'>/s,<$Q'Text'>$V8,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
- -e "/^<$Q'name'>/s,<$Q'name'>$V8,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
- -e "/^<$Q'Name'>/s,<$Q'Name'>$V8,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \
- -e "/^<$Q/d" -e "/^<!/d" -e "$amp_value" $INP # $++
- # if value="2004" then generated sed might be "\\12004" which is bad
- # instead we generate an edited value of "\\1$SS$value" and cut out
- # the spacer now after expanding the variable values:
- echo "s|$SS||g" # $++
- }
- info2meta_sed () # generate <meta name..> text portion
- {
- # http://www.metatab.de/meta_tags/DC_type.htm
- INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$DATA"
- V6=" *HTTP[.]\\([^ ][^ ]*\\) \\(.*\\)<$QX>"
- V7=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)<$QX>"
- V8=" *\\([^ ][^ ]*\\) \\(.*\\)<$QX>"
- DATA_META_TYPE_SCHEME="name=\"DC.type\" content=\"\\2\" scheme=\"\\1\""
- DATA_META_DCMI="name=\"\\1\" content=\"\\2\" scheme=\"DCMIType\""
- DATA_META_NAME_TZ="name=\"\\1\" content=\"\\2 `timezone`\""
- DATA_META_NAME="name=\"\\1\" content=\"\\2\""
- DATA_META_HTTP="http-equiv=\"\\1\" content=\"\\2\""
- $SED -e "/=....=today /d" \
- -e "/<$Q'meta'>HTTP[.]/s,<$Q'meta'>$V6, <meta $DATA_META_HTTP />," \
- -e "/<$Q'meta'>DC[.]DCMIType /s,<$Q'meta'>$V7, <meta $DATA_META_TYPE_SCHEME />," \
- -e "/<$Q'meta'>DC[.]type Collection$/s,<$Q'meta'>$V8, <meta $DATA_META_DCMI />," \
- -e "/<$Q'meta'>DC[.]type Dataset$/s,<$Q'meta'>$V8, <meta $DATA_META_DCMI />," \
- -e "/<$Q'meta'>DC[.]type Event$/s,<$Q'meta'>$V8, <meta $DATA_META_DCMI />," \
- -e "/<$Q'meta'>DC[.]type Image$/s,<$Q'meta'>$V8, <meta $DATA_META_DCMI />," \
- -e "/<$Q'meta'>DC[.]type Service$/s,<$Q'meta'>$V8, <meta $DATA_META_DCMI />," \
- -e "/<$Q'meta'>DC[.]type Software$/s,<$Q'meta'>$V8, <meta $DATA_META_DCMI />," \
- -e "/<$Q'meta'>DC[.]type Sound$/s,<$Q'meta'>$V8, <meta $DATA_META_DCMI />," \
- -e "/<$Q'meta'>DC[.]type Text$/s,<$Q'meta'>$V8, <meta $DATA_META_DCMI />," \
- -e "/<$Q'meta'>DC[.]date[.].*[+]/s,<$Q'meta'>$V8, <meta $DATA_META_NAME />," \
- -e "/<$Q'meta'>DC[.]date[.].*[:]/s,<$Q'meta'>$V8, <meta $DATA_META_NAME_TZ />," \
- -e "/<$Q'meta'>/s,<$Q'meta'>$V8, <meta $DATA_META_NAME />," \
- -e "/<meta name=\"[^\"]*\" content=\"\" /d" \
- -e "/<meta http-equiv=\"[^\"]*\" content=\"\" /d" \
- -e "/^<$Q/d" -e "/^<!/d" $INP # $++
- }
- info_get_entry () # get the first <!--vars--> value known so far
- {
- TXT="$1" ; test ".$TXT" = "." && TXT="sect"
- INP="$2" ; test ".$INP" = "." && INP="$tmp/$F.$DATA"
- $SED -e "/<$Q'text'>$TXT /!d" \
- -e "s|<$Q'text'>$TXT ||" -e "s|<$QX>||" -e "q" $INP # $++
- }
- info1grep () # test for a <!--vars--> substition to be already present
- {
- TXT="$1" ; test ".$TXT" = "." && TXT="sect"
- INP="$2" ; test ".$INP" = "." && INP="$tmp/$F.$DATA"
- $GREP "^<$Q'text'>$TXT " $INP >$NULL
- return $?
- }
- dx_init()
- {
- mkpathdir "$tmp"
- dx_meta formatter `basename $opt_formatter` > "$tmp/$F.$DATA"
- for opt in $opt_variables ; do case "$opt" in # commandline --def=value
- *_*) op_=`echo "$opt" | sed -e "y/_/-/"` # makes for <!--$def-->
- dx_meta "$op_" `eval echo "\\\$opt_$opt"` ;;
- *) dx_text "$opt" `eval echo "\\\$opt_$opt"` ;;
- esac ; done
- }
- dx_line ()
- {
- echo "<$Q$1>$2 "`trimmm "$3"`"<$QX>" >> "$tmp/$F.$DATA"
- }
- DX_line ()
- {
- dx_val_=`echo "$3" | sed -e "s/<[^<>]*>//g"`
- dx_line "$1" "$2" "$dx_val_"
- }
- dx_text ()
- {
- dx_line "'text'" "$1" "$2"
- }
- DX_text () # add a <!--vars--> substition includings format variants
- {
- N=`trimm "$1"` ; T=`trimm "$2"`
- if test ".$N" != "." ; then
- if test ".$T" != "." ; then
- text=`echo "$T" | $SED -e "y/$UPPER/$LOWER/" -e "s/<[^<>]*>//g"`
- dx_line "'text'" "$N" "$T"
- dx_line "'name'" "$N" "$text"
- varname=`echo "$N" | $SED -e 's/.*[.]//'` # cut out front part
- if test ".$N" != ".$varname" ; then
- text=`echo "$varname $T" | $SED -e "y/$UPPER/$LOWER/" -e "s/<[^<>]*>//g"`
- dx_line "'Text'" "$varname" "$T"
- dx_line "'Name'" "$varname" "$text"
- fi
- fi
- fi
- }
- dx_meta ()
- {
- DX_line "'meta'" "$1" "$2"
- }
- DX_meta () # add simple meta entry and its <!--vars--> subsitution
- {
- DX_line "'meta'" "$1" "$2"
- DX_text "$1" "$2"
- }
- DC_meta () # add new DC.meta entry plus two <!--vars--> substitutions
- {
- DX_line "'meta'" "DC.$1" "$2"
- DX_text "DC.$1" "$2"
- DX_text "$1" "$2"
- }
- HTTP_meta () # add new HTTP.meta entry plus two <!--vars--> substitutions
- {
- DX_line "'meta'" "HTTP.$1" "$2"
- DX_text "HTTP.$1" "$2"
- DX_text "$1" "$2"
- }
- DC_VARS_Of () # check DC vars as listed in $DC_VARS global and generate DC_meta
- { # the results will be added to .meta.tmp and .vars.tmp later
- FILENAME="$1" ; test ".$FILENAME" = "." && FILENAME="$SOURCEFILE"
- for M in $DC_VARS title ; do
- # scan for a <markup> of this name
- part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|</$M>.*||" -e q $FILENAME`
- part=`trimm "$part"`
- text=`echo "$part" | $SED -e "s|^[$AA]*:||"`
- text=`trimm "$text"`
- test ".$text" = "." && continue
- # <mark:part> will be <meta name="mark.part">
- if test ".$text" != ".$part" ; then
- N=`echo "$part" | $SED -e "s/:.*//"`
- DC_meta "$M.$N" "$text"
- elif test ".$M" = ".date" ; then
- DC_meta "$M.issued" "$text" # "<date>" -> "<date>issued:"
- else
- DC_meta "$M" "$text"
- fi
- done
- }
- HTTP_VARS_Of () # check HTTP-EQUIVs as listed in $_EQUIV global then
- { # generate meta tags that are http-equiv= instead of name=
- FILENAME="$1" ; test ".$FILENAME" = "." && FILENAME="$SOURCEFILE"
- for M in $_EQUIVS ; do
- # scan for a <markup> of this name
- part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|</$M>.*||" -e q $FILENAME`
- part=`trimm "$part"`
- text=`echo "$part" | $SED -e "s|^[$AA]*:||"`
- text=`trimm "$text"`
- test ".$text" = "." && continue
- if test ".$M" = ".redirect" ; then
- HTTP_meta "refresh" "5; url=$text" ; DX_text "$M" "$text"
- elif test ".$M" = ".charset" ; then
- HTTP_meta "content-type" "text/html; charset=$text"
- else
- HTTP_meta "$M" "$text"
- fi
- done
- }
- DC_isFormatOf () # make sure there is this DC.relation.isFormatOf tag
- { # choose argument for a fallback (usually $SOURCEFILE)
- NAME="$1" ; test ".$NAME" = "." && NAME="$SOURCEFILE"
- info1grep DC.relation.isFormatOf || DC_meta relation.isFormatOf "$NAME"
- }
- DC_publisher () # make sure there is this DC.publisher meta tag
- { # choose argument for a fallback (often $USER)
- NAME="$1" ; test ".$NAME" = "." && NAME="$USER"
- info1grep DC.publisher || DC_meta publisher "$NAME"
- }
- DC_modified () # make sure there is a DC.date.modified meta tag
- { # maybe choose from filesystem dates if possible
- ZZ="$1" # target file
- if info1grep DC.date.modified ; then :
- else
- _42_chars="........................................."
- cut_42_55="s/^$_42_chars\\(.............\\).*/\\1/" # i.e.`cut -b 42-55`
- text=`$STAT_R $ZZ 2>$NULL | $SED -e '/odify:/!d' -e 's|.*fy:||' -e q`
- text=`echo "$text" | $SED -e "s/:..[.][$NN]*//"`
- text=`trimm "$text"`
- test ".$text" = "." && \
- text=`$DATE_R "$ZZ" +%Y-%m-%d 2>$NULL` # GNU sed
- test ".$text" = "." &&
- text=`$LS_L "$ZZ" | $SED -e "$cut_42_55" -e "s/^ *//g" -e "q"`
- text=`echo "$text" | $SED -e "s/[$NN]*:.*//"` # cut way seconds
- DC_meta date.modified `trimm "$text"`
- fi
- }
- DC_date () # make sure there is this DC.date meta tag
- { # choose from one of the available DC.date.* specials
- ZZ="$1" # source file
- if info1grep DC.date
- then DX_text issue "dated `info_get_entry DC.date`"
- DX_text updated "`info_get_entry DC.date`"
- else text=""
- for kind in available issued modified created ; do
- text=`info_get_entry DC.date.$kind`
- # test ".$text" != "." && echo "$kind = date = $text ($ZZ)"
- test ".$text" != "." && break
- done
- if test ".$text" = "." ; then
- M="date"
- part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|</$M>.*||" -e q $ZZ`
- part=`trimm "$part"`
- text=`echo "$part" | $SED -e "s|^[$AA]*:||"`
- text=`trimm "$text"`
- fi
- if test ".$text" = "." ; then
- M="!--date:*=*--" # takeover updateable variable...
- part=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|</.*||" -e q $ZZ`
- part=`trimm "$part"`
- text=`echo "$part" | $SED -e "s|^[$AA]*:||" -e "s|\\&.*||"`
- text=`trimm "$text"`
- fi
- text=`echo "$text" | $SED -e "s/[$NN]*:.*//"` # cut way seconds
- DX_text updated "$text"
- text1=`echo "$text" | $SED -e "s|^.* *updated ||"`
- if test ".$text" != ".$text1" ; then
- kind="modified" ; text=`echo "$text1" | $SED -e "s|,.*||"`
- fi
- text1=`echo "$text" | $SED -e "s|^.* *modified ||"`
- if test ".$text" != ".$text1" ; then
- kind="modified" ; text=`echo "$text1" | $SED -e "s|,.*||"`
- fi
- text1=`echo "$text" | $SED -e "s|^.* *created ||"`
- if test ".$text" != ".$text1" ; then
- kind="created" ; text=`echo "$text1" | $SED -e "s|,.*||"`
- fi
- text=`echo "$text" | $SED -e "s/[$NN]*:.*//"` # cut way seconds
- DC_meta date `trimm "$text"`
- DX_text issue `trimm "$kind $text"`
- fi
- }
- DC_title ()
- {
- # choose a title for the document, either an explicit title-tag
- # or one of the section headers in the document or fallback to filename
- ZZ="$1" # target file
- if info1grep DC.title ; then :
- else
- for M in TITLE title H1 h1 H2 h2 H3 H3 H4 H4 H5 h5 H6 h6 ; do
- text=`$SED -e "/<$M>/!d" -e "s|.*<$M>||" -e "s|</$M>.*||" -e q $ZZ`
- text=`trimm "$text"` ; test ".$text" != "." && break
- MM="$M [^<>]*"
- text=`$SED -e "/<$MM>/!d" -e "s|.*<$MM>||" -e "s|</$M>.*||" -e q $ZZ`
- text=`trimm "$text"` ; test ".$text" != "." && break
- done
- if test ".text" = "." ; then
- text=`basename $ZZ .html`
- text=`basename $text .htm | $SED -e 'y/_/ /' -e "s/\\$/ info/"`
- fi
- term=`echo "$text" | $SED -e 's/.*[(]//' -e 's/[)].*//'`
- text=`echo "$text" | $SED -e 's/[(][^()]*[)]//'`
- if test ".$term" = "." || test ".$term" = ".$text" ; then
- DC_meta title "$text"
- else
- DC_meta title "$term - $text"
- fi
- fi
- }
- site_get_section () # return parent section page of given page
- {
- _F_=`sed_slash_key "$1"`
- $SED -e "/^<$Q'sect'>$_F_ /!d" \
- -e "s|^<$Q'sect'>$_F_ ||" -e "s|<$QX>||" \
- -e q "$MK_DATA" # $++
- }
- DC_section () # not really a DC relation (shall we use isPartOf ?)
- { # each document should know its section father
- sectn=`site_get_section "$F"`
- if test ".$sectn" != "." ; then
- DC_meta relation.section "$sectn"
- fi
- }
- info_get_entry_section()
- {
- info_get_entry DC.relation.section # $++
- }
- site_get_selected () # return section of given page
- {
- _F_=`sed_slash_key "$1"`
- $SED -e "/<$Q'use.'>$_F_ /!d" \
- -e "s|<$Q'use.'>[^ ]* ||" -e "s|<$QX>||" \
- -e q "$MK_DATA" # $++
- }
- DC_selected () # not really a DC title (shall we use alternative ?)
- {
- # each document might want to highlight the currently selected item
- short=`site_get_selected "$F"`
- if test ".$short" != "." ; then
- DC_meta title.selected "$short"
- fi
- }
- info_get_entry_selected ()
- {
- info_get_entry DC.title.selected # $++
- }
- site_get_rootsections () # return all sections from root of nav tree
- {
- $SED -e "/^<$Q'use1'>/!d" \
- -e "s|^<$Q'use.'>\\([^ ]*\\) .*|\\1|" "$MK_DATA" # $++
- }
- site_get_sectionpages () # return all children pages in the given section
- {
- _F_=`sed_slash_key "$1"`
- $SED -e "/^<$Q'sect'>[^ ]* $_F_<[^<>]*>\$/!d" \
- -e "s|^<$Q'sect'>||" -e "s|<$QX>||" \
- -e "s/ .*//" "$MK_DATA" # $++
- }
- site_get_subpages () # return all page children of given page
- {
- _F_=`sed_slash_key "$1"`
- $SED -e "/^<$Q'node'>[^ ]* $_F_<[^<>]*>\$/!d" \
- -e "s|^<$Q'node'>||" -e "s|<$QX>||" \
- -e "s/ .*//" "$MK_DATA"
- # $++
- }
- site_get_parentpage () # return parent page for given page (".." for sections)
- {
- _F_=`sed_slash_key "$1"`
- $SED -e "/^<$Q'node'>$_F_ /!d" \
- -e "s|^<$Q'node'>[^ ]* ||" -e "s|<$QX>||" \
- -e "q" "$MK_DATA" # $++
- }
- DX_alternative () # detect wether page asks for alternative style
- { # which is generally a shortpage variant
- x=`mksite_magic_option alternative $1 | sed -e "s/^ *//" -e "s/ .*//"`
- if test ".$x" != "." ; then
- DX_text alternative "$x"
- fi
- }
- info2head_sed () # append alternative handling script to $HEAD
- {
- have=`info_get_entry alternative`
- if test ".$have" != "." ; then
- echo "/<!--mksite:alternative:$have .*-->/{" # $++
- echo "s/<!--mksite:alternative:$have\\( .*\\)-->/\\1/" # $++
- echo "q" # $++
- echo "}" # $++
- fi
- }
- info2body_sed () # append alternative handling script to $BODY
- {
- have=`info_get_entry alternative`
- if test ".$have" != "." ; then
- echo "s/<!--mksite:alternative:$have\\( .*\\)-->/\\1/" # $++
- fi
- }
- bodymaker_for_sectioninfo ()
- {
- test ".$sectioninfo" = ".no" && return
- _x_="<!--mksite:sectioninfo::-->"
- _q_="\\([^<>]*[$AX][^<>]*\\)"
- test ".$sectioninfo" != ". " && _q_="[ ][ ]*$sectioninfo\\([ ]\\)"
- echo "s|\\(^<[hH][$NN][ >].*</[hH][$NN]>\\)$_q_|\\1$_x_\\2|" # $++
- echo "/$_x_/s|^|<table width=\"100%\"><tr valign=\"bottom\"><td>|" # $++
- echo "/$_x_/s|</[hH][$NN]>|&</td><td align=\"right\"><i>|" # $++
- echo "/$_x_/s|\$|</i></td></tr></table>|" # $++
- echo "s|$_x_||" # $++
- }
- fast_href () # args "$FILETOREFERENCE" "$FROMCURRENTFILE:$F"
- { # prints path to $FILETOREFERENCE href-clickable in $FROMCURRENTFILE
- # if no subdirectoy then output is the same as input $FILETOREFERENCE
- R="$2" ; test ".$R" = "." && R="$F"
- S=`back_path "$R"`
- if test ".$S" = "."
- then echo "$1" # $++
- else _1_=`echo "$1" | \
- $SED -e "/^ *\$/d" -e "/^\\//d" -e "/^[.][.]/d" -e "/^[$AA]*:/d" `
- if test ".$_1_" = "." # don't move any in the pattern above
- then echo "$1" # $++
- else echo "$S$1" # $++ prefixed with backpath
- fi fi
- }
- make_back_path () # "$FILE"
- {
- R="$1" ; test ".$R" = "." && R="$F"
- S=`back_path "$R"`
- if test ".$S" != "." ; then
- echo "s|\\(<[^<>]* href=\\\"\\)\\([$AA][^<>:]*\\\"[^<>]*>\\)|\\1$S\\2|g"
- echo "s|\\(<[^<>]* src=\\\"\\)\\([$AA][^<>:]*\\\"[^<>]*>\\)|\\1$S\\2|g"
- fi
- }
- # ============================================================== SITE MAP DATA
- # each entry needs atleast a list-title, a long-title, and a list-date
- # these are the basic information to be printed in the sitemap file
- # where it is bound the hierarchy of sect/subsect of the entries.
- site_map_list_title() # $file $text
- {
- echo "<$Q'list'>$1 $2<$QX>" >> "$MK_DATA"
- }
- info_map_list_title() # $file $text
- {
- echo "<$Q'list'>$2<$QX>" >> "$tmp/$1.$DATA"
- }
- site_map_long_title() # $file $text
- {
- echo "<$Q'long'>$1 $2<$QX>" >> "$MK_DATA"
- }
- info_map_long_title() # $file $text
- {
- echo "<$Q'long'>$2<$QX>" >> "$tmp/$1.$DATA"
- }
- site_map_list_date() # $file $text
- {
- echo "<$Q'date'>$1 $2<$QX>" >> "$MK_DATA"
- }
- info_map_list_date() # $file $text
- {
- echo "<$Q'date'>$2<$QX>" >> "$tmp/$1.$DATA"
- }
- siteinfo2sitemap () # generate <name><page><date> addon sed scriptlet
- { # the resulting script will act on each item/line
- # containing <!--"filename"--> and expand any following
- # reference of <!--name--> or <!--date--> or <!--long-->
- INP="$1" ; test ".$INP" = "." && INP="$MK_DATA"
- _list_="s|\\\\(<!--\"\\1\"-->.*\\\\)<name href=[^<>]*>.*</name>|\\\\1<name href=\"\\1\">\\2</name>|"
- _date_="s|\\\\(<!--\"\\1\"-->.*\\\\)<date>.*</date>|\\\\1<date>\\2</date>|"
- _long_="s|\\\\(<!--\"\\1\"-->.*\\\\)<long>.*</long>|\\\\1<long>\\2</long>|"
- $SED -e "s:&:\\\\&:g" \
- -e "s:<$Q'list'>\\([^ ]*\\) \\(.*\\)<$QX>:$_list_:" \
- -e "s:<$Q'date'>\\([^ ]*\\) \\(.*\\)<$QX>:$_date_:" \
- -e "s:<$Q'long'>\\([^ ]*\\) \\(.*\\)<$QX>:$_long_:" \
- -e "/^s|/!d" $INP # $++
- }
- make_multisitemap ()
- { # each category gets its own column along with the usual entries
- INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_DATA"
- siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed
- _form_="<!--\"\\2\"--><!--use\\1--><long>\\3</long><!--end\\1-->"
- _form_="$_form_<br><name href=\"\\2\">\\3</name><date>......</date>"
- _tiny_="small><small><small" ; _tinyX_="small></small></small "
- _tabb_="<br><$_tiny_> </$_tinyX_>" ; _bigg_="<big> </big>"
- echo "<table width=\"100%\"><tr><td> " # $++
- $SED -e "/^<$Q'[Uu]se.'>/!d" \
- -e "/>[$AZ$az][$AZ$az][$AZ$az][$AZ$az]*:/d" \
- -e "s|^<$Q'[Uu]se\\(.\\)'>\\([^ ]*\\) \\(.*\\)<$QX>|$_form_|" \
- -f "$MK_SITE" -e "/<name/!d" \
- -e "s|<!--use1-->|</td><td valign=\"top\"><b>|" \
- -e "s|<!--end1-->|</b>|" \
- -e "s|<!--use2-->|<br>|" \
- -e "s|<!--use.-->|<br>|" -e "s/<!--[^<>]*-->/ /g" \
- -e "s|<name |<$_tiny_><a |" -e "s|</name>||" \
- -e "s|<date>|<small style=\"date\">|" \
- -e "s|</date>|</small></a><br></$_tinyX_>|" \
- -e "s|<long>|<!--long-->|" -e "s|</long>|<!--/long-->|" \
- $INPUTS # $++
- echo "</td><tr></table>" # $++
- }
- make_listsitemap ()
- { # traditional - the body contains a list with date and title extras
- INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_DATA"
- siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed
- _form_="<!--\"\\2\"--><!--use\\1--><name href=\"\\2\">\\3</name>"
- _form_="$_form_<date>......</date><long>\\3</long>"
- _tabb_="<td>\\ \\;</td>"
- echo "<table cellspacing=\"0\" cellpadding=\"0\">" # $++
- $SED -e "/^<$Q'[Uu]se.'>/!d" \
- -e "/>[$AZ$az][$AZ$az][$AZ$az][$AZ$az]*:/d" \
- -e "s|^<$Q'[Uu]se\\(.\\)'>\\([^ ]*\\) \\(.*\\)<$QX>|$_form_|" \
- -f "$MK_SITE" -e "/<name/!d" \
- -e "s|<!--use\\(1\\)-->|<tr class=\"listsitemap\\1\"><td>*</td>|" \
- -e "s|<!--use\\(2\\)-->|<tr class=\"listsitemap\\1\"><td>-</td>|" \
- -e "s|<!--use\\(.\\)-->|<tr class=\"listsitemap\\1\"><td> </td>|" \
- -e "/<tr.class=\"listsitemap3\">/s|<name [^<>]*>|&- |" \
- -e "s|<!--[^<>]*-->| |g" \
- -e "s|<name href=\"name:sitemap:|<name href=\"|" \
- -e "s|<name |<td><a |" -e "s|</name>|</a></td>$_tabb_|" \
- -e "s|<date>|<td><small style=\"date\">|" \
- -e "s|</date>|</small></td>$_tabb_|" \
- -e "s|<long>|<td><em><!--long-->|" \
- -e "s|</long>|<!--/long--></em></td></tr>|" \
- "$INPUTS" # $++
- for xx in `grep "^<$Q'use.'>name:sitemap:" $INPUTS` ; do
- xx=`echo $xx | sed -e "s/^<$Q'use.'>name:sitemap://" -e "s|<$QX>||"`
- if test -f "$xx" ; then
- grep "<tr.class=\"listsitemap[$NN]\">" $xx # $++
- fi
- done
- echo "</table>" # $++
- }
- _xi_include_=`echo \
- "<xi:include xmlns:xi=\"http://www.w3.org/2001/XInclude\" parse=\"xml\""`
- make_xmlsitemap ()
- { # traditional - the body contains a list with date and title extras
- INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_DATA"
- siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed
- _form_="<!--\"\\2\"--><name href=\"\\2\">\\3</name>"
- _sitefile_=`sed_slash_key "$SITEFILE"`
- $SED -e "/^<$Q'[Uu]se.'>/!d" \
- -e "/>[$AZ$az][$AZ$az][$AZ$az][$AZ$az]*:/d" \
- -e "s|^<$Q'[Uu]se\\(.\\)'>\\([^ ]*\\) \\(.*\\)<$QX>|$_form_|" \
- -f "$MK_SITE" -e "/<name/!d" \
- -e "/${_sitefile_}/d" \
- -e "/${_sitefile_}l/d" \
- -e "s|\\(href=\"[^<>]*\\)\\.html\\(\"\\)|\\1.xml\\2|g" \
- -e "s|.*<name|$_xi_include_\\n |" \
- -e "s|>.*</name>| />|" \
- "$INPUTS" # $++
- }
- print_extension ()
- {
- ARG="$1" ; test ".$ARG" = "." && ARG="$opt_print"
- case "$ARG" in
- -*|.*) echo "$ARG" ;; # $++
- *) echo ".print" ;; # $++
- esac
- }
- from_sourcefile ()
- {
- if test -f "$1"
- then echo "$1"
- elif test -f "$opt_srcdir/$1"
- then echo "$opt_srcdir/$1"
- else echo "$1"
- fi
- }
-
- html_sourcefile () # generally just cut away the trailing "l" (ell)
- { # making "page.html" argument into "page.htm" return
- # (as a new addtion the source may be in ".dbk" xml)
- _SRCFILE_=`echo "$1" | $SED -e "s/l\\$//"`
- _XMLFILE_=`echo "$1" | $SED -e "s/\\.html/.dbk/"`
- if test -f "$_SRCFILE_"
- then echo "$_SRCFILE_" # $++
- elif test -f "$_XMLFILE_"
- then echo "$_XMLFILE_" # $++
- elif test -f "$opt_src_dir/$_SRCFILE_"
- then echo "$opt_src_dir/$_SRCFILE_" # $++
- elif test -f "$opt_src_dir/$_XMLFILE_"
- then echo "$opt_src_dir/$_XMLFILE_" # $++
- else echo ".//$_SRCFILE_" # $++ (not found?)
- fi
- }
- html_printerfile_sourcefile ()
- {
- if test ".$printerfriendly" = "."
- then
- echo "$1" | sed -e "s/l\$//" # $++
- else
- _ext_=`print_extension "$printerfriendly"`
- _ext_=`sed_slash_key "$_ext_"`
- echo "$1" | sed -e "s/l\$//" -e "s/$_ext_\\([.][$AA]*\\)\$/\\1/" # $++
- fi
- }
- fast_html_printerfile () {
- x=`html_printerfile "$1"` ; basename "$x" # $++
- # x=`html_printerfile "$1"` ; fast_href "$x" $2 # $++
- }
- html_printerfile () # generate the printerfile for a given normal output
- {
- _ext_=`print_extension "$printerfriendly" | sed -e "s/&/\\\\&/"`
- echo "$1" | sed -e "s/\\([.][$AA]*\\)\$/$_ext_\\1/" # $++
- }
- make_printerfile_fast () # generate s/file.html/file.print.html/ for hrefs
- { # we do that only for the $FILELIST
- ALLPAGES="$1" ; # ="$FILELIST"
- for p in $ALLPAGES ; do
- a=`sed_slash_key "$p"`
- b=`html_printerfile "$p"`
- if test "$b" != "$p" ; then
- b=`html_printerfile "$p" | sed -e "s:&:\\\\&:g" -e "s:/:\\\\\\/:g"`
- echo "s/<a href=\"$a\">/<a href=\"$b\">/" # $++
- echo "s/<a href=\"$a\" /<a href=\"$b\" /" # $++
- fi
- done
- }
- echo_printsitefile_style ()
- {
- _bold_="text-decoration : none ; font-weight : bold ; "
- echo " <style>" # $+++
- echo " a:link { $_bold_ color : #000060 ; }" # $+++
- echo " a:visited { $_bold_ color : #000040 ; }" # $+++
- echo " body { background-color : white ; }" # $+++
- echo " </style>" # $+++
- }
- make_printsitefile_head() # $sitefile
- {
- echo_printsitefile_style > "$MK_STYLE"
- $SED -e "/<title>/p" -e "/<title>/d" \
- -e "/<head>/p" -e "/<head>/d" \
- -e "/<\/head>/p" -e "/<\/head>/d" \
- -e "/<body>/p" -e "/<body>/d" \
- -e "/^.*<link [^<>]*rel=\"shortcut icon\"[^<>]*>.*\$/p" \
- -e "d" $SITEFILE | $SED -e "/<head>/r $MK_STYLE" # $+++
- }
- # ------------------------------------------------------------------------
- # The printsitefile is a long text containing html href markups where
- # each of the href lines in the file is being prefixed with the section
- # relation. During a secondary call the printsitefile can grepp'ed for
- # those lines that match a given output fast-file. The result is a
- # navigation header with 1...3 lines matching the nesting level
- # these alt-texts will be only visible in with a text-mode browser:
- printsitefile_square="width=\"8\" height=\"8\" border=\"0\""
- printsitefile_img_1="<img alt=\"|go text:\" $printsitefile_square />"
- printsitefile_img_2="<img alt=\"||topics:\" $printsitefile_square />"
- printsitefile_img_3="<img alt=\"|||pages:\" $printsitefile_square />"
- _SECT="mksite:sect:"
- echo_current_line () # $sect $extra
- {
- echo "<!--$_SECT\"$1\"-->$2" # $++
- }
- make_current_entry () # $sect $file ## requires $MK_SITE
- {
- S="$1" ; R="$2"
- SSS=`sed_slash_key "$S"`
- sep=" - " ; _left_=" [ " ; _right_=" ] "
- echo_current_line "$S" "<!--\"$R\"--><name href=\"$R\">$R</name>$sep" \
- | $SED -f "$MK_SITE" \
- -e "s|<!--[^<>]*--><name |<a |" -e "s|</name>|</a>|" \
- -e "/<a href=\"$SSS\"/s/<a href/$_left_&/" \
- -e "/<a href=\"$SSS\"/s/<\\/a>/&$_right_/" # $+++
- }
- echo_subpage_line () # $sect $extra
- {
- echo "<!--$_SECT*:\"$1\"-->$2" # $++
- }
- make_subpage_entry ()
- {
- S="$1" ; R="$2"
- RR=`sed_slash_key "$R"`
- sep=" - " ;
- echo_subpage_line "$S" "<!--\"$R\"--><name href=\"$R\">$R</name>$sep" \
- | $SED -f "$MK_SITE" \
- -e "s|<!--[^<>]*--><name |<a |" -e "s|</name>|</a>|" # $+++
- }
- make_printsitefile ()
- {
- # building the printsitefile looks big but its really a loop over sects
- INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_DATA"
- siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed
- if test -d DEBUG && test -f "$MK_SITE"
- then FFFF=`echo "$F" | sed -e "s,/,:,g"`
- cp "$MK_DATA" "DEBUG/$FFFF.SITE.tmp.sed"
- fi
- make_printsitefile_head $SITEFILE # $++
- sep=" - "
- _sect1="<a href=\"#.\" title=\"section\">$printsitefile_img_1</a> ||$sep"
- _sect2="<a href=\"#.\" title=\"topics\">$printsitefile_img_2</a> ||$sep"
- _sect3="<a href=\"#.\" title=\"pages\">$printsitefile_img_3</a> ||$sep"
- site_get_rootsections > "$MK_SECT1"
- # round one - for each root section print a current menu
- for r in `cat "$MK_SECT1"` ; do
- echo_current_line "$r" "<!--mksite:sect1:A--><br>$_sect1" # $++
- for s in `cat "$MK_SECT1"` ; do
- make_current_entry "$r" "$s" # $++
- done
- echo_current_line "$r" "<!--mksite:sect1:Z-->" # $++
- done # "$r"
- # round two - for each subsection print a current and subpage menu
- for r in `cat "$MK_SECT1"` ; do
- site_get_subpages "$r" > "$MK_SECT2"
- for s in `cat "$MK_SECT2"` ; do test "$r" = "$s" && continue
- echo_current_line "$s" "<!--mksite:sect2:A--><br>$_sect2" # $++
- for t in `cat "$MK_SECT2"` ; do test "$r" = "$t" && continue
- make_current_entry "$s" "$t" # $++
- done # "$t"
- echo_current_line "$s" "<!--mksite:sect2:Z-->" # $++
- done # "$s"
- _have_children_="0"
- for t in `cat "$MK_SECT2"` ; do test "$r" = "$t" && continue
- test "$_have_children_" = "0" && _have_children_="1" && \
- echo_subpage_line "$r" "<!--mksite:sect2:A--><br>$_sect2" # $++
- make_subpage_entry "$r" "$t" # $++
- done # "$t"
- test "$_have_children_" = "1" && \
- echo_subpage_line "$r" "<!--mksite:sect2:Z-->" # $++
- done # "$r"
- # round three - for each subsubsection print a current and subpage menu
- for r in `cat "$MK_SECT1"` ; do
- site_get_subpages "$r" > "$MK_SECT2"
- for s in `cat "$MK_SECT2"` ; do test "$r" = "$s" && continue
- site_get_subpages "$s" > "$MK_SECT3"
- for t in `cat "$MK_SECT3"` ; do test "$s" = "$t" && continue
- echo_current_line "$t" "<!--mksite:sect3:A--><br>$_sect3" # $++
- for u in `cat "$MK_SECT3"` ; do test "$s" = "$u" && continue
- make_current_entry "$t" "$u" # $++
- done # "$u"
- echo_current_line "$t" "<!--mksite:sect3:Z-->" # $++
- done # "$t"
- _have_children_="0"
- for u in `cat "$MK_SECT3"` ; do test "$u" = "$s" && continue
- test "$_have_children_" = "0" && _have_children_="1" && \
- echo_subpage_line "$s" "<!--mksite:sect3:A--><br>$_sect3" # $++
- make_subpage_entry "$s" "$u" # $++
- done # "$u"
- test "$_have_children_" = "1" && \
- echo_subpage_line "$s" "<!--mksite:sect3:Z-->" # $++
- done # "$s"
- done # "$r"
- echo "<a name=\".\"></a>" # $++
- echo "</body></html>" # $++
- }
- # create a selector that can grep a printsitefile for the matching entries
- select_in_printsitefile () # arg = "page" : return to stdout >> $P.$HEAD
- {
- _selected_="$1" ; test ".$_selected_" = "." && _selected_="$F"
- _section_=`sed_slash_key "$_selected_"`
- echo "s/^<!--$_SECT\"$_section_\"-->//" # sect3
- echo "s/^<!--$_SECT[*]:\"$_section_\"-->//" # children
- _selected_=`site_get_parentpage "$_selected_"`
- _section_=`sed_slash_key "$_selected_"`
- echo "s/^<!--$_SECT\"$_section_\"-->//" # sect2
- _selected_=`site_get_parentpage "$_selected_"`
- _section_=`sed_slash_key "$_selected_"`
- echo "s/^<!--$_SECT\"$_section_\"-->//" # sect1
- echo "/^<!--$_SECT\"[^\"]*\"-->/d"
- echo "/^<!--$_SECT[*]:\"[^\"]*\"-->/d"
- echo "s/^<!--mksite:sect[$NN]:[$AZ]-->//"
- }
- body_for_emailfooter…
Large files files are truncated, but you can click here to view the full file