<project name="fs-draft" default="build">
	<property environment="env">
	</property>
	<property name="dir.source" value="source">
	</property>
	<property name="dir.source.structure" value="${dir.source}/structure">
	</property>
	<property name="dir.source.style" value="${dir.source}/style">
	</property>
	<property name="dir.source.logic" value="${dir.source}/logic">
	</property>
	<property name="dir.source.logic.server" value="${dir.source.logic}/server">
	</property>
	<property name="dir.source.logic.client" value="${dir.source.logic}/client">
	</property>
	<property name="dir.source.media" value="${dir.source}/media">
	</property>
	<property name="dir.temp" value="temp">
	</property>
	<property name="dir.build" value="build">
	</property>
	<property name="cmd.php" value="php">
	</property>
	<property name="cmd.lessc" value="lessc">
	</property>
	<target name="build" depends="build-structure,build-style,build-logic,build-media">
	</target>
	<target name="build-structure">
		<mkdir dir="${dir.build}">
		</mkdir>
		<exec executable="${cmd.php}" output="${dir.build}/draft.html">
			<arg value="${dir.source.structure}/draft.html.php">
			</arg>
		</exec>
	</target>
	<target name="build-style">
		<mkdir dir="${dir.temp}">
		</mkdir>
		<concat destfile="${dir.temp}/draft.less">
			<filelist dir=".">
				<file name="${dir.source.style}/functions.less">
				</file>
			 	<file name="${dir.source.style}/theme.less">
				</file>
			 	<file name="${dir.source.style}/common.less">
				</file>
			 	<file name="${dir.source.style}/concrete.less">
				</file>
			</filelist>
		</concat>
		<mkdir dir="${dir.build}">
		</mkdir>
		<exec executable="${cmd.lessc}">
			<arg value="${dir.temp}/draft.less">
			</arg>
			<arg value="${dir.build}/draft.css">
			</arg>
		</exec>
	</target>
	<target name="build-logic">
		<mkdir dir="${dir.build}">
		</mkdir>
		<concat destfile="${dir.build}/draft.js">
			<filelist dir=".">
				<file name="${dir.source.logic.client}/tools.js">
				</file>
				<file name="${dir.source.logic.client}/table.js">
				</file>
				<file name="${dir.source.logic.client}/toc.js">
				</file>
				<file name="${dir.source.logic.client}/main.js">
				</file>
			</filelist>
		</concat>
	</target>
	<target name="build-media">
		<mkdir dir="${dir.build}">
		</mkdir>
		<copy file="${dir.source.media}/logo.svg" tofile="${dir.build}/logo.svg">
		</copy>
		<copy file="${dir.source.media}/folksprak_16x16.png" tofile="${dir.build}/favicon.png">
		</copy>
	</target>
	<target name="clean">
		<delete dir="${dir.temp}">
		</delete>
	</target>
	<target name="clear" depends="clean,clear-structure,clear-style,clear-logic">
		<delete dir="${dir.build}">
		</delete>
	</target>
	<target name="clear-structure">
		<delete file="${dir.build}/draft.html">
		</delete>
	</target>
	<target name="clear-style">
		<delete file="${dir.build}/draft.css">
		</delete>
	</target>
	<target name="clear-logic">
		<delete file="${dir.build}/draft.js">
		</delete>
	</target>
</project>