Skip to content

Commit

Permalink
Build out "generateSite" task.
Browse files Browse the repository at this point in the history
Files are copied into the static site directory and static HTML is
wrapped in DHQ trappings.
  • Loading branch information
amclark42 committed May 5, 2023
1 parent 3ea13ce commit 67a7a51
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 14 deletions.
5 changes: 3 additions & 2 deletions build-properties.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<build>
<!-- The base directory for storing static site content. -->
<toDir>..${file.separator}dhq-static</toDir>
<!-- The base directory for storing static site content. The directory will be
placed at the same level as the git repository. -->
<toDir>dhq-static</toDir>
<!-- This directory inside dhq-static will hold the static site's individual files
(but not the compressed site). -->
<context>dhq</context>
Expand Down
75 changes: 66 additions & 9 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
For more information, see https://ant.apache.org/manual/Tasks/xmlproperty.html
-->
<xmlproperty file="build-properties.xml" keepRoot="false"/>
<property name="toDir.path"
value="..${file.separator}${toDir}${file.separator}${context}"/>
<!--<mapper id="article.map">
<firstmatchmapper>
<regexpmapper from="^000654/(.*)$" to="vol/17/1/000654/\1" handledirsep="true"/>
<regexpmapper from="^000116/(.*)$" to="vol/7/2/000116/\1" handledirsep="true"/>
</firstmatchmapper>
</mapper>-->

<!-- Check for the XML Resolver Java class, as it is a dependency for using the
Saxon HE processor. From the Saxon documentation on XSLT with Ant:
Expand Down Expand Up @@ -46,10 +55,10 @@ is loaded when Ant starts up. Please run Ant again like this:
<!-- Generate static HTML versions of the DHQ articles. -->
<target name="generateArticles" depends="checkXmlResolver"
description="Generate static HTML versions of the DHQ articles.">
<mkdir dir="${toDir}${file.separator}${context}${file.separator}vol"/>
<mkdir dir="${toDir.path}${file.separator}vol"/>
<!-- Use XSLT to transform articles using the DHQ table of contents. -->
<xslt in="toc${file.separator}toc.xml"
out="${toDir}${file.separator}article-map.xml"
out="${toDir.path}${file.separator}article-map.xml"
style="common${file.separator}xslt${file.separator}generate_static_articles.xsl"
classpath="${processor.location}"
force="true"
Expand All @@ -63,16 +72,64 @@ is loaded when Ant starts up. Please run Ant again like this:
</target>

<!-- Generate a static version of the DHQ website. -->
<target name="generateSite" depends="generateArticles">
<mkdir dir="${toDir}${file.separator}${context}"/>
<!-- TODO -->
<antcall target="compressStatic"/>
<target name="generateSite" depends="checkXmlResolver">
<mkdir dir="${toDir.path}"/>
<!--<ant antfile="..${file.separator}${toDir}${file.separator}article-mapper.xml" inheritRefs="true">
<reference refid="map" torefid="article.map"/>
</ant>
<copy todir="${toDir.path}">
<fileset dir="articles"/>
<!-\-<mapper refid="article.map"/>-\->
</copy>-->
<!-- Copy specific files in the base directory. -->
<copy todir="${toDir.path}">
<filelist dir=".">
<file name="flow.js"/>
<file name="robots.txt"/>
<!--<file name="sitemap.xmap"/>-->
<file name="sruExplain.xml"/>
</filelist>
</copy>
<!-- Copy text files in the submissions directory. -->
<copy todir="${toDir.path}${file.separator}submissions">
<fileset dir="submissions" includes="*.txt"/>
</copy>
<!-- Copy web assets. -->
<copy todir="${toDir.path}${file.separator}common">
<fileset dir="common" excludes="lib/ tests/"/>
</copy>
<!-- Transform the test file.
TODO: is this still necessary? -->
<xslt in="common${file.separator}tests${file.separator}starter.xml"
out="${toDir.path}${file.separator}starter.html"
style="common${file.separator}tests${file.separator}test2.xsl"
classpath="${processor.location}">
<factory name="${processor.name}"/>
<param name="fpath" expression="starter.html"/>
</xslt>
<!-- Add headers and footers to static pages. -->
<xslt destdir="${toDir.path}"
style="common${file.separator}xslt${file.separator}template_static_pages.xsl"
filenameparameter="fname"
filedirparameter="fdir"
classpath="${processor.location}">
<factory name="${processor.name}"/>
<mapper>
<regexpmapper
from="^(about|contact|news|people|submissions)/(.+\.html)"
to="\1/\2" handledirsep="yes"/>
</mapper>
<param name="assets-path" expression="..${file.separator}"/>
<param name="context" expression="dhq"/>
<param name="dir-separator" expression="${file.separator}"/>
</xslt>
<!--<antcall target="compressStatic"/>-->
</target>

<!-- Compress the static site's files for backup and transportation. -->
<target name="compressStatic">
<zip destfile="${toDir}${file.separator}${context}.zip">
<fileset dir="${toDir}${file.separator}${context}"/>
<zip destfile="..${file.separator}${toDir}${file.separator}${context}.zip">
<fileset dir="${toDir.path}"/>
</zip>
</target>

Expand Down Expand Up @@ -102,9 +159,9 @@ is loaded when Ant starts up. Please run Ant again like this:
force="true"
failOnTransformationError="false">
<factory name="${processor.name}"/>
<param name="assets-path" expression="..${file.separator}"/>
<param name="context" expression="dhq"/>
<param name="dir-separator" expression="${file.separator}"/>
<param name="assets-path" expression="..${file.separator}"/>
</xslt>
<echo message="Created article preview at ${previewDir}${file.separator}${article.id}.html"/>
</target>
Expand Down
14 changes: 11 additions & 3 deletions common/xslt/template_static_pages.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
<xdoc:copyright>Copyright 2008 John A. Walsh</xdoc:copyright>
<xdoc:short>XSLT stylesheet to transform DHQ static pages to XHTML.</xdoc:short>
</xdoc:doc>
<xsl:param name="fpath"></xsl:param>
<xsl:param name="fname"/>
<xsl:param name="fdir"/>
<xsl:param name="fpath">
<xsl:if test="$fname and $fdir">
<xsl:value-of select="concat($fdir,$dir-separator,$fname)"/>
</xsl:if>
</xsl:param>

<xsl:template match="/">
<xsl:param name="basicurl" select="'http://www.digitalhumanities.org/dhq/'"/>
Expand All @@ -35,10 +41,12 @@
<!-- This template will copy the rest of the html document as it is after applying template -->
<xsl:call-template name="copy_body_text"/>
<xsl:call-template name="footer">
<xsl:with-param name="doclink_html"
<!-- 2023-05-05: Ash commented out the parameters set below,
since footer.xsl doesn't contain them. -->
<!--<xsl:with-param name="doclink_html"
select="concat($basicurl, 'how_to_get_this.html')"/>
<xsl:with-param name="doclink_xml"
select="concat($basicurl,'no_xml_for_static_pages.xml')"/>
select="concat($basicurl,'no_xml_for_static_pages.xml')"/>-->
<xsl:with-param name="docurl" select="$fpath"/>
</xsl:call-template>
</div>
Expand Down

0 comments on commit 67a7a51

Please sign in to comment.