You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Sergey Missan <ad...@javable.com> on 2003/03/05 03:39:00 UTC

suppressing index.html

Hello,

I was playing a bit more with Forrest and tried to suppress generation
of .../index.html links in menus (but still keeping them in site.xml).

I've changed the code in skins/common/book2menu.xsl to:

  <xsl:template name="unselected">
  <xsl:choose>
   <xsl:when test="contains(@href,'index.html')">
    <xsl:variable name="dir">
      <xsl:call-template name="dirname">
        <xsl:with-param name="path" select="@href"/>
      </xsl:call-template>
    </xsl:variable>
     <a href="{$dir}"><xsl:value-of select="@label"/></a>
   </xsl:when>
   <xsl:otherwise>
     <a href="{@href}"><xsl:value-of select="@label"/></a>
   </xsl:otherwise>
  </xsl:choose>
  </xsl:template>

and this stopped forrest from generating my files containing index.html
in their names! My understanding was that book2menu.xsl takes site.xml
or book.xml as a source and generates the navigational stuff. Now it
looks like it has a mind of its own?

-- Sergey



Re: suppressing index.html

Posted by Jeff Turner <je...@apache.org>.
On Wed, Mar 05, 2003 at 01:17:03AM -0400, Sergey Missan wrote:
> Hello Jeff,
> 
> Wednesday, March 05, 2003, 12:52:01 AM, you wrote:
> 
> JT> Is it wrong because the {begin,ch1,ch2}/index.html files don't exist?
> Yes,
> and
> 
> JT> If you have a link to 'ch1/', then unless you're planning to give the
> JT> user a directory listing, you'll have to serve a real file. Typically
> JT> 'ch1/' redirects to 'ch1/index.html'.  If Cocoon generated that file, why
> JT> wouldn't it be in the menu, and therefore be highlighted?
> 
> this is because different directories may have different index files
> -- it may be .shtml, .jsp, etc. It's confusing for user to have
> different index files in different cases, much better to have
> /-trailing urls (consistent), and let http server sort the mess.
> 
> 
> JT> If so, then there is an easyish fix: prevent the Cocoon command-line from
> JT> trying to render the links to directories (and adding 'index.html').
> 
> I tried that and no luck (yet). I'll try again and give you a sensible
> (hopefully) test case on all these issues.

I've found the best way to debug these "is Cocoon crawling the link"
problems is to launch the site as a webapp ('forrest run'), and then
request pages with ?cocoon-view=links.

> JT> So the question is whether the problem is with the Cocoon command-line,
> JT> or the Forrest stylesheets.
> probably both. Cocoon adds (unnecessary) index.html-s, but it looks like
> forrest stylesheets expect a filename in the urls, or they wont work
> properly (test case is how forrest determines current document and
> adds a sel. style to it in the menu).

The Forrest menu is baked into the pages it links to.  If you want a menu
link 'ch/' to link to 'ch/index.jsp', presumably index.jsp will be
responsible to rendering the menu, not Forrest.


--Jeff


> -- Sergey
> 
> 

Re[2]: suppressing index.html

Posted by Sergey Missan <ad...@javable.com>.
Hello Jeff,

Wednesday, March 05, 2003, 12:52:01 AM, you wrote:

JT> Is it wrong because the {begin,ch1,ch2}/index.html files don't exist?
Yes,
and

JT> If you have a link to 'ch1/', then unless you're planning to give the
JT> user a directory listing, you'll have to serve a real file. Typically
JT> 'ch1/' redirects to 'ch1/index.html'.  If Cocoon generated that file, why
JT> wouldn't it be in the menu, and therefore be highlighted?

this is because different directories may have different index files
-- it may be .shtml, .jsp, etc. It's confusing for user to have
different index files in different cases, much better to have
/-trailing urls (consistent), and let http server sort the mess.


JT> If so, then there is an easyish fix: prevent the Cocoon command-line from
JT> trying to render the links to directories (and adding 'index.html').

I tried that and no luck (yet). I'll try again and give you a sensible
(hopefully) test case on all these issues.

JT> So the question is whether the problem is with the Cocoon command-line,
JT> or the Forrest stylesheets.
probably both. Cocoon adds (unnecessary) index.html-s, but it looks like
forrest stylesheets expect a filename in the urls, or they wont work
properly (test case is how forrest determines current document and
adds a sel. style to it in the menu).

-- Sergey



Re: suppressing index.html

Posted by Jeff Turner <je...@apache.org>.
On Wed, Mar 05, 2003 at 12:03:46AM -0400, Sergey Missan wrote:
> Hello Jeff,
> 
> JT> I'm not sure what you're trying to do.  Do you want to completely exclude
> JT> .../index.html links, or just trim off the 'index.html' bit?
> Sorry, I should explain myself better -- yes trim the 'index.html'
> part in menu-s. Most of url-s we have are directories, and I don't
> like this index.html-centric behavior of forrest.

Neither do I.  It's a Cocoon command-line thing. There was some talk
recently of fixing it.

> If I use directories in my site.xml, for example:
> 
>    <begin label="test" href="begin/">
>     <ch1 label="Part1" href="ch1/"/>
>     <ch2 label="Part2" href="ch2/"/>
>    </begin>
> 
> forrest will
>  1 add index.html to the resulting links in menu (wrong!)

Is it wrong because the {begin,ch1,ch2}/index.html files don't exist?

Put another way, if you type 'forrest run', then view the site at
http://localhost:8888/, does the menu behave as expected?

If so, then there is an easyish fix: prevent the Cocoon command-line from
trying to render the links to directories (and adding 'index.html').

http://marc.theaimsgroup.com/?l=forrest-dev&m=104605498612122&w=2
http://cvs.apache.org/~jefft/tmp/forrest/skipdirs.tgz

>  2 won't properly highlight selected document in menu (looks like it
>  related to the way it does $actual-path = $path-noext" in book2menu
>  -- it requires name of the file there, not just directory)

If you have a link to 'ch1/', then unless you're planning to give the
user a directory listing, you'll have to serve a real file. Typically
'ch1/' redirects to 'ch1/index.html'.  If Cocoon generated that file, why
wouldn't it be in the menu, and therefore be highlighted?

> JT> So if the menu doesn't point to foo/index.html, and it isn't referenced
> JT> in the body of any page, then it is assumed un-get-to-able and won't be
> JT> rendered.  Perhaps this is the problem?
> 
> No, it just the way menu (and tabs too) are generated. It requires name of the file
> to be specified in site.xml, or adds index.html to all links. And I want
> it to leave those /-terminated links alone.

So the question is whether the problem is with the Cocoon command-line,
or the Forrest stylesheets.

--Jeff



> -- Sergey
> 
> 

Re[3]: suppressing index.html

Posted by Sergey Missan <ad...@javable.com>.
 Hello Jeff,

A couple of things to add:

When I found that site.xml containing directories as links

     <ch1 label="Part1" href="ch1/"/>

lead to the erroneous (your opinion may vary) menu generation, I
decided to add index.html there, eg:

<ch1 label="Part1" href="ch1/index.html"/>

(the gain is that selected document is properly recognised and
highlighted in the menu), but get rid of index.html-s in menu afterwards.
I was thinking that since book2menu is evoked after the document body
is rendered (that what I thought, anyways), I can safely truncate index.html there, which will lead
to the index.html-free menus. But it affected the whole rendering process
somehow.

-- Sergey



Re[2]: suppressing index.html

Posted by Sergey Missan <ad...@javable.com>.
Hello Jeff,

JT> I'm not sure what you're trying to do.  Do you want to completely exclude
JT> .../index.html links, or just trim off the 'index.html' bit?
Sorry, I should explain myself better -- yes trim the 'index.html'
part in menu-s. Most of url-s we have are directories, and I don't
like this index.html-centric behavior of forrest. If I use directories
in my site.xml, for example:

   <begin label="test" href="begin/">
    <ch1 label="Part1" href="ch1/"/>
    <ch2 label="Part2" href="ch2/"/>
   </begin>

forrest will
 1 add index.html to the resulting links in menu (wrong!)
 2 won't properly highlight selected document in menu (looks like it
 related to the way it does $actual-path = $path-noext" in book2menu
 -- it requires name of the file there, not just directory)
 

JT> So if the menu doesn't point to foo/index.html, and it isn't referenced
JT> in the body of any page, then it is assumed un-get-to-able and won't be
JT> rendered.  Perhaps this is the problem?

No, it just the way menu (and tabs too) are generated. It requires name of the file
to be specified in site.xml, or adds index.html to all links. And I want
it to leave those /-terminated links alone.

-- Sergey



Re: suppressing index.html

Posted by Jeff Turner <je...@apache.org>.
On Tue, Mar 04, 2003 at 10:39:00PM -0400, Sergey Missan wrote:
> Hello,
> 
> I was playing a bit more with Forrest and tried to suppress generation
> of .../index.html links in menus (but still keeping them in site.xml).

I'm not sure what you're trying to do.  Do you want to completely exclude
.../index.html links, or just trim off the 'index.html' bit?

> I've changed the code in skins/common/book2menu.xsl to:
> 
>   <xsl:template name="unselected">
>   <xsl:choose>
>    <xsl:when test="contains(@href,'index.html')">
>     <xsl:variable name="dir">
>       <xsl:call-template name="dirname">
>         <xsl:with-param name="path" select="@href"/>
>       </xsl:call-template>
>     </xsl:variable>
>      <a href="{$dir}"><xsl:value-of select="@label"/></a>
>    </xsl:when>
>    <xsl:otherwise>
>      <a href="{@href}"><xsl:value-of select="@label"/></a>
>    </xsl:otherwise>
>   </xsl:choose>
>   </xsl:template>
> 
> and this stopped forrest from generating my files containing index.html
> in their names! My understanding was that book2menu.xsl takes site.xml
> or book.xml as a source and generates the navigational stuff. Now it
> looks like it has a mind of its own?

The way Forrest works is:

 - Render a page, eg index.html
 - Request links for that page, eg index.html?cocoon-view=links
 - For each link, recursively render, chase links, etc.

So if the menu doesn't point to foo/index.html, and it isn't referenced
in the body of any page, then it is assumed un-get-to-able and won't be
rendered.  Perhaps this is the problem?  What are you trying to achieve
by stripping off index.html, but still requiring those pages?

Also, perhaps this will help:
 
http://xml.apache.org/forrest/faq.html#index.html


--Jeff


> -- Sergey
> 
>