etherpad_to_hdoc.ant 4.78 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
        <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" />
37
38
39
40
                <xslt in="${tmp}/${properName}/tmpPad.xhtml" out="${tmp}/${properName}/tmpPad2.xhtml" style="${xsl}/html2xhtmlv1.xsl" />
                <xslt in="${tmp}/${properName}/tmpPad2.xhtml" out="${tmp}/${properName}/tmpPad3.xhtml" style="${xsl}/html2xhtmlv2.xsl" />
                <xslt in="${tmp}/${properName}/tmpPad3.xhtml" out="${tmp}/${properName}/tmpPad4.xhtml" style="${xsl}/html2xhtml3.xsl" />
                <xslt in="${tmp}/${properName}/tmpPad4.xhtml" out="${tmp}/${properName}/tozip/content.xml" style="${xsl}/xhtml2hdoc.xsl" />
41
            </sequential>
42
        </for>
43
    </target>
44
    
45
46
    <!-- Builds Hdoc structure -->
    <target name="construct_hdoc">
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
74
        <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>
75
    </target>
76
    
77
78
79
80
81
82
83
84
85
86
87
88
    <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>
89
    </target>
Jean Vintache's avatar
Jean Vintache committed
90
    
91
92
    <!-- Zip Hdoc container -->
    <target name="zip">
93
94
95
96
97
98
99
100
101
102
        <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>
103
    </target>
104
    
105
    <target name="main">
106
107
108
109
110
111
        <antcall target="start" />
        <antcall target="apply-xslt" />
        <antcall target="construct_hdoc" />
        <antcall target="jing-hdoc" />
        <antcall target="zip" />
        <antcall target="clean-tmp" />
112
    </target>
qaomia's avatar
qaomia committed
113
    
114
</project>