Skip to content

Commit

Permalink
Create Apache Ant buildfile.
Browse files Browse the repository at this point in the history
Only working task so far is to generate a preview version of a
given article.
  • Loading branch information
amclark42 committed Apr 3, 2023
1 parent dca6f50 commit 49e6b29
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ articles/+111111+/111111.xhtml
articles/+111111+/111111.xhtml
articles/+111111+/111111.xhtml
articles/+111111+/111111.xhtml
dhq-preview
17 changes: 17 additions & 0 deletions build-properties.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<build>
<!-- The directory to which the static site content is written. -->
<toDir>../dhq-static</toDir>

<!-- The directory in which HTML articles are saved for previewing. Note that if
you change this value, you may also have to change the "assets-path" parameter
value in build.xml's "previewArticle" target. -->
<previewDir>dhq-preview</previewDir>

<!-- The XSLT processor to use. -->
<processor>
<name>net.sf.saxon.TransformerFactoryImpl</name>
<location>common/lib/saxon-he-11.5.jar</location>
</processor>

</build>
59 changes: 59 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<project xmlns:if="ant:if" xmlns:unless="ant:unless"
default="previewArticle"
name="dhq">

<!--
Apache Ant buildfile for Digital Humanities Quarterly.
-->

<!--
PROPERTIES
-->
<!-- See build-properties.xml for the settings used in this file. When referenced,
properties look like this:
${toDir}
For more information, see https://ant.apache.org/manual/Tasks/xmlproperty.html -->
<xmlproperty file="build-properties.xml" keepRoot="false"/>


<!--
ANT TASKS
-->

<!-- Generate a static version of the website. -->
<target name="generateSite"><!-- TODO -->
<mkdir dir="${toDir}"/>
<echo message="${toDir}"/>
</target>

<target name="previewArticle">
<!-- If the 'article.id' property wasn't already set using the command line, Ant
will prompt for it. -->
<input unless:set="article.id"
message="Please give the ID of the article you want to view:"
addproperty="article.id"/>
<!-- Test the 'article.id' property to make sure it has 6 digits and doesn't
start with '9'. -->
<condition property="article.id.ok" value="${article.id}">
<matches string="${article.id}" pattern="^[0-8]\d{5,5}$"/>
</condition>
<fail unless="article.id.ok"
message="An article ID must be 6 digits long. It must not start with '9'"/>
<!-- If it doesn't exist yet, create the preview directory specified in
build-properties.xml. -->
<mkdir dir="${previewDir}"/>
<!-- Transform the article with XSLT. -->
<xslt in="articles/${article.id}/${article.id}.xml"
out="${previewDir}/${article.id}.html"
style="common/xslt/template_article.xsl"
classpath="${processor.location}"
force="true"
failonerror="false">
<factory name="${processor.name}"/>
<param name="context" expression="dhq"/>
<param name="assets-path" expression="../"/>
</xslt>
<echo message="Created article preview at ${previewDir}/${article.id}.html"/>
</target>

</project>

0 comments on commit 49e6b29

Please sign in to comment.