Permalink
Browse files

Refactoring to include datauri

  • Loading branch information...
1 parent db75949 commit bb2a2b62b2f27b6bd34ae0af3a9fca75baed6c0d Nicholas C. Zakas committed Dec 6, 2009
View
@@ -4,13 +4,22 @@ lib.dir = lib
doc.dir = doc
build.dir = build
res.dir = res
-product.name = cssembed
-version.number = 0.3.1
-jar.name = ${product.name}-${version.number}.jar
-core.jar.name = ${product.name}-core-${version.number}.jar
-dist.package.name = ${product.name}-${version.number}
-main.class = net.nczonline.web.cssembed.CSSEmbed
-junit.jar = junit-4.1.jar
-datauri.jar = datauri-core-0.2.1.jar
+
+#Lib jars
jargs.jar = jargs-1.0.jar
-class.version = 1.5
+junit.jar = junit-4.1.jar
+
+#Global properties
+class.version = 1.5
+
+#CSSEmbed properties
+cssembed.name = cssembed
+cssembed.version = 0.3.1
+cssembed.jar = ${cssembed.name}-${cssembed.version}.jar
+cssembed.main = net.nczonline.web.cssembed.CSSEmbed
+
+#DataURI properties
+datauri.name = datauri
+datauri.version = 0.2.2
+datauri.jar = ${datauri.name}-${datauri.version}.jar
+datauri.main = net.nczonline.web.datauri.DataURI
View
@@ -40,7 +40,6 @@
target="${class.version}">
<classpath>
<pathelement location="${lib.dir}/${jargs.jar}"/>
- <pathelement location="${lib.dir}/${datauri.jar}"/>
<pathelement location="${lib.dir}/${junit.jar}"/>
<pathelement location="${build.dir}/classes"/>
</classpath>
@@ -51,38 +50,28 @@
</copy>
</target>
- <target name="build.jar" depends="build.classes">
- <mkdir dir="${build.dir}/jar"/>
- <unjar src="${lib.dir}/${jargs.jar}" dest="${build.dir}/jar"/>
- <unjar src="${lib.dir}/${datauri.jar}" dest="${build.dir}/jar"/>
- <copy todir="${build.dir}/jar">
- <fileset dir="${build.dir}/classes" includes="**/*.class"/>
- </copy>
- <jar destfile="${build.dir}/${jar.name}" basedir="${build.dir}/jar">
- <manifest>
- <attribute name="Main-Class" value="${main.class}"/>
- </manifest>
- </jar>
- </target>
-
- <!-- make sure to run "clean" before this if you've already run build.jar -->
- <target name="build.core.jar" depends="build.classes">
- <mkdir dir="${build.dir}/core-jar"/>
- <copy todir="${build.dir}/core-jar">
- <fileset dir="${build.dir}/classes" includes="**/*.class"/>
- </copy>
- <jar destfile="${build.dir}/${core.jar.name}" basedir="${build.dir}/core-jar">
- <manifest>
- <attribute name="Main-Class" value="${main.class}"/>
- </manifest>
- </jar>
+ <target name="build.cssembed.jar" depends="build.classes">
+ <make-jar name="${cssembed.name}" jar="${cssembed.jar}" main="${cssembed.main}">
+ <jar-files>
+ <fileset dir="${build.dir}/classes" includes="**/*.class"/>
+ </jar-files>
+ </make-jar>
+
</target>
+ <target name="build.datauri.jar" depends="build.classes">
+ <make-jar name="${datauri.name}" jar="${datauri.jar}" main="${datauri.main}">
+ <jar-files>
+ <fileset dir="${build.dir}/classes" includes="**/datauri/*.class"/>
+ </jar-files>
+ </make-jar>
+ </target>
+
<!-- build all jars -->
- <target name="build.all.jars" depends="clean,build.core.jar,build.jar"></target>
+ <target name="build.all.jars" depends="clean,build.cssembed.jar,build.datauri.jar"></target>
- <target name="build.dist.package" depends="build.jar">
+ <target name="build.dist.package" depends="build.cssembed.jar,build.datauri.jar">
<mkdir dir="${build.dir}/${dist.package.name}"/>
<mkdir dir="${build.dir}/${dist.package.name}/build"/>
<copy file="${build.dir}/${jar.name}" todir="${build.dir}/${dist.package.name}/build"/>
@@ -126,4 +115,24 @@
</junit>
</target>
+
+ <macrodef name="make-jar">
+ <attribute name="jar"/>
+ <attribute name="main"/>
+ <attribute name="name"/>
+ <element name="jar-files"/>
+ <sequential>
+ <mkdir dir="${build.dir}/@{name}-jar"/>
+ <unjar src="${lib.dir}/${jargs.jar}" dest="${build.dir}/@{name}-jar"/>
+ <copy todir="${build.dir}/@{name}-jar">
+ <jar-files/>
+ </copy>
+ <jar destfile="${build.dir}/@{jar}" basedir="${build.dir}/@{name}-jar">
+ <manifest>
+ <attribute name="Main-Class" value="@{main}"/>
+ </manifest>
+ </jar>
+ </sequential>
+ </macrodef>
+
</project>
@@ -217,6 +217,11 @@ public void embedImages(Writer out, String root) throws IOException {
//get the data URI format
String dataUriString = getImageURIString(newUrl, url);
+ //IE8 only allows dataURIs up to 32KB
+ if (verbose && dataUriString.length() > 32768){
+ System.err.println("[WARNING] File " + newUrl + " creates a data URI larger than 32KB. IE8 can't display data URI images this large.");
+ }
+
/*
* Determine what to do. Eventually, you should be able to
* have both a data URI and MHTML in the same file.
Oops, something went wrong.

0 comments on commit bb2a2b6

Please sign in to comment.