kaz         02/05/01 15:37:47

  Modified:    src/dvsl/xdocs site.dvsl
               src/java/org/apache/maven DVSLPathTool.java
               src/test/org/apache/maven DVSLPathToolTest.java
  Log:
  Made a few changes:
  
  - Renamed xdocs/project.xml to xdocs/navigation.xml to avoid unnecessary
    confusion with the project.xml in the base directory (the POM).
    Confused yet?  :-)
  
  - Based on an idea from saimonm, the navigation bar is customizable now.
    The implementation that we decided with was allowing a per-directory
    navigation.xml file (formerly xdocs/project.xml).  That way each
    directory of xdocs can have a different logo, or navigation links.  If
    a navigation.xml file does not exist in the current directory, it will
    use the top-level one in xdocs directory.
  
  - Also added the ability to offer expanding navbar.  For example, the
    new maven navbar (excluding the autogenerated maven stuff) looks like
    this:
  
       - Goals
       - Features
       - News and Status
       - Getting Started
       - Reference
       - Powered By
  
    The relevant lines from the navigation.xml file that created that menu
    bar are:
  
      <menu name="Overview">
        <item name="Goals"                   href="/goals.html"/>
        <item name="Features"                href="/features.html"/>
        <item name="News and Status"         href="/status.html"/>
        <item name="Getting Started"         href="/start/index.html"/>
        <item name="Reference"               href="/ref/index.html"/>
        <item name="Powered By"              href="/powered.html"/>
      </menu>
  
    Now, if one clicks on "Getting Started", the navbar looks like this:
  
       - Goals
       - Features
       - News and Status
       - Getting Started
         - Download
         - Install
         - Integrate
         - Use
         - Build
         - Anakia Users
       - Reference
       - Powered By
  
    This is accomplished because the getting started docs now reside in
    "xdocs/start" directory and this directory has its own navigation.xml
    file of which the contents are:
  
      <menu name="Overview">
        <item name="Goals"                   href="/goals.html"/>
        <item name="Features"                href="/features.html"/>
        <item name="News and Status"         href="/status.html"/>
        <item name="Getting Started"         href="/start/index.html">
          <item name="Download"              href="/start/download.html"/>
          <item name="Install"               href="/start/install.html"/>
          <item name="Integrate"             href="/start/integrate.html"/>
          <item name="Use"                   href="/start/use.html"/>
          <item name="Build"                 href="/start/bootstrap.html"/>
          <item name="Anakia Users"          href="/start/anakia.html"/>
        </item>
        <item name="Reference"               href="/ref/index.html"/>
        <item name="Powered By"              href="/powered.html"/>
      </menu>
  
    As you can see, <item> can contain other <item> elements which appear
    as subitems.  This enables you to create expandable menus.
  
  Overall, by allowing the user to specify their own navigation.xml file
  on a per-directory basis, you have complete control over the navigation
  bar on the left for a set of documents.  And by using the subitem
  feature, you can create hierarchial menus.
  
  Revision  Changes    Path
  1.36      +81 -59    jakarta-turbine-maven/src/dvsl/xdocs/site.dvsl
  
  Index: site.dvsl
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/dvsl/xdocs/site.dvsl,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- site.dvsl 29 Apr 2002 22:51:48 -0000      1.35
  +++ site.dvsl 1 May 2002 22:37:46 -0000       1.36
  @@ -2,7 +2,7 @@
   ## V E L O C I T Y    M A C R O S                                    ##
   #######################################################################
   
  -## Prints a standard navbar for navigation.
  +## Alternator for row style in a table
   ##
   #macro (printRow $count)
     #if ($count % 2 > 0)
  @@ -12,42 +12,61 @@
     #end
   #end
   
  +## Sets the navigation file
  +##
  +#macro (loadNavigation $filename)
  +  #set( $nav = $node.selectSingleNode("document('$filename')/project") )
  +#end
  +
  +## Selects the appropriate navigation file to use for the navbar.  The
  +## current search priority is: 
  +##    
  +##    - navigation.xml in current directory
  +##    - navigation.xml in xdocs directory 
  +##    - projext.xml in xdocs directory (deprecated)
  +##    - project.xml in xdocs/stylesheets
  +##
  +#macro (selectNavigation $fileUtil $docSrc)
  +
  +  #if ($fileUtil.file("$docSrc/$currentDir/navigation.xml").exists())
  +    #loadNavigation ("$docSrc/$currentDir/navigation.xml")
  +
  +  #elseif ($fileUtil.file("$docSrc/navigation.xml").exists())
  +    #loadNavigation ("$docSrc/navigation.xml")
  +  
  +  #elseif ($fileUtil.file("$docSrc/project.xml").exists())
  +    #loadNavigation ("$docSrc/project.xml")
  +
  +  #elseif ($fileUtil.file("$docSrc/stylesheets/project.xml").exists())
  +    #loadNavigation ("$docSrc/stylesheets/project.xml")
  +  #end
  +
  +#end
  +
  +#######################################################################
  +## D V S L    M A T C H I N G    S T A R T S    H E R E              ##
  +#######################################################################
  +
   #match( "document" )
     <!DOCTYPE html PUBLIC "-//CollabNet//DTD XHTML 1.0 Transitional//EN"
         "http://www.collabnet.com/dtds/collabnet_transitional_10.dtd";>
   
  -  #set( $projectDescriptorFilename = "$context.toolbox.basedir/project.xml")
  -  #set( $projectFilename = "$context.toolbox.docSrc/project.xml")
  -  #set( $anakiaProjectFilename = "$context.toolbox.docSrc/stylesheets/project.xml")
  -  
     ## Setup the relativePath using the toolbox.
  -
  -  #set( $filename = $context.getAppValue("infilename"))
  -  #set( $relativePath = $context.toolbox.pathtool.getRelativePath($filename))
  +  #set( $infilename = $context.getAppValue("infilename"))
  +  #set( $currentDir = $context.toolbox.pathtool.getDirectoryComponent($infilename))
  +  #set( $relativePath = $context.toolbox.pathtool.getRelativePath($infilename))
   
     ## Grab a reference to the project descriptor here so we can pull
     ## info from it such as the cvs web url, etc ...
  +  #set( $pomFilename = "$context.toolbox.basedir/project.xml")
  +  #set( $pom = $node.selectSingleNode("document('$pomFilename')/project"))
   
  -  #set( $projectDescriptor = 
$node.selectSingleNode("document('$projectDescriptorFilename')/project"))
  -
  -  ## Check to see if an xdocs/projects.xml file exists, if so, use that
  -  ## as the navigation file; otherwise, check to see if someone is using
  -  ## Anakia and has the file in xdocs/stylesheets directory.
  -
  -  #set( $projectFile = $context.toolbox.fileutil.file($projectFilename))
  -  #set( $anakiaProjectFile = $context.toolbox.fileutil.file($anakiaProjectFilename))
  -
  -  #if ($projectFile.exists())
  -      #set( $project = 
$node.selectSingleNode("document('$projectFilename')/project" ) )
  -  #else
  -      #if ($anakiaProjectFile.exists())
  -          #set( $project = 
$node.selectSingleNode("document('$anakiaProjectFilename')/project" ) )
  -      #end
  -  #end        
  +  ## Selects the correct navigation file to use for this document.
  +  #selectNavigation ($context.toolbox.fileutil $context.toolbox.docSrc)
   
     <html>
       <head>
  -      <title>$!project.title - $node.properties.title</title>
  +      <title>$!nav.title - $node.properties.title</title>
   
         <style type="text/css">
           @import url("$relativePath/style/tigris.css");
  @@ -72,16 +91,16 @@
           <table border="0" cellspacing="0" cellpadding="8" width="100%">
             <tr>
               <td>
  -              #if( $project.organizationLogo )
  +              #if( $nav.organizationLogo )
   
  -                #set( $alt = $project.organizationLogo )
  -                #set( $src = $project.organizationLogo.attribute("href") )
  +                #set( $alt = $nav.organizationLogo )
  +                #set( $src = $nav.organizationLogo.attribute("href") )
   
  -                #if ( $projectDescriptor.organization.url )
  -                  #set( $home = $projectDescriptor.organization.url )
  +                #if ( $pom.organization.url )
  +                  #set( $home = $pom.organization.url )
                   #else
                     ## Fall back to the project url
  -                  #set( $home = $project.attribute( "href" ) )
  +                  #set( $home = $nav.attribute( "href" ) )
                   #end
   
                   <a href="$home">
  @@ -103,15 +122,15 @@
               </td>
               <td>
                 <div align="right" id="login">
  -                #if( $project.logo )
  +                #if( $nav.logo )
   
  -                  #set( $alt = $project.logo )
  -                  #if( $project.attribute("href") )
  -                    #set( $home = $project.attribute("href") )
  +                  #set( $alt = $nav.logo )
  +                  #if( $nav.attribute("href") )
  +                    #set( $home = $nav.attribute("href") )
                     #else
  -                    #set( $home = $projectDescriptor.url )
  +                    #set( $home = $pom.url )
                     #end
  -                  #set( $src = $project.logo.attribute( "href" ) )
  +                  #set( $src = $nav.logo.attribute( "href" ) )
   
                     <a href="$home">
                     #if ( $src.startsWith("http") )
  @@ -131,8 +150,8 @@
           <table border="0" cellspacing="0" cellpadding="4" width="100%">
             <tr>
               <td> 
  -              #if ($project.get("body/links/*"))
  -              $context.applyTemplates( $project, "body/links" )
  +              #if ($nav.get("body/links/*"))
  +              $context.applyTemplates( $nav, "body/links" )
                 #else
                 &nbsp;
                 #end
  @@ -146,8 +165,8 @@
             <td id="leftcol" width="20%">
               <div id="navcolumn">
   
  -              #if ($project)
  -                $context.applyTemplates( $project, "body/menu" )
  +              #if ($nav)
  +                $context.applyTemplates( $nav, "body/menu" )
                 #end
             
                 ## Standard Maven Navigation 
  @@ -159,11 +178,11 @@
                   #if 
($context.toolbox.fileutil.file("$context.toolbox.docSrc/tasks.xml").exists())
                   <div><small><a 
href="$relativePath/tasks.html">Tasks</a></small></div>
                   #end
  -                #if ($projectDescriptor.cvsWebUrl)
  -                <div><small><a href="$projectDescriptor.cvsWebUrl">CVS 
Repository</a></small></div>
  +                #if ($pom.cvsWebUrl)
  +                <div><small><a href="$pom.cvsWebUrl.toString().trim()">CVS 
Repository</a></small></div>
                   #end
  -                #if ($projectDescriptor.issueTrackingUrl)
  -                <div><small><a href="$projectDescriptor.issueTrackingUrl">Issue 
Tracking</a></small></div>
  +                #if ($pom.issueTrackingUrl)
  +                <div><small><a href="$pom.issueTrackingUrl.toString().trim()">Issue 
Tracking</a></small></div>
                   #end
                   <div><small><a href="$relativePath/changelog.html">Change 
Log</a></small></div>
                   #if ($context.toolbox.testSrcPresent == "true")
  @@ -172,9 +191,9 @@
                   #if ($context.toolbox.srcPresent == "true")
                   <div><small><a href="$relativePath/jdepend-report.html">Metric 
Results</a></small></div>
                   <div><small><a 
href="$relativePath/checkstyle-report.html">Checkstyle Report</a></small></div>
  +                #end
                   <div><small><a 
href="$relativePath/apidocs/">JavaDocs</a></small></div>
                   <div><small><a href="$relativePath/xref/">Source 
XReference</a></small></div>
  -                #end
                   <div><small><a 
href="http://jakarta.apache.org/turbine/maven/development-process.html";>Development 
Process</a></small></div>
                 </div>
   
  @@ -197,15 +216,15 @@
           <table border="0" cellspacing="0" cellpadding="4">
             <tr>
               <td>
  -              #if( $projectDescriptor.organization.name )
  -                #if( $projectDescriptor.inceptionYear )
  -                    #if( $projectDescriptor.inceptionYear.toString() == 
$context.toolbox.currentYear )
  -                &copy; ${context.toolbox.currentYear}, 
$projectDescriptor.organization.name
  +              #if( $pom.organization.name )
  +                #if( $pom.inceptionYear )
  +                    #if( $pom.inceptionYear.toString() == 
$context.toolbox.currentYear )
  +                &copy; ${context.toolbox.currentYear}, $pom.organization.name
                       #else
  -                &copy; 
${projectDescriptor.inceptionYear}-${context.toolbox.currentYear}, 
$projectDescriptor.organization.name
  +                &copy; ${pom.inceptionYear}-${context.toolbox.currentYear}, 
$pom.organization.name
                       #end
                   #else
  -                &copy; ${context.toolbox.currentYear}, 
$projectDescriptor.organization.name
  +                &copy; ${context.toolbox.currentYear}, $pom.organization.name
                   #end
                 #else
                   &copy; 1999-2002, Apache Software Foundation
  @@ -233,11 +252,14 @@
   #match( "menu" )
     <div>
       <strong>$attrib.name</strong>
  -    #foreach ($item in $node.selectNodes("item"))
  -      <div><small>
  -      #itemLink( $item )
  -      </small></div>
  -    #end
  +    $context.applyTemplates( "item" )
  +  </div>
  +#end
  +
  +#match( "item" )
  +  <div>
  +    <small> #itemLink( $node ) </small>
  +    $context.applyTemplates( "item" )
     </div>
   #end
   
  @@ -373,9 +395,9 @@
   #end
   
   #match("file")
  -  <a href="$projectDescriptor.cvsWebUrl$node.name.value()">
  +  <a href="$pom.cvsWebUrl.toString().trim()$node.name.value()">
       $node.name.value()</a> - 
  -  <a 
href="$projectDescriptor.cvsWebUrl$node.name.value()?rev=$node.revision.value()&amp;content-type=text/vnd.viewcvs-markup">
  +  <a 
href="$pom.cvsWebUrl.toString().trim()$node.name.value()?rev=$node.revision.value()&amp;content-type=text/vnd.viewcvs-markup">
       v$node.revision.value()</a> <br/>
   #end
   
  
  
  
  1.4       +34 -1     
jakarta-turbine-maven/src/java/org/apache/maven/DVSLPathTool.java
  
  Index: DVSLPathTool.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/DVSLPathTool.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DVSLPathTool.java 22 Apr 2002 01:14:56 -0000      1.3
  +++ DVSLPathTool.java 1 May 2002 22:37:46 -0000       1.4
  @@ -62,7 +62,7 @@
    * relative paths.
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Pete Kazmier</a>
  - * @version $Id: DVSLPathTool.java,v 1.3 2002/04/22 01:14:56 dion Exp $
  + * @version $Id: DVSLPathTool.java,v 1.4 2002/05/01 22:37:46 kaz Exp $
    */
   public class DVSLPathTool
   {
  @@ -156,6 +156,39 @@
           }
   
           return determineRelativePath(filename, separator);
  +    }
  +
  +    /** 
  +     * Determines the directory component of a filename.  This is useful
  +     * within DVSL templates when used in conjunction with the DVSL's
  +     * <code>$context.getAppValue("infilename")</code> to get the
  +     * current directory that is currently being processed.
  +     * <p/>
  +     * This method is thread-safe.
  +     * 
  +     * @param filename The filename to be parsed.
  +     * @return The directory portion of the <code>filename</code>.  If
  +     * the filename does not contain a directory component, "." is
  +     * returned.
  +     */
  +    public static final String getDirectoryComponent(String filename)
  +    {
  +        if (filename == null || filename.length() == 0)
  +        {
  +            return "";
  +        }
  +
  +        String separator = determineSeparator(filename);
  +        String directory = Strings.chomp(filename, separator);
  +
  +        if (filename.equals(directory))
  +        {
  +            return ".";
  +        }
  +        else
  +        {
  +            return directory;
  +        }
       }
   
       /** 
  
  
  
  1.3       +33 -2     
jakarta-turbine-maven/src/test/org/apache/maven/DVSLPathToolTest.java
  
  Index: DVSLPathToolTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/test/org/apache/maven/DVSLPathToolTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DVSLPathToolTest.java     18 Mar 2002 04:38:49 -0000      1.2
  +++ DVSLPathToolTest.java     1 May 2002 22:37:46 -0000       1.3
  @@ -62,7 +62,7 @@
    * Unit test for <code>DVSLPathTool</code>.
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Pete Kazmier</a>
  - * @version $Id: DVSLPathToolTest.java,v 1.2 2002/03/18 04:38:49 kaz Exp $
  + * @version $Id: DVSLPathToolTest.java,v 1.3 2002/05/01 22:37:46 kaz Exp $
    */
   public class DVSLPathToolTest extends TestCase 
   {
  @@ -77,6 +77,37 @@
       }
   
       /** 
  +     * Tests <code>DVSLPathTool.getDirectoryComponent</code>.
  +     */
  +    public void testGetDirectoryComponent()
  +    {
  +        String[] test = 
  +        {
  +            "file1.xml", 
  +            "ref/file1", 
  +            "/home/test/file2.vm", 
  +            "d1\\d2\\d3\\file", 
  +            "/d1/d2/"
  +        };
  +
  +        String[] expected = 
  +        {
  +            ".", 
  +            "ref", 
  +            "/home/test", 
  +            "d1\\d2\\d3", 
  +            "/d1/d2"
  +        };
  +
  +        DVSLPathTool pt = new DVSLPathTool();
  +
  +        for (int i = 0; i < test.length; i++)
  +        {
  +            assertEquals(expected[i], pt.getDirectoryComponent(test[i]));
  +        }
  +    }
  +
  +    /** 
        * Tests <code>DVSLPathTool.getRelativePath</code>.  
        */
       public void testGetRelativePath()
  @@ -179,7 +210,7 @@
        * both expected values are stored as part of the class.
        * 
        * @author <a href="mailto:[EMAIL PROTECTED]";>Pete Kazmier</a>
  -     * @version $Id: DVSLPathToolTest.java,v 1.2 2002/03/18 04:38:49 kaz Exp $
  +     * @version $Id: DVSLPathToolTest.java,v 1.3 2002/05/01 22:37:46 kaz Exp $
        */
       private static class TestArgs
       {
  
  
  


Reply via email to