etherpad_to_hdoc.ant 4.65 KB
Newer Older
1 2
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="myantce" default="main">
3
    <property file="etherpad_to_hdoc.properties"/>
4 5 6 7
    <!-- import classes -->
    <taskdef resource="net/sf/antcontrib/antlib.xml"></taskdef>
    <taskdef name="htmlcleaner" classname="org.htmlcleaner.HtmlCleanerForAnt"></taskdef>
    <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask"></taskdef>
8

9 10 11 12 13 14 15 16
    <target name="start">
        <delete dir="${tmp}" failonerror="false"/>
        <mkdir dir="${tmp}"/>
        <delete dir="${out}" failonerror="false"/>
        <mkdir dir="${out}"/>
        <delete dir="${log}" failonerror="false"/>
        <mkdir dir="${log}"/>
    </target>
17
    
18 19 20 21
    <target name="clean-tmp">
        <delete dir="${tmp}" failonerror="false"/>
        <mkdir dir="${tmp}"/>
    </target>
qaomia's avatar
qaomia committed
22

23 24
    <!-- Apply Xslt -->
    <target name="apply-xslt">
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
        <for param="inputPad">
            <path>
                <fileset dir="${in}" includes="*.html" />
            </path>
            <sequential>
                <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>        
42
    </target>
43
    
44 45
    <!-- Builds Hdoc structure -->
    <target name="construct_hdoc">
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
        <for param="inputPad">
            <path>
                <fileset dir="${in}" includes="*.html" />
            </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 -->
                <touch file="${tmp}/${properName}/META-INF/container.xml" />
                <echoxml file="${tmp}/${properName}/META-INF/container.xml">
                    <container version="1.0">
                        <rootfiles>
                            <rootfile full-path="${rootfilename}" media-type="text/xml" />
                        </rootfiles>
                    </container>
                </echoxml>
                <xslt in="${tmp}/${properName}/META-INF/container.xml" out="${tmp}/${properName}/tozip/META-INF/container.xml" style="${xsl}/addNamespaceToContainer.xsl"/>
                
                <!-- mimetype -->
                <touch file="${tmp}/${properName}/mimetype" />
                <echo message="application/x-hdoc+zip" file="${tmp}/${properName}/tozip/mimetype" />
            </sequential>
        </for>
74
    </target>
75
    
76 77 78 79 80 81 82 83 84 85 86 87
    <target name="jing-hdoc">
        <for param="inputPad" keepgoing="true">
            <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>
88
    </target>
Jean Vintache's avatar
Jean Vintache committed
89
    
90 91
    <!-- Zip Hdoc container -->
    <target name="zip">
92 93 94 95 96 97 98 99 100 101
        <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>
102
    </target>
103
    
104
    <target name="main">
105 106 107 108 109 110
        <antcall target="start" />
        <antcall target="apply-xslt" />
        <antcall target="construct_hdoc" />
        <antcall target="jing-hdoc" />
        <antcall target="zip" />
        <antcall target="clean-tmp" />
111
    </target>
qaomia's avatar
qaomia committed
112
    
113
</project>