From: Guido Draheim Date: Fri, 22 Sep 2006 00:34:11 +0000 (+0000) Subject: rpms X-Git-Tag: v0.13.48~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=189b89de6f850524a2561ba28d751a697f81b857;p=zziplib rpms (.) --- diff --git a/ChangeLog b/ChangeLog index be15046..98e0be0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-09-21 + * last doc/*.py updates + * last doc/mksite.* updates + * last doc/body.htm updates - including new zzipmmapped.html docu + * "make install-sf" will copy the doctree directly to sourceforge + 2006-09-18 * docs/makedocs.py docs/zzipdoc/*.py creates new docs/zziplib-man3.tar.gz plus zziplib.html zzipmmapped.html zzipfseeko.html diff --git a/Makefile.am b/Makefile.am index a2f5276..7e39caa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,10 +10,9 @@ SUBDIRS = zzip zzipwrap bins test docs @SDL@ rpm2: dist-bzip2 $(PACKAGE).spec rpmbuild -ta $(PACKAGE)-$(VERSION).tar.bz2 -zzip.html zzip.xml zzip.pdf \ -doc docu clean-doc clean-docs clean-docu \ -man manpages htmpages unpack clean-unpack \ -omf install-omf install-doc install-sfnet install-man3 docu x : +doc docs docu clean-doc clean-docs clean-docu zzip.html zzip.xml zzip.pdf \ +man mans manpages htmpages unpack clean-unpack pdfs \ +omf install-omf install-doc install-docs install-sf install-man3 install-mans : (cd docs && $(MAKE) `basename $@`) sdl testsdl test-sdl install-sdl : @@ -51,7 +50,6 @@ EXTRA_DIST = zziplib.spec zzipback.sed Makefile.mk \ PHONY = auto boottrap rpm doc docs man manpages htmpages sdl testsdl \ comp compats msvc6 msvc7 -docs : docu # ------------------------------------------------------------------------ test-comp: @@ -77,3 +75,49 @@ msvc : zip -9r $(srcdir)/$(PACKAGE)-$(VERSION)-msvc6-bin.zip bin/ zip -9r $(srcdir)/$(PACKAGE)-$(VERSION)-msvc6-lib.zip lib/ include/ rm -r bin lib include + +# ------------------------------------------------------------------ zzip64 +_FILE_OFFSET64 = -D_ZZIP_LARGEFILE -D_FILE_OFFSET_BITS=64 +_RELEASEINFO64 = "RELEASE_INFO=-release 0-64" + +zzip64-setup: zzip64-setup.tmp +zzip64-setup.tmp : zzip/Makefile zzip/_config.h zzip/.deps/* zzip/zziplib.pc + - mkdir zzip64 + cp -a zzip/Makefile zzip/_config.h zzip/.deps/ zzip/zziplib.pc zzip64/ + date > zzip64.dir +zzip64-build: zzip64-build.tmp +zzip64-build.tmp : zzip64-setup.tmp $(top_srcdir)/zzip/* + cd zzip64 && $(MAKE) "AM_CFLAGS=$(_FILE_OFFSET64)" $(_RELEASEINFO64) +zzip64-install: zzip64-install.tmp +zzip64-install.tmp : zzip64-build.tmp + cd zzip64 && $(MAKE) install $(_RELEASEINFO64) + cd $(DESTDIR)$(libdir) && mv libzzip.so libzzip64.so + cd $(DESTDIR)$(libdir) && mv libzzip.a libzzip64.a + cd $(DESTDIR)$(libdir) && \ + sed -e 's/zzip.so/zzip64.so/' \ + -e 's/zzip.a/zzip64.a/' libzzip.la > libzzip64.la + cd $(DESTDIR)$(libdir)/pkgconfig && \ + sed -e 's/largefile=/largefile= %_FILE_OFFSET64/' \ + -e 's/-lzzip/-lzzip64/' \ + -e 's/zziplib/zziplib64/' zziplib.pc > zziplib64.pc +zzip32-postinstall: + cd $(DESTDIR)$(libdir) && mv libzzip.so libzzip32.so + cd $(DESTDIR)$(libdir) && mv libzzip.a libzzip32.a + cd $(DESTDIR)$(libdir) && ln -s libzzip32.so libzzip.so + cd $(DESTDIR)$(libdir) && ln -s libzzip32.a libzzip.a + cd $(DESTDIR)$(libdir) && \ + sed -e 's/zzip.so/zzip32.so/' \ + -e 's/zzip.a/zzip32.a/' libzzip.la > libzzip32.la + cd $(DESTDIR)$(libdir)/pkgconfig && \ + sed -e 's/-lzzip/-lzzip32/' \ + -e 's/zziplib/zziplib32/' zziplib.pc > zziplib32.pc +zzip-postinstall: + : "the 12.8x and 11.8x and 10.8x packages are all the same actually" + cd $(DESTDIR)$(libdir) || exit 1 \ + ; for i in libzzip*.so.1? ; do : \ + ; v10=`echo $i | sed -e "s/.so.../.so.10/"` \ + ; v11=`echo $i | sed -e "s/.so.../.so.11/"` \ + ; v12=`echo $i | sed -e "s/.so.../.so.12/"` \ + ; test ! -e $v10 && test -e $v12 && ln -s $v12 $v10 \ + ; test ! -e $v12 && test -e $v10 && ln -s $v10 $v12 \ + ; ln -s $v10 $v11 || true; done diff --git a/Makefile.in b/Makefile.in index 9f01e98..ec0352b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -261,6 +261,10 @@ EXTRA_DIST = zziplib.spec zzipback.sed Makefile.mk \ PHONY = auto boottrap rpm doc docs man manpages htmpages sdl testsdl \ comp compats msvc6 msvc7 + +# ------------------------------------------------------------------ zzip64 +_FILE_OFFSET64 = -D_ZZIP_LARGEFILE -D_FILE_OFFSET_BITS=64 +_RELEASEINFO64 = "RELEASE_INFO=-release 0-64" all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -701,10 +705,9 @@ uninstall-info: uninstall-info-recursive rpm2: dist-bzip2 $(PACKAGE).spec rpmbuild -ta $(PACKAGE)-$(VERSION).tar.bz2 -zzip.html zzip.xml zzip.pdf \ -doc docu clean-doc clean-docs clean-docu \ -man manpages htmpages unpack clean-unpack \ -omf install-omf install-doc install-sfnet install-man3 docu x : +doc docs docu clean-doc clean-docs clean-docu zzip.html zzip.xml zzip.pdf \ +man mans manpages htmpages unpack clean-unpack pdfs \ +omf install-omf install-doc install-docs install-sf install-man3 install-mans : (cd docs && $(MAKE) `basename $@`) sdl testsdl test-sdl install-sdl : @@ -714,7 +717,6 @@ check-test0 check-test1 check-zzdir check-zzcat \ check-zzxor check-zzxordir check-zzxorcat \ check-sfx check-readme : \ (cd test && $(MAKE) `basename $@`) -docs : docu # ------------------------------------------------------------------------ test-comp: @@ -740,6 +742,48 @@ msvc : zip -9r $(srcdir)/$(PACKAGE)-$(VERSION)-msvc6-bin.zip bin/ zip -9r $(srcdir)/$(PACKAGE)-$(VERSION)-msvc6-lib.zip lib/ include/ rm -r bin lib include + +zzip64-setup: zzip64-setup.tmp +zzip64-setup.tmp : zzip/Makefile zzip/_config.h zzip/.deps/* zzip/zziplib.pc + - mkdir zzip64 + cp -a zzip/Makefile zzip/_config.h zzip/.deps/ zzip/zziplib.pc zzip64/ + date > zzip64.dir +zzip64-build: zzip64-build.tmp +zzip64-build.tmp : zzip64-setup.tmp $(top_srcdir)/zzip/* + cd zzip64 && $(MAKE) "AM_CFLAGS=$(_FILE_OFFSET64)" $(_RELEASEINFO64) +zzip64-install: zzip64-install.tmp +zzip64-install.tmp : zzip64-build.tmp + cd zzip64 && $(MAKE) install $(_RELEASEINFO64) + cd $(DESTDIR)$(libdir) && mv libzzip.so libzzip64.so + cd $(DESTDIR)$(libdir) && mv libzzip.a libzzip64.a + cd $(DESTDIR)$(libdir) && \ + sed -e 's/zzip.so/zzip64.so/' \ + -e 's/zzip.a/zzip64.a/' libzzip.la > libzzip64.la + cd $(DESTDIR)$(libdir)/pkgconfig && \ + sed -e 's/largefile=/largefile= %_FILE_OFFSET64/' \ + -e 's/-lzzip/-lzzip64/' \ + -e 's/zziplib/zziplib64/' zziplib.pc > zziplib64.pc +zzip32-postinstall: + cd $(DESTDIR)$(libdir) && mv libzzip.so libzzip32.so + cd $(DESTDIR)$(libdir) && mv libzzip.a libzzip32.a + cd $(DESTDIR)$(libdir) && ln -s libzzip32.so libzzip.so + cd $(DESTDIR)$(libdir) && ln -s libzzip32.a libzzip.a + cd $(DESTDIR)$(libdir) && \ + sed -e 's/zzip.so/zzip32.so/' \ + -e 's/zzip.a/zzip32.a/' libzzip.la > libzzip32.la + cd $(DESTDIR)$(libdir)/pkgconfig && \ + sed -e 's/-lzzip/-lzzip32/' \ + -e 's/zziplib/zziplib32/' zziplib.pc > zziplib32.pc +zzip-postinstall: + : "the 12.8x and 11.8x and 10.8x packages are all the same actually" + cd $(DESTDIR)$(libdir) || exit 1 \ + ; for i in libzzip*.so.1? ; do : \ + ; v10=`echo $i | sed -e "s/.so.../.so.10/"` \ + ; v11=`echo $i | sed -e "s/.so.../.so.11/"` \ + ; v12=`echo $i | sed -e "s/.so.../.so.12/"` \ + ; test ! -e $v10 && test -e $v12 && ln -s $v12 $v10 \ + ; test ! -e $v12 && test -e $v10 && ln -s $v10 $v12 \ + ; ln -s $v10 $v11 || true; done # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/Makefile.mk b/Makefile.mk index e25c541..f77ccb6 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -15,7 +15,7 @@ boottrap: automake -a -c rpm: dist-bzip $(PACKAGE).spec - rpmbuild -ta $(PACKAGE)-$(VERSION).tar.bz2 + rpmbuild -ta pub/$(PACKAGE)-$(VERSION).tar.bz2 dist-bzip : dist-bzip2 $(MAKE) dist-bzip2-done diff --git a/docs/Makefile.am b/docs/Makefile.am index 1962c95..1c3a08f 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -3,15 +3,17 @@ AUTOTOOL_VERSION=autoconf-2.52 automake-1.5 libtool-1.4.2 PYRUN = $(PYDEFS) @PYTHON@ $(PYFLAGS) PLRUN = $(PLDEFS) @PERL@ $(PLFLAGS) +DELETE = echo deleting... doc_FILES = README.MSVC6 README.SDL COPYING.MPL COPYING.LIB COPYING.ZLIB \ - zziplib.html + zziplib.html zzipmmapped.html zzipfseeko.html htm_FILES = zzip-index.htm zzip-zip.htm zzip-file.htm zzip-sdl-rwops.htm \ zzip-extio.htm zzip-xor.htm zzip-crypt.htm zzip-cryptoid.htm \ zzip-api.htm zzip-basics.htm zzip-extras.htm zzip-parse.htm \ 64on32.htm future.htm fseeko.htm mmapped.htm memdisk.htm \ configs.htm sfx-make.htm developer.htm download.htm \ - history.htm referentials.htm faq.htm copying.htm + history.htm referentials.htm faq.htm copying.htm \ + functions.htm SDL = @top_srcdir@/SDL SDL_RWOPS = $(SDL)/SDL_rwops_zzcat.c \ $(SDL)/SDL_rwops_zzip.c $(SDL)/SDL_rwops_zzip.h @@ -19,7 +21,8 @@ changelog = @top_srcdir@/ChangeLog EXTRA_DIST = make-doc.py $(doc_FILES) $(htm_FILES) $(SDL_RWOPS) \ make-doc.pl make-dbk.pl mksite.sh mksite.pl body.htm \ - manpages.ar zziplib-master.dbk $(zzipdoc_FILES) + manpages.ar zziplib-manpages.dbk zziplib-master.dbk \ + $(zzipdoc_FILES) sdocbook.css CLEANFILES = *.pc *.omf DISTCLEANFILES = zziplib.spec manpages.ar htmpages.ar *.html *.xml @@ -28,8 +31,9 @@ zzipdoc_FILES = makedocs.py zzipdoc/__init__.py \ zzipdoc/dbk2htm.py zzipdoc/htm2dbk.py \ zzipdoc/functionheader.py zzipdoc/options.py \ zzipdoc/functionlisthtmlpage.py zzipdoc/textfileheader.py \ - zzipdoc/functionlistreference.py zzipdoc/textfile.py - zzipdoc/functionprototype.py + zzipdoc/functionlistreference.py zzipdoc/textfile.py \ + zzipdoc/functionprototype.py zzipdoc/htmldocument.py \ + zzipdoc/docbookdocument.py html_FILES = $(htm_FILES:.htm=.html) \ $(htm_FILES:.htm=.print.html) \ @@ -48,143 +52,112 @@ docs : doc manpages.ar htmpages.ar # docu : docs docu : - rm zziplib2.html zzipmmapped.html zzipfseeko.html - $(MAKE) zziplib2.html - $(MAKE) zzipmmapped.html - $(MAKE) zzipfseeko.html - $(MAKE) zziplib-man3.tar.gz - -zziplib.html : zziplib1.html zziplib0.html - - test -s zziplib0.html && cp zziplib0.html zziplib.html - - test -s zziplib1.html && cp zziplib1.html zziplib.html - - test -s zziplib2.html && cp zziplib2.html zziplib.html - test -s $@ -zziplib.xml : zziplib1.xml zziplib0.xml - - test -s zziplib0.xml && cp zziplib0.xml zziplib.xml - - test -s zziplib1.xml && cp zziplib1.xml zziplib.xml - - test -s zziplib2.xml && cp zziplib2.xml zziplib.xml - test -s $@ || rm $@ - -_zziplib0 = $(zziplib0) \ - "suffix=0" "package=$(PACKAGE)" "version=$(VERSION)" \ - "mainheader=zzip/zzip.h" "exported= // or " \ - "docbookfile=$@" -zziplib0.html : zziplib0.xml -zziplib0.xml : zziplib.spec @srcdir@/Makefile.am @srcdir@/make-doc.pl \ - $(srcdir)/make-doc.pl @top_srcdir@/zzip/*.c - - $(PLRUN) $(srcdir)/make-doc.pl @top_srcdir@/zzip/*.c $(_zziplib0) - - test -s $@ -_zziplib1 = $(zziplib1) \ - "--suffix=1" -zziplib1.html : zziplib1.xml -zziplib1.xml : zziplib.spec @srcdir@/Makefile.am @srcdir@/make-doc.py \ - $(srcdir)/make-doc.py @top_srcdir@/zzip/*.c - - $(PYRUN) $(srcdir)/make-doc.py @top_srcdir@/zzip/*.c $(_zziplib1) - - test -f zziplib1.docbook && mv zziplib1.docbook $@ ; test -s $@ -_zziplib2 = $(zziplib2) "--package=$(PACKAGE)" "--version=$(VERSION)" \ - "--onlymainheader=zzip/lib.h" "--suffix=2" -zziplib2.html : zziplib2.xml -zziplib2.xml : zziplib.spec $(srcdir)/Makefile.am $(srcdir)/zzipdoc/*.py \ - $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c - - $(PYRUN) $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c $(_zziplib2) - - test -f zziplib2.docbook && mv zziplib2.docbook $@ ; test -s $@ -_zzipmmapped = $(zziplib2) "--package=$(PACKAGE)" "--version=$(VERSION)" \ - "--onlymainheader=zzip/mmapped.h" "--suffix=3" -zzipmmapped.html : zzipmmapped.xml -zzipmmapped.xml : zziplib.spec $(srcdir)/Makefile.am $(srcdir)/zzipdoc/*.py \ - $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c - - $(PYRUN) $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c $(_zzipmmapped) - - test -f zziplib3.docbook && mv zziplib3.docbook $@ ; test -s $@ -_zzipfseeko = $(zziplib2) "--package=$(PACKAGE)" "--version=$(VERSION)" \ - "--onlymainheader=zzip/fseeko.h" "--suffix=4" -zzipfseeko.html : zzipfseeko.xml -zzipfseeko.xml : zziplib.spec $(srcdir)/Makefile.am $(srcdir)/zzipdoc/*.py \ - $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c - - $(PYRUN) $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c $(_zzipfseeko) - - test -f zziplib4.docbook && mv zziplib4.docbook $@ ; test -s $@ - -zziplib-man3.tar.gz : zziplib2.xml - - mkdir zziplib-man3 || rm zziplib-man3/* - (cd zziplib-man3 && xmlto man ../zziplib2.xml) - (cd zziplib-man3 && xmlto man ../zzipmmapped.xml) - (cd zziplib-man3 && xmlto man ../zzipfseeko.xml) - tar czf $@ zziplib-man3/ + $(MAKE) manpages.ar htmpages.ar DELETE=exit + +zziplib.html zziplib.xml : zziplib.spec $(srcdir)/Makefile.am \ + $(srcdir)/zzipdoc/*.py \ + $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c + $(PYRUN) $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c $(zziplib) \ + "--package=$(PACKAGE)" "--version=$(VERSION)" \ + "--onlymainheader=zzip/lib.h" "--output=zziplib" + test -s zziplib.docbook && mv zziplib.docbook zziplib.xml +zzipmmapped.html zzipmmapped.xml : zziplib.spec $(srcdir)/Makefile.am \ + $(srcdir)/zzipdoc/*.py \ + $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c + $(PYRUN) $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c $(zziplib) \ + "--package=$(PACKAGE)" "--version=$(VERSION)" \ + "--onlymainheader=zzip/mmapped.h" "--output=zzipmmapped" + test -s zzipmmapped.docbook && mv zzipmmapped.docbook zzipmmapped.xml +zzipfseeko.html zzipfseeko.xml : zziplib.spec $(srcdir)/Makefile.am \ + $(srcdir)/zzipdoc/*.py \ + $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c + $(PYRUN) $(srcdir)/makedocs.py @top_srcdir@/zzip/*.c $(zziplib) \ + "--package=$(PACKAGE)" "--version=$(VERSION)" \ + "--onlymainheader=zzip/fseeko.h" "--output=zzipfseeko" + test -s zzipfseeko.docbook && mv zzipfseeko.docbook zzipfseeko.xml omfdir=${datadir}/omf pkgomfdir=${omfdir}/${PACKAGE} SFNETDIR=/groups/z/zz/zziplib/htdocs -SFNETDOC=${datadir}${SFNETDIR} -pkgdocdir=${datadir}${SFNETDIR} +pkgdocdir=${mandir}/../doc/${PACKAGE} bins = @top_srcdir@/bins DOCEXAMPLES = $(bins)/zzdir.c $(bins)/zzcat.c \ $(bins)/zzobfuscated.c $(bins)/zziptest.c \ $(bins)/zzxordir.c $(bins)/zzxorcat.c \ $(bins)/zzxorcopy.c $(SDL_RWOPS) -install-docu: $(doc_FILES) $(man_FILES) site.html $(PACKAGE)-doc.omf +install-docs: $(doc_FILES) $(man_FILES) site.html htmpages.ar $(mkinstalldirs) $(DESTDIR)$(pkgdocdir) - for i in $(html_FILES) ; do cat $$i \ - | sed -e 's:--START-->:-- :' -e 's::-- :' -e 's: -
- The Manual Pages # +
  - unix man pages -
    (# autogenerated) - +
 
 
Download Area
<> Developer Area diff --git a/docs/functions.htm b/docs/functions.htm new file mode 100644 index 0000000..c4e4d89 --- /dev/null +++ b/docs/functions.htm @@ -0,0 +1,28 @@ +

Exported Functions

+2006-09-21 + +

+ The ZZipLib Project does already profive THREE libraries. The classic + zziplib.so (via "zzip/lib.h") is the most prominent one and used in + a number of different projects. The zzipfseeko.so ("zzip/fseeko.html") + and zzipmmapped.so ("zzip/mmapped.html") are technology demonstrations. +

+ + + +

+ Additonally, there is a complete set of unpacked documentation - the + unix manual pages are translated to html manual pages. +

+ + + +

 

+

 

+

 

diff --git a/docs/makedocs.py b/docs/makedocs.py index 0771870..1bc8f88 100644 --- a/docs/makedocs.py +++ b/docs/makedocs.py @@ -9,6 +9,8 @@ from zzipdoc.commentmarkup import * from zzipdoc.functionlisthtmlpage import * from zzipdoc.functionlistreference import * from zzipdoc.dbk2htm import * +from zzipdoc.htmldocument import * +from zzipdoc.docbookdocument import * def _src_to_xml(text): return text.replace("&", "&").replace("<", "<").replace(">", ">") @@ -270,7 +272,8 @@ def makedocs(filenames, o): # per_file.print_list_mainheader() # per_function.print_list_titleline() # per_function.print_list_name() - per_family.print_list_name() + # per_family.print_list_name() + # html = FunctionListHtmlPage(o) for item in per_family.entries: for func in item.functions: @@ -281,14 +284,15 @@ def makedocs(filenames, o): html.add(func_adapter) html.cut() html.cut() - html_filename = "zziplib"+o.suffix+".html" - try: - print "writing "+html_filename - fd = open(html_filename, "w") - print >>fd, section2html(paramdef2html(html.xml_text())) - fd.close() - except IOError, e: - print "could not open '"+html_filename+"'file", e + class _Html_: + def __init__(self, html): + self.html = html + def html_text(self): + return section2html(paramdef2html(self.html.xml_text())) + def get_title(self): + return self.html.get_title() + HtmlDocument(o).add(_Html_(html)).save(o.output+o.suffix) + # man3 = FunctionListReference(o) for item in per_family.entries: for func in item.functions: @@ -297,17 +301,9 @@ def makedocs(filenames, o): & func_adapter.src_mainheader()): continue man3.add(func_adapter) - man3.add_overview(func_adapter) man3.cut() man3.cut() - man3_filename = "zziplib"+o.suffix+".docbook" - try: - print "writing "+man3_filename - fd = open(man3_filename, "w") - print >>fd, man3.xml_text() - fd.close() - except IOError, e: - print "could not open '"+man3_filename+"'file", e + DocbookDocument(o).add(man3).save(o.output+o.suffix) if __name__ == "__main__": @@ -315,6 +311,10 @@ if __name__ == "__main__": o = Options() o.package = "ZZipLib" o.program = sys.argv[0] + o.html = "html" + o.docbook = "docbook" + o.output = "zziplib" + o.suffix = "" for item in sys.argv[1:]: if o.scan(item): continue filenames += [ item ] diff --git a/docs/mksite.pl b/docs/mksite.pl index 14acc6d..a463b3a 100644 --- a/docs/mksite.pl +++ b/docs/mksite.pl @@ -2,14 +2,14 @@ # this is the perl variant of the mksite script. It based directly on a # copy of mksite.sh which is derived from snippets that I was using to # finish doc pages for website publishing. Using only sh/sed along with -# files has a great disadvantage: it is very slow process atleast. The +# files has a great disadvantage: it is a very slow process atleast. The # perl language in contrast has highly optimized string, replace, search # functions as well as data structures to store intermediate values. As # an advantage large parts of the syntax are similar to the sh/sed variant. # # http://zziplib.sf.net/mksite/ # THE MKSITE.SH (ZLIB/LIBPNG) LICENSE -# Copyright (c) 2004 Guido Draheim +# Copyright (c) 2004 Guido U. Draheim # 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. @@ -23,7 +23,7 @@ # 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.pl,v 1.1 2005-12-13 00:27:06 guidod Exp $ +# $Id: mksite.pl,v 1.2 2006-09-22 00:33:22 guidod Exp $ use strict; use warnings; no warnings "uninitialized"; use File::Basename qw(basename); @@ -37,7 +37,7 @@ $SITEFILE="site.htm" if not $SITEFILE; # my $MK="-mksite"; # note the "-" at the start my $SED="sed"; -my $INFO="~~"; # extension for meta data files +my $DATA="~~"; # extension for meta data files my $HEAD="~head~"; # extension for head sed script my $BODY="~body~"; # extension for body sed script my $FOOT="~foot~"; # append to body text (non sed) @@ -51,11 +51,50 @@ my $AA="_$NN$AZ$az"; # that makes the resulting my $AX="$AA.+-"; # script more readable my $n = "\n"; +my $Q = "q class"; +my $QX = "/q"; # 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 +my @HTMLTAGS = qw/a p h1 h2 h3 h4 h5 h6 dl dd dt ul ol li pre code + table tr td th b u i s q em strong strike cite big small sup sub tt + thead tbody center hr br nobr wbr span div img adress blockquote/; +my @HTMLTAGS2 = qw/html head body title meta http-equiv style link/; + +# ========================================================================== +my $hint=""; + +sub echo +{ + print join(" ",@_),$n; +} +sub error +{ + print STDERR "ERROR: ", join(" ",@_),$n; +} +sub warns +{ + print STDERR "WARN: ", join(" ",@_), $n; +} +sub hint +{ + print STDERR "NOTE: ", join(" ", @_), $n if $hint; +} +sub init +{ + $hint="1" if -d "DEBUG"; +} + +&init ("NOW!!!"); + +sub ls_s { + my $x=`ls -s @_`; + chomp($x); + return $x; +} + # ========================================================================== # reading options from the command line GETOPT my %o = (); # to store option variables @@ -74,17 +113,17 @@ for my $arg (@ARGV) { # this variant should allow to embed spaces in $arg if (/^-.*=.*$/) { $opt=$arg; $opt =~ s/-*([$AA][$AA-]*).*/$1/; $opt =~ y/-/_/; if (not $opt) { - print STDERR "ERROR: invalid option $arg$n"; + error "invalid option $arg"; } else { $arg =~ s/^[^=]*=//; $o{$opt} = $arg; $o{variables} .= " ".$opt; } $opt="";; - } elsif (/^-.*-.*$/) { + } elsif (/^-.*.-.*$/) { $opt=$arg; $opt =~ s/-*([$AA][$AA-]*).*/$1/; $opt =~ y/-/_/; if (not $opt) { - print STDERR "ERROR: invalid option $arg$n"; + error "invalid option $arg"; $opt=""; } else { # keep the option for next round @@ -92,13 +131,14 @@ for my $arg (@ARGV) { # this variant should allow to embed spaces in $arg } elsif (/^-.*/) { $opt=$arg; $opt =~ s/^-*([$AA][$AA-]*).*/$1/; $opt =~ y/-/_/; if (not $opt) { - print STDERR "ERROR: invalid option $arg$n"; + error "invalid option $arg"; } else { $arg =~ s/^[^=]*=//; $o{$opt} = ' '; } $opt="" ;; } else { + hint "<$arg>"; if (not $o{main_file}) { $o{main_file} = $arg; } else { $o{files} .= $o{fileseparator} if $o{files}; $o{files} .= $arg; }; @@ -114,31 +154,35 @@ for my $arg (@ARGV) { # this variant should allow to embed spaces in $arg $SITEFILE=$o{main_file} if $o{main_file} and -f $o{main_file}; $SITEFILE=$o{site_file} if $o{site_file} and -f $o{site_file}; +$hint="1" if $o{debug}; if ($o{help}) { $_=$SITEFILE; - print "$0 [sitefile]$n"; - print " default sitefile = $_$n"; - print "options:$n" - . " --filelist : show list of target files as ectracted from $_$n" - . " --src xx : if source files are not where mksite is executed$n"; + echo "$0 [sitefile]"; + echo " default sitefile = $_ ($o{main_file}) ($o{files})"; + echo "options:"; + echo " --filelist : show list of target files as ectracted from $_"; + 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/mksite.*"; exit; - print " internal:$n" - ."--fileseparator=x : for building the internal filelist (def. '?')$n" - ."--files xx : for list of additional files to be processed$n" - ."--main-file xx : for the main sitefile to take file list from$n"; + echo " internal:"; + echo "--fileseparator=x : for building the internal filelist (def. '?')"; + echo "--files xx : for list of additional files to be processed"; + echo "--main-file xx : for the main sitefile to take file list from"; } if (not $SITEFILE) { - print STDERR "error: no SITEFILE found (default would be 'site.htm')$n"; + error "no SITEFILE found (default would be 'site.htm')$n"; exit 1; } else { - print STDERR "NOTE: sitefile: ",`ls -s $SITEFILE`,"$n"; + hint "sitefile: ", ls_s($SITEFILE); } # we use internal hashes to store mappings - kind of relational tables my @MK_TAGS= (); # "./$MK.tags.tmp" my @MK_VARS= (); # "./$MK.vars.tmp" +my @MK_SPAN= (); # "./$MK.span.tmp" my @MK_META= (); # "./$MK.meta.tmp" my @MK_METT= (); # "./$MK.mett.tmp" my @MK_TEST= (); # "./$MK.test.tmp" @@ -150,9 +194,8 @@ my @MK_SITE= (); # "./$MK.site.tmp" my @MK_SECT1= (); # "./$MK.sect1.tmp" my @MK_SECT2= (); # "./$MK.sect2.tmp" my @MK_SECT3= (); # "./$MK.sect3.tmp" -my @MK_INFO= (); # "./$MK~~" -my %INFO= (); # used for $F.$PARTs -my %FAST= (); +my @MK_DATA= (); # "./$MK~~" +my %DATA= (); # used for $F.$PARTs # ======================================================================== # ======================================================================== @@ -162,11 +205,10 @@ my %FAST= (); my $printerfriendly=""; my $sectionlayout="list"; my $sitemaplayout="list"; -my $simplevars="warn"; # default my $attribvars=" "; # my $updatevars=" "; # default my $expandvars=" "; # -my $commentvars=" "; # $updatevars && $expandsvars && $simplevars +my $commentvars=" "; # $updatevars && $expandsvars my $sectiontab=" "; # highlight ^...href="$section" my $currenttab=" "; # highlight ^
.. my $headsection="no"; @@ -176,7 +218,7 @@ my $emailfooter="no"; for (source($SITEFILE)) { if (//) { - warn("WARNING: do not use ," + warns("do not use ," ." change to $SITEFILE" ."warning: or" ." " @@ -218,8 +260,6 @@ sub mksite_magic_option ($x =~ /^(list|multi)$/) { $sectionlayout="$x" ; } $x=mksite_magic_option("sitemaplayout"); if ($x =~ /^(list|multi)$/) { $sitemaplayout="$x" ; } - $x=mksite_magic_option("simplevars"); if - ($x =~ /^( |no|warn)$/) { $simplevars="$x" ; } $x=mksite_magic_option("attribvars"); if ($x =~ /^( |no|warn)$/) { $attribvars="$x" ; } $x=mksite_magic_option("updatevars"); if @@ -245,20 +285,12 @@ sub mksite_magic_option $printerfriendly=$o{print} if $o{print}; $updatevars="no" if $commentvars eq "no"; # duplicated into $expandvars="no" if $commentvars eq "no"; # info2vars_sed -$simplevars="no" if $commentvars eq "no"; # function above - -print "NOTE: '$sectionlayout\'sectionlayout '$sitemaplayout\'sitemaplayout$n" - if -d "DEBUG"; -print "NOTE: '$simplevars\'simplevars '$printerfriendly\'printerfriendly$n" - if -d "DEBUG"; -print "NOTE: '$attribvars\'attribvars '$updatevars\'updatevars$n" - if -d "DEBUG"; -print "NOTE: '$expandvars\'expandvars '$commentvars\'commentvars $n" - if -d "DEBUG"; -print "NOTE: '$currenttab\'currenttab '$sectiontab\'sectiontab$n" - if -d "DEBUG"; -print "NOTE: '$headsection\'headsection '$tailsection\'tailsection$n" - if -d "DEBUG"; + +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"; # ========================================================================== # init a few global variables @@ -271,16 +303,21 @@ print "NOTE: '$headsection\'headsection '$tailsection\'tailsection$n" # tag via "h;y;x" or something we do want to convert all the tags on # a single line of course. @MK_TAGS=(); -for my $P (qw/P H1 H2 H3 H4 H5 H6 DL DD DT UL OL LI PRE CODE TABLE TR TD TH - B U I S Q EM STRONG STRIKE CITE BIG SMALL SUP SUB TT THEAD TBODY - CENTER HR BR NOBR WBR SPAN DIV IMG ADRESS BLOCKQUOTE/) { - my $M=lc($P); +{ my ($M,$P); for $M (@HTMLTAGS) { + $P=uc($M); push @MK_TAGS, "s|<$P>|<$M class=\\\"$P\\\">|g;"; push @MK_TAGS, "s|<$P |<$M class=\\\"$P\\\" |g;"; push @MK_TAGS, "s|||g;"; -} +}} push @MK_TAGS, "s|<>|\\ \\;|g;"; push @MK_TAGS, "s|<->|\\;|g;"; +push @MK_TAGS, "s|||g;"; +push @MK_TAGS, "s|||g;"; +push @MK_TAGS, "s|
||g;"; +push @MK_TAGS, "s|
||g;"; +push @MK_TAGS, "s|<(a [^<>]*) />|<\$1>
|g"; +my $_ulink_="\$1"; +push @MK_TAGS, "s|\\s*(\\w+://[^<>]*)|$_ulink_|g;"; # 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 @@ -293,13 +330,13 @@ my @_EQUIVS = ("refresh", "expires", "content-type", "cache-control", "redirect", "charset", # mapped to refresh / content-type "content-language", "content-script-type", "content-style-type"); -for my $P (@DC_VARS) { # dublin core embedded +{ my $P; for $P (@DC_VARS) { # dublin core embedded push @MK_TAGS, "s|<$P>[^<>]*||g;"; -} -for my $P (@_EQUIVS) { +}} +{ my $P; for $P (@_EQUIVS) { push @MK_TAGS, "s|<$P>[^<>]*||g;"; -} -push @MK_TAGS, "s|||g;"; +}} +push @MK_TAGS, "s|||g;"; push @MK_TAGS, "s|||g;"; push @MK_TAGS, "s|||g;"; @@ -367,25 +404,33 @@ my $F; # current file during loop <<<<<<<<< my $i = 100; sub savelist { if (-d "DEBUG") { - my $X = "$F._$i"; $i++; $X =~ s|/|:|g; + my ($script,$ext,$Z) = @_; + if (not $ext) { $ext = "_".$i; $i++; } + my $X = "$F.$ext.tmp.PL"; $X =~ s|/|:|g; open X, ">DEBUG/$X" or die "could not open $X: $!"; - print X "#! /usr/bin/perl -".$#_."$n"; - print X join("$n", @{$_[0]}),$n; close X; + print X "#! /usr/bin/env perl",$n; + print X "# ",$#_," $ext files ",localtime(),$n; + my $TEXT = join("$n", @{$script}); + $TEXT =~ s|source\([^()]*\)|<>|; + print X $TEXT,$n; close X; } } sub eval_MK_LIST # $str @list { + my $FILETYPE = $_[0]; shift @_; my $result = $_[0]; shift @_; my $extra = ""; my $script = "\$_ = \$result; my \$Z;"; $script .= join(";$n ", @_); $script .= "$n;\$result = \$_;$n"; + savelist([$script],$FILETYPE); eval $script; return $result.$extra; } sub eval_MK_FILE { + my $FILETYPE = $_[0]; shift @_; my $FILENAME = $_[0]; shift @_; my $result = ""; my $script = "my \$FILE; my \$extra = ''; my \$Z; $n"; @@ -394,18 +439,13 @@ sub eval_MK_FILE { $script.= "$n; \$result .= \$_; "; $script.= "$n if(\$extra){\$result.=\$extra;\$extra='';\$result.=\"\\n\"}"; $script.= "$n} if(\$extra){\$result.=\$extra;}$n"; - savelist([$script,""]); + savelist([$script],$FILETYPE); eval $script; return $result; } my $sed_add = "\$extra .= "; # "/r "; sub foo { print " '$F'$n"; } -sub ls_s { - my $result = `ls -s @_`; - chomp($result); - return $result; -} # ====================================================================== # FUNCS @@ -437,47 +477,15 @@ sub dir_name return $R; } -sub info2test_sed # \@ \@ # cut out all old-style usages -{ - my ($INP,$XXX) = @_; - $INP = \@{$INFO{$F}} if not $INP; - my @OUT = (); - my $V8=" *([^ ][^ ]*) (.*)"; - my $V9=" *DC[.]([^ ][^ ]*) (.*)"; - my $q="\\\$"; - my ($_x_,$_y_,$_X_,$_Y_); my $W = "WARNING:"; - $_x_= sub {"$W: assumed simplevar changed to " }; - $_y_= sub {"$W: assumed simplevar changed to " }; - $_X_= sub {"$W: assumed tailvar changed to " }; - $_Y_= sub {"$W: assumed tailvar changed to " }; - push @OUT, "s/^/ /;"; - for (@$INP) { - if (/^=....=formatter /) { next; }; - if (/=[Tt]ext=$V9%/){ push @OUT, esc("s|.*.*|".&$_x_."|;");} - if (/=[Nn]ame=$V9%/){ push @OUT, esc("s|.*.*|".&$_y_."|;");} - if (/=[Tt]ext=$V8%/){ push @OUT, esc("s|.*.*|".&$_x_."|;");} - if (/=[Nn]ame=$V8%/){ push @OUT, esc("s|.*.*|".&$_y_."|;");} - } - for (@$INP) { - if (/^=....=formatter /) { next; }; - if (/=[Tt]ext=$V9%/){ push @OUT, esc("s|.*.*|".&$_X_."|;");} - if (/=[Nn]ame=$V9%/){ push @OUT, esc("s|.*.*|".&$_Y_."|;");} - if (/=[Tt]ext=$V8%/){ push @OUT, esc("s|.*.*|".&$_X_."|;");} - if (/=[Nn]ame=$V8%/){ push @OUT, esc("s|.*.*|".&$_Y_."|;");} - } - push @OUT, "/^WARNING:/ || next;"; - return @OUT; -} - sub info2vars_sed # generate substition sed addon script { my ($INP,$Z) = @_; - $INP = \@{$INFO{$F}} if not $INP; + $INP = \@{$DATA{$F}} if not $INP; my @OUT = (); - my $V8=" *([^ ][^ ]*) +(.*)"; - my $V9=" *DC[.]([^ ][^ ]*) +(.*)"; - my $N8=" *([^ ][^ ]*) ([$NN].*)"; - my $N9=" *DC[.]([^ ][^ ]*) ([$NN].*)"; + my $V8=" *([^ ][^ ]*) +(.*)<$QX>"; + my $V9=" *DC[.]([^ ][^ ]*) +(.*)<$QX>"; + my $N8=" *([^ ][^ ]*) ([$NN].*)<$QX>"; + my $N9=" *DC[.]([^ ][^ ]*) ([$NN].*)<$QX>"; my $V0="([<]*)\\\$"; my $V1="([^<>]*)\\\$"; my $V2="([^{<>}]*)"; @@ -486,94 +494,69 @@ sub info2vars_sed # generate substition sed addon script $Z="\$Z="; $updatevars = "no" if $commentvars eq "no"; # duplicated from $expandvars = "no" if $commentvars eq "no"; # option handling - $simplevars = "no" if $commentvars eq "no"; # tests below - my @_INP = (); for (@{$INP}) { my $x=$_; $x =~ s/'/\\'/; push @_INP, $x; } + my @_INP = (); for (@{$INP}) { + my $x=$_; $x =~ s/(>[^<>]*)'([^<>]*<)/$1\\'$2/; push @_INP, $x; # OOOOPS + } if ($expandvars ne "no") { - for (@_INP) { + for (@_INP) { if (/^=....=formatter /) { next; } - elsif (/^=name=$V9/){push @OUT, "\$Z='$2';s||- \$Z|;"} - elsif (/^=Name=$V9/){push @OUT, "\$Z='$2';s||(\$Z)|;"} - elsif (/^=name=$V8/){push @OUT, "\$Z='$2';s||- \$Z|;"} - elsif (/^=Name=$V8/){push @OUT, "\$Z='$2';s||(\$Z)|;"} + elsif (/^<$Q='name'>$V9/){push @OUT, "\$Z='$2';s||- \$Z|;"} + elsif (/^<$Q='Name'>$V9/){push @OUT, "\$Z='$2';s||(\$Z)|;"} + elsif (/^<$Q='name'>$V8/){push @OUT, "\$Z='$2';s||- \$Z|;"} + elsif (/^<$Q='Name'>$V8/){push @OUT, "\$Z='$2';s||(\$Z)|;"} } } if ($expandvars ne "no") { for (@_INP) { if (/^=....=formatter /) { next; } - elsif (/^=text=$V9/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} - elsif (/^=Text=$V9/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} - elsif (/^=name=$V9/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} - elsif (/^=Name=$V9/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} - elsif (/^=text=$V8/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} - elsif (/^=Text=$V8/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} - elsif (/^=name=$V8/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} - elsif (/^=Name=$V8/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} - } - } - if ($simplevars ne "no" && $updatevars ne "no") { - for (@_INP) { my $Q = "[$AX]*"; - if (/^=....=formatter /) { next; } - elsif (/^=text=$V9/){push @OUT, "\$Z='$2';s|$Q|\$Z|;"} - elsif (/^=Text=$V9/){push @OUT, "\$Z='$2';s|$Q|\$Z|;"} - elsif (/^=name=$V9/){push @OUT, "\$Z='$2';s|$Q|- \$Z|;"} - elsif (/^=Name=$V9/){push @OUT, "\$Z='$2';s|$Q|(\$Z)|;"} - elsif (/^=text=$V8/){push @OUT, "\$Z='$2';s|$Q|\$Z|;"} - elsif (/^=Text=$V8/){push @OUT, "\$Z='$2';s|$Q|\$Z|;"} - elsif (/^=name=$V8/){push @OUT, "\$Z='$2';s|$Q|- \$Z|;"} - elsif (/^=Name=$V8/){push @OUT, "\$Z='$2';s|$Q|(\$Z)|;"} + elsif (/^<$Q='text'>$V9/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} + elsif (/^<$Q='Text'>$V9/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} + elsif (/^<$Q='name'>$V9/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} + elsif (/^<$Q='Name'>$V9/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} + elsif (/^<$Q='text'>$V8/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} + elsif (/^<$Q='Text'>$V8/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} + elsif (/^<$Q='name'>$V8/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} + elsif (/^<$Q='Name'>$V8/){push @OUT, "\$Z='$2';s||\$1$SS\$Z|;"} } } if ($updatevars ne "no") { - for (@_INP) { my $Q = "[^<>]*"; + for (@_INP) { my $H = "[^<>]*"; if (/^=....=formatter /) { next; } - elsif (/^=name=$V9/){push @OUT, "\$Z='$2';s|$Q|- \$Z|;"} - elsif (/^=Name=$V9/){push @OUT, "\$Z='$2';s|$Q|(\$Z)|;"} - elsif (/^=name=$V8/){push @OUT, "\$Z='$2';s|$Q|- \$Z|;"} - elsif (/^=Name=$V8/){push @OUT, "\$Z='$2';s|$Q|(\$Z)|;"} + elsif (/^<$Q='name'>$V9/){push @OUT, "\$Z='$2';s|$H|- \$Z|;"} + elsif (/^<$Q='Name'>$V9/){push @OUT, "\$Z='$2';s|$H|(\$Z)|;"} + elsif (/^<$Q='name'>$V8/){push @OUT, "\$Z='$2';s|$H|- \$Z|;"} + elsif (/^<$Q='Name'>$V8/){push @OUT, "\$Z='$2';s|$H|(\$Z)|;"} } } if ($updatevars ne "no") { - for (@_INP) { my $Q = "[^<>]*"; + for (@_INP) { my $H = "[^<>]*"; if (/^=....=formatter /) { next; } - elsif (/^=text=$V9/){push @OUT,"\$Z='$2';s|$Q|\$1$SS\$Z|;"} - elsif (/^=Text=$V9/){push @OUT,"\$Z='$2';s|$Q|\$1$SS\$Z|;"} - elsif (/^=name=$V9/){push @OUT,"\$Z='$2';s|$Q|\$1$SS\$Z|;"} - elsif (/^=Name=$V9/){push @OUT,"\$Z='$2';s|$Q|\$1$SS\$Z|;"} - elsif (/^=text=$V8/){push @OUT,"\$Z='$2';s|$Q|\$1$SS\$Z|;"} - elsif (/^=Text=$V8/){push @OUT,"\$Z='$2';s|$Q|\$1$SS\$Z|;"} - elsif (/^=name=$V8/){push @OUT,"\$Z='$2';s|$Q|\$1$SS\$Z|;"} - elsif (/^=Name=$V8/){push @OUT,"\$Z='$2';s|$Q|\$1$SS\$Z|;"} + elsif (/^<$Q='text'>$V9/){push @OUT,"\$Z='$2';s|$H|\$1$SS\$Z|;"} + elsif (/^<$Q='Text'>$V9/){push @OUT,"\$Z='$2';s|$H|\$1$SS\$Z|;"} + elsif (/^<$Q='name'>$V9/){push @OUT,"\$Z='$2';s|$H|\$1$SS\$Z|;"} + elsif (/^<$Q='Name'>$V9/){push @OUT,"\$Z='$2';s|$H|\$1$SS\$Z|;"} + elsif (/^<$Q='text'>$V8/){push @OUT,"\$Z='$2';s|$H|\$1$SS\$Z|;"} + elsif (/^<$Q='Text'>$V8/){push @OUT,"\$Z='$2';s|$H|\$1$SS\$Z|;"} + elsif (/^<$Q='name'>$V8/){push @OUT,"\$Z='$2';s|$H|\$1$SS\$Z|;"} + elsif (/^<$Q='Name'>$V8/){push @OUT,"\$Z='$2';s|$H|\$1$SS\$Z|;"} } } if ($attribvars ne "no") { - for (@_INP) { my $Q = "[^<>]*"; + for (@_INP) { my $H = "[^<>]*"; if (/^=....=formatter /) { next; } - elsif (/^=text=$V9/){push @OUT,"\$Z='$2';s|<$V1\{$1:[=]$V2}$V3>|<\$1$SS\$Z\$3>|;"} - elsif (/^=Text=$V9/){push @OUT,"\$Z='$2';s|<$V1\{$1:[=]$V2}$V3>|<\$1$SS\$Z\$3>|;"} - elsif (/^=name=$V9/){push @OUT,"\$Z='$2';s|<$V1\{$1:[?]$V2}$V3>|<\$1$SS\$Z\$3>|;"} - elsif (/^=Name=$V9/){push @OUT,"\$Z='$2';s|<$V1\{$1:[?]$V2}$V3>|<\$1$SS\$Z\$3>|;"} - elsif (/^=text=$V8/){push @OUT,"\$Z='$2';s|<$V1\{$1:[=]$V2}$V3>|<\$1$SS\$Z\$3>|;"} - elsif (/^=Text=$V8/){push @OUT,"\$Z='$2';s|<$V1\{$1:[=]$V2}$V3>|<\$1$SS\$Z\$3>|;"} - elsif (/^=name=$V8/){push @OUT,"\$Z='$2';s|<$V1\{$1:[?]$V2}$V3>|<\$1$SS\$Z\$3>|;"} - elsif (/^=Name=$V8/){push @OUT,"\$Z='$2';s|<$V1\{$1:[?]$V2}$V3>|<\$1$SS\$Z\$3>|;"} + elsif (/^<$Q='text'>$V9/){push @OUT,"\$Z='$2';s|<$V1\{$1:[=]$V2}$V3>|<\$1$SS\$Z\$3>|;"} + elsif (/^<$Q='Text'>$V9/){push @OUT,"\$Z='$2';s|<$V1\{$1:[=]$V2}$V3>|<\$1$SS\$Z\$3>|;"} + elsif (/^<$Q='name'>$V9/){push @OUT,"\$Z='$2';s|<$V1\{$1:[?]$V2}$V3>|<\$1$SS\$Z\$3>|;"} + elsif (/^<$Q='Name'>$V9/){push @OUT,"\$Z='$2';s|<$V1\{$1:[?]$V2}$V3>|<\$1$SS\$Z\$3>|;"} + elsif (/^<$Q='text'>$V8/){push @OUT,"\$Z='$2';s|<$V1\{$1:[=]$V2}$V3>|<\$1$SS\$Z\$3>|;"} + elsif (/^<$Q='Text'>$V8/){push @OUT,"\$Z='$2';s|<$V1\{$1:[=]$V2}$V3>|<\$1$SS\$Z\$3>|;"} + elsif (/^<$Q='name'>$V8/){push @OUT,"\$Z='$2';s|<$V1\{$1:[?]$V2}$V3>|<\$1$SS\$Z\$3>|;"} + elsif (/^<$Q='Name'>$V8/){push @OUT,"\$Z='$2';s|<$V1\{$1:[?]$V2}$V3>|<\$1$SS\$Z\$3>|;"} } for (split / /, $o{variables}) { {push @OUT,"\$Z='$o{$_}';s|<$V1\{$_:[?]$V2}$V3>|<\$1$SS\$Z\$3>|;"} } } - if ($simplevars ne "no") { - for (@_INP) { my $Q = "[$AX]*"; - if (/^=....=formatter /) { next; } - elsif (/^=text=$V9/){push @OUT, "\$Z='$2';s|$Q|\$Z|;"} - elsif (/^=Text=$V9/){push @OUT, "\$Z='$2';s|$Q|\$Z|;"} - elsif (/^=name=$V9/){push @OUT, "\$Z='$2';s|$Q| - \$Z|;"} - elsif (/^=Name=$V9/){push @OUT, "\$Z='$2';s|$Q| (\$Z)|;"} - elsif (/^=text=$V8/){push @OUT, "\$Z='$2';s|$Q|\$Z|;"} - elsif (/^=Text=$V8/){push @OUT, "\$Z='$2';s|$Q|\$Z|;"} - elsif (/^=name=$V8/){push @OUT, "\$Z='$2';s|$Q| - \$Z|;"} - elsif (/^=Name=$V8/){push @OUT, "\$Z='$2';s|$Q| (\$Z)|;"} - } - } # 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: @@ -585,12 +568,12 @@ sub info2vars_sed # generate substition sed addon script sub info2meta_sed # generate text portion { my ($INP,$XXX) = @_; - $INP = \@{$INFO{$F}} if not $INP; + $INP = \@{$DATA{$F}} if not $INP; my @OUT = (); # http://www.metatab.de/meta_tags/DC_type.htm - my $V6=" *HTTP[.]([^ ]+) (.*)"; - my $V7=" *DC[.]([^ ]+) (.*)"; - my $V8=" *([^ ]+) (.*)" ; + my $V6=" *HTTP[.]([^ ]+) (.*)<$QX>"; + my $V7=" *DC[.]([^ ]+) (.*)<$QX>"; + my $V8=" *([^ ]+) (.*)<$QX>" ; sub __TYPE_SCHEME { "name=\"DC.type\" content=\"$2\" scheme=\"$1\"" }; sub __DCMI { "name=\"$1\" content=\"$2\" scheme=\"DCMIType\"" }; sub __NAME { "name=\"$1\" content=\"$2\"" }; @@ -598,31 +581,31 @@ sub info2meta_sed # generate text portion sub __HTTP { "http-equiv=\"$1\" content=\"$2\"" }; for (@$INP) { if (/=....=today /) { next; } - if (/=meta=HTTP[.]/ && /=meta=$V6/) { + if (/<$Q='meta'>HTTP[.]/ && /<$Q='meta'>$V6/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]DCMIType / && /=meta=$V7/) { + if (/<$Q='meta'>DC[.]DCMIType / && /<$Q='meta'>$V7/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]type Collection$/ && /=meta=$V8/) { + if (/<$Q='meta'>DC[.]type Collection$/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]type Dataset$/ && /=meta=$V8/) { + if (/<$Q='meta'>DC[.]type Dataset$/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]type Event$/ && /=meta=$V8/) { + if (/<$Q='meta'>DC[.]type Event$/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]type Image$/ && /=meta=$V8/) { + if (/<$Q='meta'>DC[.]type Image$/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]type Service$/ && /=meta=$V8/) { + if (/<$Q='meta'>DC[.]type Service$/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]type Software$/ && /=meta=$V8/) { + if (/<$Q='meta'>DC[.]type Software$/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]type Sound$/ && /=meta=$V8/) { + if (/<$Q='meta'>DC[.]type Sound$/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]type Text$/ && /=meta=$V8/) { + if (/<$Q='meta'>DC[.]type Text$/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]date[.].*[+]/ && /=meta=$V8/) { + if (/<$Q='meta'>DC[.]date[.].*[+]/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } - if (/=meta=DC[.]date[.].*[:]/ && /=meta=$V8/) { + if (/<$Q='meta'>DC[.]date[.].*[:]/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } - if (/=meta=/ && /=meta=$V8/) { + if (/<$Q='meta'>/ && /<$Q='meta'>$V8/) { push @OUT, " " if $2; next; } } return @OUT; @@ -632,10 +615,10 @@ sub info_get_entry # get the first value known so far { my ($TXT,$INP,$XXX) = @_; $TXT = "sect" if not $TXT; - $INP = \@{$INFO{$F}} if not $INP; - for (grep {/=text=$TXT /} @$INP) { + $INP = \@{$DATA{$F}} if not $INP; + for (grep {/<$Q='text'>$TXT /} @$INP) { my $info = $_; - $info =~ s/=text=$TXT //; + $info =~ s|<$Q='text'>$TXT ||; $info =~ s|<$QX>||; chomp($info); chomp($info); return $info; } } @@ -644,13 +627,13 @@ sub info1grep # test for a substition to be already present { my ($TXT,$INP,$XXX) = @_; $TXT = "sect" if not $TXT; - $INP = \@{$INFO{$F}} if not $INP; - return scalar(grep {/^=text=$TXT /} @$INP); # returning the count + $INP = \@{$DATA{$F}} if not $INP; + return scalar(grep {/^<$Q='text'>$TXT /} @$INP); # returning the count } sub dx_init { - @{$INFO{$F}} = (); + @{$DATA{$F}} = (); &dx_meta ("formatter", basename($o{formatter})); for (split / /, $o{variables}) { # commandline --def=value if (/_/) { my $u=$_; $u =~ y/_/-/; # makes for override @@ -662,7 +645,7 @@ sub dx_init sub dx_line { my ($U,$V,$W,$Z) = @_; chomp($U); chomp($V); - push @{$INFO{$F}}, $U.$V." ".trimmm($W); + push @{$DATA{$F}}, "<$Q=$U>".$V." ".trimmm($W)."<$QX>"; } sub DX_line @@ -674,7 +657,7 @@ sub DX_line sub dx_text { my ($U,$V,$Z) = @_; - &dx_line ("=text=",$U,$V); + &dx_line ("'text'",$U,$V); } sub DX_text # add a substition includings format variants @@ -684,13 +667,13 @@ sub DX_text # add a substition includings format variants if ($N) { if ($T) { my $text=lc("$T"); $text =~ s/<[^<>]*>//g; - &dx_line ("=text=",$N,$T); - &dx_line ("=name=",$N,$text); + &dx_line ("'text'",$N,$T); + &dx_line ("'name'",$N,$text); my $varname=$N; $varname =~ s/.*[.]//; # cut out front part if ($N ne $varname and $varname) { $text=lc("$varname $T"); $text =~ s/<[^<>]*>//g; - &dx_line ("=Text=",$varname,$T); - &dx_line ("=Name=",$varname,$text); + &dx_line ("'Text'",$varname,$T); + &dx_line ("'Name'",$varname,$text); } } } @@ -699,20 +682,20 @@ sub DX_text # add a substition includings format variants sub dx_meta { my ($U,$V,$Z) = @_; - &DX_line ("=meta=",$U,$V); + &DX_line ("'meta'",$U,$V); } sub DX_meta # add simple meta entry and its subsitution { my ($U,$V,$Z) = @_; - &DX_line ("=meta=",$U,$V); + &DX_line ("'meta'",$U,$V); &DX_text ("$U", $V); } sub DC_meta # add new DC.meta entry plus two substitutions { my ($U,$V,$Z) = @_; - &DX_line ("=meta=","DC.$U",$V); + &DX_line ("'meta'","DC.$U",$V); &DX_text ("DC.$U", $V); &DX_text ("$U", $V); } @@ -720,7 +703,7 @@ sub DC_meta # add new DC.meta entry plus two substitutions sub HTTP_meta # add new HTTP.meta entry plus two substitutions { my ($U,$V,$Z) = @_; - &DX_line ("=meta=","HTTP.$U",$V); + &DX_line ("'meta'","HTTP.$U",$V); &DX_text ("HTTP.$U", $V); &DX_text ("$U", $V); } @@ -793,9 +776,9 @@ sub DC_publisher # make sure there is this DC.publisher meta tag sub DC_modified # make sure there is a DC.date.modified meta tag { # maybe choose from filesystem dates if possible - my ($Q,$Z) = @_; # target file + my ($ZZ,$Z) = @_; # target file if (not &info1grep ("DC.date.modified")) { - my @stats = stat($Q); + my @stats = stat($ZZ); my $text = strftime("%Y-%m-%d", localtime($stats[9])); &DC_meta ("date.modified", $text); } @@ -803,7 +786,7 @@ sub DC_modified # make sure there is a DC.date.modified meta tag sub DC_date # make sure there is this DC.date meta tag { # choose from one of the available DC.date.* specials - my ($Q,$Z) = @_; # source file + my ($ZZ,$Z) = @_; # source file if (&info1grep ("DC.date")) { &DX_text ("issue", "dated ".&info_get_entry("DC.date")); &DX_text ("updated", &info_get_entry("DC.date")); @@ -811,12 +794,12 @@ sub DC_date # make sure there is this DC.date meta tag my $text=""; my $kind; for $kind (qw/available issued modified created/) { $text=&info_get_entry("DC.date.$kind"); - # test ".$text" != "." && echo "$kind = date = $text ($Q)" + # test ".$text" != "." && echo "$kind = date = $text ($ZZ)" last if $text; } if (not $text) { my $part; my $M="date"; - for (source($Q)) { + for (source($ZZ)) { /<$M>/ or next; s|.*<$M>||; s|.*||; $part=trimm($_); last; } @@ -825,7 +808,7 @@ sub DC_date # make sure there is this DC.date meta tag } if (not $text) { my $part; my $M="!--date:*=*--"; # takeover updateable variable... - for (source($Q)) { + for (source($ZZ)) { /<$M>/ or next; s|.*<$M>||; s|/ or next; s|.*<$M>||; s|.*||; $text = trimm($_); last; } last if $text; - for (source($Q)) { + for (source($ZZ)) { /<$M [^<>]*>/ or next; s|.*<$M [^<>]*>||; s|.*||; $text = trimm($_); last; } last if $text; } if (not $text) { - $text=basename($Q,".html"); + $text=basename($ZZ,".html"); $text=basename($text,".htm"); $text =~ y/_/ /; $text =~ s/$/ info/; $text=~ s/\n/ /g; } @@ -888,15 +871,16 @@ sub DC_title sub site_get_section # return parent section page of given page { my $_F_ = &sed_slash_key(@_); - for my $x (grep {/=sect=$_F_ /} @MK_INFO) { - my $info = $x; $info =~ s/=sect=[^ ]* //; return $info; + for my $x (grep {/<$Q='sect'>$_F_ /} @MK_DATA) { + my $info = $x; $info =~ s|<$Q='sect'>[^ ]* ||; $info =~ s|<$QX>||; + return $info; } } sub DC_section # not really a DC relation (shall we use isPartOf ?) { # each document should know its section father my $sectn = &site_get_section($F); - if ($sectn) { + if ($sectn) { &DC_meta ("relation.section", $sectn); } } @@ -909,8 +893,10 @@ sub info_get_entry_section sub site_get_selected # return section of given page { my $_F_ = &sed_slash_key(@_); - for my $x (grep {/=[u]se.=$_F_ /} @MK_INFO) { - my $info = $x; $info =~ s/=[u]se.=[^ ]* //; return $info; + for my $x (grep {/<$Q='[u]se.'>$_F_ /} @MK_DATA) { + my $info = $x; + $info =~ s/<$Q='[u]se.'>[^ ]* //; $info =~ s|<$QX>||; + return $info; } } @@ -931,9 +917,9 @@ sub info_get_entry_selected sub site_get_rootsections # return all sections from root of nav tree { my @OUT; - for (grep {/=[u]se1=/} @MK_INFO) { + for (grep {/<$Q='[u]se1'>/} @MK_DATA) { my $x = $_; - $x =~ s/=[u]se.=([^ ]*) .*/$1/; + $x =~ s/<$Q='[u]se.'>([^ ]*) .*/$1/; push @OUT, $x; } return @OUT; @@ -943,9 +929,9 @@ sub site_get_sectionpages # return all children pages in the given section { my $_F_=&sed_slash_key(@_); my @OUT = (); - for (grep {/^=sect=[^ ]* $_F_$/} @MK_INFO) { + for (grep {/^<$Q='sect'>[^ ]* $_F_$/} @MK_DATA) { my $x = $_; - $x =~ s/^=sect=//; $x =~ s/ .*//; + $x =~ s/^<$Q='sect'>//; $x =~ s/ .*//; $x =~ s|<$QX>||; push @OUT, $x; } return @OUT; @@ -955,9 +941,9 @@ sub site_get_subpages # return all page children of given page { my $_F_=&sed_slash_key(@_); my @OUT = (); - for (grep {/^=node=[^ ]* $_F_$/} @MK_INFO) { - my $x = $_; - $x =~ s/^=node=//; $x =~ s/ .*//; + for (grep {/^<$Q='node'>[^ ]* $_F_<[^<>]*>$/} @MK_DATA) { + my $x = $_; + $x =~ s/^<$Q='node'>//; $x =~ s/ .*//; $x =~ s|<$QX>||; push @OUT, $x; } return @OUT; @@ -966,9 +952,9 @@ sub site_get_subpages # return all page children of given page sub site_get_parentpage # ret parent page for given page (".." for sections) { my $_F_=&sed_slash_key(@_); - for (grep {/^=node=$_F_ /} @MK_INFO) { + for (grep {/^<$Q='node'>$_F_ /} @MK_DATA) { my $x = $_; - $x =~ s/^=node=[^ ]* //; + $x =~ s/^<$Q='node'>[^ ]* //; $x =~ s|<$QX>||; return $x; } } @@ -1038,41 +1024,18 @@ sub fast_href # args "$FILETOREFERENCE" "$FROMCURRENTFILE:$F" } } -sub make_fast # experimental - make a FAST file that can be applied -{ # to htm sourcefiles in a subdirectory of the sitefile. -# R="$1" ; test ".$R" = "." && R="$F" +sub make_back_path # "$FILE" +{ my ($R,$Z) = @_; my $S=&back_path ($R); my @OUT = (); - if (not $S) { - # echo "backpath '$F' = none needed" - return @OUT; - } else { - # print "backpath '$F' -> '$S'$n"; - my @hrefs = (); - for (source($SITEFILE)) { - /href=\"[^\"]*\"/ or next; - s/.*href=\"//; s/\".*//; chomp; - if (/^ *$/ || /^\// || /^[.][.]/ || /^[\w]*:/) { next; } - push @hrefs, $_; - } - for (source($SOURCEFILE)) { - /href=\"[^\"]*\"/ or next; - s/.*href=\"//; s/\".*//; chomp; - if (/^ *$/ || /^\// || /^[.][.]/ || /^[\w]*:/) { next; } - push @hrefs, $_; - } - my $ref = ""; - for (sort(@hrefs)) { - next if /\$/; # some href="${...}" is problematic - next if $ref eq $_; $ref = $_; # uniq - push @OUT, "s|href=\\\"$ref\\\"|href=\\\"$S$ref\\\"|;"; - } - return @OUT; - } + return @OUT if $S !~ /^\.\./; + push @OUT, "s|(<[^<>]*\\shref=\\\")(\\w[^<>:]*\\\"[^<>]*>)|\$1$S\$2|g;"; + push @OUT, "s|(<[^<>]*\\ssrc=\\\")(\\w[^<>:]*\\\"[^<>]*>)|\$1$S\$2|g;"; + return @OUT; } -# ============================================================== SITE MAP INFO +# ============================================================== 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. @@ -1080,68 +1043,68 @@ sub make_fast # experimental - make a FAST file that can be applied sub site_map_list_title # $file $text { my ($U,$V,$Z) = @_; chomp($U); - push @MK_INFO, "=list=$U ".trimm($V); + push @MK_DATA, "<$Q='list'>$U ".trimm($V)."<$QX>"; } sub info_map_list_title # $file $text { my ($U,$V,$Z) = @_; chomp($U); - push @{$INFO{$U}}, "=list=".trimm($V); + push @{$DATA{$U}}, "<$Q='list'>".trimm($V)."<$QX>"; } sub site_map_long_title # $file $text { my ($U,$V,$Z) = @_; chomp($U); - push @MK_INFO, "=long=$U ".trimm($V); + push @MK_DATA, "<$Q='long'>$U ".trimm($V)."<$QX>"; } sub info_map_long_title # $file $text { my ($U,$V,$Z) = @_; chomp($U); - push @{$INFO{$U}}, "=long=".trimm($V); + push @{$DATA{$U}}, "<$Q='long'>".trimm($V)."<$QX>"; } sub site_map_list_date # $file $text { my ($U,$V,$Z) = @_; chomp($U); - push @MK_INFO, "=date=$U ".trimm($V); + push @MK_DATA, "<$Q='date'>$U ".trimm($V)."<$QX>"; } sub info_map_list_date # $file $text { my ($U,$V,$Z) = @_; chomp($U); - push @{$INFO{$U}}, "=date=".trimm($V); + push @{$DATA{$U}}, "<$Q='date'>".trimm($V)."<$QX>"; } sub site_get_list_title { my ($U,$V,$Z) = @_; - for (@MK_INFO) { if (m|^=list=$U (.*)|) { return $1; } } return ""; + for (@MK_DATA) { if (m|^<$Q='list'>$U (.*)<$QX>|) { return $1; } } return ""; } sub site_get_long_title { my ($U,$V,$Z) = @_; - for (@MK_INFO) { if (m|^=long=$U (.*)|) { return $1; } } return ""; + for (@MK_DATA) { if (m|^<$Q='long'>$U (.*)<$QX>|) { return $1; } } return ""; } sub site_get_list_date { my ($U,$V,$Z) = @_; - for (@MK_INFO) { if (m|^=date=$U (.*)|) { return $1; } } return ""; + for (@MK_DATA) { if (m|^<$Q='date'>$U (.*)<$QX>|) { return $1; } } return ""; } sub siteinfo2sitemap# generate addon sed scriptlet { # the resulting script will act on each item/line # containing and expand any following # reference of or or - my ($INP,$Z) = @_ ; $INP= \@MK_INFO if not $INP; + my ($INP,$Z) = @_ ; $INP= \@MK_DATA if not $INP; my @OUT = (); my $_list_= - sub{"s|.*|\$\&$2|"}; + sub{"s|(.*)]*>.*|\$1$2|"}; my $_date_= - sub{"s|.*|\$\&$2|"}; + sub{"s|(.*).*|\$1$2|"}; my $_long_= - sub{"s|.*|\$\&$2|"}; + sub{"s|(.*).*|\$1$2|"}; for (@$INP) { my $info = $_; - $info =~ s:=list=([^ ]*) (.*):&$_list_:e; - $info =~ s:=date=([^ ]*) (.*):&$_date_:e; - $info =~ s:=long=([^ ]*) (.*):&$_long_:e; + $info =~ s:<$Q='list'>([^ ]*) (.*)<$QX>:&$_list_:e; + $info =~ s:<$Q='date'>([^ ]*) (.*)<$QX>:&$_date_:e; + $info =~ s:<$Q='long'>([^ ]*) (.*)<$QX>:&$_long_:e; $info =~ /^s\|/ || next; push @OUT, $info; } @@ -1150,25 +1113,30 @@ sub siteinfo2sitemap# generate addon sed scriptlet sub make_multisitemap { # each category gets its own column along with the usual entries - my ($INPUTS,$Z)= @_ ; $INPUTS=\@MK_INFO if not $INPUTS; + my ($INPUTS,$Z)= @_ ; $INPUTS=\@MK_DATA if not $INPUTS; @MK_SITE = &siteinfo2sitemap(); # have addon-sed my @OUT = (); - my $_form_= sub{"" - ."
" }; + my $_form_= sub{"$3" + ."
$3......" }; my $_tiny_="small> ".$n; - for (grep {/=[u]se.=/} @$INPUTS) { + for (grep {/<$Q='[Uu]se.'>/} @$INPUTS) { my $x = $_; - $x =~ s|=[u]se(.)=([^ ]*) .*|&$_form_|e; - $x = &eval_MK_LIST($x, @MK_SITE); $x =~ /\w\w\w\w*:/ and next; # name: http: ftp: mailto: ... + $x =~ s|<$Q='[Uu]se(.)'>([^ ]*) (.*)<$QX>|&$_form_|e; + $x = &eval_MK_LIST("multisitemap", $x, @MK_SITE); + $x =~ /||; $x =~ s|||; $x =~ s||
|; $x =~ s||
|; $x =~ s// /g; - $x =~ s|||; $x =~ s|||; $x =~ s|
||; - $x =~ s|| |; $x =~ s||
|; + $x =~ s|||; + $x =~ s||
|; + $x =~ s|||; + $x =~ s|||; + chomp $x; push @OUT, $x.$n; } push @OUT, "".$n; @@ -1177,31 +1145,36 @@ sub make_multisitemap sub make_listsitemap { # traditional - the body contains a list with date and title extras - my ($INPUTS,$Z)= @_ ; $INPUTS=\@MK_INFO if not $INPUTS; + my ($INPUTS,$Z)= @_ ; $INPUTS=\@MK_DATA if not $INPUTS; @MK_SITE = &siteinfo2sitemap(); # have addon-sed my @OUT = (); my $_form_=sub{ - ""}; + "$3......$3"}; my $_tabb_="\ \;"; push @OUT, "".$n; my $xx; - for $xx (grep {/=[u]se.=/} @$INPUTS) { + for $xx (grep {/<$Q='[Uu]se.'>/} @$INPUTS) { my $x = "".$xx; - $x =~ s|=[u]se(.)=([^ ]*) .*|&$_form_|e; - $x = &eval_MK_LIST($x, @MK_SITE); $x =~ /\w\w\w\w*:/ and next; + $x =~ s|<$Q='[Uu]se(.)'>([^ ]*) (.*)<$QX>|&$_form_|e; + $x = &eval_MK_LIST("listsitemap", $x, @MK_SITE); + $x =~ /||; $x =~ s|||; $x =~ s|||; - $x =~ // and $x =~ s|]*>|$&- |; + $x =~ // and $x =~ s|(]*>)|$1- |; $x =~ s|| |g; $x =~ s||$_tabb_|; - $x =~ s||$_tabb_|; - $x =~ s|||; - push @OUT, $x; - } - for $xx (grep {/=[u]se.=/} @$INPUTS) { - my $x = $xx; $x =~ s/=[u]se.=name:sitemap://; $x =~ s:\s*::gs; + $x =~ s||$_tabb_|; + $x =~ s|||; + push @OUT, $x.$n; + } + for $xx (grep {/<$Q='[u]se.'>/} @$INPUTS) { + my $x = $xx; + $x =~ s/<$Q='[u]se.'>name:sitemap://; $x =~ s|<$QX>||; $x =~ s:\s*::gs; if (-f $x) { for (grep {//} source($x)) { push @OUT, $_; @@ -1212,6 +1185,32 @@ sub make_listsitemap return @OUT; } +my $_xi_include_= + " addon-sed + my @OUT = (); + my $_form_=sub{"$3"}; + my $xx; + for $xx (grep {/<$Q='[Uu]se.'>/} @$INPUTS) { + my $x = "".$xx; + $x =~ />\w\w\w\w*:/ and next; + $x =~ s|<$Q='[Uu]se(.)'>([^ ]*) (.*)<$QX>|&$_form_|e; + $x = &eval_MK_LIST("listsitemap", $x, @MK_SITE); + $x =~ /.*| />|; + push @OUT, $x.$n; + } + return @OUT; +} + sub print_extension { my ($ARG,$Z)= @_ ; $ARG=$o{print} if not $ARG; @@ -1221,15 +1220,32 @@ sub print_extension return ".print"; } } - + +sub from_sourcefile +{ + my ($U,$Z) = @_; + if (-f $U) { + return $U; + } elsif (-f "$o{src_dir}/$U") { + return "$o{src_dir}/$U"; + } else { + return $U; + } +} + sub html_sourcefile # generally just cut away the trailing "l" (ell) -{ # making "page.html" argument into "page.htm" return +{ # making "page.html" argument into "page.htm" return my ($U,$Z) = @_; my $_SRCFILE_=$U; $_SRCFILE_ =~ s/l$//; + my $_XMLFILE_=$U; $_XMLFILE_ =~ s/\.html$/.dbk/; if (-f $_SRCFILE_) { return $_SRCFILE_; + } elsif (-f $_XMLFILE_) { + return $_XMLFILE_; } elsif (-f "$o{src_dir}/$_SRCFILE_") { return "$o{src_dir}/$_SRCFILE_"; + } elsif (-f "$o{src_dir}/$_XMLFILE_") { + return "$o{src_dir}/$_XMLFILE_"; } else { return ".//$_SRCFILE_"; } @@ -1355,11 +1371,11 @@ sub make_subpage_entry sub make_printsitefile { # building the printsitefile looks big but its really a loop over sects - my ($INPUTS,$Z) = @_; $INPUTS=\@MK_INFO if not $INPUTS; + my ($INPUTS,$Z) = @_; $INPUTS=\@MK_DATA if not $INPUTS; @MK_SITE = &siteinfo2sitemap(); # have addon-sed - savelist(\@MK_SITE); - my @OUT = &make_printsitefile_head ($SITEFILE); + savelist(\@MK_SITE,"SITE"); + my @OUT = &make_printsitefile_head ($SITEFILE); my $sep=" - " ; my $_sect1= "$printsitefile_img_1 ||$sep"; @@ -1428,6 +1444,7 @@ sub make_printsitefile } # "$r" push @OUT, ""; push @OUT, ""; + savelist(\@OUT,"FORM"); return @OUT; } @@ -1441,7 +1458,6 @@ sub select_in_printsitefile # arg = "page" : return to stdout >> $P.$HEAD push @OUT, "s/^//;"; # sect3 push @OUT, "s/^//;"; # children $_selected_=&site_get_parentpage($_selected_); - if ($F =~ /testscript/) { print "($F)parent=$_selected_$n"; } $_section_=&sed_slash_key($_selected_); push @OUT, "s/^//;"; # sect2 $_selected_=&site_get_parentpage($_selected_); @@ -1465,6 +1481,420 @@ sub body_for_emailfooter ."$n"; } +# =================================================================== CSS +# There was another project to support sitemap build from xml files. +# The source format was using .dbk+xml with embedded references to .css +# files for visual preview in a browser. An docbook xml file with semantic +# outlines is far better suited for quality documentation than any html +# source. It happens that the xml/css support in browsers is still not +# very portable - especially embedded css style blocks are a nightmare. +# Instead we (a) grab all non-html xml markup tags (b) grab all referenced +# css stylesheets (c) cut out css defs from [b] that are known by [a] and +# (d) append those to the +#
exe +#
+ +sub css_sourcefile +{ + my ($X,$XXX) = @_; + return $X if -f $X; + return "$o{src_dir}/$X" if -f "$o{src_dir}/$X"; + return "$X" if "$X" =~ m:^/:; + return "./$X"; +} + +my %XMLTAGS = (); +sub css_xmltags # $SOURCEFILE +{ + my $X=$SOURCEFILE; + my %R = (); + my $line; + foreach $line (source($SOURCEFILE)) { + $line =~ s|>[^<>]*<|><|g; + $line =~ s|^[^<>]*<|<|; + $line =~ s|>[^<>]*\$|>|; + my $item; + foreach $item (split /| and next; + $item =~ s|>.*||; + chomp $item; + $R{$item} = ""; + } + } + @{$XMLTAGS{$X}} = keys %R; +} + +my %XMLSTYLESHEETS = (); +sub css_xmlstyles # $SOURCEFILE +{ + my $X=$SOURCEFILE; + my %R = (); + my $text = ""; + my $line = ""; + foreach $line (source($SOURCEFILE)) { + $text .= $line; + $text =~ s|) + { + $text .= $line; + if ($text =~ /^[^\{]*\}/s) { $text = ""; next; } + if ($text !~ /^[^\{]*\{.*\}/s) { next; } + $text =~ s|\r||g; + my $xmltag; my $found = 0; + foreach $xmltag (grep /^\w/, @{$XMLTAGS{$X}}) { + $xmltag =~ s| .*||; + if (grep {$_ eq $xmltag} qw/title section/) { + next if $xmltag eq "section"; + $found++ if $text =~ + /\b$xmltag\s*(?:,[^{},]*)*\s*\{/s; + my $xmlparent; + foreach $xmlparent (@{$XMLTAGS{$X}}) { + $xmlparent =~ s| .*||; + /^\w/ or next; + $found++ if $text =~ + /\b$xmlparent\s+$xmltag\s*(?:,[^{},]*)*\s*\{/s; + } + } else { + $found++ if $text =~ + /\b$xmltag\s*(?:,[^\{\},]*)*\{/s; + } + last if $found; + } + if (not $found) { $text = ""; next; } + foreach $xmltag (grep /^\w/, @{$XMLTAGS{$X}}) { + $xmltag =~ s| .*||; + if (grep {$_ eq $xmltag} @HTMLTAGS) { next; } + if (grep {$_ eq $xmltag} @HTMLTAGS2) { next; } + $text =~ s/(\b$xmltag\s*(?:,[^{},]*)*\s*\{)/.$1/gs; + } + chomp $text; + push @R, $text; $text = ""; next; + } + } else { + warn "$xmlstylesheet : ERROR, no such stylesheet $xmlstylesheet"; + } + } + @{$XMLTAGSCSS{$X}} = @R; +} + +my %XMLMAPPING = (); +sub css_xmlmapping # $SOURCEFILE +{ + my $X=$SOURCEFILE; + my %R = (); + foreach (@{$XMLTAGSCSS{$X}}) { + my $span = ""; + $span="li" if /\bdisplay\s*:\s*list-item\b/; + $span="caption" if /\bdisplay\s*:\s*table-caption\b/; + $span="td" if /\bdisplay\s*:\s*table-cell\b/; + $span="tr" if /\bdisplay\s*:\s*table-row\b/; + $span="table" if /\bdisplay\s*:\s*table\b/; + $span="div" if /\bdisplay\s*:\s*block\b/; + $span="span" if /\bdisplay\s*:\s*inline\b/; + $span="small" if /\bdisplay\s*:\s*none\b/; + $span="ul" if /\blist-style-type\s*:\s*disc\b/ and $span eq "div"; + $span="ol" if /\blist-style-type\s*:\s*decimal\b/ and $span eq "div"; + $span="tt" if /\bfont-family\s*:\s*monospace\b/ and $span eq "span"; + $span="em" if /\bfont-style\s*:\s*italic\b/ and $span eq "span"; + $span="b" if /\bfont-weight\s*:\s*bold\b/ and $span eq "span"; + $span="pre" if /\bwhite-space\s*:\s*pre\b/ and $span eq "div"; + my $xmltag; + for $xmltag (grep /^\w/, @{$XMLTAGS{$X}}) { + $xmltag =~ s| .*||; + if (/\.$xmltag\b/s) { + $R{$xmltag} = $span; + $R{$xmltag} = "p" if $xmltag eq "para" and $span eq "div"; + $R{$xmltag} = "a" if $xmltag eq "ulink" and $span eq "span"; + } + } + } + %{$XMLMAPPING{$X}} = %R; +} + +sub css_scan # $SOURCEFILE +{ + css_xmltags (); + css_xmlstyles (); + css_xmltags_css (); + css_xmlmapping (); +} + +sub tags2span_sed # $SOURCEFILE > $++ +{ + my $X=$SOURCEFILE; + my $xmltag; + my @R = (); + push @R, "s|<[?]xml-stylesheet[^<>]*[?]>||"; + push @R, "s|]*>||"; + push @R, "s|]*>||g;"; + push @R, "s|]*>||g;"; + for $xmltag (grep /^\w/, @{$XMLTAGS{$X}}) { + $xmltag =~ s| .*||; + if (grep {$_ eq $xmltag} @HTMLTAGS) { next; } + if (grep {$_ eq $xmltag} @HTMLTAGS2) { next; } + my $span = $XMLMAPPING{$X}{$xmltag}; + $span = "span" if $span eq ""; + push @R, "s|<$xmltag([\\n\\t ][^<>]*)url=|<$span class=\"$xmltag\"\$1href=|g;"; + push @R, "s|<$xmltag([\\n\\t >])|<$span class=\"$xmltag\"\$1|g;"; + push @R, "s|])|]*href=[\'\"]${xmlstylesheet}[\'\"][^<>]*"; + push @R, "s|<[?]xml-stylesheet$H>||;"; + push @R, "s|]* rel=['\"]*stylesheet['\"]$H>||;"; + } + return @R; +} + +sub tags2meta_sed # $SOURCEFILE > $++ +{ + my @R = (); + push @R, " "; + @R = () if $#R < 3; + return @R; +} + +# ========================================================================== +# xml/docbook support is taking an dbk input file converting any html DBK +# syntax into pure docbook tagging. Each file is being given a docbook +# doctype so that an xml/docbook viewer can render it correctly - that +# is needed atleast since docbook files do not embed stylesheet infos. +# Most of the processing is related to remap html markup and some other +# shortcut markup into correct docbook markup. The result is NOT checked +# for being well-formed or even matching the docbook schema DTD at all. + +sub scan_xml_rootnode +{ + my ($INF,$XXX) = @_; + $INF = \@{$DATA{$F}} if not $INF; + for my $entry (source($SOURCEFILE)) { + my $line = $entry; next if $line !~ /<\w/; + $line =~ s/<(\w*).*/$1/s; + # print ":",$line,$n; + push @{$INF}, "$line"; + return; + } +} + +sub get_xml_rootnode +{ + my ($INF,$XXX) = @_; + $INF = \@{$DATA{$F}} if not $INF; + my $_file_ = sed_slash_key($F); + foreach my $entry (grep /^/, @{$INF}) { + my $line=$entry; $line =~ s|.*>||; + return $line; + } +} + +sub xml_sourcefile +{ + my ($X,$XXX) = @_; + my $XMLFILE=$X; $XMLFILE =~ s/\.xml$/.dbk/; + my $SRCFILE=$X; $SRCFILE =~ s/\.xml$/.htm/; + $XMLFILE="///" if $X eq $XMLFILE; + $SRCFILE="///" if $X eq $SRCFILE; + return $XMLFILE if -f $XMLFILE; + return $SRCFILE if -f $SRCFILE; + return "$o{src_dir}/$XMLFILE" if -f "$o{src_dir}/$XMLFILE"; + return "$o{src_dir}/$SRCFILE" if -f "$o{src_dir}/$SRCFILE"; + return ".//$XMLFILE"; # $++ (not found?) +} + +sub scan_xmlfile +{ + $SOURCEFILE= &xml_sourcefile($F); + hint "'$SOURCEFILE': scanning xml -> '$F'"; + scan_xml_rootnode(); + my $rootnode=&get_xml_rootnode(); $rootnode =~ s|^(h\d.*$)|$1 |; + hint "'$SOURCEFILE': rootnode ('$rootnode')"; +} + +sub make_xmlfile +{ + $SOURCEFILE= &xml_sourcefile($F); + my $X=$SOURCEFILE; + my $article= &get_xml_rootnode(); + $article="article" if $article eq ""; + my $text = ""; + $text .= '' + .$n; + for my $stylesheet (@{$XMLSTYLESHEETS{$X}}) { + $text .= "" + .$n; + } + for (source($SOURCEFILE)) { + s!<>!\ \;!g; + s!(&)(&)!${1}amp;${2}amp;!g; + s!(<[^<>]*)(width)(=)(\d+\%*)!$1$2$3\"$4\"!g; + s!(<[^<>]*)(cellpadding)(=)(\d+\%*)!$1$2$3\"$4\"!g; + s!(<[^<>]*)(border)(=)(\d+\%*)!$1$2$3\"$4\"!g; + s!<[?]xml-stylesheet[^<>]*>!!; + s!]* rel=[\'\"]*stylesheet[^<>]*>!!; + s!<[hH]\d! *)([^<>]*\w[^<>\r\n]*)$!$1$2!; + s!(.*)!$1!g; + s!(.*)!$1!g; + s!(
[^<>]*)(.*[^<>\n]*)$!$1$2!gx; + s!!!g; + s!!!g; + s!!!g; + s!!!g; + s!!!g; + s!!!g; + s!!!g; + s!!!g; + s!!!g; + s!!!g; + s!<(s|strike)>!!g; + s!!!g; + s!
!
!g; + s!
!!g; + s!

!!g; + s!<[pP]>!!g; + s!!!g; + s!<(pre|PRE)>!!g; + s!!!g; + s!]*)name=([^<>]*)/>!!g; + s!]*)name=([^<>]*)>!!g; + s!]*)href=!!!g; + s! remap=\"url\">[^<>]*! />!g; + s!<(/?)span(\s[^<>]*)?>!<${1}phrase${2}>!g; + s!]*)?>!!g; + s!]*)?>!!g; + s!<(/?)(sup)>!<${1}superscript>!g; + s!<(/?)(sub)>!<${1}subscript>!g; + s!(<)(li)(><)!${1}listitem${3}!g; + s!(>)!${1}listitem${3}!g; + s!(<)(li)(>)!${1}listitem${3}!g; + s!()!${1}listitem${3}!g; + s!(!${1}itemizedlist>!g; + s!(!${1}orderedlist>!g; + s!(!${1}variablelist>!g; + s!<(/?)DT>!<${1}dt>!g; + s!<(/?)DD>!<${1}dd>!g; + s!<(/?)DL>!<${1}dl>!g; + s!

!
!g; + s!
!
!g; + s!<(/?)dl>!<${1}variablelist>!g; + s!]*)>!!g; + s!]*)>!!g; + s!]*)>]*)>!>!g; + s!]*)>!!g; + s!]*)>!!g; + s!]*>
*
-
|; $x =~ s|||; $x =~ s||
|; + $x =~ s|||; + $x =~ s||
(]*>)!$1!; + s!(
)!$1!; + s!]*)>!!g; + s!]*)>!!g; + s!(]*)?>!${1}row${2}>!g; + s!(]*)?>!${1}entry${2}>!g; + s!(]*\swidth=\"100\%\")!$1 pgwide=\"1\"!g; + s!(]*\scols=\"2\">)() + !$1$2!gx; + s!(]*\s)width=(\"\d*\%*\")!${1}remap=${2}!g; + s!([\'\`]*)!$1!g; + s!([\'\`]*)!$1!g; + s!<(tt|code)>([\`\"\'])!$2!g; + s!<(tt|code)>([\`\"\'])!$2!g; + s!([\`\"\'])!$1!g; + s!([\`\"\'])!$1!g; + s!(!${1}constant>!g; + s!(!${1}literal>!g; + s!
!
!g; + s!
!\n!g; + $text .= $_; + } + open F, ">$F" or die "could not write $F: $!"; print F $text; close F; + echo "'$SOURCEFILE': ",&ls_s($SOURCEFILE)," >> ",&ls_s($F); +} + +sub make_xmlmaster +{ + $SOURCEFILE= &xml_sourcefile($F); + my $X=$SOURCEFILE; + my $article="section"; # book? chapter? + my $text = ""; + $text .= '' + .$n; + for my $stylesheet (@{$XMLSTYLESHEETS{$X}}) { + $text .= "" + .$n; + } + # $text .= "
..."; + $text .= "
Documentation$n"; + for (make_xmlsitemap()) { + $text .= $_; + } + $text .= "
$n"; + open F, ">$F" or die "could not write $F: $!"; print F $text; close F; + echo "'$SOURCEFILE': ",&ls_s($SOURCEFILE)," >*> ",&ls_s($F); +} + # ========================================================================== # # During processing we will create a series of intermediate files that @@ -1479,7 +1909,7 @@ sub body_for_emailfooter # we scan the SITEFILE for href references to be converted # - in the new variant we use a ".gets.tmp" sed script that SECTS # marks all interesting lines so they can be checked later -# with an sed anchor of (or ) +# with an sed anchor of sect="[$NN]" (or sect="[$AZ]") my $S="\\ \\;"; # S="[&]nbsp[;]" @@ -1490,13 +1920,13 @@ sub echo_HR_EM_PP { my ($U,$V,$W,$X,$Z) = @_; my @list = ( - "/^$U$V$W*$U$V$W*$V$W*$W*$U$V$W*$V$W*$W*$V$W*$W*$V$W*$W*$U$V*$V*$U$V*$V*$V*$V*$U*<>$U*$U<>*<>**$U*<>$U*$U<>*<>**$U<>$U$U<><>$U*<>$U*$U<>*<>**$U<>$U$U<><>", "$h1", ""); - push @MK_GETS, &echo_HR_EM_PP("
","", "$h1", ""); - push @MK_GETS, &echo_HR_EM_PP("
","", "$h1", ""); - push @MK_GETS, &echo_HR_PP ("
", , "$b1$b1", ""); - push @MK_GETS, &echo_HR_PP ("
", , "$b2$b2", ""); - push @MK_GETS, &echo_HR_PP ("
", , "$b3$b3", ""); - push @MK_GETS, &echo_br_PP ("
", , "$b2$b2", ""); - push @MK_GETS, &echo_br_PP ("
", , "$b3$b3", ""); - push @MK_GETS, &echo_br_EM_PP("
","" , "$q3" , ""); - push @MK_GETS, &echo_br_EM_PP("
","" , "$q3" , ""); - push @MK_GETS, &echo_br_EM_PP("
","" , "$q3" , ""); - push @MK_GETS, &echo_HR_PP ("
", , "$q3" , ""); - push @MK_GETS, &echo_sp_PP ( "$q3" , ""); - push @MK_GETS, &echo_sp_sp ( "$q3" , ""); + push @MK_GETS, &echo_HR_PP ("
", "$h1", "sect=\\\"1\\\""); + push @MK_GETS, &echo_HR_EM_PP("
","", "$h1", "sect=\\\"1\\\""); + push @MK_GETS, &echo_HR_EM_PP("
","", "$h1", "sect=\\\"1\\\""); + push @MK_GETS, &echo_HR_PP ("
", , "$b1$b1", "sect=\\\"1\\\""); + push @MK_GETS, &echo_HR_PP ("
", , "$b2$b2", "sect=\\\"2\\\""); + push @MK_GETS, &echo_HR_PP ("
", , "$b3$b3", "sect=\\\"3\\\""); + push @MK_GETS, &echo_br_PP ("
", , "$b2$b2", "sect=\\\"2\\\""); + push @MK_GETS, &echo_br_PP ("
", , "$b3$b3", "sect=\\\"3\\\""); + push @MK_GETS, &echo_br_EM_PP("
","" , "$q3" , "sect=\\\"3\\\""); + push @MK_GETS, &echo_br_EM_PP("
","" , "$q3" , "sect=\\\"3\\\""); + push @MK_GETS, &echo_br_EM_PP("
","" , "$q3" , "sect=\\\"3\\\""); + push @MK_GETS, &echo_HR_PP ("
", , "$q3" , "sect=\\\"3\\\""); + push @MK_GETS, &echo_br_PP ("", , "$b2" , "sect=\\\"2\\\""); + push @MK_GETS, &echo_sp_PP ( "$q3" , "sect=\\\"3\\\""); + push @MK_GETS, &echo_sp_SP ( "" , "sect=\\\"2\\\""); + push @MK_GETS, &echo_sp_sp ( "$q3" , "sect=\\\"9\\\""); + push @MK_GETS, &echo_sp_sp ("
", "sect=\\\"9\\\""); @MK_PUTS = map { my $x=$_; $x =~ s/(>)(\[)/$1 *$2/; $x } @MK_GETS; # the .puts.tmp variant is used to
some hrefs which # shall not be used otherwise for being generated - this is nice for # some quicklinks somewhere. The difference: a whitspace "
" } -my $_uses_= sub{"=use$1=$2 $3" }; my $_name_= sub{"=use$1=name:$2 $3" }; -my $_getW_=""; -my $_getX_="<[^<>]*>[^<>]*"; -my $_getY_="<[^<>]*>[^<>]*<[^<>]*>[^<>]*"; +my $_uses_= sub{"<$Q='use$1'>$2 $3<$QX>" }; +my $_name_= sub{"<$Q='use$1'>name:$2 $3<$QX>" }; sub make_sitemap_list { + my ($V,$Z) = @_; $V = $SITEFILE if not $V; # scan sitefile for references pages - store as "=use+=href+ anchortext" - for (source($SITEFILE)) { -# print join("$n;",@MK_GETS),$n; - $_ = &eval_MK_LIST($_, @MK_GETS); - /^/ or next; - s{^$_getX_
]*>(.*).*}{&$_uses_}e; - s{^$_getY_]*>(.*).*}{&$_uses_}e; - s{^$_getW_]*>(.*).*}{&$_name_}e; - s{^$_getX_]*>(.*).*}{&$_name_}e; - s{^$_getY_]*>(.*).*}{&$_name_}e; - /^=....=/ or next; - push @MK_INFO, $_; + for (source($V)) { + my $x = $_; + local $_ = &eval_MK_LIST("sitemap_list", $x, @MK_GETS); + /]*>(.*).*}{&$_uses_}e; + s{.*]*>(.*).*}{&$_name_}e; + s{.*]*>(.*)}{&$_name_}e; + /^<$Q=/ or next; + /^$2 $3<$QX>" }; +my $_Name_= sub{"<$Q='Use$1'>name:$2 $3<$QX>" }; + +sub make_subsitemap_list # file-to-scan +{ + my ($V,$W,$Z) = @_; $V = $SITEFILE if not $V; + # scan sitefile for references pages - store as "=use+=href+ anchortext" + for (source($V)) { + my $x = $_; + local $_ = &eval_MK_LIST("subsitemap_list", $x, @MK_GETS); + /]*>(.*).*}{&$_Uses_}e; + s{.*]*>(.*).*}{&$_Name_}e; + s{.*]*>(.*)}{&$_Name_}e; + /^<$Q=/ or next; + /^([^:./][^:./]*[./])|>$W$1|; + push @MK_DATA, $_; } } @@ -1628,16 +2102,18 @@ sub make_sitemap_sect # (A) each "use1" creates "=sect=href+ href1" for all following non-"use1" # (B) each "use1" creates "=node=href2 href1" for all following "use2" my $sect = ""; - for (grep {/=[u]se.=/} @MK_INFO) { - if (/=[u]se1=([^ ]*) .*/) { $sect = $1; } - my $x = $_; $x =~ s/=[u]se.=([^ ]*) .*/=sect=$1/; chomp $x; - push @MK_INFO, "$x $sect"; + for (grep {/<$Q='[u]se.'>/} @MK_DATA) { + if (/<$Q='[u]se1'>([^ ]*) .*/) { $sect = $1; } + my $x = $_; # chomp $x; + $x =~ s|<$Q='[u]se.'>([^ ]*) .*|<$Q='sect'>$1 $sect<$QX>|; + push @MK_DATA, $x; } - for (grep {/=[u]se.=/} @MK_INFO) { - if (/=[u]se1=([^ ]*) .*/) { $sect = $1; } - /=[u]se[13456789]=/ and next; - my $x = $_; $x =~ s/=[u]se.=([^ ]*) .*/=node=$1/; chomp $x; - push @MK_INFO, "$x $sect"; + for (grep {/<$Q='[u]se.'>/} @MK_DATA) { + if (/<$Q='[u]se1'>([^ ]*) .*/) { $sect = $1; } + /<$Q='[u]se[13456789]'>/ and next; + my $x = $_; # chomp $x; + $x =~ s|<$Q='[u]se.'>([^ ]*) .*|<$Q='node'>$1 $sect<$QX>|; + push @MK_DATA, $x; } } @@ -1646,31 +2122,34 @@ sub make_sitemap_page # scan used pages and store secondary group relation =page= and =node= # the parenting =node= for use3 is usually a use2 (or use1 if none there) my $sect = ""; - for (grep {/=[u]se.=/} @MK_INFO) { - if (/=[u]se1=([^ ]*) .*/) { $sect = $1; } - if (/=[u]se2=([^ ]*) .*/) { $sect = $1; } - /=[u]se[1]=/ and next; - my $x = $_; $x =~ s/=[u]se.=([^ ]*) .*/=page=$1/; chomp $x; - push @MK_INFO, "$x $sect"; - } - for (grep {/=[u]se.=/} @MK_INFO) { - if (/=[u]se1=([^ ]*) .*/) { $sect = $1; } - if (/=[u]se2=([^ ]*) .*/) { $sect = $1; } - /=[u]se[12456789]=/ and next; - my $x = $_; $x =~ s/=[u]se.=([^ ]*) .*/=node=$1/; chomp $x; - push @MK_INFO, "$x $sect"; print "(",$_,")","$x $sect", $n; + for (grep {/<$Q='[u]se.'>/} @MK_DATA) { + if (/<$Q='[u]se1'>([^ ]*) .*/) { $sect = $1; } + if (/<$Q='[u]se2'>([^ ]*) .*/) { $sect = $1; } + /<$Q='[u]se[1]'>/ and next; + my $x = $_; + $x =~ s|<$Q='[u]se.'>([^ ]*) .*|<$Q='page'>$1<$QX>|; chomp $x; + push @MK_DATA, "$x $sect"; + } + for (grep {/<$Q='[u]se.'>/} @MK_DATA) { + if (/<$Q='[u]se1'>([^ ]*) .*/) { $sect = $1; } + if (/<$Q='[u]se2'>([^ ]*) .*/) { $sect = $1; } + /<$Q='[u]se[12456789]'>/ and next; + my $x = $_; + $x =~ s/<$Q='[u]se.'>([^ ]*) .*/<$Q='node'>$1<$QX>/; chomp $x; + push @MK_DATA, "$x $sect"; ## print "(",$_,")","$x $sect", $n; } # and for the root sections we register ".." as the parenting group - for (grep {/=[u]se1=/} @MK_INFO) { - my $x = $_; $x =~ s/=[u]se.=([^ ]*) .*/=node=$1/; chomp $x; - push @MK_INFO, trimm("$x .."); + for (grep {/<$Q='[u]se1'>/} @MK_DATA) { + my $x = $_; $x = trimm($x); + $x =~ s/<$Q='[u]se.'>([^ ]*) .*/<$Q='node'>$1 ..<$QX>/; chomp $x; + push @MK_DATA, $x; } } sub echo_site_filelist { my @OUT = (); - for (grep {/=[u]se.=/} @MK_INFO) { - my $x = $_; $x =~ s/=[u]se.=//; $x =~ s/ .*[\n]*//; + for (grep {/<$Q='[u]se.'>/} @MK_DATA) { + my $x = $_; $x =~ s/<$Q='[u]se.'>//; $x =~ s/ .*[\n]*//; push @OUT, $x; } return @OUT; @@ -1686,6 +2165,7 @@ sub echo_site_filelist sub scan_sitefile # $F { $SOURCEFILE=&html_sourcefile($F); + hint "'$SOURCEFILE': scanning -> sitefile"; if ($SOURCEFILE ne $F) { dx_init "$F"; dx_text ("today", &timetoday()); @@ -1703,7 +2183,7 @@ sub scan_sitefile # $F if ($printerfriendly) { DX_text ("printerfriendly", fast_html_printerfile($F)); } if ($ENV{USER}) { DC_publisher ($ENV{USER}); } - print "'$SOURCEFILE': $short (sitemap)$n"; + echo "'$SOURCEFILE': $short (sitemap)"; site_map_list_title ($F, "$short"); site_map_long_title ($F, "generated sitemap index"); site_map_list_date ($F, &timetoday()); @@ -1714,9 +2194,9 @@ sub scan_htmlfile # "$F" { my ($FF,$Z) = @_; $SOURCEFILE=&html_sourcefile($F); # SCAN : - if ($SOURCEFILE ne $F) { # HTML : + hint "'$SOURCEFILE': scanning -> $F"; # HTML : + if ($SOURCEFILE ne $F) { if ( -f $SOURCEFILE) { - @{$FAST{$F}} = &make_fast ($F); dx_init "$F"; dx_text ("today", &timetoday()); dx_text ("todays", &timetodays()); @@ -1741,14 +2221,29 @@ sub scan_htmlfile # "$F" my $issue=&info_get_entry("issue"); &site_map_list_date ($F, "$edate"); &info_map_list_date ($F, "$edate"); - print "'$SOURCEFILE': '$title' ('$short') @ '$issue' ('$sectn')$n"; + css_scan(); + echo "'$SOURCEFILE': '$title' ('$short') @ '$issue' ('$sectn')"; }else { - print "'$SOURCEFILE': does not exist$n"; + echo "'$SOURCEFILE': does not exist"; site_map_list_title ($F, "$F"); site_map_long_title ($F, "$F (no source)"); } } else { - print "<$F> - skipped - ($SOURCEFILE)$n"; + echo "<$F> - skipped - ($SOURCEFILE)"; + } +} + +sub scan_subsitemap_long +{ + my ($V,$W,$ZZZ) = @_; + for (source($V)) { + my $x = $_; + if ($x =~ m|.*([^<>]*)|) { + &site_map_list_date($W.$1,$2); + } + if ($x =~ m|.*([^<>]*)|) { + &site_map_long_title($W.$1,$2); + } } } @@ -1764,7 +2259,14 @@ sub scan_namespec site_map_list_title ($F, "$short"); site_map_long_title ($F, "external sitemap index"); site_map_list_date ($F, &timetoday()); - print "'$F' external sitemap index$n"; + echo "'$F' external sitemap index"; + } + elsif ($F =~ /^name:(.*\.html*)$/) { # assuming it is a subsitefile + my $FF=$1; + my $FFF=$FF; $FFF =~ s:/[^/]*$:/:; # dirname + $FFF="" if $FFF !~ m:/:; + make_subsitemap_list($FF, $FFF); + scan_subsitemap_long($FF, $FFF); } } sub scan_httpspec @@ -1788,13 +2290,12 @@ sub skip_httpspec sub head_sed_sitemap # $filename $section { my ($U,$V,$Z) = @_; - my $FF=&sed_slash_key($U); + my $FF=&sed_piped_key($U); my $SECTION=&sed_slash_key($V); - my $SECTS="" ; - my $SECTN=""; # lines with hrefs + my $SECTS="sect=\"[$NN$AZ]\"" ; + my $SECTN="sect=\"[$NN]\""; # lines with hrefs my @OUT = (); - push @OUT, "/^$SECTS.*/ and s|||;"; - push @OUT, "/^$SECTS.*/ and s|.*)|\$1|;"; push @OUT, "/ href=\\\"$SECTION\\\"/ " ."and s|^/ and s|||;"; - push @OUT, "/^$SECTS.*/ and s|.*)|\$1|;"; push @OUT, "/ href=\\\"$SECTION\\\"/ " ."and s|^\)|\1|" + # build foreach an sed line "s|||" # after that all the (still) numeric SECTNs are deactivated / killed. for my $section ($SECTION, $headsection, $tailsection) { next if $section eq "no"; - for (grep {/^=sect=[^ ]* $section/} @MK_INFO) { + for (grep {/^<$Q='sect'>[^ ]* $section/} @MK_DATA) { + my $x = $_; + $x =~ s|<$Q='sect'>||; $x =~ s| .*||; # $filename + $x =~ s/(.*)/s|name:[^ ]* $section/} @MK_DATA) { my $x = $_; - $x =~ s, .*,\\\"\)|\$1|,; - $x =~ s,^=sect=,s|^$SECTS\(.*name:||; $x =~ s| .*||; # $filename + $x =~ s/(.*)/s|]*>).*||;"; - push @OUT, "/^$SECTS.*/ and s|||;"; - push @OUT, "/^$SECTS.*/ and s|]*)>.*||;"; + push @OUT, "s|.*]*)>.*||;"; + push @OUT, "s|(.*)|\$1|;"; push @OUT, "/ href=\\\"$SECTION\\\"/ " ."and s|^ vars substituted @MK_META = &info2meta_sed(); # add values - if ( $simplevars eq "warn") { - @MK_TEST = &info2test_sed(); # check vars old-style -## $SED_LONGSCRIPT ./$MK_TEST $SOURCEFILE | tee -a ./$MK_OLDS ; fi - } my @F_HEAD = (); my @F_FOOT = (); push @F_HEAD, @MK_PUTS; push @F_HEAD, &head_sed_sitemap ($F, &info_get_entry_section()); @@ -1870,18 +2372,18 @@ sub make_sitefile # "$F" } my $html = ""; # - $html .= &eval_MK_FILE($SITEFILE, @F_HEAD); + $html .= &eval_MK_FILE("SITE", $SITEFILE, @F_HEAD); $html .= join("", @F_FOOT); for (source($SITEFILE)) { /<\/body>/ or next; - $html .= &eval_MK_LIST($_, @MK_VARS); + $html .= &eval_MK_LIST("sitefile", $_, @MK_VARS); } open F, ">$F"; print F $html; close F; - print "'$SOURCEFILE': ",ls_s($SOURCEFILE)," >-> ",ls_s($F),"$n"; + echo "'$SOURCEFILE': ",ls_s($SOURCEFILE)," >-> ",ls_s($F); savesource("$F.~head~", \@F_HEAD); savesource("$F.~foot~", \@F_FOOT); } else { - print "'$SOURCEFILE': does not exist$n"; + echo "'$SOURCEFILE': does not exist"; } } } @@ -1891,15 +2393,13 @@ sub make_htmlfile # "$F" if ("$SOURCEFILE" ne "$F") { if (-f "$SOURCEFILE") { if (grep {/ vars substituted @MK_META = &info2meta_sed(); # add values - if ( $simplevars eq "warn") { - @MK_TEST = &info2test_sed(); # check vars old-style -## $SED_LONGSCRIPT ./$MK_TEST $SOURCEFILE | tee -a ./$MK_OLDS ; fi - } + @MK_SPAN = &tags2span_sed(); # extern text/css -> intern css classes + push @MK_META, &tags2meta_sed(); # extern text/css -> intern css classes my @F_HEAD = (); my @F_BODY = (); my $F_FOOT = ""; push @F_HEAD, @MK_PUTS; if ( $sectionlayout eq "multi") { @@ -1907,36 +2407,35 @@ sub make_htmlfile # "$F" } else { push @F_HEAD, &head_sed_listsection ($F, &info_get_entry_section()); } - push @F_HEAD, @MK_VARS; push @F_HEAD, @MK_TAGS; #tag and vars + push @F_HEAD, @MK_VARS; push @F_HEAD, @MK_TAGS; push @F_HEAD, @MK_SPAN; push @F_HEAD, "/<\\/body>/ and next;"; #cut lastline push @F_HEAD, "// and $sed_add join(\"\\n\",\@MK_META);"; #add metatags push @F_BODY, "// and next;"; #not that line - push @F_BODY, @MK_VARS; push @F_BODY, @MK_TAGS; #tag and vars + push @F_BODY, @MK_VARS; push @F_BODY, @MK_TAGS; push @F_BODY, @MK_SPAN; push @F_BODY, &bodymaker_for_sectioninfo(); #if sectioninfo push @F_BODY, &info2body_sed(); #cut early push @F_HEAD, &info2head_sed(); - push @F_HEAD, @{$FAST{$F}}; + push @F_HEAD, &make_back_path($F); if ($emailfooter ne "no") { $F_FOOT = &body_for_emailfooter(); } my $html = ""; - $html .= eval_MK_FILE($SITEFILE, @F_HEAD); - $html .= eval_MK_FILE($SOURCEFILE, @F_BODY); + $html .= eval_MK_FILE("head", $SITEFILE, @F_HEAD); + $html .= eval_MK_FILE("body", $SOURCEFILE, @F_BODY); $html .= $F_FOOT; for (source($SITEFILE)) { /<\/body>/ or next; - $_ = &eval_MK_LIST($_, @MK_VARS); + $_ = &eval_MK_LIST("htmlfile", $_, @MK_VARS); $html .= $_; } - savelist(\@{$INFO{$F}}); - open F, ">$F" or die "could not write $F: $!"; print F $html; close F; - print "'$SOURCEFILE': ",&ls_s($SOURCEFILE)," -> ",&ls_s($F),"$n"; + open F, ">$F" or die "could not write $F: $!"; print F $html; close F; + echo "'$SOURCEFILE': ",&ls_s($SOURCEFILE)," -> ",&ls_s($F); savesource("$F.~head~", \@F_HEAD); savesource("$F.~body~", \@F_BODY); } else { - print "'$SOURCEFILE': does not exist$n"; + echo "'$SOURCEFILE': does not exist"; }} else { - print "<$F> - skipped$n"; + echo "<$F> - skipped"; } } @@ -1944,46 +2443,43 @@ my $PRINTSITEFILE; sub make_printerfriendly # "$F" { # PRINTER my $printsitefile="0"; # FRIENDLY - my @F_FAST = (); my $BODY_TXT; my $BODY_SED; + my $BODY_TXT; my $BODY_SED; my $P=&html_printerfile ($F); my @P_HEAD = (); my @P_BODY = (); if ("$F" =~ /^(${SITEFILE}|${SITEFILE}l)$/) { - @F_FAST = &make_fast ("$F"); $printsitefile=">=>" ; $BODY_TXT="$F.~foot~" ; } elsif ("$F" =~ /^(.*[.]html)$/) { $printsitefile="=>" ; $BODY_TXT="$SOURCEFILE"; } if (grep {/<meta name="formatter"/} source($BODY_TXT)) { return; } - if ($printsitefile ne "0" and -f $SOURCEFILE) { + if ($printsitefile ne "0" and -f $SOURCEFILE) { my $x; @MK_FAST = &make_printerfile_fast (\@FILELIST); push @P_HEAD, @MK_VARS; push @P_HEAD, @MK_TAGS; push @P_HEAD, @MK_FAST; - @MK_METT = map { my $x = $_; $x =~ + @MK_METT = map { $x = $_; $x =~ /DC.relation.isFormatOf/ and $x =~ s|content=\"[^\"]*\"|content=\"$F\"| ; $x } @MK_META; push @P_HEAD, "/<head>/ and $sed_add join(\"\\n\", \@MK_METT);"; push @P_HEAD, "/<\\/body>/ and next;"; push @P_HEAD, &select_in_printsitefile ("$F"); my $_ext_=&print_extension($printerfriendly); - push @P_HEAD, map { my $x=$_; $x =~ s/[.]html\"|/$_ext_$&/g; $x} @F_FAST; # my $line_=&sed_slash_key($printsitefile_img_2); push @P_HEAD, "/\\|\\|topics:/" ." and s| href=\\\"\\#\\.\\\"| href=\\\"$F\\\"|;"; push @P_HEAD, "/\\|\\|\\|pages:/" ." and s| href=\\\"\\#\\.\\\"| href=\\\"$F\\\"|;"; - push @P_HEAD, @F_FAST; + push @P_HEAD, &make_back_path("$F"); push @P_BODY, @MK_VARS; push @P_BODY, @MK_TAGS; push @P_BODY, @MK_FAST; - push @P_BODY, map { my $x=$_; $x =~ s/[.]html\"|/$_ext_$&/g; $x} @F_FAST; - push @P_BODY, @F_FAST; + push @P_BODY, &make_back_path("$F"); my $html = ""; - $html .= eval_MK_FILE($PRINTSITEFILE, @P_HEAD); - $html .= eval_MK_FILE($BODY_TXT, @P_BODY); + $html .= eval_MK_FILE("p_head", $PRINTSITEFILE, @P_HEAD); + $html .= eval_MK_FILE("p_body", $BODY_TXT, @P_BODY); for (source($PRINTSITEFILE)) { /<\/body>/ or next; - $_ = &eval_MK_LIST($_, @MK_VARS); + $_ = &eval_MK_LIST("printerfriendly", $_, @MK_VARS); $html .= $_; } open P, ">$P" or die "could not write $P: $!"; print P $html; close P; - print "'$SOURCEFILE': ",ls_s($SOURCEFILE)," $printsitefile ",ls_s($P),"$n"; + echo "'$SOURCEFILE': ",ls_s($SOURCEFILE)," $printsitefile ",ls_s($P); } } @@ -1995,45 +2491,53 @@ sub make_printerfriendly # "$F" # #### 0. INIT $F=$SITEFILE; &make_sitemap_init(); -&make_sitemap_list(); +&make_sitemap_list($SITEFILE); &make_sitemap_sect(); &make_sitemap_page(); -savelist(\@MK_INFO); +savelist(\@MK_DATA, "DATA"); @FILELIST=&echo_site_filelist(); if ($o{filelist} or $o{list} eq "file" or $o{list} eq "files") { - for (@FILELIST) { print $_,"$n"; } exit; # --filelist + for (@FILELIST) { echo $_; } exit; # --filelist } if ($o{files}) { @FILELIST=split(/ /, $o{files}); } # --files -if ($#FILELIST < 0) { print STDERR "nothing to do$n"; } +if ($#FILELIST < 0) { warns "nothing to do (no --filelist)"; } if ($#FILELIST == 0 and - $FILELIST[0] eq $SITEFILE) { print STDERR "only '$SITEFILE'!?$n"; } + $FILELIST[0] eq $SITEFILE) { warns "only '$SITEFILE'?!"; } for (@FILELIST) { #### 1. PASS $F = $_; if (/^(name:.*)$/) { &scan_namespec ("$F"); - } elsif (/^(http:.*|.*:\/\/.*)$/) { + } elsif (/^(http:|https:|ftp:|mailto:|telnet:|news:|gopher:|wais:)/) { &scan_httpspec ("$F"); } elsif (/^(${SITEFILE}|${SITEFILE}l)$/) { &scan_sitefile ("$F") ;; # ........... SCAN SITE + } elsif (/^(.*\@.*\.de)$/) { + echo "!! -> '$F' (skipping malformed mailto:-link)"; } elsif (/^(\.\.\/.*)$/) { - print "!! -> '$F' (skipping topdir build)$n"; + echo "!! -> '$F' (skipping topdir build)"; # */*.html) -# make_fast # try for later subdir build +# make_back_path # try for later subdir build # echo "!! -> '$F' (skipping subdir build)" # ;; # */*/*/|*/*/|*/|*/index.htm|*/index.html) # echo "!! -> '$F' (skipping subdir index.html)" # ;; } elsif (/^(.*\.html)$/) { - &scan_htmlfile ("$F") ;; # ........... SCAN HTML + &scan_htmlfile ("$F"); # ........... SCAN HTML + if ($o{xml}) { + $F =~ s/\.html$/.xml/; + &scan_xmlfile ("$F"); + } + } elsif (/^(.*\.xml)$/) { + &scan_xmlfile ("$F") ;; } elsif (/^(.*\/)$/) { - print "'$F' : directory - skipped$n"; + echo "'$F' : directory - skipped"; &site_map_list_title ("$F", &sed_slash_key($F)); &site_map_long_title ("$F", "(directory)"); } else { - print "?? -> '$F'$n"; + echo "?? -> '$F'"; } } @@ -2042,9 +2546,9 @@ if ($printerfriendly) { # .......... PRINT VERSION $PRINTSITEFILE=$SITEFILE; $PRINTSITEFILE =~ s/(\.\w*)$/$_ext_$1/; $F=$PRINTSITEFILE; my @TEXT = &make_printsitefile(); - print "NOTE: going to create printer-friendly sitefile '$PRINTSITEFILE'" - ." $F._$i$n"; - savelist(\@TEXT); + echo "NOTE: going to create printer-friendly sitefile '$PRINTSITEFILE'" + ." $F._$i"; + savelist(\@TEXT, "TEXT"); my @LINES = map { chomp; $_."$n" } @TEXT; savesource($PRINTSITEFILE, \@LINES); if (1) { @@ -2054,21 +2558,23 @@ if ($printerfriendly) { # .......... PRINT VERSION } } -if ($simplevars eq " ") { - @MK_OLDS = (); -} - for (@FILELIST) { #### 2. PASS $F = $_; if (/^(name:.*)$/) { &skip_namespec ("$F") ;; - } elsif (/^(http:.*|.*:\/\/.*)$/) { + } elsif (/^(http:|https:|ftp:|mailto:|telnet:|news:|gopher:|wais:)/) { &skip_httpspec ("$F") ;; } elsif (/^(${SITEFILE}|${SITEFILE}l)$/) { &make_sitefile ("$F") ;; # ........ SITE FILE &make_printerfriendly ("$F") if ($printerfriendly); + if ($o{xml}) { + $F =~ s/\.html$/.xml/; + &make_xmlmaster ("$F"); + } + } elsif (/^(.*\@.*\.de)$/) { + echo "!! -> '$F' (skipping malformed mailto:-link)"; } elsif (/^(\.\.\/.*)$/) { - print "!! -> '$F' (skipping topdir build)$n"; + echo "!! -> '$F' (skipping topdir build)"; # */*.html) # echo "!! -> '$F' (skipping subdir build)" # ;; @@ -2076,39 +2582,53 @@ for (@FILELIST) { #### 2. PASS # echo "!! -> '$F' (skipping subdir index.html)" # ;; } elsif (/^(.*\.html)$/) { - &make_htmlfile ("$F") ;; # .................. HTML FILES + &make_htmlfile ("$F") ; # .................. HTML FILES &make_printerfriendly ("$F") if ($printerfriendly); + if ($o{xml}) { + $F =~ s/\.html$/.xml/; + &make_xmlfile ("$F"); + } + } elsif (/^(.*\.xml)$/) { + &make_xmlfile ("$F") ;; } elsif (/^(.*\/)$/) { - print "'$F' : directory - skipped$n"; + echo "'$F' : directory - skipped"; } else { - print "?? -> '$F'$n"; + echo "?? -> '$F'"; } + # .............. debug .................... -## if test -d DEBUG && test -f "./$F" ; then -## cp ./$F.$INFO DEBUG/$F.info.TMP -## for P in tags vars meta page date list html sect info ; do -## test -f ./$MK.$P.tmp && cp ./$MK.$P.tmp DEBUG/$F.$P.tmp -## test -f ./$MK.$P.TMP && cp ./$MK.$P.TMP DEBUG/$F.$P.TMP -## done -## fi + if (-d "DEBUG" and -f $F) { + my $INP = \@{$DATA{$F}}; + my $FFFF = $F; $FFFF =~ s,/,:,g; + if (open FFFF, ">DEBUG/$FFFF.data.tmp.ht") { + for (@{$INP}) { print FFFF $_,$n; } close FFFF; + } + if (open FFFF, ">DEBUG/$FFFF.tags.tmp.pl") { + print FFFF "# /usr/bin/env perl -p",$n; + for (@MK_TAGS) { print FFFF $_,$n; } close FFFF; + } + if (open FFFF, ">DEBUG/$FFFF.vars.tmp.pl") { + print FFFF "# /usr/bin/env perl -p",$n; + for (@MK_VARS) { print FFFF $_,$n; } close FFFF; + } + if (open FFFF, ">DEBUG/$FFFF.span.tmp.pl") { + print FFFF "# /usr/bin/env perl -p",$n; + for (@MK_SPAN) { print FFFF $_,$n; } close FFFF; + } + if (open FFFF, ">DEBUG/$FFFF.meta.tmp.ht") { + for (@MK_META) { print FFFF $_,$n; } close FFFF; + } + if (open FFFF, ">DEBUG/$FFFF.gets.tmp.ht") { + for (@MK_GETS) { print FFFF $_,$n; } close FFFF; + } + if (open FFFF, ">DEBUG/$FFFF.puts.tmp.ht") { + for (@MK_PUTS) { print FFFF $_,$n; } close FFFF; + } + if (open FFFF, ">DEBUG/$FFFF.fast.tmp.ht") { + for (@MK_FAST) { print FFFF $_,$n; } close FFFF; + } + } } # done -if ( $simplevars eq "warn") { - my $oldvars = $#MK_OLDS; $oldvars ++; - if (not $oldvars) { -print "HINT: you have no simplevars in your htm sources, so you may want to$n"; -print "hint: set the magic <!--mksite:nosimplevars--> in your $SITEFILE$n"; -print "hint: which makes execution _faster_ actually in the 2. pass$n"; -print "note: simplevars expansion was the oldstyle way of variable expansion$n"; -} else { -print "HINT: there were $oldvars simplevars found in your htm sources.$n"; -print "hint: This style of variable expansion will be disabled in the near$n"; -print "hint: future. If you do not want change then add the $SITEFILE magic$n"; -print "hint: <!--mksite:simplevars--> somewhere to suppress this warning$n"; -print "note: simplevars expansion will be an explicit option in the future.$n"; -print "note: errornous simplevar detection can be suppressed with a magic$n"; -print "note: hint of <!--mksite:nosimplevars--> in the $SITEFILE for now.$n"; -} } - -## rm ./$MK.*.tmp +## rm ./$MK.*.tmp.* if not $o{keeptmpfiles} exit 0 diff --git a/docs/mksite.sh b/docs/mksite.sh index 2c5a786..12af794 100644 --- a/docs/mksite.sh +++ b/docs/mksite.sh @@ -6,7 +6,7 @@ # 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 Draheim <guidod@gmx.de> +# 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. @@ -20,7 +20,7 @@ # 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.4 2005-05-14 15:08:23 guidod Exp $ +# $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 @@ -41,16 +41,17 @@ 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 -INFO="~~" # extension for meta data files +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) -FAST="~move~" # extension for printer friendly 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 @@ -58,20 +59,86 @@ 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 -if $SED -V 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 -elif uname -s | $GREP HP-UX >$NULL ; then -SED_LONGSCRIPT="sed_longscript" # due to 100 sed lines limit -fi +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" @@ -89,31 +156,32 @@ do if test ".$opt" != "." ; then -*=*) opt=`echo "$arg" | $SED -e "s/-*\\([$AA][$AA-]*\\).*/\\1/" -e y/-/_/` if test ".$opt" = "." ; then - echo "ERROR: invalid option $arg" >&2 + 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 - echo "ERROR: invalid option $arg" >&2 + 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 - echo "ERROR: invalid option $arg" >&2 + error "invalid option $arg" else arg=`echo "$arg" | $SED -e "s/^[^=]*=//"` eval "export opt_$opt=' '" fi opt="" ;; - *) if test ".$opt_main_file" = "." ; then opt_main_file="$arg" ; else + *) $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="" ;; @@ -129,6 +197,8 @@ 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" @@ -147,14 +217,10 @@ if test ".$opt_help" != "." ; then fi if test ".$SITEFILE" = "." ; then - echo "error: no SITEFILE found (default would be 'site.htm')" + error "no SITEFILE found (default would be 'site.htm')" exit 1 else - echo "NOTE: sitefile: `ls -s $SITEFILE`" -fi - -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 + $hint "sitefile:" `ls -s $SITEFILE` fi tmp="." ; if test ".$opt_tmp_dir" != "." ; then tmp="$opt_tmp_dir" ; fi @@ -162,21 +228,21 @@ 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" -MK_VARS="$tmp/$MK.vars.tmp" -MK_META="$tmp/$MK.meta.tmp" -MK_METT="$tmp/$MK.mett.tmp" -MK_TEST="$tmp/$MK.test.tmp" -MK_FAST="$tmp/$MK.fast.tmp" -MK_GETS="$tmp/$MK.gets.tmp" -MK_PUTS="$tmp/$MK.puts.tmp" -MK_OLDS="$tmp/$MK.olds.tmp" -MK_SITE="$tmp/$MK.site.tmp" -MK_SECT1="$tmp/$MK.sect1.tmp" -MK_SECT2="$tmp/$MK.sect2.tmp" -MK_SECT3="$tmp/$MK.sect3.tmp" -MK_STYLE="$tmp/$MK.style.tmp" -MK_INFO="$tmp/$MK.$INFO" +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" # ======================================================================== # ======================================================================== @@ -186,11 +252,10 @@ MK_INFO="$tmp/$MK.$INFO" printerfriendly="" sectionlayout="list" sitemaplayout="list" -simplevars="warn" # <!--varname-->default attribvars=" " # <x ref="${varname:=default}"> updatevars=" " # <!--$varname:=-->default expandvars=" " # <!--$varname--> -commentvars=" " # $updatevars && $expandsvars && $simplevars +commentvars=" " # $updatevars && $expandsvars sectiontab=" " # highlight ^<td class=...>...href="$section" currenttab=" " # highlight ^<br>..<a href="$topic"> headsection="no" @@ -232,8 +297,6 @@ 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 simplevars` ; case "$x" in - " "|"no"|"warn") simplevars="$x" ;; esac x=`mksite_magic_option attribvars` ; case "$x" in " "|"no"|"warn") attribvars="$x" ;; esac x=`mksite_magic_option updatevars` ; case "$x" in @@ -256,20 +319,13 @@ x=`mksite_magic_option emailfooter` test ".$opt_print" != "." && printerfriendly="$opt_print" test ".$commentvars" = ".no" && updatevars="no" # duplicated into test ".$commentvars" = ".no" && expandvars="no" # info2vars_sed () -test ".$commentvars" = ".no" && simplevars="no" # function above - -test -d DEBUG && \ -echo "NOTE: '$sectionlayout'sectionlayout '$sitemaplayout'sitemaplayout" -test -d DEBUG && \ -echo "NOTE: '$simplevars'simplevars '$printerfriendly'printerfriendly" -test -d DEBUG && \ -echo "NOTE: '$attribvars'attribvars '$updatevars'updatevars" -test -d DEBUG && \ -echo "NOTE: '$expandvars'expandvars '$commentvars'commentvars " -test -d DEBUG && \ -echo "NOTE: '$currenttab'currenttab '$sectiontab'sectiontab" -test -d DEBUG && \ -echo "NOTE: '$headsection'headsection '$tailsection'tailsection" + + +$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 # ========================================================================== @@ -304,16 +360,21 @@ if test ! -d "$tmp" ; then mkpathdir "$tmp" ; tmp_dir_was_created="yes" ; fi # 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 P in P H1 H2 H3 H4 H5 H6 DL DD DT UL OL LI PRE CODE TABLE TR TD TH \ - B U I S Q EM STRONG STRIKE CITE BIG SMALL SUP SUB TT THEAD TBODY \ - CENTER HR BR NOBR WBR SPAN DIV IMG ADRESS BLOCKQUOTE -do M=`echo "$P" | $SED -e "y/$UPPER/$LOWER/"` +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|<->|<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 @@ -327,7 +388,8 @@ _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 - echo "s|<!--sect[$AZ$NN]-->||g" >> "$MK_TAGS" + 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" @@ -388,13 +450,18 @@ sed_longscript () -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 -e "s|[./[-]|\\\\&|g" -e "s|\\]|\\\\&|g" + 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 -e "s/[.|[-]/\\\\&/g" -e "s/\\]/\\\\&/g" + echo "$1" | sed_escape_key -e "s/|/\\\\&/g" } back_path () # helper to get the series of "../" for a given path @@ -407,47 +474,15 @@ dir_name () echo "$1" | $SED -e "s:/[^/][^/]*\$::" } -info2test_sed () # cut out all old-style <!--vars--> usages -{ - INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$INFO" - V8=" *\\([^ ][^ ]*\\) \\(.*\\)" - V9=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)" - q="\\\$" - _x_="WARNING: assumed simplevar <!--\\\\1--> changed to <!--$q\\\\1:=-->" - _y_="WARNING: assumed simplevar <!--\\\\1--> changed to <!--$q\\\\1:?-->" - _X_="WARNING: assumed tailvar <!--$q\\\\1:--> changed to <!--$q\\\\1:=-->" - _Y_="WARNING: assumed tailvar <!--$q\\\\1:--> changed to <!--$q\\\\1:?-->" - echo "s/^/ /" # $++ - $SED -e "/^=....=formatter /d" \ - -e "/=text=/s%=text=$V9%s|.*<!--\\\\(\\1\\\\)-->.*|$_x_|%" \ - -e "/=Text=/s%=Text=$V9%s|.*<!--\\\\(\\1\\\\)-->.*|$_x_|%" \ - -e "/=name=/s%=name=$V9%s|.*<!--\\\\(\\1\\\\)[?]-->.*|$_y_|%" \ - -e "/=Name=/s%=Name=$V9%s|.*<!--\\\\(\\1\\\\)[?]-->.*|$_y_|%" \ - -e "/=text=/s%=text=$V8%s|.*<!--\\\\(\\1\\\\)-->.*|$_x_|%" \ - -e "/=Text=/s%=Text=$V8%s|.*<!--\\\\(\\1\\\\)-->.*|$_x_|%" \ - -e "/=name=/s%=name=$V8%s|.*<!--\\\\(\\1\\\\)[?]-->.*|$_y_|%" \ - -e "/=Name=/s%=Name=$V8%s|.*<!--\\\\(\\1\\\\)[?]-->.*|$_y_|%" \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ - $SED -e "/^=....=formatter /d" \ - -e "/=text=/s%=text=$V9%s|.*<!--$q\\\\(\\1\\\\):-->.*|$_X_|%" \ - -e "/=Text=/s%=Text=$V9%s|.*<!--$q\\\\(\\1\\\\):-->.*|$_X_|%" \ - -e "/=name=/s%=name=$V9%s|.*<!--$q\\\\(\\1\\\\)[?]:-->.*|$_Y_|%" \ - -e "/=Name=/s%=Name=$V9%s|.*<!--$q\\\\(\\1\\\\)[?]:-->.*|$_Y_|%" \ - -e "/=text=/s%=text=$V8%s|.*<!--$q\\\\(\\1\\\\):-->.*|$_X_|%" \ - -e "/=Text=/s%=Text=$V8%s|.*<!--$q\\\\(\\1\\\\):-->.*|$_X_|%" \ - -e "/=name=/s%=name=$V8%s|.*<!--$q\\\\(\\1\\\\)[?]:-->.*|$_Y_|%" \ - -e "/=Name=/s%=Name=$V8%s|.*<!--$q\\\\(\\1\\\\)[?]:-->.*|$_Y_|%" \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ - echo "/^WARNING:/!d" # $++ -} - +piped_value="s/|/\\\\|/g" +amp_value="s|&|\\\\&|g" info2vars_sed () # generate <!--$vars--> substition sed addon script { - INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$INFO" - V8=" *\\([^ ][^ ]*\\) \\(.*\\)" - V9=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)" - N8=" *\\([^ ][^ ]*\\) \\([$NN].*\\)" - N9=" *DC[.]\\([^ ][^ ]*\\) \\([$NN].*\\)" + INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$DATA" + V8=" *\\([^ ][^ ]*\\) \\(.*\\)<$QX>" + V9=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)<$QX>" + N8=" *\\([^ ][^ ]*\\) \\([$NN].*\\)<$QX>" + N9=" *DC[.]\\([^ ][^ ]*\\) \\([$NN].*\\)<$QX>" V0="\\\\([<]*\\\\)\\\\\\\$" V1="\\\\([^<>]*\\\\)\\\\\\\$" V2="\\\\([^{<>}]*\\\\)" @@ -455,76 +490,53 @@ info2vars_sed () # generate <!--$vars--> substition sed addon script 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 ".$commentvars" = ".no" && simplevars="no" # tests below test ".$expandvars" != ".no" && \ - $SED -e "/^=....=formatter /d" \ - -e "/^=name=/s,=name=$V9,s|<!--$V0\\1[?]-->|- \\2|," \ - -e "/^=Name=/s,=Name=$V9,s|<!--$V0\\1[?]-->|(\\2)|," \ - -e "/^=name=/s,=name=$V8,s|<!--$V0\\1[?]-->|- \\2|," \ - -e "/^=Name=/s,=Name=$V8,s|<!--$V0\\1[?]-->|(\\2)|," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ + $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 "/^=text=/s,=text=$V9,s|<!--$V1\\1-->|\\\\1$SS\\2|," \ - -e "/^=Text=/s,=Text=$V9,s|<!--$V1\\1-->|\\\\1$SS\\2|," \ - -e "/^=name=/s,=name=$V9,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \ - -e "/^=Name=/s,=Name=$V9,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \ - -e "/^=text=/s,=text=$V8,s|<!--$V1\\1-->|\\\\1$SS\\2|," \ - -e "/^=Text=/s,=Text=$V8,s|<!--$V1\\1-->|\\\\1$SS\\2|," \ - -e "/^=name=/s,=name=$V8,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \ - -e "/^=Name=/s,=Name=$V8,s|<!--$V1\\1[?]-->|\\\\1$SS\\2|," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ - test ".$simplevars" != ".no" && test ".$updatevars" != ".no" && \ - $SED -e "/^=....=formatter /d" \ - -e "/^=text=/s,=text=$V9,s|<!--$V0\\1:-->[$AX]*|\\2|," \ - -e "/^=Text=/s,=Text=$V9,s|<!--$V0\\1:-->[$AX]*|\\2|," \ - -e "/^=name=/s,=name=$V9,s|<!--$V0\\1[?]:-->[$AX]*|- \\2|," \ - -e "/^=Name=/s,=Name=$V9,s|<!--$V0\\1[?]:-->[$AX]*| (\\2) |," \ - -e "/^=text=/s,=text=$V8,s|<!--$V0\\1:-->[$AX]*|\\2|," \ - -e "/^=Text=/s,=Text=$V8,s|<!--$V0\\1:-->[$AX]*|\\2|," \ - -e "/^=name=/s,=name=$V8,s|<!--$V0\\1[?]:-->[$AX]*|- \\2|," \ - -e "/^=Name=/s,=Name=$V8,s|<!--$V0\\1[?]:-->[$AX]*| (\\2) |," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ + $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 "/^=name=/s,=name=$V9,s|<!--$V0\\1:[?]-->[^<>]*|- \\2|," \ - -e "/^=Name=/s,=Name=$V9,s|<!--$V0\\1:[?]-->[^<>]*| (\\2) |," \ - -e "/^=name=/s,=name=$V8,s|<!--$V0\\1:[?]-->[^<>]*|- \\2|," \ - -e "/^=Name=/s,=Name=$V8,s|<!--$V0\\1:[?]-->[^<>]*| (\\2) |," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ + $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 "/^=text=/s,=text=$V9,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \ - -e "/^=Text=/s,=Text=$V9,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \ - -e "/^=name=/s,=name=$V9,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \ - -e "/^=Name=/s,=Name=$V9,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \ - -e "/^=text=/s,=text=$V8,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \ - -e "/^=Text=/s,=Text=$V8,s|<!--$V1\\1:[=]-->[^<>]*|\\\\1$SS\\2|," \ - -e "/^=name=/s,=name=$V8,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \ - -e "/^=Name=/s,=Name=$V8,s|<!--$V1\\1:[?]-->[^<>]*|\\\\1$SS\\2|," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ + $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 "/^=text=/s,=text=$V9,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/^=Text=/s,=Text=$V9,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/^=name=/s,=name=$V9,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/^=Name=/s,=Name=$V9,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/^=text=/s,=text=$V8,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/^=Text=/s,=Text=$V8,s|<$V1{\\1:[=]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/^=name=/s,=name=$V8,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/^=Name=/s,=Name=$V8,s|<$V1{\\1:[?]$V2}$V3>|<\\\\1$SS\\2\\\\3>|," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ - test ".$simplevars" != ".no" && \ - $SED -e "/^=....=formatter /d" \ - -e "/^=text=/s,=text=$V9,s|<!--\\1-->[$AX]*|\\2|," \ - -e "/^=Text=/s,=Text=$V9,s|<!--\\1-->[$AX]*|\\2|," \ - -e "/^=name=/s,=name=$V9,s|<!--\\1[?]-->[$AX]*| - \\2|," \ - -e "/^=Name=/s,=Name=$V9,s|<!--\\1[?]-->[$AX]*| (\\2) |," \ - -e "/^=text=/s,=text=$V8,s|<!--\\1-->[$AX]*|\\2|," \ - -e "/^=Text=/s,=Text=$V8,s|<!--\\1-->[$AX]*|\\2|," \ - -e "/^=name=/s,=name=$V8,s|<!--\\1[?]-->[$AX]*| - \\2|," \ - -e "/^=Name=/s,=Name=$V8,s|<!--\\1[?]-->[$AX]*| (\\2) |," \ - -e "/^=/d" -e "s|&|\\\\&|g" $INP # $++ + $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: @@ -534,53 +546,54 @@ info2vars_sed () # generate <!--$vars--> substition sed addon script info2meta_sed () # generate <meta name..> text portion { # http://www.metatab.de/meta_tags/DC_type.htm - INP="$1" ; test ".$INP" = "." && INP="$tmp/$F.$INFO" - V6=" *HTTP[.]\\([^ ][^ ]*\\) \\(.*\\)" - V7=" *DC[.]\\([^ ][^ ]*\\) \\(.*\\)" - V8=" *\\([^ ][^ ]*\\) \\(.*\\)" - INFO_META_TYPE_SCHEME="name=\"DC.type\" content=\"\\2\" scheme=\"\\1\"" - INFO_META_DCMI="name=\"\\1\" content=\"\\2\" scheme=\"DCMIType\"" - INFO_META_NAME_TZ="name=\"\\1\" content=\"\\2 `timezone`\"" - INFO_META_NAME="name=\"\\1\" content=\"\\2\"" - INFO_META_HTTP="http-equiv=\"\\1\" content=\"\\2\"" + 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 "/=meta=HTTP[.]/s,=meta=$V6, <meta $INFO_META_HTTP />," \ - -e "/=meta=DC[.]DCMIType /s,=meta=$V7, <meta $INFO_META_TYPE_SCHEME />," \ - -e "/=meta=DC[.]type Collection$/s,=meta=$V8, <meta $INFO_META_DCMI />," \ - -e "/=meta=DC[.]type Dataset$/s,=meta=$V8, <meta $INFO_META_DCMI />," \ - -e "/=meta=DC[.]type Event$/s,=meta=$V8, <meta $INFO_META_DCMI />," \ - -e "/=meta=DC[.]type Image$/s,=meta=$V8, <meta $INFO_META_DCMI />," \ - -e "/=meta=DC[.]type Service$/s,=meta=$V8, <meta $INFO_META_DCMI />," \ - -e "/=meta=DC[.]type Software$/s,=meta=$V8, <meta $INFO_META_DCMI />," \ - -e "/=meta=DC[.]type Sound$/s,=meta=$V8, <meta $INFO_META_DCMI />," \ - -e "/=meta=DC[.]type Text$/s,=meta=$V8, <meta $INFO_META_DCMI />," \ - -e "/=meta=DC[.]date[.].*[+]/s,=meta=$V8, <meta $INFO_META_NAME />," \ - -e "/=meta=DC[.]date[.].*[:]/s,=meta=$V8, <meta $INFO_META_NAME_TZ />," \ - -e "/=meta=/s,=meta=$V8, <meta $INFO_META_NAME />," \ + -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 "/^=/d" $INP # $++ + -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.$INFO" - $SED -e "/=text=$TXT /!d" -e "s/=text=$TXT //" -e "q" $INP # $++ + 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.$INFO" - $GREP "^=text=$TXT " $INP >$NULL + 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.$INFO" + 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"` ;; @@ -590,7 +603,7 @@ dx_init() dx_line () { - echo "$1$2 "`trimmm "$3"` >> "$tmp/$F.$INFO" + echo "<$Q$1>$2 "`trimmm "$3"`"<$QX>" >> "$tmp/$F.$DATA" } DX_line () @@ -601,7 +614,7 @@ DX_line () dx_text () { - dx_line "=text=" "$1" "$2" + dx_line "'text'" "$1" "$2" } DX_text () # add a <!--vars--> substition includings format variants @@ -610,13 +623,13 @@ DX_text () # add a <!--vars--> substition includings format variants 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" + 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" + dx_line "'Text'" "$varname" "$T" + dx_line "'Name'" "$varname" "$text" fi fi fi @@ -624,25 +637,25 @@ DX_text () # add a <!--vars--> substition includings format variants dx_meta () { - DX_line "=meta=" "$1" "$2" + DX_line "'meta'" "$1" "$2" } DX_meta () # add simple meta entry and its <!--vars--> subsitution { - DX_line "=meta=" "$1" "$2" + 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_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_line "'meta'" "HTTP.$1" "$2" DX_text "HTTP.$1" "$2" DX_text "$1" "$2" } @@ -703,18 +716,18 @@ DC_publisher () # make sure there is this DC.publisher meta tag DC_modified () # make sure there is a DC.date.modified meta tag { # maybe choose from filesystem dates if possible - Q="$1" # target file + 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 $Q 2>$NULL | $SED -e '/odify:/!d' -e 's|.*fy:||' -e q` + 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 "$Q" +%Y-%m-%d 2>$NULL` # GNU sed + text=`$DATE_R "$ZZ" +%Y-%m-%d 2>$NULL` # GNU sed test ".$text" = "." && - text=`$LS_L "$Q" | $SED -e "$cut_42_55" -e "s/^ *//g" -e "q"` + 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 @@ -722,26 +735,26 @@ DC_modified () # make sure there is a DC.date.modified meta tag DC_date () # make sure there is this DC.date meta tag { # choose from one of the available DC.date.* specials - Q="$1" # source file + 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 ($Q)" + # 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 $Q` + 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 $Q` + 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"` @@ -770,18 +783,18 @@ 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 - Q="$1" # target file + 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 $Q` + 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 $Q` + 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 $Q .html` + text=`basename $ZZ .html` text=`basename $text .htm | $SED -e 'y/_/ /' -e "s/\\$/ info/"` fi term=`echo "$text" | $SED -e 's/.*[(]//' -e 's/[)].*//'` @@ -797,7 +810,9 @@ DC_title () site_get_section () # return parent section page of given page { _F_=`sed_slash_key "$1"` - $SED -e "/^=sect=$_F_ /!d" -e "s/^=sect=$_F_ //" -e q "$MK_INFO" # $++ + $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 ?) @@ -816,7 +831,9 @@ info_get_entry_section() site_get_selected () # return section of given page { _F_=`sed_slash_key "$1"` - $SED -e "/=use.=$_F_ /!d" -e "s/=use.=[^ ]* //" -e q "$MK_INFO" # $++ + $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 ?) @@ -835,27 +852,33 @@ info_get_entry_selected () site_get_rootsections () # return all sections from root of nav tree { - $SED -e "/=use1=/!d" -e "s/=use.=\\([^ ]*\\) .*/\\1/" "$MK_INFO" # $++ + $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 "/^=sect=[^ ]* $_F_\$/!d" -e "s/^=sect=//" \ - -e "s/ .*//" "$MK_INFO" # $++ + $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 "/^=node=[^ ]* $_F_\$/!d" -e "s/^=node=//" -e "s/ .*//" "$MK_INFO" + $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 "/^=node=$_F_ /!d" -e "s/^=node=[^ ]* //" -e "q" "$MK_INFO" # $++ + $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 @@ -912,97 +935,97 @@ fast_href () # args "$FILETOREFERENCE" "$FROMCURRENTFILE:$F" fi fi } -make_fast () # experimental - make a FAST file that can be applied -{ # to htm sourcefiles in a subdirectory of the sitefile. -# R="$1" ; test ".$R" = "." && R="$F" - S=`back_path "$F"` - if test ".$S" = "" ; then - # echo "backpath '$F' = none needed" - $CATNULL # $++ - else - # echo "backpath '$F' -> '$S'" - $SED -e "/href=\"[^\"]*\"/!d" -e "s/.*href=\"//" -e "s/\".*//" \ - -e "/^ *\$/d" -e "/^\\//d" -e "/^[.][.]/d" -e "/^[$AA]*:/d" \ - $SITEFILE $SOURCEFILE | sort | uniq \ - | $SED -e "s,.*,s|href=\"&\"|href=\"$S&\"|," # $++ +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 INFO +# ============================================================== 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 "=list=$1 $2" >> "$MK_INFO" + echo "<$Q'list'>$1 $2<$QX>" >> "$MK_DATA" } info_map_list_title() # $file $text { - echo "=list=$2" >> "$tmp/$1.$INFO" + echo "<$Q'list'>$2<$QX>" >> "$tmp/$1.$DATA" } site_map_long_title() # $file $text { - echo "=long=$1 $2" >> "$MK_INFO" + echo "<$Q'long'>$1 $2<$QX>" >> "$MK_DATA" } info_map_long_title() # $file $text { - echo "=long=$2" >> "$tmp/$1.$INFO" + echo "<$Q'long'>$2<$QX>" >> "$tmp/$1.$DATA" } site_map_list_date() # $file $text { - echo "=date=$1 $2" >> "$MK_INFO" + echo "<$Q'date'>$1 $2<$QX>" >> "$MK_DATA" } info_map_list_date() # $file $text { - echo "=date=$2" >> "$tmp/$1.$INFO" + 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_INFO" - _list_="s|<!--\"\\1\"-->.*<!--name-->|\\&<name href=\"\\1\">\\2</name>|" - _date_="s|<!--\"\\1\"-->.*<!--date-->|\\&<date>\\2</date>|" - _long_="s|<!--\"\\1\"-->.*<!--long-->|\\&<long>\\2</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:=list=\\([^ ]*\\) \\(.*\\):$_list_:" \ - -e "s:=date=\\([^ ]*\\) \\(.*\\):$_date_:" \ - -e "s:=long=\\([^ ]*\\) \\(.*\\):$_long_:" \ + -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_INFO" + INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_DATA" siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed - _form_="<!--\"\\2\"--><!--use\\1--><!--long--><!--end\\1-->" - _form_="$_form_<br><!--name--><!--date-->" + _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 "/=use.=/!d" -e "s|=use\\(.\\)=\\([^ ]*\\) .*|$_form_|" \ + $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|<long>||" -e "s|</long>||" \ -e "s|<name |<$_tiny_><a |" -e "s|</name>||" \ - -e "s|<date>| |" -e "s|</date>|</a><br></$_tinyX_>|" \ + -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_INFO" + INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_DATA" siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed - _form_="<!--\"\\2\"--><!--use\\1--><!--name--><!--date--><!--long-->" + _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 "/=use.=/!d" -e "s|=use\\(.\\)=\\([^ ]*\\) .*|$_form_|" \ + $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>|" \ @@ -1011,11 +1034,13 @@ make_listsitemap () -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>|" -e "s|</date>|</small></td>$_tabb_|" \ - -e "s|<long>|<td><em>|" -e "s|</long>|</em></td></tr>|" \ - $INPUTS # $++ - for xx in `grep "=use.=name:sitemap:" $INPUTS` ; do - xx=`echo $xx | sed -e "s/=use.=name:sitemap://"` + -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 @@ -1023,6 +1048,26 @@ make_listsitemap () 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" @@ -1031,14 +1076,31 @@ print_extension () *) 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\\$//"` - if test -f "$_SRCFILE_" ; then echo "$_SRCFILE_" # $++ + _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_" # $++ - else echo ".//$_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 () @@ -1123,11 +1185,11 @@ make_current_entry () # $sect $file ## requires $MK_SITE S="$1" ; R="$2" SSS=`sed_slash_key "$S"` sep=" - " ; _left_=" [ " ; _right_=" ] " - echo_current_line "$S" "<a href=\"$R\"><!--\"$R\"--><!--name--></a>$sep" \ - | $SED -f "$MK_SITE" -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \ + 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_/" \ - -e "s/<!--\"[^\"]*\"--><!--name-->//" # $+++ + -e "/<a href=\"$SSS\"/s/<\\/a>/&$_right_/" # $+++ } echo_subpage_line () # $sect $extra { @@ -1139,18 +1201,22 @@ make_subpage_entry () S="$1" ; R="$2" RR=`sed_slash_key "$R"` sep=" - " ; - echo_subpage_line "$S" "<a href=\"$R\"><!--\"$R\"--><!--name--></a>$sep" \ - | $SED -f "$MK_SITE" -e "s/<name[^<>]*>//" -e "s/<\\/name>//" \ - -e "s/<!--\"[^\"]*\"--><!--name-->//" # $+++ + 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_INFO" + INPUTS="$1" ; test ".$INPUTS" = "." && INPUTS="$MK_DATA" siteinfo2sitemap > "$MK_SITE" # have <name><long><date> addon-sed - make_printsitefile_head $SITEFILE # $++ + 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" @@ -1240,6 +1306,418 @@ body_for_emailfooter () echo "$_dated_</td></tr></table>" } +# =================================================================== CSS +# There was another project to support sitemap build from xml files. +# The source format was using .dbk+xml with embedded references to .css +# files for visual preview in a browser. An docbook xml file with semantic +# outlines is far better suited for quality documentation than any html +# source. It happens that the xml/css support in browsers is still not +# very portable - especially embedded css style blocks are a nightmare. +# Instead we (a) grab all non-html xml markup tags (b) grab all referenced +# css stylesheets (c) cut out css defs from [b] that are known by [a] and +# (d) append those to the <style> tag in the output html file as well as +# (e) reformatting the defs as well as markups from tags to tag classes. +# Input dbk/htm +# <?xml-stylesheet type="text/css" href="html.css" ?> <!-- dbk/xml --> +# <link rel="stylesheet" type="text/css" href="sdocbook.css" /> <!-- xhtml --> +# <article><para> +# Using some <command>exe</command> +# </para></article> +# Input css: +# article { .. ; display : block } +# para { .. ; display : block } +# command { .. ; display : inline } +# Output html: +# <html><style type="text/css"> +# div .article { .. } +# div .para { .. } +# span .command { .. } +# </style> +# <div class="article"><div class="para> +# Using some <span class="command">exe</span> +# </div></div> + +css_sourcefile () +{ + if test -f "$1" ; then echo "$1" + elif test -f "$opt_src_dir/$1" ; then echo "$opt_src_dir/$1" + elif echo "$1" | grep "^/" > $NULL ; then echo "$1" + else echo "./$1" + fi +} + +css_xmltags () # $SOURCEFILE +{ + X=`echo $SOURCEFILE | sed -e "y:/:~:"` + S="$SOURCEFILE" + cat "$S" | $SED -e "s|>[^<>]*<|><|g" -e "s|^[^<>]*<|<|" \ + -e "s|>[^<>]*\$|>|" -e "s|<|\\n|g" \ + | $SED -e "/^\\//d" -e "/^ *\$/d" -e "/>/!d" -e "s|>.*||" \ + | sort | uniq > "$tmp/$MK.$X.xmltags.tmp.txt" +} + +css_xmlstyles () # $SOURCEFILE +{ + X=`echo $SOURCEFILE | sed -e "y:/:~:"` + S="$SOURCEFILE" + cat "$S" "$SITEFILE" \ + | sed \ + -e "s|<link *rel=['\"]*stylesheet|<?xml-stylesheet |" \ + -e "/<.xml-stylesheet/!d" -e "/href/!N" -e "/href/!N" \ + -e "s|^.*<.xml-stylesheet||" -e 's|^.*href="||' -e 's|".*||' \ + | sort | uniq > "$tmp/$MK.$X.xmlstylesheets.tmp.txt" +} + +css_xmlstyles_sed () # $SOURCEFILE +{ + X=`echo $SOURCEFILE | sed -e "y:/:~:"` + S="$tmp/$MK.$X.xmltags.tmp.txt" + R="$tmp/$MK.$X.xmltags.tmp.sed" + rm -f "$R" + { + for x in 1 2 3 4 5 6 7 8 9 ; do echo "/}/d" ; echo "/{/!N" ; done + echo "s|\\r||g" + $SED "/^[$AZ$az$NN]/!d" "$S" | { while read xmltag ; do + xmltag=`echo "$xmltag" | sed -e "s/ .*//"` + _xmltag=`sed_slash_key "$xmltag"` + if echo " title section " | grep " $xmltag " > $NULL ; then + test "$xmltag" = "section" && continue; + echo "/^ *$_xmltag *[,\\n{]/bfound" >> "$R" + echo "/[,\\n] *$_xmltag *[,\\n{]/bfound" >> "$R" + $SED "/^[$AZ$az$NN]/!d" "$S" | { while read xmlparent ; do + xmlparent=`echo "$xmlparent" | sed -e "s/ .*//"` + _xmlparent=`sed_slash_key "$xmlparent"` + echo "/^ *$_xmlparent *$_xmltag *[,\\n{]/bfound" + echo "/[ ,\\n] *$_xmlparent *$_xmltag *[,\\n{]/bfound" + done } + else + echo "/^ *$_xmltag *[ ,\\n{]/bfound" + echo "/[ ,\\n] *$_xmltag *[ ,\\n{]/bfound" + fi + done } + echo "d" ; echo ":found" + for x in 1 2 3 4 5 6 7 8 9 ; do echo "/}/!N" ; done + $SED "/^[$AZ$az$NN]/!d" "$S" | { while read xmltag ; do + xmltag=`echo "$xmltag" | sed -e "s/ .*//"` + if echo " $HTMLTAGS $HTMLTAGS2" | grep " $xmltag " > $NULL ; then + continue # keep html tags + fi + echo "s|^\\( *\\)\\($xmltag *[ ,\\n{]\\)|\\1.\\2|g" + echo "s|\\([ ,\\n] *\\)\\($xmltag *[ ,\\n{]\\)|\\1.\\2|g" + done } + } > "$R" +} + +css_xmltags_css () # $SOURCEFILE +{ + X=`echo $SOURCEFILE | sed -e "y:/:~:"` + S="$tmp/$MK.$X.xmltags.tmp.sed" + R="$tmp/$MK.$X.xmltags.tmp.css" + { + cat "$tmp/$MK.$X.xmlstylesheets.tmp.txt" | { while read xmlstylesheet ; do + stylesheet=`css_sourcefile "$xmlstylesheet"` + if test -f "$stylesheet" ; then + echo "/* $xmlstylesheet */" + cat "$stylesheet" | $SED -f "$S" + else + error "$xmlstylesheet : ERROR, no such stylesheet" + fi + done } + } > "$R" +} + +css_xmlmapping_sed () # $SOURCEFILE +{ + X=`echo $SOURCEFILE | sed -e "y:/:~:"` + S="$tmp/$MK.$X.xmltags.tmp.txt" + R="$tmp/$MK.$X.xmlmapping.tmp.sed" + rm -f "$R" + { + for x in 1 2 3 4 5 6 7 8 9 ; do echo "/}/d" ; echo "/{/!N" ; done + echo "s|\\r||g" + $SED "/^[$AZ$az$NN]/!d" "$S" | { while read xmltag ; do + xmltag=`echo "$xmltag" | sed -e "s/ .*//"` + xmltag=`sed_slash_key "$xmltag"` + echo "/^ *\\.$xmltag *[ ,\\n{]/bfound" + echo "/[ ,\\n] *\\.$xmltag *[,\\n{]/bfound" + done } + echo "d" ; echo ":found" + for x in 1 2 3 4 5 6 7 8 9 ; do echo "/}/!N" ; done + echo "s/^/>>/" + echo "/[\\n ]display *: *list-item/s|^.*>>|li>>|" + echo "/[\\n ]display *: *table-caption/s|^.*>>|caption>>|" + echo "/[\\n ]display *: *table-cell/s|^.*>>|td>>|" + echo "/[\\n ]display *: *table-row/s|^.*>>|tr>>|" + echo "/[\\n ]display *: *table/s|^.*>>|table>>|" + echo "/[\\n ]display *: *block/s|^.*>>|div>>|" + echo "/[\\n ]display *: *inline/s|^.*>>|span>>|" + echo "/[\\n ]display *: *none/s|^.*>>|small>>|" + echo "/^div>>.*[\\n ]list-style-type *: *disc/s|^.*>>|ul>>|" + echo "/^div>>.*[\\n ]list-style-type *: *decimal/s|^.*>>|ol>>|" + echo "/^span>>.*[\\n ]font-family *: *monospace/s|^.*>>|tt>>|" + echo "/^span>>.*[\\n ]font-style *: *italic/s|^.*>>|em>>|" + echo "/^span>>.*[\\n ]font-weight *: *bold/s|^.*>>|b>>|" + echo "/^div>>.*[\\n ]white-space *: *pre/s|^.*>>|pre>>|" + echo "/^div>>.*[\\n ]margin-left *: *[$NN]/s|^.*>>|blockquote>>|" + $SED "/^[$AZ$az$NN]/!d" "$S" | { while read xmltag ; do + xmltag=`echo "$xmltag" | sed -e "s/ .*//"` + echo "s|^\\(.*\\)>> *\\.$xmltag *[ ,\\n{].*|\\1 .$xmltag|" + echo "s|^\\(.*\\)>>.*[ ,\\n] *\\.$xmltag *[ ,\\n{].*|\\1 .$xmltag|" + done } + echo "s/^div \\.para\$/p .para/" + echo "s/^span \\.ulink\$/a .ulink/" + } > "$R" +} + +css_xmlmapping () # $SOURCEFILE +{ + X=`echo $SOURCEFILE | sed -e "y:/:~:"` + cat "$tmp/$MK.$X.xmltags.tmp.css" | \ + $SED -f "$tmp/$MK.$X.xmlmapping.tmp.sed" \ + > "$tmp/$MK.$X.xmlmapping.tmp.txt" +} + +css_scan() # $SOURCEFILE +{ + css_xmltags + css_xmlstyles + css_xmlstyles_sed + css_xmltags_css + css_xmlmapping_sed + css_xmlmapping +} + +tags2span_sed() # $SOURCEFILE > $++ +{ + X=`echo $SOURCEFILE | sed -e "y:/:~:"` + S="$tmp/$MK.$X.xmltags.tmp.txt" + R="$tmp/$MK.$X.xmltags.tmp.css" + echo "s|<[?]xml-stylesheet[^<>]*[?]>||" + echo "s|<link *rel=['\"]*stylesheet[^<>]*>||" + echo "s|<section[^<>]*>||g" + echo "s|</section>||g" + $SED "/^[$AZ$az$NN]/!d" "$S" | { while read xmltag ; do + # note "xmltag=$xmltag" + xmltag=`echo "$xmltag" | sed -e "s/ .*//"` + if echo " $HTMLTAGS $HTMLTAGS2" | grep " $xmltag " > $NULL ; then + continue # keep html tags + fi + _xmltag=`sed_slash_key "$xmltag"` + _span_=`$SED -e "/ \\.$_xmltag\$/!d" -e "s/ .*//" -e q \ + < "$tmp/$MK.$X.xmlmapping.tmp.txt"` + test ".$_span_" = "." && _span_="span" + _xmltag=`sed_piped_key "$xmltag"` + echo "s|<$xmltag\\([\\n\\t ][^<>]*\\)url=|<$_span_ class=\"$xmltag\"\\1href=|g" + echo "s|<$xmltag\\([\\n\\t >]\\)|<$_span_ class=\"$xmltag\"\\1|g" + echo "s|</$xmltag\\([\\n\\t >]\\)|</$_span_\\1|g" + done } + cat "$tmp/$MK.$X.xmlstylesheets.tmp.txt" | { while read xmlstylesheet ; do + if test -f "$xmlstylesheet" ; then + R="[^<>]*href=['"'"'"]$xmlstylesheet['"'"'"][^<>]*" + echo "s|<[?]xml-stylesheet$R>||" + echo "s|<link[^<>]* rel=['"'"'"]*stylesheet['"'"'" ]$R>||" + fi + done } +} + +tags2meta_sed() # $SOURCEFILE > $++ +{ + X=`echo $SOURCEFILE | sed -e "y:/:~:"` + S="$tmp/$MK.$X.xmlstylesheets.tmp.txt" + R="$tmp/$MK.$X.xmltags.tmp.css" + cat "$tmp/$MK.$X.xmlstylesheets.tmp.txt" | { while read xmlstylesheet ; do + if test -f "$xmlstylesheet" ; then + echo " <style type=\"text/css\"><!--" + $SED -e "s/^/ /" < "$R" + echo " --></style>" + break + fi + done } +} + +# ========================================================================== +# xml/docbook support is taking an dbk input file converting any html DBK +# syntax into pure docbook tagging. Each file is being given a docbook +# doctype so that an xml/docbook viewer can render it correctly - that +# is needed atleast since docbook files do not embed stylesheet infos. +# Most of the processing is related to remap html markup and some other +# shortcut markup into correct docbook markup. The result is NOT checked +# for being well-formed or even matching the docbook schema DTD at all. + +scan_xml_rootnode () +{ + rootnode=`cat "$SOURCEFILE" | \ + $SED -e "/<[$AZ$az$NN]/!d" -e "s/<\\([$AZ$az$NN]*\\).*/\\1/" -e q` + echo "<$Q'root'>$F $rootnode<$QX>" >> "$MK_DATA" +} + +get_xml_rootnode () +{ + _file_=`sed_slash_key "$F"` + $SED -e "/^<$Q'root'>$_file_ /!d" \ + -e "s|.* ||" -e "s|<.*||" -e q "$MK_DATA" # + +} + +xml_sourcefile () +{ + _XMLFILE_=`echo "$1" | $SED -e "s/\\.xml\\$/.dbk/"` + _SRCFILE_=`echo "$1" | $SED -e "s/\\.xml\\$/.htm/"` + test "$1" = "$_XMLFILE_" && _XMLFILE_="///" + test "$1" = "$_SRCFILE_" && _SRCFILE_="///" + if test -f "$_XMLFILE_" + then echo "$_XMLFILE_" # $++ + elif test -f "$_SRCFILE_" + then echo "$_SRCFILE_" # $++ + elif test -f "$opt_src_dir/$_XMLFILE_" + then echo "$opt_src_dir/$_XMLFILE_" # $++ + elif test -f "$opt_src_dir/$_SRCFILE_" + then echo "$opt_src_dir/$_SRCFILE_" # $++ + else echo ".//$_XMLFILE_" # $++ (not found?) + fi +} + +scan_xmlfile() +{ + SOURCEFILE=`xml_sourcefile "$F"` + $hint "'$SOURCEFILE': scanning xml -> '$F'" + scan_xml_rootnode + rootnode=`get_xml_rootnode | sed -e "/^h[$NN]/s|\$| <?section?>|"` + $hint "'$SOURCEFILE': rootnode ('$rootnode')" +} + +make_xmlfile() +{ + SOURCEFILE=`xml_sourcefile "$F"` + X=`echo $SOURCEFILE | sed -e "y:/:~:"` + article=`get_xml_rootnode` + test ".$article" = "." && article="article" + echo '<!DOCTYPE '$article' PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"' \ + > "$F" + echo ' "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">' \ + >> "$F" + cat "$tmp/$MK.$X.xmlstylesheets.tmp.txt" | { while read stylesheet ; do + echo "<?xml-stylesheet type=\"text/css\" href=\"$stylesheet\" ?>" \ + >> "$F" + done } + __secinfo="\\1<sectioninfo>\\2</sectioninfo>" + cat "$SOURCEFILE" | $SED \ + -e "s!<>!\ \;!g" \ + -e "s!\\(&\\)\\(&\\)!\\1amp;\\2amp;!g" \ + -e "s!\\(<[^<>]*\\)\\(width\\)\\(=\\)\\([$NN]*\%*\\)!\\1\\2\\3\"\\4\"!g" \ + -e "s!\\(<[^<>]*\\)\\(cellpadding\\)\\(=\\)\\([$NN]*\%*\\)!\\1\\2\\3\"\\4\"!g" \ + -e "s!\\(<[^<>]*\\)\\(border\\)\\(=\\)\\([$NN]*\%*\\)!\\1\\2\\3\"\\4\"!g" \ + -e "s!<[?]xml-stylesheet[^<>]*>!!" \ + -e "s!<link[^<>]* rel=[\'\"]*stylesheet[^<>]*>!!" \ + -e "s!<[hH][$NN]!<title!g" \ + -e "s!</[hH][$NN]!</title!g" \ + -e "s!\\( *\\)\\([^<>]*[$AZ$az$NN][^<>\r\n]*\\)\$!\\1\\2!" \ + -e "s!\\(.*\\)!\\1!g" \ + -e "s!\\(.*\\)!\\1!g" \ + -e "s!\\(
[^<>]*\\)\\(.*[^<>]*\\)\$!\\1\\2!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!<\\(strike\\)>!!g" \ + -e "s!<\\(s\\)>!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!
!
!g" \ + -e "s!
!!g" \ + -e "s!

!!g" \ + -e "s!<[pP]>!!g" \ + -e "s!!!g" \ + -e "s!<\\(pre\\)>!!g" \ + -e "s!<\\(PRE\\)>!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!]*\\)name=\\([^<>]*\\)/>!!g" \ + -e "s!]*\\)name=\\([^<>]*\\)>!!g" \ + -e "s!]*\\)href=!!!g" \ + -e "s! remap=\"url\">[^<>]*! />!g" \ + -e "s!<\\(/*\\)span\\([ ][^<>]*\\)>!<\\1phrase\\2>!g" \ + -e "s!<\\(/*\\)span>!<\\1phrase>!g" \ + -e "s!]*\\)>!!g" \ + -e "s!!!g" \ + -e "s!!!g" \ + -e "s!<\\(/*\\)\\(sup\\)>!<\\1superscript>!g" \ + -e "s!<\\(/*\\)\\(sub\\)>!<\\1subscript>!g" \ + -e "s!\\(<\\)\\(li\\)\\(><\\)!\\1listitem\\3!g" \ + -e "s!\\(>\\)!\\1listitem\\3!g" \ + -e "s!\\(<\\)\\(li\\)\\(>\\)!\\1listitem\\3!g" \ + -e "s!\\(\\)!\\1listitem\\3!g" \ + -e "s!\\(!\\1itemizedlist>!g" \ + -e "s!\\(!\\1orderedlist>!g" \ + -e "s!\\(!\\1variablelist>!g" \ + -e "s!<\\(/*\\)DT>!<\\1dt>!g" \ + -e "s!<\\(/*\\)DD>!<\\1dd>!g" \ + -e "s!<\\(/*\\)DL>!<\\1dl>!g" \ + -e "s!

!
!g" \ + -e "s!
!
!g" \ + -e "s!<\\(/*\\)dl>!<\\1variablelist>!g" \ + -e "s!]*\\)>!!g" \ + -e "s!
!!g" \ + -e "s!
!
!g" \ + -e "s!]*\\)>!>!g" \ + -e "s!]*\\)>!!g" \ + -e "s!
!!g" \ + -e "s!
!
!g" \ + -e "s!]*>\\(]*>\\)!\\1!" \ + -e "s!\\(\\)!\\1!" \ + -e "s!]*\\)>!!g" \ + -e "s!!!g" \ + -e "s!
!
!g" \ + -e "s!\\(]*\\)>!\\1row\\2>!g" \ + -e "s!\\(!\\1row>!g" \ + -e "s!\\(]*\\)>!\\1entry\\2>!g" \ + -e "s!\\(!\\1entry>!g" \ + -e "s!\\(]*[ ]width=\"100\%\"\\)!\\1 pgwide=\"1\"!g" \ + -e "s!\\(]*[ ]cols=\"2\">\\)\\(\\)!\\1\\2!g" \ + -e "s!\\(]*[ ]\\)width=\\(\"[$NN]*\%*\"\\)!\\1remap=\\2!g" \ + -e "s!\\([\'\`]*\\)!\\1!g" \ + -e "s!\\([\'\`]*\\)!\\1!g" \ + -e "s!<\\(code\\)>\\([\`\"\']\\)!\\2!g" \ + -e "s!<\\(code\\)>\\([\`\"\']\\)!\\2!g" \ + -e "s!\\([\`\"\']\\)!\\1!g" \ + -e "s!\\([\`\"\']\\)!\\1!g" \ + -e "s!<\\(tt\\)>\\([\`\"\']\\)!\\2!g" \ + -e "s!<\\(tt\\)>\\([\`\"\']\\)!\\2!g" \ + -e "s!\\([\`\"\']\\)!\\1!g" \ + -e "s!\\([\`\"\']\\)!\\1!g" \ + -e "s!\\(!\\1constant>!g" \ + -e "s!\\(!\\1literal>!g" \ + -e "s!
!
!g" \ + -e "s!
!\n!g" \ + >> "$F" + echo "'$SOURCEFILE': " `ls -s $SOURCEFILE` ">>" `ls -s $F` +} + +make_xmlmaster () +{ + SOURCEFILE=`xml_sourcefile "$F"` + X=`echo $SOURCEFILE | sed -e "y:/:~:"` + article="section" # book? chapter? + echo '$F + echo ' "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">' >>$F + cat "$tmp/$MK.$X.xmlstylesheets.tmp.txt" | { while read stylesheet ; do + echo "" \ + >> "$F" + done } + echo "
Documentation" >>$F + make_xmlsitemap >> $F + echo "
" >> $F + echo "'$SOURCEFILE': " `ls -s $SOURCEFILE` ">*>" `ls -s $F` +} + # ========================================================================== # # During processing we will create a series of intermediate files that @@ -1254,7 +1732,7 @@ body_for_emailfooter () # we scan the SITEFILE for href references to be converted # - in the new variant we use a ".gets.tmp" sed script that SECTS # marks all interesting lines so they can be checked later -# with an sed anchor of (or ) +# with an sed anchor of sect="[$NN]" (or sect="[$AZ]") S="\\ \\;" # S="[&]nbsp[;]" @@ -1263,154 +1741,204 @@ S="\\ \\;" # note that "
" is sometimes used with HR - it must exist in input echo_HR_EM_PP () { - echo "/^$1$2$3*$1$2$3*$2$3*$3*$1$2$3*$2$3*$3*$2$3*$3*$2$3*$3*$1$2*$2*$1$2*$2*$2*$2*$1*<>$1*$1<>*<>**$1*<>$1*$1<>*<>**$1<>$1$1<><>$1*<>$1*$1<>*<>**$1<>$1$1<><>" "$h1" "" > "$MK_GETS" - echo_HR_EM_PP "
" "" "$h1" "" >> "$MK_GETS" - echo_HR_EM_PP "
" "" "$h1" "" >> "$MK_GETS" - echo_HR_PP "
" "$b1$b1" "" >> "$MK_GETS" - echo_HR_PP "
" "$b2$b2" "" >> "$MK_GETS" - echo_HR_PP "
" "$b3$b3" "" >> "$MK_GETS" - echo_br_PP "
" "$b2$b2" "" >> "$MK_GETS" - echo_br_PP "
" "$b3$b3" "" >> "$MK_GETS" - echo_br_EM_PP "
" "" "$q3" "" >> "$MK_GETS" - echo_br_EM_PP "
" "" "$q3" "" >> "$MK_GETS" - echo_br_EM_PP "
" "" "$q3" "" >> "$MK_GETS" - echo_HR_PP "
" "$q3" "" >> "$MK_GETS" - echo_sp_PP "$q3" "" >> "$MK_GETS" - echo_sp_sp "$q3" "" >> "$MK_GETS" + b2="[-$AP$AK]" + b3="[:/]" + q3="[:/,$AK]" + echo_HR_PP "
" "$h1" "sect=\"1\"" > "$MK_GETS" + echo_HR_EM_PP "
" "" "$h1" "sect=\"1\"" >> "$MK_GETS" + echo_HR_EM_PP "
" "" "$h1" "sect=\"1\"" >> "$MK_GETS" + echo_HR_PP "
" "$b1$b1" "sect=\"1\"" >> "$MK_GETS" + echo_HR_PP "
" "$b2$b2" "sect=\"2\"" >> "$MK_GETS" + echo_HR_PP "
" "$b3$b3" "sect=\"3\"" >> "$MK_GETS" + echo_br_PP "
" "$b2$b2" "sect=\"2\"" >> "$MK_GETS" + echo_br_PP "
" "$b3$b3" "sect=\"3\"" >> "$MK_GETS" + echo_br_EM_PP "
" "" "$q3" "sect=\"3\"" >> "$MK_GETS" + echo_br_EM_PP "
" "" "$q3" "sect=\"3\"" >> "$MK_GETS" + echo_br_EM_PP "
" "" "$q3" "sect=\"3\"" >> "$MK_GETS" + echo_HR_PP "
" "$q3" "sect=\"3\"" >> "$MK_GETS" + echo_br_PP "" "$b2" "sect=\"2\"" >> "$MK_GETS" + echo_sp_PP "$q3" "sect=\"3\"" >> "$MK_GETS" + echo_sp_SP "" "sect=\"2\"" >> "$MK_GETS" + echo_sp_sp "$q3" "sect=\"9\"" >> "$MK_GETS" + echo_sp_sp "
" "sect=\"9\"" >> "$MK_GETS" $SED -e "s/\\(>\\)\\(\\[\\)/\\1 *\\2/" "$MK_GETS" > "$MK_PUTS" # the .puts.tmp variant is used to
some hrefs which # shall not be used otherwise for being generated - this is nice for # some quicklinks somewhere. The difference: a whitspace "
" + echo "" > "$MK_DATA" # fresh start } -_uses_="=use\\1=\\2 \\3" ; _name_="=use\\1=name:\\2 \\3" ; -_getW_="" -_getX_="<[^<>]*>[^<>]*" -_getY_="<[^<>]*>[^<>]*<[^<>]*>[^<>]*" +_uses_="<$Q'use\\1'>\\2 \\3<$QX>" +_name_="<$Q'use\\1'>name:\\2 \\3<$QX>" ; make_sitemap_list() { + _sitefile_="$1" ; test ".$_sitefile_" = "." && _sitefile_="$SITEFILE" # scan sitefile for references pages - store as "=use+=href+ anchortext" - $SED -f $MK_GETS -e "/^/!d" \ - -e "s|^$_getX_
]*>\\(.*\\).*|$_uses_|" \ - -e "s|^$_getY_]*>\\(.*\\).*|$_uses_|" \ - -e "s|^$_getW_]*>\\(.*\\).*|$_name_|" \ - -e "s|^$_getX_]*>\\(.*\\).*|$_name_|" \ - -e "s|^$_getY_]*>\\(.*\\).*|$_name_|" \ - -e "/^=....=/!d" "$SITEFILE" > "$MK_INFO" + $SED -f "$MK_GETS" -e "/]*>\\(.*\\).*|$_uses_|" \ + -e "s|.*]*>\\(.*\\).*|$_name_|" \ + -e "s|.*]*>\\(.*\\)|$_name_|" \ + -e "/^<$Q/!d" -e "/^> "$MK_DATA" +} + +_Uses_="<$Q'Use\\1'>\\2 \\3<$QX>" +_Name_="<$Q'Use\\1'>name:\\2 \\3<$QX>" ; + +make_subsitemap_list() +{ + _sitefile_="$1" ; test ".$_sitefile_" = "." && _sitefile_="$SITEFILE" + # scan sitefile for references pages - store as "=use+=href+ anchortext" + $SED -f "$MK_GETS" -e "/]*>\\(.*\\).*|$_Uses_|" \ + -e "s|.*]*>\\(.*\\).*|$_Name_|" \ + -e "s|.*]*>\\(.*\\)|$_Name_|" \ + -e "/^<$Q/!d" -e "/^\\([^:./][^:./]*[./]\\)|>$2\\1|" \ + "$_sitefile_" >> "$MK_DATA" } make_sitemap_sect() { - # scan used pages and store prime section group relation =sect= and =node= - # (A) each "use1" creates "=sect=href+ href1" for all following non-"use1" - # (B) each "use1" creates "=node=href2 href1" for all following "use2" - $SED -e "/=use.=/!d" \ - -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "s/=use.=\\([^ ]*\\) .*/=sect=\\1/" \ - -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO" - $SED -e "/=use.=/!d" \ - -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "/=use[13456789]=/d" \ - -e "s/=use.=\\([^ ]*\\) .*/=node=\\1/" \ - -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO" + # scan used pages and store prime section group relation 'sect' and 'node' + # (A) each "use1" creates "'sect'>href+ href1" for all following non-"use1" + # (B) each "use1" creates "'node'>href2 href1" for all following "use2" + $SED -e "/^<$Q'use.'>/!d" \ + -e "/^<$Q'use1'>/{" \ + -e "h" -e "s|^<$Q'use1'>\\([^ ]*\\) .*|\\1|" \ + -e "x" -e "}" \ + -e "s|^<$Q'use.'>\\([^ ]*\\) .*|<$Q'sect'>\\1|" \ + -e G -e "s|\\n| |" -e "s|\$|<$QX>|" "$MK_DATA" >> "$MK_DATA" + $SED -e "/^<$Q'use.'>/!d" \ + -e "/^<$Q'use1'>/{" \ + -e "h" -e "s|^<$Q'use1'>\\([^ ]*\\) .*|\\1|" \ + -e "x" -e "}" \ + -e "/^<$Q'use[13456789]'>/d" \ + -e "s|<$Q'use.'>\\([^ ]*\\) .*|<$Q'node'>\\1|" \ + -e G -e "s|\\n| |" -e "s|\$|<$QX>|" "$MK_DATA" >> "$MK_DATA" } make_sitemap_page() { - # scan used pages and store secondary group relation =page= and =node= - # the parenting =node= for use3 is usually a use2 (or use1 if none there) - $SED -e "/=use.=/!d" \ - -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "/=use2=/{" -e "h" -e "s:=use2=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "/=use[1]=/d" \ - -e "s/=use.=\\([^ ]*\\) .*/=page=\\1/" \ - -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO" - $SED -e "/=use.=/!d" \ - -e "/=use1=/{" -e "h" -e "s:=use1=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "/=use2=/{" -e "h" -e "s:=use2=\\([^ ]*\\) .*:\\1:" -e "x" -e "}" \ - -e "/=use[12456789]=/d" \ - -e "s/=use.=\\([^ ]*\\) .*/=node=\\1/" \ - -e G -e "s:\\n: :" "$MK_INFO" >> "$MK_INFO" + # scan used pages and store secondary group relation 'page' and 'node' + # the parenting 'node' for use3 is usually a use2 (or use1 if none there) + $SED -e "/^<$Q'use.'>/!d" \ + -e "/^<$Q'use1'>/{" \ + -e "h" -e "s|^<$Q'use1'>\\([^ ]*\\) .*|\\1|" \ + -e "x" -e "}" \ + -e "/^<$Q'use2'>/{" \ + -e "h" -e "s|^<$Q'use2'>\\([^ ]*\\) .*|\\1|" \ + -e "x" -e "}" \ + -e "/^<$Q'use1'>/d" \ + -e "s|^<$Q'use.'>\\([^ ]*\\) .*|<$Q'page'>\\1<$QX>|" \ + -e G -e "s|\\n| |" "$MK_DATA" >> "$MK_DATA" + $SED -e "/^<$Q'use.'>/!d" \ + -e "/^<$Q'use1'>/{" \ + -e "h" -e "s|^<$Q'use1'>\\([^ ]*\\) .*|\\1|" \ + -e "x" -e "}" \ + -e "/^<$Q'use2'>/{" \ + -e "h" -e "s|^<$Q'use2'>\\([^ ]*\\) .*|\\1|" \ + -e "x" -e "}" \ + -e "/^<$Q'use[12456789]'>/d" \ + -e "s|^<$Q'use.'>\\([^ ]*\\) .*|<$Q'node'>\\1<$QX>|" \ + -e G -e "s|\\n| |" "$MK_DATA" >> "$MK_DATA" # and for the root sections we register ".." as the parenting group - $SED -e "/=use1=/!d" \ - -e "s/=use.=\\([^ ]*\\) .*/=node=\\1 ../" "$MK_INFO" >> "$MK_INFO" + $SED -e "/^<$Q'use1'>/!d" \ + -e "s|^<$Q'use.'>\\([^ ]*\\) .*|<$Q'node'>\\1 ..<$QX>|" "$MK_DATA" >> "$MK_DATA" } + echo_site_filelist() { - $SED -e "/=use.=/!d" -e "s/=use.=//" -e "s/ .*//" "$MK_INFO" + $SED -e "/^<$Q'use.'>/!d" \ + -e "s|^<$Q'use.'>||" -e "s| .*||" "$MK_DATA" } # ========================================================================== @@ -1423,6 +1951,7 @@ echo_site_filelist() scan_sitefile () # $F { SOURCEFILE=`html_sourcefile "$F"` + $hint "'$SOURCEFILE': scanning -> sitefile" if test "$SOURCEFILE" != "$F" ; then dx_init "$F" dx_text today "`timetoday`" @@ -1449,8 +1978,9 @@ scan_sitefile () # $F scan_htmlfile() # "$F" { SOURCEFILE=`html_sourcefile "$F"` # SCAN : - if test "$SOURCEFILE" != "$F" ; then : # HTML : - if test -f "$SOURCEFILE" ; then make_fast "$F" > "$tmp/$F.$FAST" + $hint "'$SOURCEFILE': scanning -> $F" # HTML : + if test "$SOURCEFILE" != "$F" ; then : + if test -f "$SOURCEFILE" ; then dx_init "$F" dx_text today "`timetoday`" dx_text todays "`timetodays`" @@ -1474,6 +2004,7 @@ scan_htmlfile() # "$F" issue=`info_get_entry issue` site_map_list_date "$F" "$edate" info_map_list_date "$F" "$edate" + css_scan echo "'$SOURCEFILE': '$title' ('$short') @ '$issue' ('$sectn')" else echo "'$SOURCEFILE': does not exist" @@ -1484,6 +2015,23 @@ scan_htmlfile() # "$F" fi } +scan_subsitemap_long () +{ + grep "" "$1" | { + while read _line_ ; do + _href_=`echo "$_line_" | $SED -e "s|.*.*|\\1|"` + _date_=`echo "$_line_" | $SED -e "s|.*\\([^<>]*\\).*|\\1|" -e "//d"` + _long_=`echo "$_line_" | $SED -e "s|.*\\([^<>]*\\).*|\\1|" -e "//d"` + if test ".$_href_" != "." && test ".$_date_" != "." ; then + site_map_list_date "$2$_href_" "$_date_" + fi + if test ".$_href_" != "." && test ".$_long_" != "." ; then + site_map_long_title "$2$_href_" "$_long_" + fi + done + } +} + scan_namespec () { # nothing so far @@ -1496,6 +2044,13 @@ scan_namespec () site_map_list_date "$F" "`timetoday`" echo "'$F' external sitemap index$n" ;; + name:*.htm|name:*.html) + FF=`echo "$1" | $SED -e "s|name:||"` + FFF=`echo "$FF" | $SED -e "s|/[^/]*\$|/|"` # dirname + case "$FFF" in */*) : ;; *) FFF="" ;; esac + make_subsitemap_list "$FF" "$FFF" + scan_subsitemap_long "$FF" "$FFF" + ;; esac } scan_httpspec () @@ -1521,11 +2076,10 @@ skip_httpspec () head_sed_sitemap() # $filename $section { - FF="$1" + FF=`sed_piped_key "$1"` SECTION=`sed_slash_key "$2"` - SECTS="" ; SECTN="" # lines with hrefs - echo "/^$SECTS.*/s|||" # $++ - echo "/^$SECTS.*/s|.*\\)|\\1|" # $++ test ".$sectiontab" != ".no" && \ echo "/ href=\"$SECTION\"/s|^/s|||" # $++ - echo "/^$SECTS.*/s|.*\\)|\\1|" # $++ test ".$sectiontab" != ".no" && \ echo "/ href=\"$SECTION\"/s|^\)|\1|" # after that all the (still) numeric SECTNs are deactivated / killed. for section in $SECTION $headsection $tailsection ; do test ".$section" = ".no" && continue - $SED -e "/^=sect=[^ ]* $section/!d" \ - -e "s, .*,\"\\\\)|\\\\1|," \ - -e "s,^=sect=,s|^$SECTS\\\\(.*[^ ]* $section/!d" \ + -e "s|<$Q'sect'>||" -e "s| .*||" \ + -e "s/.*/s|name:[^ ]* $section/!d" \ + -e "s|<$Q'sect'>name:||" -e "s| .*||" \ + -e "s/.*/s|]*>\\).*||" # $++ - echo "/^$SECTS.*/s|||" # $++ - echo "/^$SECTS.*/s|]*\\)>.*||" # $++ + echo "s|.*]*\\)>.*||" # $++ + echo "s|\\(\\)|\\1|" # $++ test ".$sectiontab" != ".no" && \ echo "/ href=\"$SECTION\"/s|^ $MK_VARS # have vars substituted info2meta_sed > $MK_META # add values - if test ".$simplevars" = ".warn" ; then - info2test_sed > $MK_TEST # check vars old-style - $SED_LONGSCRIPT "$MK_TEST" "$SOURCEFILE" | tee -a "$MK_OLDS" ; fi F_HEAD="$tmp/$F.$HEAD" ; F_FOOT="$tmp/$F.$FOOT" $CAT "$MK_PUTS" > "$F_HEAD" head_sed_sitemap "$F" "`info_get_entry_section`" >> "$F_HEAD" @@ -1601,31 +2156,30 @@ make_htmlfile() # "$F" SOURCEFILE=`html_sourcefile "$F"` # 2.PASS if test "$SOURCEFILE" != "$F" ; then if test -f "$SOURCEFILE" ; then - if grep '/dev/null ; then - echo "$SOURCEFILE: SKIP, this sourcefile looks like a formatted file" - echo "$SOURCEFILE: (may be a sourcefile in place of a targetfile?)" + if grep ' $NULL ; then + echo "'$SOURCEFILE': SKIP, this sourcefile looks like a formatted file" + echo "'$SOURCEFILE': (may be a sourcefile in place of a targetfile?)" return fi info2vars_sed > $MK_VARS # have vars substituted info2meta_sed > $MK_META # add values - if test ".$simplevars" = ".warn" ; then - info2test_sed > $MK_TEST # check vars old-style - $SED_LONGSCRIPT "$MK_TEST" "$SOURCEFILE" | tee -a "$MK_OLDS" ; fi + tags2span_sed > $MK_SPAN # extern text/css -> intern css classes + tags2meta_sed >>$MK_META # extern text/css -> intern css classes F_HEAD="$tmp/$F.$HEAD" ; F_BODY="$tmp/$F.$BODY" ; F_FOOT="$tmp/$F.$FOOT" $CAT "$MK_PUTS" > "$F_HEAD" case "$sectionlayout" in multi) head_sed_multisection "$F" "`info_get_entry_section`" >> "$F_HEAD" ;; *) head_sed_listsection "$F" "`info_get_entry_section`" >> "$F_HEAD" ;; esac - $CAT "$MK_VARS" "$MK_TAGS" >> "$F_HEAD" #tag and vars + $CAT "$MK_VARS" "$MK_TAGS" "$MK_SPAN" >> "$F_HEAD" #tag and vars echo "/<\\/body>/d" >> "$F_HEAD" #cut lastline echo "//r $MK_META" >> "$F_HEAD" #add metatags echo "//d" > "$F_BODY" #not that line - $CAT "$MK_VARS" "$MK_TAGS" >> "$F_BODY" #tag and vars + $CAT "$MK_VARS" "$MK_TAGS" "$MK_SPAN" >> "$F_BODY" #tag and vars bodymaker_for_sectioninfo >> "$F_BODY" #if sectioninfo info2body_sed >> "$F_BODY" #cut early info2head_sed >> "$F_HEAD" - $CAT "$tmp/$F.$FAST" >> "$F_HEAD" + make_back_path "$F" >> "$F_HEAD" test ".$emailfooter" != ".no" && \ body_for_emailfooter > "$F_FOOT" @@ -1646,15 +2200,14 @@ make_printerfriendly () # "$F" { # PRINTER printsitefile="0" # FRIENDLY P=`html_printerfile "$F"` - F_FAST="$tmp/$F.$FAST" P_HEAD="$tmp/$P.$HEAD" P_BODY="$tmp/$P.$BODY" case "$F" in - ${SITEFILE}|${SITEFILE}l) make_fast "$F" > "$F_FAST" + ${SITEFILE}|${SITEFILE}l) printsitefile=">=>" ; BODY_TXT="$tmp/$F.$FOOT" ;; *.html) printsitefile="=>" ; BODY_TXT="$SOURCEFILE" ;; esac - if grep '<meta name="formatter"' "$BODY_TXT" >/dev/null ; then return; fi + if grep '<meta name="formatter"' "$BODY_TXT" > $NULL ; then return; fi if test ".$printsitefile" != ".0" && test -f "$SOURCEFILE" ; then make_printerfile_fast "$FILELIST" > ./$MK_FAST $CAT "$MK_VARS" "$MK_TAGS" "$MK_FAST" > "$P_HEAD" @@ -1663,15 +2216,13 @@ make_printerfriendly () # "$F" echo "/<head>/r $MK_METT" >> "$P_HEAD" # meta echo "/<\\/body>/d" >> "$P_HEAD" select_in_printsitefile "$F" >> "$P_HEAD" - _ext_=`print_extension "$printerfriendly"` # head- - $SED -e "s/[.]html\"|/$_ext_&/g" "$F_FAST" >> "$P_HEAD" # hrefs - # line_=`sed_slash_key "$printsitefile_img_2"` # back- + _ext_=`print_extension "$printerfriendly"` # head- + # line_=`sed_slash_key "$printsitefile_img_2"` # back- echo "/||topics:/s| href=\"[#][.]\"| href=\"$F\"|" >> "$P_HEAD" echo "/|||pages:/s| href=\"[#][.]\"| href=\"$F\"|" >> "$P_HEAD" - $CAT "$F_FAST" >> "$P_HEAD" # subdir + make_back_path "$F" >> "$P_HEAD" $CAT "$MK_VARS" "$MK_TAGS" "$MK_FAST" > "$P_BODY" - $SED -e "s/[.]html\"|/$_ext_&/g" "$F_FAST" >> "$P_BODY" # body- - $CAT "$F_FAST" >> "$P_BODY" # hrefs + make_back_path "$F" >> "$P_BODY" mkpathfile "$P" $SED_LONGSCRIPT "$P_HEAD" $PRINTSITEFILE > $P # ~head~ @@ -1693,29 +2244,42 @@ make_sitemap_list make_sitemap_sect make_sitemap_page +if test -d DEBUG && test -f "$MK_DATA" +then FFFF=`echo "$F" | sed -e "s,/,:,g"` + cp "$MK_DATA" "DEBUG/$FFFF.DATA.tmp.htm" +fi + FILELIST=`echo_site_filelist` if test ".$opt_filelist" != "." || test ".$opt_list" = ".file"; then for F in $FILELIST; do echo "$F" ; done ; exit # --filelist fi if test ".$opt_files" != "." ; then FILELIST="$opt_files" ; fi # --files -if test ".$FILELIST" = "."; then echo "nothing to do" >&2 ; fi -if test ".$FILELIST" = ".SITEFILE" ; then echo "only '$SITEFILE'?!" >&2 ; fi +if test ".$FILELIST" = "."; then warn "nothing to do (no --filelist)" ; fi +if test ".$FILELIST" = ".SITEFILE" ; then warn "only '$SITEFILE'?!" ; fi for F in $FILELIST ; do case "$F" in #### 1. PASS name:*) scan_namespec "$F" ;; -http:*|*://*) scan_httpspec "$F" ;; +http:*|https:*|ftp:*|mailto:*|telnet:*|news:*|gopher:*|wais:*) + scan_httpspec "$F" ;; ${SITEFILE}|${SITEFILE}l) scan_sitefile "$F" ;; # ........... SCAN SITE +*@*.de) + echo "!! -> '$F' (skipping malformed mailto:-link)" + ;; ../*) echo "!! -> '$F' (skipping topdir build)" ;; # */*.html) -# make_fast > $F.$FAST # try for later subdir build # echo "!! -> '$F' (skipping subdir build)" # ;; # */*/*/|*/*/|*/|*/index.htm|*/index.html) # echo "!! -> '$F' (skipping subdir index.html)" # ;; -*.html) scan_htmlfile "$F" ;; # ........... SCAN HTML +*.html) scan_htmlfile "$F" # ........... SCAN HTML + if test ".$opt_xml" != "." ; then + F=`echo "$F" | sed -e "s/\\.html$/.xml/"` + scan_xmlfile "$F" + fi ;; +*.xml) scan_xmlfile "$F" ;; */) echo "'$F' : directory - skipped" site_map_list_title "$F" "`sed_slash_key $F`" site_map_long_title "$F" "(directory)" @@ -1731,15 +2295,19 @@ if test ".$printerfriendly" != "." ; then # .......... PRINT VERSION make_printsitefile > "$PRINTSITEFILE" fi -if test ".$simplevars" = ". " ; then -mknewfile $MK_OLDS -fi - for F in $FILELIST ; do case "$F" in #### 2. PASS name:*) skip_namespec "$F" ;; -http:*|*://*) skip_httpspec "$F" ;; +http:*|https:*|ftp:*|mailto:*|telnet:*|news:*|gopher:*|wais:*) + skip_httpspec "$F" ;; ${SITEFILE}|${SITEFILE}l) make_sitefile "$F" # ........ SITE FILE - if test ".$printerfriendly" != "." ; then make_printerfriendly "$F" ; fi ;; + if test ".$printerfriendly" != "." ; then make_printerfriendly "$F" ; fi + if test ".$opt_xml" != "." ; then _old_F_="$F" + F=`echo "$F" | sed -e "s/\\.html$/.xml/"` + make_xmlmaster "$F" ;F="$_old_F_" + fi ;; +*@*.de) + echo "!! -> '$F' (skipping malformed mailto:-link)" + ;; ../*) echo "!! -> '$F' (skipping topdir build)" ;; @@ -1750,7 +2318,12 @@ ${SITEFILE}|${SITEFILE}l) make_sitefile "$F" # ........ SITE FILE # echo "!! -> '$F' (skipping subdir index.html)" # ;; *.html) make_htmlfile "$F" # .................. HTML FILES - if test ".$printerfriendly" != "." ; then make_printerfriendly "$F" ; fi ;; + test ".$printerfriendly" != "." && make_printerfriendly "$F" + if test ".$opt_xml" != "." ; then _old_F_="$F" + F=`echo "$F" | sed -e "s/\\.html$/.xml/"` + make_xmlfile "$F" ;F="$_old_F_" + fi ;; +*.xml) make_xmlfile "$F" ;; */) echo "'$F' : directory - skipped" ;; *) echo "?? -> '$F'" @@ -1758,32 +2331,25 @@ ${SITEFILE}|${SITEFILE}l) make_sitefile "$F" # ........ SITE FILE esac # .............. debug .................... if test -d DEBUG && test -f "./$F" ; then - FFFF=`echo "$F" | sed -e s,/,:,g` - cp "$tmp/$F.$INFO" DEBUG/$FFFF.info.TMP - for P in tags vars meta page date list html sect info ; do - test -f $tmp/$MK.$P.tmp && cp $tmp/$MK.$P.tmp DEBUG/$FFFF.$P.tmp - test -f $tmp/$MK.$P.TMP && cp $tmp/$MK.$P.TMP DEBUG/$FFFF.$P.TMP + FFFF=`echo "$F" | sed -e "s,/,:,g"` + test -f "$tmp/$F.$DATA" && cp "$tmp/$F.$DATA" DEBUG/$FFFF.data.tmp.htm + test -f "$tmp/$F.$HEAD" && cp "$tmp/$F.$HEAD" DEBUG/$FFFF.head.tmp.sed + test -f "$tmp/$F.$BODY" && cp "$tmp/$F.$BODY" DEBUG/$FFFF.body.tmp.sed + test -f "$tmp/$F.$FOOT" && cp "$tmp/$F.$FOOT" DEBUG/$FFFF.foot.tmp.sed + for P in tags vars span meta page date list html sect \ + data head body foot fast xmlmapping \ + gets puts site mett sect1 sect2 sect3 style ; do + test -f $tmp/$MK.$P.tmp.htm && cp $tmp/$MK.$P.tmp.htm DEBUG/$FFFF.$P.tmp.htm + test -f $tmp/$MK.$P.tmp.sed && cp $tmp/$MK.$P.tmp.sed DEBUG/$FFFF.$P.tmp.sed done fi done -if test ".$simplevars" = ".warn" ; then if test -f "$MK_OLDS" ; then -oldvars=`cat "$MK_OLDS" | wc -l | $SED -e "s/ *//g"` -if test "$oldvars" = "0" ; then -echo "HINT: you have no simplevars in your htm sources, so you may want to" -echo "hint: set the magic <!--mksite:nosimplevars--> in your $SITEFILE" -echo "hint: which makes execution _faster_ actually in the 2. pass" -echo "note: simplevars expansion was the oldstyle way of variable expansion" -else -echo "HINT: there were $oldvars simplevars found in your htm sources." -echo "hint: This style of variable expansion will be disabled in the near" -echo "hint: future. If you do not want change then add the $SITEFILE magic" -echo "hint: <!--mksite:simplevars--> somewhere to suppress this warning" -echo "note: simplevars expansion will be an explicit option in the future." -echo "note: errornous simplevar detection can be suppressed with a magic" -echo "note: hint of <!--mksite:nosimplevars--> in the $SITEFILE for now." -fi fi fi - -rm $tmp/$MK.*.tmp +if test ".$opt_keeptmpfiles" = "." ; then + for i in $tmp/$MK.*.tmp.htm $tmp/$MK.*.tmp.sed \ + $tmp/$MK.*.tmp.css $tmp/$MK.*.tmp.txt + do test -f "$i" && rm "$i" + done +fi if test ".$tmp_dir_was_created" != ".no" ; then rm $tmp/* ; rmdir $tmp ; fi exit 0 diff --git a/docs/zzipdoc/commentmarkup.py b/docs/zzipdoc/commentmarkup.py index d9444c2..3f605a7 100644 --- a/docs/zzipdoc/commentmarkup.py +++ b/docs/zzipdoc/commentmarkup.py @@ -7,11 +7,9 @@ def markup_link_syntax(text): >> r"\1<link>\2</link>" & Match(r"(?m)(^|\s)\=\>\'([^\']*)\'") >> r"\1<link>\2</link>" - & Match(r"(?m)(^|\s)\=\>\s(\w[\w.]*\w\([^\(\)]*\))") + & Match(r"(?m)(^|\s)\=\>\s(\w[\w.]*\w\(\d+\))") >> r"\1<link>\2</link>" - & Match(r"(?m)(^|\s)\=\>\s(\w[\w.]*\w)\b") - >> r"\1<link>\2</link>" - & Match(r"(?m)(^|\s)\=\>\s([^\s\,\.\!\?\:\;\<\>\&\'\=\-]+)") + & Match(r"(?m)(^|\s)\=\>\s([^\s\,\.\!\?]+)") >> r"\1<link>\2</link>") class CommentMarkup: @@ -44,7 +42,7 @@ class CommentMarkup: if mode: text += "</"+mode+">" mode = "ul" ; text += "<"+mode+">" line = check.group(1) - text += "<li> "+self.markup_para_line(line)+" </li>\n" + text += "<li><p> "+self.markup_para_line(line)+" </p></li>\n" elif line & check(r"^\s?\s?\s?[*](.*)"): if mode != "para": if mode: text += "</"+mode+">" @@ -64,6 +62,7 @@ class CommentMarkup: & Match(r"(<para>)(\s*[R]eturns)") >>r"\1This function\2" & Match(r"(?s)<para>\s*</para><para>") >> "<para>" & Match(r"(?s)<screen>\s*</screen>") >> "") + return True def markup_screen_line(self, line): return self.markup_line(line.replace("&","&") .replace("<","<") diff --git a/docs/zzipdoc/docbookdocument.py b/docs/zzipdoc/docbookdocument.py new file mode 100644 index 0000000..c4602ad --- /dev/null +++ b/docs/zzipdoc/docbookdocument.py @@ -0,0 +1,95 @@ +#! /usr/bin/env python +# -*- coding: UTF-8 -*- +from match import Match + +class DocbookDocument: + """ binds some xml content page with additional markup - in this + variant we set the rootnode container to 'reference' and the DTD + to the Docbook 4.1.2 version. Modify as you like.""" + has_title_child = [ "book", "chapter", "section", "reference" ] + docbook_dtd = ( + ' PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"'+"\n"+ + ' "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"') + def __init__(self, o, filename = None): + self.o = o + self.rootnode = "reference" + self.filename = filename + self.title = "" + self.text = [] + def add(self, text): + """ add some content """ + self.text += [ text ] + return self + def get_title(self): + if self.title: return title + try: return self.text[0].get_title() + except Exception, e: pass + return self.title + def _xml_doctype(self, rootnode): + return "<!DOCTYPE "+rootnode+self.docbook_dtd+">" + def _xml_text(self, xml): + """ accepts adapter objects with .xml_text() """ + try: return xml.xml_text() + except Exception, e: print "DocbookDocument/text", e; pass + return str(xml) + def _fetch_rootnode(self, text): + fetch = Match(r"^[^<>]*<(\w+)\b") + if text & fetch: return fetch[1] + return self.rootnode + def _filename(self, filename): + if filename is not None: + self.filename = filename + filename = self.filename + if not filename & Match(r"\.\w+$"): + ext = self.o.docbook + if not ext: ext = "docbook" + filename += "."+ext + return filename + def save(self, filename = None): + filename = self._filename(filename) + print "writing '"+filename+"'" + if len(self.text) > 1: + self.save_all(filename) + else: + self.save_text(filename, self.text[0]) + def save_text(self, filename, text): + try: + fd = open(filename, "w") + xml_text = self._xml_text(text) + rootnode = self._fetch_rootnode(xml_text) + doctype = self._xml_doctype(rootnode) + print >>fd, doctype + print >>fd, xml_text + fd.close() + return True + except IOError, e: + print "could not open '"+filename+"'file", e + return False + def save_all(self, filename): + assert len(self.text) > 1 + try: + fd = open(filename, "w") + xml_text = self._xml_text(self.text[0]) + rootnode = self._fetch_rootnode(xml_text) + if rootnode == self.rootnode: + rootnode = "book" + else: + rootnode = self.rootnode + doctype = self._xml_doctype(rootnode) + print >>fd, doctype + title = self.get_title() + if title and self.rootnode in self.has_title_child: + print >>fd, "<"+self.rootnode+'><title>'+title+'' + elif title: + print >>fd, "<"+self.rootnode+' id="'+title+'">' + else: + print >>fd, "<"+self.rootnode+'>' + for text in self.text: + text = self._xml_text(text) + print >>fd, text + print >>fd, "" + fd.close() + return True + except IOError, e: + print "could not open '"+filename+"'file", e + return False diff --git a/docs/zzipdoc/functionheader.py b/docs/zzipdoc/functionheader.py index 8e6bf2f..81bb385 100644 --- a/docs/zzipdoc/functionheader.py +++ b/docs/zzipdoc/functionheader.py @@ -46,7 +46,6 @@ class FunctionHeader: self.titleline = line[:x] for also in line[x+5:].split(","): self.alsolist += [ also.strip() ] - print "[[[", self.alsolist, "}}}", self.titleline self._alsolist = self.alsolist return True def get_alsolist(self): diff --git a/docs/zzipdoc/functionlisthtmlpage.py b/docs/zzipdoc/functionlisthtmlpage.py index e4dd4ec..4ec9178 100644 --- a/docs/zzipdoc/functionlisthtmlpage.py +++ b/docs/zzipdoc/functionlisthtmlpage.py @@ -24,6 +24,7 @@ class FunctionListHtmlPage: self.anchors = [] self.o = o if self.o is None: self.o = Options() + self.not_found_in_anchors = [] def cut(self): self.text += ("
"+self._ul_start+self.head+self._ul_end+"
"+ "
"+self._ul_start+self.body+self._ul_end+"
") @@ -33,7 +34,9 @@ class FunctionListHtmlPage: name = entry.get_name() head_text = entry.head_xml_text() body_text = entry.body_xml_text(name) - assert head_text + if not head_text: + print "no head_text for", name + return try: prespec = entry.head_get_prespec() namespec = entry.head_get_namespec() @@ -47,9 +50,9 @@ class FunctionListHtmlPage: title = entry.get_title() filename = entry.get_filename().replace("../","") if title: - extraline = (self._null_table100+''+ - ' '+title+''+ - ' '+ + subtitle = ' '+title+'' + extraline = (self._null_table100+' '+subtitle+' '+ + ' '+ ''+filename+''+ '') body_text = extraline + body_text @@ -70,18 +73,20 @@ class FunctionListHtmlPage: self.toc += self._li_start+self.sane(link(head_text))+self._li_end self.head += self._li_start+self.sane(here(head_text))+self._li_end self.body += self._li_start+self.sane(body_text)+self._li_end + def get_title(self): + return self.o.package+" Library Functions" def xml_text(self): self.cut() - title=self.o.package+" Library Functions" - return (""+title+"" - "

"+title+"

"+ + return ("

"+self.get_title()+"

"+ self.version_line()+ self.mainheader_line()+ self._ul_start+ self.resolve_links(self.toc)+ self._ul_end+ - "

Documentation

"+self.resolve_links(self.text)+ - "
") + "

Documentation

"+ + "
"+ + self.resolve_links(self.text)+ + "
") def version_line(self): if self.o.version: return "

Version "+self.o.version+"

" @@ -96,6 +101,8 @@ class FunctionListHtmlPage: >> (lambda x: self.resolve_external(x.group(1), x.group(2)))) text &= (Match("(?s)(\w+)") >> (lambda x: self.resolve_internal(x.group(1)))) + if len(self.not_found_in_anchors): + print "not found in anchors: ", self.not_found_in_anchors return (text & Match("(?s)([^<>]*)") >> "\\1") def resolve_external(self, func, sect): @@ -110,7 +117,8 @@ class FunctionListHtmlPage: def resolve_internal(self, func): if func in self.anchors: return '
'+func+"" - print "not in anchors '"+func+"'" + if func not in self.not_found_in_anchors: + self.not_found_in_anchors += [ func ] return ""+func+"" def sane(self, text): return (text diff --git a/docs/zzipdoc/functionlistreference.py b/docs/zzipdoc/functionlistreference.py index ec94840..944d005 100644 --- a/docs/zzipdoc/functionlistreference.py +++ b/docs/zzipdoc/functionlistreference.py @@ -1,36 +1,32 @@ +#! /usr/bin/env python +# -*- coding: UTF-8 -*- from match import Match from htm2dbk import * -def _to_word(text): - return text & Match("[^\w]+") >> "_" - class FunctionListReference: """ Creating a docbook-style list of parts that will each be translated into a unix manual page in a second step """ - doctype = ( - ''+ - "\n") def __init__(self, o = None): self.o = o self.pages = [] self.entry = None - self.overview = None def cut(self): if not self.entry: return self.pages += [ self.entry ] self.entry = None def add(self, entry): + name = entry.get_name() + description = entry.body_xml_text(name) + funcsynopsis = entry.head_xml_text() + if not funcsynopsis: + print "no funcsynopsis for", name + return if self.entry is None: self.entry = FunctionListRefEntry(entry, self.o) self.entry.funcsynopsisinfo = entry.get_mainheader() self.entry.refpurpose = entry.get_title() self.entry.refentrytitle = entry.get_name() # self.entry.refname = entry.get_name() - name = entry.get_name() - description = entry.body_xml_text(name) - funcsynopsis = entry.head_xml_text() self.entry.funcsynopsis_list += [ funcsynopsis ] self.entry.description_list += [ description ] self.entry.refname_list += [ name ] @@ -38,30 +34,18 @@ class FunctionListReference: for item in entry.list_seealso(): if item not in self.entry.seealso_list: self.entry.seealso_list += [ item ] - def add_overview(self, entry): - if self.overview is None: - title = entry.get_mainheader() & Match(".*<(.*)>.*") >> "\\1" - self.overview = FunctionListRefEntry(entry, self.o) - self.overview.funcsynopsisinfo = entry.get_mainheader() - self.overview.refpurpose = self.o.package.strip() - self.overview.refentrytitle = title - self.overview.refname = _to_word(title) - description = entry.get_title().strip() & Match("^[.]+") >> "" - funcsynopsis = entry.head_xml_text() - self.overview.funcsynopsis_list += [ funcsynopsis ] - if description: - self.overview.description_list += [ - " - "+ description +"" ] + def get_title(self): + return self.o.package+" Function List" def xml_text(self): - T = self.doctype - T += ""+self.o.package+" Function List\n" + T = ""+self.get_title()+"\n" for item in self.pages: - T += self.sane(item.refentry_text()) - T += self.sane(self.overview.refentry_text()) + text = item.refentry_text() + if not text: "OOPS, no text for", item.name ; continue + T += self.sane(text) T += "\n" return T def sane(self, text): - return (html2docbook(text).replace("->","->") + return (html2docbook(text) .replace("","") .replace("","") .replace("","") @@ -71,9 +55,7 @@ class FunctionListReference: .replace("","") .replace("","") .replace("","") - .replace("","")) & ( - Match("((?:.(?!(") - >> "\\1") + .replace("","")) class FunctionListRefEntry: @@ -86,10 +68,10 @@ class FunctionListRefEntry: self.name = func.get_name() self.refhint = "\n\n" self.refentry = None - self.refentry_date = o.version.strip() # //refentryinfo/date - self.refentry_productname = o.package.strip() # //refentryinfo/prod* - self.refentry_title = None # //refentryinfo/title - self.refentryinfo = None # override + self.refentry_date = o.version.strip() #! //refentryinfo/date + self.refentry_productname = o.package.strip() #! //refentryinfo/prod* + self.refentry_title = None #! //refentryinfo/title + self.refentryinfo = None #! override self.manvolnum = "3" # //refmeta/manvolnum self.refentrytitle = None # //refmeta/refentrytitle self.refmeta = None # override diff --git a/docs/zzipdoc/functionprototype.py b/docs/zzipdoc/functionprototype.py index 5924ce8..fda85bb 100644 --- a/docs/zzipdoc/functionprototype.py +++ b/docs/zzipdoc/functionprototype.py @@ -54,6 +54,7 @@ class FunctionPrototype: if not self._assert_parsed(): return None return self.name def xml_text(self): + if not self.namespec: return self.namespec return (""+self.prespec+""+ ""+self.namespec+""+ ""+self.callspec+"") diff --git a/docs/zzipdoc/htm2dbk.py b/docs/zzipdoc/htm2dbk.py index b4a4e2e..ec9685b 100644 --- a/docs/zzipdoc/htm2dbk.py +++ b/docs/zzipdoc/htm2dbk.py @@ -90,14 +90,14 @@ class htm2dbk_conversion_base: m()(r"") >> "", m()(r"") >> "", m()(r"(?s)\s*") >> "", - # m()(r"
    ") >> "", - # m()(r"
") >> "", - # m()(r"
  • ") >> "", - # m()(r"
  • ") >> "
    \n", - m()(r"
      ") >> "\n", - m()(r"
    ") >> "", - m()(r"
  • ") >> "", - m()(r"
  • ") >> "" + # m()(r"
      ") >> "\n", + # m()(r"
    ") >> "", + m()(r"
      ") >> "", + m()(r"
    ") >> "", + # m()(r"
  • ") >> "", + # m()(r"
  • ") >> "" + m()(r"
  • ") >> "", + m()(r"
  • ") >> "
    \n", ] class htm2dbk_conversion(htm2dbk_conversion_base): def __init__(self): diff --git a/docs/zzipdoc/htmldocument.py b/docs/zzipdoc/htmldocument.py new file mode 100644 index 0000000..47d58dc --- /dev/null +++ b/docs/zzipdoc/htmldocument.py @@ -0,0 +1,117 @@ +#! /usr/bin/env python +# -*- coding: UTF-8 -*- +from match import Match + +class HtmlDocument: + """ binds some html content page with additional markup - in this + base version it is just the header information while other variants + might add navigation items around the content block elements """ + def __init__(self, o, filename = None): + self.o = o + self.filename = filename + self.title = "" + self.meta = [] + self.style = [] + self.text = [] + self.navi = None + def meta(self, style): + """ add some header meta entry """ + self.meta += [ meta ] + return self + def style(self, style): + """ add a style block """ + self.style += [ style ] + return self + def add(self, text): + """ add some content """ + self.text += [ text ] + return self + def get_title(self): + if self.title: return self.title + try: return self.text[0].get_title() + except Exception, e: pass + return self.title + def _html_meta(self, meta): + """ accepts adapter objects with .html_meta() """ + try: return meta.html_meta() + except Exception, e: pass + return str(meta) + def _html_style(self, style): + """ accepts adapter objects with .html_style() and .xml_style() """ + ee = None + try: return style.html_style() + except Exception, e: ee = e; pass + try: return style.xml_style() + except Exception, e: print "HtmlDocument/style", ee, e; pass + try: return str(style) + except Exception, e: print "HtmlDocument/style", e; return "" + def _html_text(self, html): + """ accepts adapter objects with .html_text() and .xml_text() """ + ee = None + try: return html.html_text() + except Exception, e: ee = e; pass + try: return html.xml_text() + except Exception, e: print "HtmlDocument/text", ee, e; pass + try: return str(html) + except Exception, e: print "HtmlDocument/text", e; return " " + def navigation(self): + if self.navi: + return self.navi + if self.o.body: + try: + fd = open(self.o.body, "r") + self.navi = fd.read() + fd.close() + return self.navi + except Exception, e: + pass + return None + def html_header(self): + navi = self.navigation() + if not navi: + T = "" + title = self.get_title() + if title: + T += ""+title+"" + T += "\n" + for style in self.style: + T += self._html_style(style) + T += "\n" + return T+"" + else: + title = self.get_title() + return navi & ( + Match(r"") >> " - "+title) & ( + Match(r"") >> self.o.version) & ( + Match(r"(?m).*") >> "") + def html_footer(self): + navi = self.navigation() + if not navi: + return "" + else: + return navi & ( + Match(r"(?m)(.*)") >> "%&%&%&%\\1") & ( + Match(r"(?s).*%&%&%&%") >> "") + def _filename(self, filename): + if filename is not None: + self.filename = filename + filename = self.filename + if not filename & Match(r"\.\w+$"): + ext = self.o.html + if not ext: ext = "html" + filename += "."+ext + return filename + def save(self, filename = None): + filename = self._filename(filename) + print "writing '"+filename+"'" + try: + fd = open(filename, "w") + print >>fd, self.html_header() + for text in self.text: + print >>fd, self._html_text(text) + print >>fd, self.html_footer() + fd.close() + return True + except IOError, e: + print "could not open '"+filename+"'file", e + return False diff --git a/docs/zziplib-manpages.dbk b/docs/zziplib-manpages.dbk new file mode 100644 index 0000000..d3c8998 --- /dev/null +++ b/docs/zziplib-manpages.dbk @@ -0,0 +1,12 @@ + + + ZZIPlib Manual Pages + + + + + diff --git a/zzip/file.c b/zzip/file.c index d8c1dc8..b80be7c 100644 --- a/zzip/file.c +++ b/zzip/file.c @@ -619,11 +619,11 @@ zzip_freopen(zzip_char_t* filename, zzip_char_t* mode, ZZIP_FILE* stream) * There was a possibility to transfer zziplib-specific openmodes * through o_flags but you should please not use them anymore and * look into => zzip_open_ext_io to submit them down. This function - * is shallow in that it just extracts the zzipflags and calls
    • - * zzip_open_ext_io(filename, o_flags, zzipflags|0664, 0, 0) - *

    you must stop using this extra functionality (not well - * known anyway) since zzip_open might be later usable to open files - * for writing in which case the _EXTRAFLAGS will get in conflict. + * is shallow in that it just extracts the zzipflags and calls + * * zzip_open_ext_io(filename, o_flags, zzipflags|0664, 0, 0) + * you must stop using this extra functionality (not well known anyway) + * since zzip_open might be later usable to open files for writing + * in which case the _EXTRAFLAGS will get in conflict. * * compare with => open(2) and => zzip_fopen */ diff --git a/zziplib.spec b/zziplib.spec index 58f02b6..d0571f1 100644 --- a/zziplib.spec +++ b/zziplib.spec @@ -2,9 +2,8 @@ Summary: ZZipLib - libZ-based ZIP-access Library Name: zziplib Version: 0.13.48 -Release: 1.suse100 -Serial: 1 -Copyright: LGPL +Release: 1 +License: LGPL Group: Development/Libraries URL: http://zziplib.sf.net Vendor: Guido Draheim @@ -75,54 +74,23 @@ Requires: zziplib-%lib = %version # fixing relink problems during install too LDFLAGS="-L%buildroot%_libdir" \ CFLAGS="$RPM_OPT_FLAGS" \ -sh configure --prefix=%{_prefix} --enable-sdl --disable-builddir \ - --with-docdir=%{_docdir} --mandir=%{_mandir} TIMEOUT=9 -cp -a zzip zzip64 +sh configure --prefix=%{_prefix} --with-docdir=%{_docdir} --mandir=%{_mandir} \ + --enable-sdl TIMEOUT=9 +make zzip64-setup %build -%define _FILE_OFFSET64 -D_ZZIP_LARGEFILE -D_FILE_OFFSET_BITS=64 -%define _RELEASEINFO64 "RELEASE_INFO=-release 0-64" -%define _CFLAGS_OFFSET64 "AM_CFLAGS=%_FILE_OFFSET64" -make -(cd zzip64 && make %_CFLAGS_OFFSET64 %_RELEASEINFO64) +make +make zzip64-build make doc %install rm -rf %{buildroot} -(cd zzip64 && make install %_RELEASEINFO64 DESTDIR=%{buildroot}) -(cd %buildroot/%_libdir && mv libzzip.so libzzip64.so) -(cd %buildroot/%_libdir && mv libzzip.a libzzip64.a) -(cd %buildroot/%_libdir && \ -sed -e 's/zzip.so/zzip64.so/' -e 's/zzip.a/zzip64.a/' libzzip.la >libzzip64.la) -(cd %buildroot/%_libdir/pkgconfig && \ -sed -e 's/largefile=/largefile= %_FILE_OFFSET64/' \ - -e 's/-lzzip/-lzzip64/' -e 's/zziplib/zziplib64/' zziplib.pc >zziplib64.pc) - +make zzip64-install DESTDIR=%{buildroot} make install DESTDIR=%{buildroot} -(cd %buildroot/%_libdir && mv libzzip.so libzzip32.so) -(cd %buildroot/%_libdir && mv libzzip.a libzzip32.a) -(cd %buildroot/%_libdir && ln -s libzzip32.so libzzip.so) -(cd %buildroot/%_libdir && ln -s libzzip32.a libzzip.a) -(cd %buildroot/%_libdir && \ -sed -e 's/zzip.so/zzip32.so/' -e 's/zzip.a/zzip32.a/' libzzip.la >libzzip32.la) -(cd %buildroot/%_libdir/pkgconfig && \ -sed -e 's/-lzzip/-lzzip32/' -e 's/zziplib/zziplib32/' zziplib.pc >zziplib32.pc) - -# the 12.8x and 11.8x and 10.8x packages are all the same actually -(cd %buildroot/%_libdir && \ -(for i in libzzip*.so.1? ; do : \ -; v10=`echo $i | sed -e "s/.so.../.so.10/"` \ -; v11=`echo $i | sed -e "s/.so.../.so.11/"` \ -; v12=`echo $i | sed -e "s/.so.../.so.12/"` \ -; test ! -e $v10 && test -e $v12 && ln -s $v12 $v10 \ -; test ! -e $v12 && test -e $v10 && ln -s $v10 $v12 \ -; ln -s $v10 $v11 || true; done)) - +make zzip32-postinstall DESTDIR=%{buildroot} +make zzip-postinstall make install-doc DESTDIR=%{buildroot} -make install-man3 DESTDIR=%{buildroot} - -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig +make install-mans DESTDIR=%{buildroot} %clean rm -rf %{buildroot} @@ -131,9 +99,14 @@ rm -rf %{buildroot} %defattr(-,root,root) %{_libdir}/lib*.so.* +%post %lib +/sbin/ldconfig || true +%postun %lib +/sbin/ldconfig || true + %files doc %defattr(-,root,root) - %{_datadir}/groups/* + %{_datadir}/doc/* %dir %{_datadir}/omf/%{name} %{_datadir}/omf/%{name}/* %post doc