Actualización del fichero site.xml (Gaia Framework) con ANT
He introducido un pequeño cambio en el fichero build.xml, para que actualice los parámetros bytes y seoBytes del fichero site.xml, de momento solo actualiza el tag page, además he actualizado el framework de gaia con la versión 3.2.0.
Para actualizar el fichero site.xml solo es necesario ejecutar el nuevo target refresh-site-xml, este automáticamente actualizará el fichero xml. Se sobrescribe el fichero site.xml a continuación se muestra el código del target y demás macros.
<target name="refresh-site-xml">
<echo message="refresh-site-xml"/>
<update-page-site-xml/>
</target>
<macrodef name="update-bytes-page">
<attribute name="input" default="home"/>
<attribute name="bytes" default="0"/>
<attribute name="seoBytes" default="0"/>
<sequential>
<echo message="@{input}"/>
<if>
<equals arg1="${seoBytes}" arg2="0" />
<then>
<xmltask source="${bin}/site.xml" dest="${bin}/site3.xml">
<attr path="//page[@id='@{input}']" attr="bytes" value="@{bytes}"/>
<attr path="//page[@id='@{input}']" attr="seoBytes" remove="true"/>
</xmltask>
</then>
<else>
<xmltask source="${bin}/site.xml" dest="${bin}/site3.xml">
<attr path="//page[@id='@{input}']" attr="bytes" value="@{bytes}"/>
<attr path="//page[@id='@{input}']" attr="seoBytes" value="@{seoBytes}"/>
</xmltask>
</else>
</if>
<copy file="${bin}/site3.xml" tofile="${bin}/site.xml"
overwrite="true"/>
<delete file="${bin}/site3.xml"/>
</sequential>
</macrodef>
<macrodef name="update-page-site-xml">
<sequential>
<xmltask source="${bin}/site.xml" dest="${bin}/site2.xml">
<call path="//page">
<param name="swffile" path="@src"/>
<param name="htmlfile" path="@seo" default="false"/>
<param name="ident" path="@id" default="false"/>
<actions>
<var name="branch" value="" unset="true"/>
<var name="existSwf" value="" unset="true"/>
<var name="existHtmlSeo" value="" unset="true"/>
<var name="existHtmlId" value="" unset="true"/>
<var name="bytes" unset="true"/>
<var name="seoBytes" value="0" unset="true"/>
<available file="${bin}\@{swffile}" property="existSwf"/>
<available file="${bin}\@{htmlfile}.html" property="existHtmlSeo"/>
<available file="${bin}\@{ident}.html" property="existHtmlId"/>
<if>
<equals arg1="${existSwf}" arg2="true" />
<then>
<length file="${bin}/@{swffile}" property="bytes" />
<get-branch-page input="site" page="@{ident}"/>
<if>
<equals arg1="${existHtmlSeo}" arg2="true" />
<then>
<length file="${bin}/@{htmlfile}.html" property="seoBytes" />
</then>
<elseif>
<equals arg1="${existHtmlId}" arg2="true" />
<then>
<length file="${bin}/@{ident}.html" property="seoBytes" />
</then>
</elseif>
<else>
<var name="seoBytes" value="0"/>
</else>
</if>
<update-bytes-page input="@{ident}" bytes="${bytes}" seoBytes="${seoBytes}"/>
</then>
</if>
</actions>
</call>
</xmltask>
<delete file="${bin}/site2.xml"/>
</sequential>
</macrodef>
Para descargar el fichero
pulsa aquí.



Thank you for your superb job. I like it very much.
While working with your script, I’ve found an issue in “get-branch” macro.
Here is my test site.xml:
After scaffolding, I’ve got an error in Page.as, seems like it has a wrong page structure. May I asking you to fix that? Thanks in advance.
XML is here: http://dl.dropbox.com/u/129805/site.xml
Hello kyoji, thanks you. i change this macro to solve that issue, change the “get-branch” macro in build.xml file for:
<macrodef name="get-branch"> <attribute name="input" default=""/> <attribute name="parent" default=""/> <sequential> <echo message="get-branch: @{input} | @{parent}"/> <xmltask source="${sitexml}"> <call path="@{input}/page"> <param name="class" path="@id"/> <actions> <var name="uppercase" unset="true"/> <var name="lowercase" unset="true"/> <var name="ruta" unset="true"/> <var name="parentid" unset="true"/> <uppercase property="uppercase" input="@{class}"/> <lowercase property="lowercase" input="@{class}"/> <drop-first-character property="ruta" input="@{parent}/${lowercase}"/> <var name="pagesconst" value="${pagesconst}${line.separator} public static const ${uppercase}:String = '${ruta}';"/> <get-branch input="@{input}/page[@id='@{class}']" parent="@{parent}/${lowercase}"/> </actions> </call> </xmltask> </sequential> </macrodef>Hello Sobre Mi, I have customized your code to meet my own needs, and upload it to git.
Please check this out:
http://github.com/kyoji2/RobotGaiaAnt
Feel free to inform me if there is a better way to give you a credit info.
Really appreciate your help.
Hello kyoji, thanks for the credit. I add a new link in the blog to that project.
wow!!.. keep up the good job!!
Thanks angel
Hi Sobre Mi, how’s the thing going on.
I updated the ant file to support assets bytes updating basically base on your “update-page-site-xml” function. It work fine unless if there are assets using the same id. Any ideas to fix that?
btw, I also fixed some bugs in “seo-scaffolding”, and add a “xml-remove-bytes” function to suit my need.
check http://github.com/kyoji2/RobotGaiaAnt