Commits

Anonymous committed 09755da

r4999@telaviv1: shlomi | 2008-05-12 09:46:57 +0300
Added the DocBook/XML build-system to create the PDFs, FOs etc. out of
the *.xml's.

  • Participants
  • Parent commits 06f08fe

Comments (0)

Files changed (8)

 SCREENPLAY_XMLS = $(patsubst %,lib/screenplay-xml/xml/%.xml,$(SCREENPLAY_DOCS))
 SCREENPLAY_HTMLS = $(patsubst %,lib/screenplay-xml/html/%.html,$(SCREENPLAY_DOCS))
 
+DOCBOOK_FO_DIR = lib/docbook/fo
+DOCBOOK_FOS = $(patsubst %,$(DOCBOOK_FO_DIR)/%.fo,$(DOCBOOK_DOCS))
+
+DOCBOOK_PDF_DIR = lib/docbook/pdf
+DOCBOOK_PDFS = $(patsubst %,$(DOCBOOK_PDF_DIR)/%.pdf,$(DOCBOOK_DOCS))
+
 # SCREENPLAY_DOCBOOK_HTMLS = $(patsubst %,lib/docbook/essays/%/all-in-one.html,$(SCREENPLAY_DOCS))
 SCREENPLAY_DOCBOOK_HTMLS = 
 
 
 SCREENPLAY_SOURCES_ON_DEST = $(T2_DEST)/humour/TOWTF/TOW_Fountainhead_1.txt $(T2_DEST)/humour/TOWTF/TOW_Fountainhead_2.txt $(T2_DEST)/humour/humanity/Humanity-Movie.txt $(T2_DEST)/humour/Star-Trek/We-the-Living-Dead/star-trek--we-the-living-dead.txt
 
-docbook_targets: $(DOCBOOK_TARGETS) $(ST_WTLD_TEXT_IN_TREE) $(SCREENPLAY_RENDERED_HTMLS) $(SCREENPLAY_SOURCES_ON_DEST)
+docbook_targets: $(DOCBOOK_TARGETS) $(ST_WTLD_TEXT_IN_TREE) $(SCREENPLAY_RENDERED_HTMLS) $(SCREENPLAY_SOURCES_ON_DEST) $(DOCBOOK_FOS) $(DOCBOOK_PDFS)
 
 lib/docbook/rendered/%.html: lib/docbook/essays/%/all-in-one.html
 	./bin/clean-up-docbook-xsl-xhtml.pl -o $@ $<
 
-DOCBOOK_MAK_PATH = /home/shlomi/apps/docbook-builder
+$(DOCBOOK_FO_DIR)/%.fo: lib/docbook/xml/%.xml
+	$(XMLTO_WITH_PARAMS) -o $(DOCBOOK_FO_DIR) --stringparam "docmake.output.format=fo" -m $(FO_XSLT_SS) fo $<
 
-DOCBOOK_MAK_MAKEFILES_PATH = $(DOCBOOK_MAK_PATH)/share/make/
+$(DOCBOOK_PDF_DIR)/%.pdf: $(DOCBOOK_FO_DIR)/%.fo
+	fop -fo $< -pdf $@
+
+DOCMAKE_SGML_PATH = lib/sgml/shlomif-docbook
+DOCBOOK_MAK_MAKEFILES_PATH = lib/make/docbook
 
 include $(DOCBOOK_MAK_MAKEFILES_PATH)/docbook-render.mak
 

File lib/make/docbook/docbook-render.mak

+# Declare some paths
+
+DOCMAKE_XSLT_PATH = $(DOCMAKE_SGML_PATH)/xsl-stylesheets
+DOCMAKE_DSSSL_PATH = $(DOCMAKE_SGML_PATH)/dsssl-stylesheets
+
+
+# Flags for the db2pdf, db2rtf, etc. DSSSL-based scripts
+
+DB2_DSSSL_SS = $(DOCMAKE_DSSSL_PATH)/shlomif-essays.dsl
+
+DB2_COMMON_FLAGS = -c /etc/sgml/catalog
+DB2_PRINT_FLAGS = $(DB2_COMMON_FLAGS) -d '$(DB2_DSSSL_SS)\#print'
+DB2_HTML_FLAGS = $(DB2_COMMON_FLAGS) -d '$(DB2_DSSSL_SS)\#html'
+
+# Declare the main DocBook/XML source for the document.
+
+MAIN_SOURCE = $(DOC).xml
+
+
+# Declare the XSLT Stylesheets
+
+XHTML_XSLT_SS = $(DOCMAKE_XSLT_PATH)/shlomif-essays-xhtml.xsl
+
+FO_XSLT_SS = $(DOCMAKE_XSLT_PATH)/shlomif-essays-fo.xsl
+
+XHTML_ONE_CHUNK_XSLT_SS = $(DOCMAKE_XSLT_PATH)/shlomif-essays-xhtml-onechunk.xsl
+
+# Declare the PDF and RTF documents.
+
+PDF_DOC = $(DOC).pdf
+RTF_DOC = $(DOC).rtf
+FO_DOC = $(DOC).fo
+
+# Declare the default HTML XSL target directory.
+# If over-rided by the user - it would be left as is.
+
+HTML_XSL_TARGET ?= $(DOC)
+
+
+# Declare the default HTML DSSSL target directory.
+# If over-rided by the user - it would be left as is.
+
+HTML_DSSSL_TARGET = $(DOC)-dsssl
+
+
+# Declare the default HTML XSL all-in-one-chunck target directory.
+# If over-rided by the user - it would be left as is.
+
+HTML_ONECHUNK_TARGET ?= $(DOC)-onechunk
+
+
+# A file inside the XSL target directory for dependency resolution
+
+HTML_XSL_TARGET_FILE_IN_DIR = $(HTML_XSL_TARGET)/index.html
+
+
+# Declare macros related to the CSS stylesheet for the HTML.
+
+HTML_XSL_CSS_SOURCE ?= style.css
+
+
+# A file inside the XSL target directory for dependency resolution
+
+HTML_ONE_CHUNK_TARGET_FILE = $(HTML_ONECHUNK_TARGET)/index.html
+
+
+# Define common Commands
+
+XMLTO ?= xmlto
+
+XMLTO_WITH_PARAMS = $(XMLTO) $(XMLTO_PARAMS)
+
+# Define upload-related macros
+
+UPLOAD_DEPS ?= html-xsl pdf rtf
+FILES_TO_UPLOAD ?= $(HTML_XSL_TARGET) $(PDF_DOC) $(RTF_DOC) $(ALL_SOURCES)  
+
+
+MAKEFILE_SOURCE ?= Makefile
+
+
+# A temporary location for uploading the all-in-one-documents for peer-review.
+
+UPLOAD_ONECHUNK_PATH = $${HOMEPAGE_SSH_PATH}
+
+##################################################
+
+
+COMMON_SOURCES = $(MAIN_SOURCE) $(MAKEFILE_SOURCE) $(MORE_XML_FILES)
+
+DSSSL_SPECIFIC_SOURCES = $(DB2_DSSSL_SS) jadetex.cfg
+DSSSL_SOURCES =  $(COMMON_SOURCES) $(DSSSL_SPECIFIC_SOURCES)
+
+XSL_SPECIFIC_SOURCES = $(XSLT_SS)
+XSL_SOURCES = $(COMMON_SOURCES) $(XSL_SPECIFIC_SOURCES)
+
+OTHER_SOURCES = $(HTML_XSL_CSS_SOURCE) $(HTML_RAW_FILES)
+
+ALL_SOURCES = $(COMMON_SOURCES) $(DSSSL_SPECIFIC_SOURCES) $(XSL_SPECIFIC_SOURCES) $(OTHER_SOURCES) $(MAKEFILE_SOURCE)
+
+RSYNC = rsync --progress --verbose --rsh=ssh
+
+
+HTML_OTHER_SOURCES_DEST = $(patsubst %,$(HTML_XSL_TARGET)/%,$(OTHER_SOURCES))
+
+
+# Declare the source archive URL.
+
+SRC_ARCHIVE = $(DOC)-docbook-source.zip
+
+
+arc : $(SRC_ARCHIVE)
+	
+
+# Define some shorthand targets
+
+html-dsssl: $(HTML_DSSSL_TARGET)
+
+html-xsl: $(HTML_XSL_TARGET_FILE_IN_DIR) $(HTML_OTHER_SOURCES_DEST)
+
+pdf: $(PDF_DOC)
+
+rtf: $(RTF_DOC)
+
+all_in_one_html: $(HTML_ONE_CHUNK_TARGET_FILE)
+
+
+
+# Define the build targets.
+
+# HTML.
+
+$(HTML_XSL_TARGET_FILE_IN_DIR): $(XSL_SOURCES)
+	$(XMLTO_WITH_PARAMS) --stringparam "docmake.output.format=xhtml" -m $(XHTML_XSLT_SS) -o $(HTML_XSL_TARGET) xhtml $<
+
+$(HTML_OTHER_SOURCES_DEST) :: $(HTML_XSL_TARGET)/%: %
+	cp -f $< $@
+
+$(HTML_DSSSL_TARGET): $(DSSSL_SOURCES)
+	db2html $(DB2_HTML_FLAGS) $(MAIN_SOURCE)
+
+$(HTML_ONE_CHUNK_TARGET_FILE): $(XSL_SOURCES)
+	$(XMLTO_WITH_PARAMS) --stringparam "docmake.output.format=xhtml" -m $(XHTML_ONE_CHUNK_XSLT_SS) -o $(HTML_XSL_TARGET)-onechunk xhtml $<
+
+
+# PDF and RTF.
+
+# $(PDF_DOC): $(DSSSL_SOURCES)
+#	db2pdf $(DB2_PRINT_FLAGS) $(MAIN_SOURCE)
+$(FO_DOC): $(XSL_SOURCES)
+	$(XMLTO_WITH_PARAMS) --stringparam "docmake.output.format=fo" -m $(FO_XSLT_SS) fo $<
+
+$(PDF_DOC): $(FO_DOC)
+	fop -fo $< -pdf $@
+
+$(RTF_DOC): $(DSSSL_SOURCES)
+	db2rtf $(DB2_PRINT_FLAGS) $(MAIN_SOURCE)
+
+
+# Source archive.
+
+$(SRC_ARCHIVE) : $(ALL_SOURCES)
+	zip -u $@ $(ALL_SOURCES)
+
+%.show:
+	@echo "$* = $($*)"

File lib/sgml/shlomif-docbook/dsssl-stylesheets/jadetex.cfg

+\hypersetup{urlcolor=blue}

File lib/sgml/shlomif-docbook/dsssl-stylesheets/shlomif-essays.dsl

+<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
+<!ENTITY html-ss 
+  PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA dsssl>
+<!ENTITY print-ss
+  PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA dsssl>
+]>
+<style-sheet>
+<style-specification id="print" use="print-stylesheet">
+<style-specification-body> 
+(define %bop-footnotes%
+   ;; Make "bottom-of-page" footnotes?
+   #t)
+
+(declare-flow-object-class formatting-instruction
+  "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction")
+
+(element ulink
+  (let ((type (attribute-string (normalize "type"))))
+    (if (equal? type "htmlonly")
+      (sosofo-append
+        (process-children)                ;; Wrote the text
+      )
+      (sosofo-append
+        (make formatting-instruction  data: "\\href{" )
+        (make formatting-instruction 
+            data: (attribute-string (normalize "url")) )
+        (make formatting-instruction  data: "}{" )
+        (process-children) ;; Wrote the text with its format (HTML anchor)
+        (make formatting-instruction  data: "}" ) )
+    )
+  )
+)
+
+(define %generate-article-toc%
+    1
+)
+
+(define (toc-depth nd)
+    100
+)
+
+</style-specification-body>
+</style-specification>
+<style-specification id="html" use="html-stylesheet">
+<style-specification-body> 
+
+;; customize the html stylesheet
+(define %html-ext%
+    ".html"
+)
+
+; Make sure there is a table of contents
+(define %generate-article-toc%
+    1
+)
+
+(define (toc-depth nd)
+    100
+)
+
+</style-specification-body>
+</style-specification>
+<external-specification id="print-stylesheet" document="print-ss">
+<external-specification id="html-stylesheet"  document="html-ss">
+</style-sheet>
+

File lib/sgml/shlomif-docbook/xsl-stylesheets/shlomif-essays-fo.xsl

+<xsl:stylesheet
+     version='1.0'
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:fo="http://www.w3.org/1999/XSL/Format"> 
+
+    <xsl:import href="shlomif-essays.xsl" />
+
+<!--colored and hyphenated links --> 
+<xsl:template match="ulink"> 
+    <fo:basic-link external-destination="{@url}" 
+         xsl:use-attribute-sets="xref.properties" 
+         text-decoration="underline" 
+         color="blue"> 
+         <xsl:choose> 
+         <xsl:when test="count(child::node())=0"> 
+         <xsl:value-of select="@url"/> 
+         </xsl:when> 
+         <xsl:otherwise> 
+         <xsl:apply-templates/> 
+         </xsl:otherwise> 
+         </xsl:choose> 
+    </fo:basic-link> 
+</xsl:template>
+</xsl:stylesheet>

File lib/sgml/shlomif-docbook/xsl-stylesheets/shlomif-essays-xhtml-onechunk.xsl

+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version='1.0'>
+
+    <xsl:import href="file:///usr/share/sgml/docbook/xsl-stylesheets/xhtml/onechunk.xsl" />
+
+    <!-- Avoid Generating a Table-of-Contents-->
+    <xsl:param name="generate.toc"></xsl:param>
+</xsl:stylesheet>
+

File lib/sgml/shlomif-docbook/xsl-stylesheets/shlomif-essays-xhtml.xsl

+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version='1.0'>
+
+    <xsl:import href="shlomif-essays.xsl" />
+
+<xsl:template match="itemizedlist">
+    <div xmlns="http://www.w3.org/1999/xhtml" class="{name(.)}">
+    <xsl:call-template name="anchor"/>
+    <xsl:if test="title">
+      <xsl:call-template name="formal.object.heading"/>
+    </xsl:if>
+
+    <xsl:apply-templates select="*[not(self::listitem or self::title 
+        or self::titleabbrev)]"/>
+
+    <ul>
+         <xsl:if test="@role">
+             <xsl:attribute name="class">
+                 <xsl:value-of select="@role"/>
+             </xsl:attribute>
+         </xsl:if>
+
+
+      <xsl:if test="$css.decoration != 0">
+        <xsl:attribute name="type">
+          <xsl:call-template name="list.itemsymbol"/>
+        </xsl:attribute>
+      </xsl:if>
+
+      <xsl:if test="@spacing='compact'">
+        <xsl:attribute name="compact">
+          <xsl:value-of select="@spacing"/>
+        </xsl:attribute>
+      </xsl:if>
+      <xsl:apply-templates select="listitem"/>
+    </ul>
+  </div>
+</xsl:template>
+
+</xsl:stylesheet>

File lib/sgml/shlomif-docbook/xsl-stylesheets/shlomif-essays.xsl

+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version='1.0'>
+    <xsl:param name="use.id.as.filename">1</xsl:param>
+    <xsl:param name="html.stylesheet">style.css</xsl:param>
+    <xsl:param name="itemizedlist.propagates.style">1</xsl:param>
+    <xsl:param name="chunker.output.doctype-public">-//W3C//DTD XHTML 1.0 Transitional//EN</xsl:param>
+    <xsl:param name="chunker.output.doctype-system">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</xsl:param>
+    <!-- Parameters for Generating Strict Output. See:
+    http://www.sagehill.net/docbookxsl/OtherOutputForms.html#StrictXhtmlValid
+    -->
+    <xsl:param name="css.decoration">0</xsl:param>
+    <xsl:param name="ulink.target"></xsl:param>
+    <xsl:param name="use.viewport">0</xsl:param>
+    <!-- End of Strict Params -->    
+    <xsl:param name="toc.section.depth">10</xsl:param> 
+    <xsl:param name="generate.section.toc.level">10</xsl:param>
+    <!-- Enable fop extensions - see:
+    http://www.sagehill.net/docbookxsl/InstallingAnFO.html
+    http://www.mail-archive.com/fop-users%40xmlgraphics.apache.org/msg06170.html
+    -->
+    <xsl:param name="fop1.extensions">1</xsl:param>
+
+<xsl:template name="html_itemized_list">
+    <div xmlns="http://www.w3.org/1999/xhtml" class="{name(.)}">
+    <xsl:call-template name="anchor"/>
+    <xsl:if test="title">
+      <xsl:call-template name="formal.object.heading"/>
+    </xsl:if>
+
+    <xsl:apply-templates select="*[not(self::listitem or self::title 
+        or self::titleabbrev)]"/>
+
+    <ul>
+         <xsl:if test="@role">
+             <xsl:attribute name="class">
+                 <xsl:value-of select="@role"/>
+             </xsl:attribute>
+         </xsl:if>
+
+
+      <xsl:if test="$css.decoration != 0">
+        <xsl:attribute name="type">
+          <xsl:call-template name="list.itemsymbol"/>
+        </xsl:attribute>
+      </xsl:if>
+
+      <xsl:if test="@spacing='compact'">
+        <xsl:attribute name="compact">
+          <xsl:value-of select="@spacing"/>
+        </xsl:attribute>
+      </xsl:if>
+      <xsl:apply-templates select="listitem"/>
+    </ul>
+  </div>
+</xsl:template>
+
+<!-- Insert some AdSense Ads -->
+<xsl:template name="user.header.navigation">
+    <div class="center ads_top">
+    <script type="text/javascript">
+google_ad_client = "pub-2480595666283917";
+google_ad_width = 468;
+google_ad_height = 60;
+google_ad_format = "468x60_as";
+google_ad_type = "text";
+google_ad_channel ="";
+google_color_border = "336699";
+google_color_text = "000000";
+google_color_bg = "FFFFFF";
+google_color_link = "0000FF";
+google_color_url = "008000";
+</script>
+<script type="text/javascript"
+  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+    </div>
+</xsl:template>
+
+
+</xsl:stylesheet>