Title: RE: [nant-dev] New NAnt tasks (NVelocity)

Here is the start of something, I think I would need some more direction on what you think you want the site to look like.  I certainly think that some kind of html template will help you a lot with this site.  Theoretically, getting the content together should be the hardest part, since the style can be changed at whim in the site template.  I have kind of taken a liking to the Jakarta feel, so NVelocity takes its style from there, but anything is really possible.

I didn't try to tackle the user documentation, it looks like you might have generated that from something else (based on the file names).  You can take a look at the NAnt task pages on the NVelocity site (http://nvelocity.sourceforge.net) to see that I borrowed and modified your task definition page layout and was able to simply that to a structure that can be included in a page that looks like:

    <nanttask name="anakia">
        <description>
        Anakia is a XML transformation tool that uses NVelocity templates merged with XML documents to transform XML into the format of your choice.  This page was generated using the AnakiaTask.

        </description>
        <parameters>
                <parameter name="destdir" required="true">Directory in which to store the results.</parameter>
                <parameter name="extension" required="false">This is the extension that is appended to the end of your .xml file. For example, with an extension of ".html", index.xml would be converted into index.html. By default, the extension is .html.</parameter>

                <parameter name="style" required="true">This is the path to the .vsl template</parameter>
                <parameter name="projectFile" required="false">This is the path to a "project" file. This file is an XML file that can be used as a "navigation" file. If you look at the Anakia example in the NVelocity/examples/anakia directory, you can see the project.xml file being used in the .vsl file.</parameter>

                <parameter name="lastModifiedCheck" required="false">This turns on or off the ability to check the last modified date on files in order to determine whether or not they need to be re-rendered or not. The value of this attribute can be "true, false, yes, no". By default, it is true, meaning that the last modified date should be checked and if the original .xml file, project file, or .vsl file have not changed, then don't process the page. This accelerates processing because pages that have not changed will not get reprocessed.</parameter>

                <parameter name="templatePath" required="true">This is the path to the templateRoot which is the directory where your site.vsl file is located. This can be defined in the nvelocity.properties or it can be defined here. It it an optional argument if it is defined in the NVelocity properties file already. However, if defined, this value will override the path defined in the nvelocity.properties file.</parameter>

                <parameter name="propertiesFile" required="false">This is the path to the nvelocity.properties file. It is an optional argument and by default is set to find the properties file in the same directory that the JVM was started in.</parameter>

        </parameters>
        <context>
                <object name="$root">This contains the root XmlElement to your .xml document. When this (or any other variable containing an element) are simply placed into template output, their XML form is rendered.</object>

                <object name="$project">This contains the root XmlElement to your project.xml document. If you have not specified a project.xml document, then this variable will not be in the context.</object>

                <object name="$escape.GetText($string)">This context object will convert HTML Entities in the $string that is passed into it and it will return the converted String. This is good for dealing with CDATA. The entities that are converted are: " -&gt; &amp;quot; | &lt; -&gt; &amp;lt; | &gt; -&gt; &amp;gt; | &amp; - &gt; &amp;amp; </object>

                <object name="$relativePath">This contains a String which is the relative path to your .xml document from the BaseDirectory of the fileset that was specified in your NAnt task attributes. Please see the examples/anakia .vsl document for example usage of this String.</object>

                <object name="$date">This is an instance of System.Date.Now. Useful for putting the current date/time into a page.</object>

        </context>
        <example>
            <p class="i1">This is the task definition to create the NVelocity site documentation</p>
            <pre class="code">&lt;anakia basedir="../xdocs"
    destdir="../wwwsite"
    extension=".html"
    style="../xdocs/stylesheets/site.vsl"
    projectFile="../xdocs/stylesheets/project.xml"
    templatePath="../xdocs/stylesheets"
    lastModifiedCheck="true"&gt;
        &lt;fileset basedir="../xdocs"&gt;
                &lt;includes name="**/*.xml"/&gt;
                &lt;excludes name="**/stylesheets/*" /&gt;
        &lt;/fileset&gt;
&lt;/anakia&gt;
 </pre>
        </example>
    </nanttask>

I am attaching zips of the /xdocs folder that has all of the "source" to build the web site and the generated html itself.  Here is the additional task that I added to my local copy of the projects NAnt.build file:

    <target name="xdocs" description="Create html docs from xdocs.">
        <anakia basedir="xdocs"
            destdir="doc/site"
            extension=".html"
            style="xdocs/stylesheets/site.vsl"
            projectFile="xdocs/stylesheets/project.xml"
            templatePath="xdocs/stylesheets"
            lastModifiedCheck="true">
                <fileset basedir="xdocs">
                        <includes name="**/*.xml"/>
                        <excludes name="**/stylesheets/*" />
                </fileset>
        </anakia>
       
        <copy todir="doc/site">
            <fileset basedir="xdocs">
                <includes name="**/*.jpg"/>
                <includes name="**/*.gif"/>
                <includes name="**/*.ico"/>
                <includes name="**/*.css"/>
            </fileset>
        </copy>
    </target>

You will also need to make sure that you have the NAnt tasks from NVelocity and NVelocity itself, with all of its dependencies:

        NVelocity.NantTasks.dll (it is named NVelocity.NAnt.dll in the version 0.3 download, I will fix that in later builds).

        NVelocity.dll
        Commons.dll
        Log4net.dll

The idea here is that you define you content in xml files that can be processed and inserted into a site template (.vsl).  The project.xml file contains the navigation menu for the site.  Anakia transforms each xml file, combined with information from the project.xml, with the site template to generate .html files.

Let me know what you think of this so far and more of what you are thinking if you like the direction.

Cort

-----Original Message-----
From: Gerry Shaw [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 23, 2002 11:04 PM
To: 'Cort Schaefer'; [EMAIL PROTECTED]
Subject: RE: [nant-dev] New NAnt tasks (NVelocity)

This is an interesting project Cort.  I've taken a look at it and it
seems like it might solve a problem we have been facing but I'm having a
hard time getting started with it.

We want to convert the nant documentation into some sort of format that
doesn't have any layout it.  Our initial thoughts were docbook but I and
other do not have experience with it.  I would be willing to try out
using nvelocity if you could help us out a bit.

What I need is:
* a simple example that could generate a web site very similar to what
we already have.  Just a couple of pages that show the navigation bar on
the top getting created and the format of the template and content
files.

* the nant build file that would take the templates and generate the
.html files that we could post to the site.

If nothing else it would make for a great example for your project.

 

Attachment: xdocs.zip
Description: Binary data

Attachment: site.zip
Description: Binary data

Reply via email to