Commit c6e3ac77 authored by Jean Vintache's avatar Jean Vintache

ant script handles multiple files in input, and names the output hdoc files accordingly

parent 90e63253
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="myantce" default="main"> <project basedir="." name="myantce" default="main">
<property file="etherpad_to_hdoc.properties"/> <property file="etherpad_to_hdoc.properties"/>
<!-- import classes -->
<taskdef name="htmlcleaner" classname="org.htmlcleaner.HtmlCleanerForAnt"> <taskdef resource="net/sf/antcontrib/antlib.xml"></taskdef>
<classpath> <taskdef name="htmlcleaner" classname="org.htmlcleaner.HtmlCleanerForAnt"></taskdef>
<pathelement location="lib/htmlcleaner-2.16.jar"/> <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask"></taskdef>
</classpath>
</taskdef>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="lib/jing.jar"/>
</classpath>
</taskdef>
<target name="start"> <target name="start">
<delete dir="${tmp}" failonerror="false"/> <delete dir="${tmp}" failonerror="false"/>
...@@ -30,55 +22,92 @@ ...@@ -30,55 +22,92 @@
<!-- Apply Xslt --> <!-- Apply Xslt -->
<target name="apply-xslt"> <target name="apply-xslt">
<htmlcleaner src="${in}/pad.html" dest="${tmp}/pad-clean.xml"/> <for param="inputPad">
<xslt in="${xsl}/html2xhtml.xsl" out="${tmp}/tmpPad.xhtml" style="${xsl}/html2xhtml.xsl" /> <path>
<xslt in="${tmp}/tmpPad.xhtml" out="${tmp}/tmpPad2.xhtml" style="${xsl}/html2xhtmlv2.xsl" /> <fileset dir="${in}" includes="*.html" />
<!-- a priori la tâche suivante ne sert à rien --> </path>
<xslt in="${tmp}/tmpPad2.xhtml" out="${tmp}/tmpPad3.xhtml" style="${xsl}/html2xhtml3.xsl" /> <sequential>
<xslt in="${tmp}/tmpPad3.xhtml" out="${tmp}/tozip/content.xml" style="${xsl}/xhtml2hdoc.xsl" /> <local name="padFileName" />
<basename property="padFileName" file="@{inputPad}"/>
<local name="properName" />
<basename property="properName" file="@{inputPad}" suffix=".html"/>
<htmlcleaner src="${in}/${padFileName}" dest="${tmp}/pad-clean.xml"/>
<xslt in="${xsl}/html2xhtml.xsl" out="${tmp}/${properName}/tmpPad.xhtml" style="${xsl}/html2xhtml.xsl" />
<xslt in="${tmp}/${properName}/tmpPad.xhtml" out="${tmp}/${properName}/tmpPad2.xhtml" style="${xsl}/html2xhtmlv2.xsl" />
<xslt in="${tmp}/${properName}/tmpPad2.xhtml" out="${tmp}/${properName}/tmpPad3.xhtml" style="${xsl}/html2xhtml3.xsl" />
<xslt in="${tmp}/${properName}/tmpPad3.xhtml" out="${tmp}/${properName}/tozip/content.xml" style="${xsl}/xhtml2hdoc.xsl" />
</sequential>
</for>
</target> </target>
<!-- Builds Hdoc structure --> <!-- Builds Hdoc structure -->
<target name="construct_hdoc"> <target name="construct_hdoc">
<mkdir dir="${tmp}/tozip/" /> <for param="inputPad">
<mkdir dir="${tmp}/META-INF/" /> <path>
<mkdir dir="${tmp}/tozip/META-INF" /> <fileset dir="${in}" includes="*.html" />
<mkdir dir="${tmp}/META-INF" /> </path>
<sequential>
<local name="properName" />
<basename property="properName" file="@{inputPad}" suffix=".html"/>
<mkdir dir="${tmp}/${properName}/tozip/" />
<mkdir dir="${tmp}/${properName}/META-INF/" />
<mkdir dir="${tmp}/${properName}/tozip/META-INF" />
<!-- container --> <!-- container -->
<touch file="${tmp}/META-INF/container.xml" /> <touch file="${tmp}/${properName}/META-INF/container.xml" />
<echoxml file="${tmp}/META-INF/container.xml"> <echoxml file="${tmp}/${properName}/META-INF/container.xml">
<container version="1.0"> <container version="1.0">
<rootfiles> <rootfiles>
<rootfile full-path="${rootfilename}" media-type="text/xml" /> <rootfile full-path="${rootfilename}" media-type="text/xml" />
</rootfiles> </rootfiles>
</container> </container>
</echoxml> </echoxml>
<xslt in="${tmp}/META-INF/container.xml" out="${tmp}/tozip/META-INF/container.xml" style="${xsl}/addNamespaceToContainer.xsl"/> <xslt in="${tmp}/${properName}/META-INF/container.xml" out="${tmp}/${properName}/tozip/META-INF/container.xml" style="${xsl}/addNamespaceToContainer.xsl"/>
<!-- mimetype --> <!-- mimetype -->
<touch file="${tmp}/mimetype" /> <touch file="${tmp}/${properName}/mimetype" />
<echo message="application/x-hdoc+zip" file="${tmp}/tozip/mimetype" /> <echo message="application/x-hdoc+zip" file="${tmp}/${properName}/tozip/mimetype" />
</sequential>
</for>
</target> </target>
<target name="jing-hdoc"> <target name="jing-hdoc">
<jing file="${tmp}/tozip/content.xml" rngfile="schema/xhtml/hdoc1-xhtml.rng"></jing> <for param="inputPad" keepgoing="true">
<echo>content.xml respecte le schema hdoc1-xhtml.rng</echo> <path>
<fileset dir="${in}" includes="*.html" />
</path>
<sequential>
<local name="properName" />
<basename property="properName" file="@{inputPad}" suffix=".html"/>
<jing file="${tmp}/${properName}/tozip/content.xml" rngfile="${schema}/xhtml/hdoc1-xhtml.rng" />
</sequential>
</for>
</target> </target>
<!-- Zip Hdoc container --> <!-- Zip Hdoc container -->
<target name="zip"> <target name="zip">
<zip basedir="${tmp}/tozip/" destfile="${out}/output.hdoc" /> <for param="inputPad">
<path>
<fileset dir="${in}" includes="*.html" />
</path>
<sequential>
<local name="properName" />
<basename property="properName" file="@{inputPad}" suffix=".html"/>
<zip basedir="${tmp}/${properName}/tozip/" destfile="${out}/${properName}.hdoc" />
</sequential>
</for>
</target> </target>
<target name="main"> <target name="main">
<antcall target="start"></antcall> <antcall target="start" />
<antcall target="apply-xslt"></antcall> <antcall target="apply-xslt" />
<antcall target="construct_hdoc"></antcall> <antcall target="construct_hdoc" />
<antcall target="jing-hdoc"></antcall> <antcall target="jing-hdoc" />
<antcall target="zip"></antcall> <antcall target="zip" />
<antcall target="clean-tmp"></antcall> <antcall target="clean-tmp" />
</target> </target>
</project> </project>
\ No newline at end of file
...@@ -4,5 +4,6 @@ tmp = ${basedir}/tmp ...@@ -4,5 +4,6 @@ tmp = ${basedir}/tmp
xsl = ${basedir}/xsl xsl = ${basedir}/xsl
lib = ${basedir}/lib lib = ${basedir}/lib
log = ${basedir}/log log = ${basedir}/log
schema = ${basedir}/schema
rootfilename = content.xml rootfilename = content.xml
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment