mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-01 05:44:41 +03:00
921f382c6a
Move client side templates from "handlebars_templates" to "templates_src/client_side"
427 lines
17 KiB
XML
427 lines
17 KiB
XML
<project name="mibew messenger" default="all">
|
|
|
|
|
|
<property name="mibew_path" value="mibew" />
|
|
<property name="closure.c" value="/opt/closure/compiler.jar" />
|
|
<property name="handlebars" value="handlebars" />
|
|
<property name="dialogs_styles_path" value="${mibew_path}/styles/dialogs" />
|
|
<property name="pages_styles_path" value="${mibew_path}/styles/pages" />
|
|
<property name="js_path" value="${mibew_path}/js" />
|
|
|
|
|
|
<!-- Compile Handlebars templates for dialogs styles -->
|
|
<target name="dialogs_handlebars" description="Compile Handlebars templates for dialogs styles">
|
|
<echo>Flatten templates directory structure</echo>
|
|
|
|
<!-- Use system 'mkdir' instead of ant 'mkdir' task because it do not
|
|
work with dirsets -->
|
|
<apply executable="mkdir" addsourcefile="false">
|
|
<targetfile />
|
|
<dirset dir=".">
|
|
<include name="${dialogs_styles_path}/*/templates_src/client_side" />
|
|
</dirset>
|
|
<mapper type="glob" from="*/templates_src/client_side" to="*/templates_compiled/client_side_tmp" />
|
|
</apply>
|
|
|
|
<!-- Flatten templates directory structure -->
|
|
<apply executable="tools/flat_cp" force="true">
|
|
<srcfile />
|
|
<targetfile />
|
|
<arg value="client_side" />
|
|
<fileset dir=".">
|
|
<include name="${dialogs_styles_path}/*/templates_src/client_side/**/*.handlebars" />
|
|
</fileset>
|
|
<mapper type="regexp" from="^(.*)/templates_src/client_side/(.*)$$" to="\1/templates_compiled/client_side_tmp" />
|
|
</apply>
|
|
|
|
<echo>Compile templates</echo>
|
|
|
|
<!-- Compile templates -->
|
|
<apply executable="${handlebars}">
|
|
<arg value="-f"/>
|
|
<targetfile />
|
|
<dirset dir=".">
|
|
<include name="${dialogs_styles_path}/*/templates_compiled/client_side_tmp" />
|
|
</dirset>
|
|
<mapper type="glob" from="*/client_side_tmp" to="*/client_side/templates_tmp.js" />
|
|
</apply>
|
|
|
|
<!-- Use closule compiler instead of handlebars minifyer (-m flag)
|
|
because of handlebars does not insert line breaks.
|
|
Very long lines are cutted by ant and this brings problems -->
|
|
<apply executable="java">
|
|
<arg value="-jar" />
|
|
<arg value="${closure.c}" />
|
|
<arg value="--js" />
|
|
<srcfile />
|
|
<arg value="--js_output_file" />
|
|
<targetfile />
|
|
<fileset dir=".">
|
|
<include name="${dialogs_styles_path}/*/templates_compiled/client_side/templates_tmp.js" />
|
|
</fileset>
|
|
<mapper type="glob" from="*_tmp.js" to="*_tmp.c.js" />
|
|
</apply>
|
|
|
|
<!-- Add license info. Use move because of it is the best way to append
|
|
some info to files -->
|
|
<move todir="${dialogs_styles_path}" overwrite="true">
|
|
<fileset dir="${dialogs_styles_path}"/>
|
|
<mapper type="glob" from="*/templates_compiled/client_side/templates_tmp.c.js" to="*/templates_compiled/client_side/templates.js"/>
|
|
|
|
<filterchain>
|
|
<!-- Add header -->
|
|
<concatfilter prepend="tools/compiled_templates_header.txt" />
|
|
<!-- Skip empty lines -->
|
|
<linecontainsregexp negate="true">
|
|
<regexp pattern="^\s+$$" />
|
|
</linecontainsregexp>
|
|
</filterchain>
|
|
</move>
|
|
|
|
<!-- Remove all temporary files -->
|
|
<!-- Use system 'rm' instead of ant
|
|
'delete' task because it does not work with dirsets -->
|
|
<echo>Remove temporary files</echo>
|
|
<apply executable="rm">
|
|
<arg value="-r" />
|
|
<arg value="-f" />
|
|
<dirset dir=".">
|
|
<include name="${dialogs_styles_path}/*/templates_compiled/client_side_tmp" />
|
|
</dirset>
|
|
</apply>
|
|
|
|
<delete>
|
|
<fileset dir=".">
|
|
<include name="${dialogs_styles_path}/*/templates_compiled/client_side/templates_tmp.js" />
|
|
</fileset>
|
|
</delete>
|
|
|
|
<echo>Done</echo>
|
|
</target>
|
|
|
|
<!-- Compile Handlebars templates for pages styles -->
|
|
<target name="pages_handlebars" description="Compile Handlebars templates for pages styles">
|
|
<!-- Compile applications templates -->
|
|
<apply executable="${handlebars}">
|
|
<arg value="-f"/>
|
|
<targetfile />
|
|
<dirset dir=".">
|
|
<include name="${pages_styles_path}/*/templates_src/client_side/*" />
|
|
</dirset>
|
|
<mapper
|
|
type="regexp"
|
|
from="^(.*)/templates_src/client_side/(.*)$$"
|
|
to="\1/templates_compiled/client_side/\2_app_tmp.tpl.js"
|
|
/>
|
|
</apply>
|
|
|
|
<!-- Use closule compiler instead of handlebars minifyer (-m flag)
|
|
because of handlebars does not insert line breaks.
|
|
Very long lines are cutted by ant and this brings problems -->
|
|
<apply executable="java">
|
|
<arg value="-jar" />
|
|
<arg value="${closure.c}" />
|
|
<arg value="--js" />
|
|
<srcfile />
|
|
<arg value="--js_output_file" />
|
|
<targetfile />
|
|
<fileset dir=".">
|
|
<include name="${pages_styles_path}/*/templates_compiled/client_side/*_app_tmp.tpl.js" />
|
|
</fileset>
|
|
<mapper type="glob" from="*_app_tmp.tpl.js" to="*_app_tmp.c.tpl.js" />
|
|
</apply>
|
|
|
|
<!-- Add license info. Use move because of it is the best way to append
|
|
some info to files -->
|
|
<move todir="${pages_styles_path}" overwrite="true">
|
|
<fileset dir="${pages_styles_path}">
|
|
<include name="*/templates_compiled/client_side/*_tmp.c.tpl.js" />
|
|
</fileset>
|
|
<!--<mapper type="glob" from="*/templates_compiled/client_side/*_tmp.c.tpl.js" to="*.tpl.js"/>-->
|
|
<mapper type="glob" from="*_tmp.c.tpl.js" to="*.tpl.js"/>
|
|
|
|
<filterchain>
|
|
<!-- Add header -->
|
|
<concatfilter prepend="tools/compiled_templates_header.txt" />
|
|
<!-- Skip empty lines -->
|
|
<linecontainsregexp negate="true">
|
|
<regexp pattern="^\s+$$" />
|
|
</linecontainsregexp>
|
|
</filterchain>
|
|
</move>
|
|
|
|
<!-- Remove all temporary files. -->
|
|
<delete>
|
|
<fileset dir="${pages_styles_path}">
|
|
<include name="*/templates_compiled/client_side/*_tmp.tpl.js" />
|
|
</fileset>
|
|
</delete>
|
|
|
|
<echo>Done</echo>
|
|
</target>
|
|
|
|
|
|
<!-- Compile Handlebars templates for all styles (both dialogs and pages) -->
|
|
<target name="styles_handlebars" depends="pages_handlebars,dialogs_handlebars" description="Compile Handlebars templates for all styles">
|
|
<echo>Handlebars templates from all styles are built.</echo>
|
|
</target>
|
|
|
|
|
|
<!-- Compile and concatenate JavaScript files for dialog styles -->
|
|
<target name="styles_js" description="Compile JavaScript files for all dialogs styles">
|
|
<echo>Compile and concatenate JavaScript files for dialogs styles:</echo>
|
|
|
|
<!-- Create temporary directories for compiled JavaScript files -->
|
|
<echo>Create temporary directories</echo>
|
|
<apply executable="mkdir" addsourcefile="false">
|
|
<targetfile />
|
|
<dirset dir=".">
|
|
<include name="${dialogs_styles_path}/*/js/source" />
|
|
</dirset>
|
|
<mapper type="glob" from="*/source" to="*/tmp" />
|
|
</apply>
|
|
|
|
<!-- Compile JavaScript files -->
|
|
<echo>Compile JavaScript files</echo>
|
|
<apply executable="java">
|
|
<arg value="-jar" />
|
|
<arg value="${closure.c}" />
|
|
<arg value="--js" />
|
|
<srcfile />
|
|
<arg value="--js_output_file" />
|
|
<targetfile />
|
|
<fileset dir=".">
|
|
<include name="${dialogs_styles_path}/*/js/source/*.js" />
|
|
</fileset>
|
|
<mapper type="regexp" from="^(.+)/source/(.+)$$" to="\1/tmp/\2" />
|
|
</apply>
|
|
|
|
<!-- Concatenate all scripts in one file. Use special script for
|
|
expanding wildcards. -->
|
|
<echo>Concatenate JavaScript files</echo>
|
|
<apply executable="tools/cat">
|
|
<srcfile suffix="/*.js"/>
|
|
<targetfile />
|
|
<dirset dir=".">
|
|
<include name="${dialogs_styles_path}/*/js/tmp" />
|
|
</dirset>
|
|
<mapper type="glob" from="*/tmp" to="*/compiled/scripts.js" />
|
|
</apply>
|
|
|
|
<!-- Remove temporary directories -->
|
|
<echo>Remove temporary directories</echo>
|
|
<apply executable="rm">
|
|
<arg value="-r" />
|
|
<arg value="-f" />
|
|
<dirset dir=".">
|
|
<include name="${dialogs_styles_path}/*/js/tmp" />
|
|
</dirset>
|
|
</apply>
|
|
|
|
<echo>Done</echo>
|
|
</target>
|
|
|
|
|
|
<!-- Build all stuff related to dialogs styles -->
|
|
<target name="styles_all" depends="styles_handlebars,styles_js" description="Run styles_handlebars and styles_js targets">
|
|
<echo>Styles built.</echo>
|
|
</target>
|
|
|
|
|
|
<!-- Compile all JavaScript files of the Mibew Core -->
|
|
<target name="core_js">
|
|
<echo>Compile JavaScript files of the Mibew Core</echo>
|
|
|
|
<!-- Copy directory tree from source to compiled -->
|
|
<echo>Copy directory tree</echo>
|
|
<copy todir="${js_path}/compiled">
|
|
<dirset dir="${js_path}/source">
|
|
<include name="**" />
|
|
</dirset>
|
|
</copy>
|
|
|
|
<!-- Compile JavaScript files -->
|
|
<echo>Compile JavaScript files</echo>
|
|
<apply executable="java">
|
|
<arg value="-jar" />
|
|
<arg value="${closure.c}" />
|
|
<arg value="--js" />
|
|
<srcfile />
|
|
<arg value="--js_output_file" />
|
|
<targetfile />
|
|
<fileset dir=".">
|
|
<include name="${js_path}/source/**/*.js" />
|
|
</fileset>
|
|
<mapper type="regexp" from="^(.+)/source/(.+)$$" to="\1/compiled/\2" />
|
|
</apply>
|
|
|
|
<echo>Done</echo>
|
|
</target>
|
|
|
|
|
|
<!-- Build JavaScript application -->
|
|
<target name="app_js">
|
|
<echo>Build "${app_name}" JavaScript application</echo>
|
|
|
|
<!-- Remove old application file -->
|
|
<delete file="${js_path}/compiled/${app_name}_app.js" />
|
|
|
|
<!-- Append application files to the result file -->
|
|
<concat destfile="${js_path}/compiled/${app_name}_app.js" eol="lf">
|
|
<!-- Append application static initialization code -->
|
|
<filelist dir="${js_path}/compiled/${app_name}" files="init.js" />
|
|
|
|
<!-- Include files from ${js_path}/compiled/${app_name}/ -->
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="*.js" />
|
|
<exclude name="init.js" />
|
|
<exclude name="app.js" />
|
|
</fileset>
|
|
|
|
<!-- Include models files -->
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="models/**/base*.js" />
|
|
</fileset>
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="models/**/*.js" />
|
|
<!-- Exclude base files -->
|
|
<exclude name="models/**/base*.js" />
|
|
</fileset>
|
|
|
|
<!-- Include collections files -->
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="collections/**/base*.js" />
|
|
</fileset>
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="collections/**/*.js" />
|
|
<!-- Exclude base files -->
|
|
<exclude name="collections/**/base*.js" />
|
|
</fileset>
|
|
|
|
<!-- Include models views files -->
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="model_views/**/base*.js" />
|
|
</fileset>
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="model_views/**/*.js" />
|
|
<!-- Exclude base files -->
|
|
<exclude name="model_views/**/base*.js" />
|
|
</fileset>
|
|
|
|
<!-- Include collections views files -->
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="collection_views/**/base*.js" />
|
|
</fileset>
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="collection_views/**/*.js" />
|
|
<!-- Exclude base files -->
|
|
<exclude name="collection_views/**/base*.js" />
|
|
</fileset>
|
|
|
|
<!-- Include regions files -->
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="regions/**/base*.js" />
|
|
</fileset>
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="regions/**/*.js" />
|
|
<!-- Exclude base files -->
|
|
<exclude name="regions/**/base*.js" />
|
|
</fileset>
|
|
|
|
<!-- Include layouts files -->
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="layouts/**/base*.js" />
|
|
</fileset>
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="layouts/**/*.js" />
|
|
<!-- Exclude base files -->
|
|
<exclude name="layouts/**/base*.js" />
|
|
</fileset>
|
|
|
|
<!-- Include all other files -->
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="**/base*.js" />
|
|
<exclude name="models/**/base*.js" />
|
|
<exclude name="collections/**/base*.js" />
|
|
<exclude name="model_views/**/base*.js" />
|
|
<exclude name="collection_views/**/base*.js" />
|
|
<exclude name="regions/**/base*.js" />
|
|
<exclude name="layouts/**/base*.js" />
|
|
</fileset>
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="**/*.js" />
|
|
<!-- Exclude files from ${js_path}/compiled/${app_name}/ -->
|
|
<exclude name="*.js" />
|
|
<!-- Exclude models, collections, views, regions and layouts
|
|
files -->
|
|
<exclude name="models/**/*.js" />
|
|
<exclude name="collections/**/*.js" />
|
|
<exclude name="model_views/**/*.js" />
|
|
<exclude name="collection_views/**/*.js" />
|
|
<exclude name="regions/**/*.js" />
|
|
<exclude name="layouts/**/*.js" />
|
|
<!-- Exclude base files -->
|
|
<exclude name="**/base*.js" />
|
|
</fileset>
|
|
|
|
<fileset dir="${js_path}/compiled/${app_name}">
|
|
<include name="app.js" />
|
|
</fileset>
|
|
|
|
<!-- Apply filters -->
|
|
<filterchain>
|
|
<!-- Skip empty lines -->
|
|
<linecontainsregexp negate="true">
|
|
<regexp pattern="^\s+$$" />
|
|
</linecontainsregexp>
|
|
</filterchain>
|
|
</concat>
|
|
|
|
<echo>Done</echo>
|
|
</target>
|
|
|
|
|
|
<!-- Build JavaScript files related to default application -->
|
|
<target name="default_app_js" depends="core_js" description="Build JavaScript files related to default application">
|
|
<antcall target="app_js">
|
|
<param name="app_name" value="default" />
|
|
</antcall>
|
|
<echo>Default JavaScript application built.</echo>
|
|
</target>
|
|
|
|
|
|
<!-- Compile and concatenate JavaScript files related to chat application -->
|
|
<target name="chat_app_js" depends="default_app_js" description="Build JavaScript files related to chat application">
|
|
<antcall target="app_js">
|
|
<param name="app_name" value="chat" />
|
|
</antcall>
|
|
<echo>Chat JavaScript application built.</echo>
|
|
</target>
|
|
|
|
|
|
|
|
<!-- Compile and concatenate JavaScript files related to users application -->
|
|
<target name="users_app_js" depends="default_app_js" description="Build JavaScript files related to users application">
|
|
<antcall target="app_js">
|
|
<param name="app_name" value="users" />
|
|
</antcall>
|
|
<echo>Users JavaScript application built.</echo>
|
|
</target>
|
|
|
|
|
|
<!-- Compile and concatenate JavaScript files related to thread log application -->
|
|
<target name="thread_log_app_js" depends="default_app_js" description="Build JavaScript files related to thread log application">
|
|
<antcall target="app_js">
|
|
<param name="app_name" value="thread_log" />
|
|
</antcall>
|
|
<echo>Thread log JavaScript application built.</echo>
|
|
</target>
|
|
|
|
|
|
<!-- Build all project -->
|
|
<target name="all" depends="chat_app_js,thread_log_app_js,users_app_js,styles_all" description="Build everything">
|
|
<echo>Mibew Messenger built.</echo>
|
|
</target>
|
|
|
|
|
|
</project> |