Mailing List Archive

using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8
Hello,

This is a follow-up to my previous post on this subject.

The last time I asked, I was told to wait until Forrest 0.8 was
released, then ask again.

I have upgraded one Web site to use Forrest 0.8. Everything appears
OK in the generated static site.

I want to use SVN keyword substitution to put the expansion of the
"Id" keyword for each page in my site in the pelt skin's navstrip,
replacing the "Last published" text.

Currently, I have a locally-modified copy of Forrest 0.7 with the pelt
skin changed in order to suppress the output of the "Last Published"
text. I then use the SVN "Id" keyword in the body of each xdocs
source file.

Now I am using Forrest 0.8, so I would prefer an ideal solution where
I do not have to remember to include the SVN "Id" keyword in each
xdocs source file and enable SVN keyword substitution for each file.

If my ideal solution is not possible, then I will settle for creating
a custom skin based on pelt in order to suppress the "Last Published"
text. I would continue to keep the SVN "Id" keyword in the page body.

Where do I start?

Thanks,
Brolin
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
Brolin Empey wrote:
> Now I am using Forrest 0.8, so I would prefer an ideal solution where
> I do not have to remember to include the SVN "Id" keyword in each
> xdocs source file and enable SVN keyword substitution for each file.
>
> If my ideal solution is not possible, then I will settle for creating
> a custom skin based on pelt in order to suppress the "Last Published"
> text. I would continue to keep the SVN "Id" keyword in the page body.

A custom Cocoon generator was mentioned in the previous thread for this
topic. I can't see how to get what you want without adding data to each
source file.

Also in the old thread, you mentioned rebuilding your static site. A
static build should show the correct modification time, like on
Forrest's site. Is your public site static or dynamic?

Brian
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
On 5/7/07, Brian M Dube <brian.dube@gmail.com> wrote:
> A custom Cocoon generator was mentioned in the previous thread for this
> topic. I can't see how to get what you want without adding data to each
> source file.

The idea was to add the expansion of the SVN "Id" keyword as metadata
to each source file.

I asked what was meant by "metadata", but did not receive an answer.

I was thinking that I could include the "Id" keyword in each source
file, but in the head part of the document or somewhere else other
than the body so that the expansion of the "Id" keyword is not visible
when the document is viewed. Maybe then I could extract the expansion
of the "Id" keyword from the source file and include it in the skin
footer of the generated static page?

> Also in the old thread, you mentioned rebuilding your static site. A
> static build should show the correct modification time, like on
> Forrest's site.

Yes, but only when I am viewing my local copy of the static build.

The Web server that hosts the public site does not send a header to
tell the client when the served document was last modified.

The last modification time in the pelt skin is output by a JavaScript
method call that returns the last modification time of the document.

The problem is that the Web browser does not know when the document
was last modified because the Web server does not tell it.
Consequently, the Web browser (with Firefox on Linux, at least) thinks
the document was last modified when it was served the document.

Needless to say, this is confusing and misleading to someone who does
not understand the problem. This is why I need the last modified time
to be included in the output static page.

> Is your public site static or dynamic?

Static, but see above.
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
Brolin Empey wrote:
> On 5/7/07, Brian M Dube <brian.dube@gmail.com> wrote:
>> A custom Cocoon generator was mentioned in the previous thread for this
>> topic. I can't see how to get what you want without adding data to each
>> source file.
>
> The idea was to add the expansion of the SVN "Id" keyword as metadata
> to each source file.
>
> I asked what was meant by "metadata", but did not receive an answer.

XDoc allows meta elements [1] similar to HTML.

> I was thinking that I could include the "Id" keyword in each source
> file, but in the head part of the document or somewhere else other
> than the body so that the expansion of the "Id" keyword is not visible
> when the document is viewed. Maybe then I could extract the expansion
> of the "Id" keyword from the source file and include it in the skin
> footer of the generated static page?

For example:

<document>
<header>
<title>title</title>
<meta name="svnid">$Id$</meta>
</header>
.
.
.
</document>

After setting the relevant svn properties, your custom skin could make
use of this metadata as you see fit. Pelt relies on common for this part
of the document. See how common handles it [2] as a reference and let us
know if you get stuck.

Brian

[1]
http://forrest.apache.org/dtdx/document-v20.dtdx.html#meta

[2]
$FORREST_HOME/main/webapp/skins/common/xslt/html/site-to-xhtml.xsl
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
Brian,

Here is my plan:

1. Copy pelt and common skins to my Forrest site
2. Make needed changes to my local copies of above skins
3. Get my changes committed to SVN, in order to simplify future
Forrest upgrades, reduce duplication of custom files between my
multiple Forrest sites, and possibly help other Forrest users

Right now I am stuck at step 2.

I decided that it would be better to make a user-set variable to
control whether to suppress the "Last Modified" text in the pelt
skin's header and footer. I used an xsl:choose element to emulate an
if/else construct. An xsl:when element tests a skinconfig variable
named "disable-last-published".

The problem is that I do not know where to declare user-defined skin
variables such as "disable-last-published". I cannot declare my
variable in skinconf.xml, because the name of my variable is not
included in the list of legal elements in the skinconfig DTD.
Furthermore, it appears that I would have to modify some other skin
files in order for the skin to make my variable available for testing
in my xsl:when element.

Initially I was going to declare my variable in forrest.properties,
but I did not know what name to use. I tried setting
"disable-last-published=true" but this did not seem to work.

I know my changes to the pelt skin work because I made the changes
unconditional at first. However, now I am trying to get both the
variable declaration and the conditional xsl template working. I
realise this is a poor idea since I am dealing with 2 unknowns, but I
did not anticipate getting sidetracked by searching for the right
place to declare my variable.

Thanks,
Brolin
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
On Fri, 2007-05-11 at 17:01 -0700, Brolin Empey wrote:
> Brian,
>

hi Brain,

> Here is my plan:
>
> 1. Copy pelt and common skins to my Forrest site
> 2. Make needed changes to my local copies of above skins
> 3. Get my changes committed to SVN, in order to simplify future
> Forrest upgrades, reduce duplication of custom files between my
> multiple Forrest sites, and possibly help other Forrest users
>
> Right now I am stuck at step 2.
>
> I decided that it would be better to make a user-set variable to
> control whether to suppress the "Last Modified" text in the pelt
> skin's header and footer. I used an xsl:choose element to emulate an
> if/else construct. An xsl:when element tests a skinconfig variable
> named "disable-last-published".
>
> The problem is that I do not know where to declare user-defined skin
> variables such as "disable-last-published". I cannot declare my
> variable in skinconf.xml, because the name of my variable is not
> included in the list of legal elements in the skinconfig DTD.
> Furthermore, it appears that I would have to modify some other skin
> files in order for the skin to make my variable available for testing
> in my xsl:when element.
>
> Initially I was going to declare my variable in forrest.properties,
> but I did not know what name to use. I tried setting
> "disable-last-published=true" but this did not seem to work.
>
> I know my changes to the pelt skin work because I made the changes
> unconditional at first. However, now I am trying to get both the
> variable declaration and the conditional xsl template working. I
> realise this is a poor idea since I am dealing with 2 unknowns, but I
> did not anticipate getting sidetracked by searching for the right
> place to declare my variable.

If you want to implement disable-last-published in the skinconf.xml then
you have to patch the core skinconfig DTD or create a new version of it
and use this dtd in your skinconf.

The problem is that you always have to update both files as soon as you
want add new variables.

Are you adventurous?

Since you are now getting into deeper chances of skins (with all the
downside you describe above) you may want to look into the dispatcher.
http://forrest.apache.org/pluginDocs/plugins_0_80/org.apache.forrest.plugin.internal.dispatcher/

It is still in the whiteboard but hopefully not for much more longer. It
takes the skinconf.xml to the next level. You will have full control
over the contracts that you want to add to your pages.

salu2
--
Thorsten Scherler thorsten.at.apache.org
Open Source Java consulting, training and solutions
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
Brolin Empey wrote:
>
> Here is my plan:
>
> 1. Copy pelt and common skins to my Forrest site

You should not need to copy the "common".

> 2. Make needed changes to my local copies of above skins
> 3. Get my changes committed to SVN, in order to simplify future
> Forrest upgrades, reduce duplication of custom files between my
> multiple Forrest sites, and possibly help other Forrest users

No, the project will not be adding copies of skins
to SVN.

If you make your changes optional in the pelt skin
then yes we can add them.

> Right now I am stuck at step 2.
>
> I decided that it would be better to make a user-set variable to
> control whether to suppress the "Last Modified" text in the pelt
> skin's header and footer. I used an xsl:choose element to emulate an
> if/else construct. An xsl:when element tests a skinconfig variable
> named "disable-last-published".

Follow how that is done with other similar "disable-" variables.
See below.

> The problem is that I do not know where to declare user-defined skin
> variables such as "disable-last-published". I cannot declare my
> variable in skinconf.xml, because the name of my variable is not
> included in the list of legal elements in the skinconfig DTD.
> Furthermore, it appears that I would have to modify some other skin
> files in order for the skin to make my variable available for testing
> in my xsl:when element.

Thorsten explained in another email that you need to
add to the skinconf DTD.

> Initially I was going to declare my variable in forrest.properties,
> but I did not know what name to use. I tried setting
> "disable-last-published=true" but this did not seem to work.

To incorporate this in the pelt skin, you need to follow
how other default properties get set. Search the code
and the mailing lists.

Search the code for one of the other "disable-" variables:
find . -type f | xargs grep "disable-compliance-links" | grep -v "\.svn"

e.g. among other things, this show that you need to add to
main/webapp/skins/common/skinconf.xsl ...

As Thorsten says, you might prefer the Dispatcher.

-David

> I know my changes to the pelt skin work because I made the changes
> unconditional at first. However, now I am trying to get both the
> variable declaration and the conditional xsl template working. I
> realise this is a poor idea since I am dealing with 2 unknowns, but I
> did not anticipate getting sidetracked by searching for the right
> place to declare my variable.
>
> Thanks,
> Brolin
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
I am stuck again.

I got the "disable-last-published" variable working by modifying the
skinconfig DTD.

Now I am trying to get my copy of the "pelt" skin to use the value of
my source file's "rev_id" metadata property.

Here is my source file:

...
<document>
<header>
<title>...</title>
<meta name="rev_id">$Id$</meta>
</header>
...

The "Id" keyword is not expanded because I have not yet committed the
changes to my SVN working copy.

Here is what I have in my site's
src/documentation/skins/pelt-brolin/xslt/html/site-to-xhtml.xsl file.
("pelt-brolin" is my copy of the "pelt" skin.)

<xsl:template match="meta[@name = 'rev_id']" name="rev_id">
rev_id template called.
<xsl:value-of select="."/>
</xsl:template>
<xsl:template name="last-published">
<xsl:choose>
<xsl:when test="$config/disable-last-published = 'true'">
checking for rev_id metadata.
<xsl:if test="meta[@name = 'rev_id']">
calling rev_id template.
<xsl:call-template name="rev_id"/>
</xsl:if>
<xsl:value-of select="meta[@name = 'rev_id']"/>
&#160;
</xsl:when>
<xsl:otherwise>
<script type="text/javascript"><![CDATA[<!--
document.write("]]><i18n:text >Last Published:</i18n:text><![CDATA[ "
+ document.lastModified);
// -->]]></script>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


I am new to XSL(T). I have been experimenting with different
approaches, as you can see.

What is the simplest way to have either the "last-published" or
"rev_id" template above output the "$Id$" from my source file's
"rev_id" metadata property? I need a working XSL(T) example.

Thanks,
Brolin
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
Brolin Empey wrote:
> I am stuck again.

You're nearly there.

> I got the "disable-last-published" variable working by modifying the
> skinconfig DTD.
>
> Now I am trying to get my copy of the "pelt" skin to use the value of
> my source file's "rev_id" metadata property.
>
> Here is my source file:
>
> ...
> <document>
> <header>
> <title>...</title>
> <meta name="rev_id">$Id$</meta>
> </header>
> ...
>
> The "Id" keyword is not expanded because I have not yet committed the
> changes to my SVN working copy.
>
> Here is what I have in my site's
> src/documentation/skins/pelt-brolin/xslt/html/site-to-xhtml.xsl file.
> ("pelt-brolin" is my copy of the "pelt" skin.)
>
> <xsl:template match="meta[@name = 'rev_id']" name="rev_id">
> rev_id template called.
> <xsl:value-of select="."/>
> </xsl:template>
> <xsl:template name="last-published">
> <xsl:choose>
> <xsl:when test="$config/disable-last-published = 'true'">
> checking for rev_id metadata.
> <xsl:if test="meta[@name = 'rev_id']">
> calling rev_id template.
> <xsl:call-template name="rev_id"/>
> </xsl:if>
> <xsl:value-of select="meta[@name = 'rev_id']"/>
> &#160;
> </xsl:when>
> <xsl:otherwise>
> <script type="text/javascript"><![CDATA[<!--
> document.write("]]><i18n:text >Last Published:</i18n:text><![CDATA[ "
> + document.lastModified);
> // -->]]></script>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
>
> I am new to XSL(T). I have been experimenting with different
> approaches, as you can see.
>
> What is the simplest way to have either the "last-published" or
> "rev_id" template above output the "$Id$" from my source file's
> "rev_id" metadata property? I need a working XSL(T) example.

What you have is close. I just tested something similar.

<xsl:template name="last-published">
<xsl:choose>
<xsl:when test="$config/disable-last-published = 'true'">
<xsl:if test="//meta-data/meta[@name = 'rev_id']">
<xsl:value-of select="//meta-data/meta[@name = 'rev_id']"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<script>...</script>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

The omitted script in the lower part is the same as you have; the
original last-published template content. You can use a separate
template (your rev_id template) if you like, but this is short enough
that I wouldn't bother.

Brian
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
David Crossley wrote:
> Brolin Empey wrote:
>> Here is my plan:
>>
>> 1. Copy pelt and common skins to my Forrest site
>
> You should not need to copy the "common".

If you copy pelt and leave in the import calls, the calls fail unless
you also copy common.

Brian
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
Brolin Empey wrote:
>
> I got the "disable-last-published" variable working by modifying the
> skinconfig DTD.

If this is intended for contribution, then that is
confusing. The "disable-last-published" should switch
it off. Some other parameter should control the method,
if it is enabled.

> ... I need a working XSL(T) example.

There are plenty of examples in the existing
stylesheets. As i said in another email, use your
system's "find" facility to follow how another
parameter is handled.

-David
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
Thorsten:
I might consider using the dispatcher in the future, if I need to make
more changes to the pelt skin. For now, I will settle with hacking
pelt to fit my needs. :)

David:
I copied the "common" skin because the documentation I read about
creating a new skin said to do so.

I should have been more clear about which changes I wanted to get
committed. I wanted my changes to the pelt skin to be committed, not
my entire copied skin.

If you use "grep -F" to match a fixed string then you do not need to
escape the period character in the pattern as you do when using grep
to match a regex. I am not sure how portable "grep -F" is, though.
It works with GNU grep, which is pretty much all that matters in the
desktop Linux world. :)

Brian:
Thank you so much! :D
pelt-brolin is successfully using the "rev_id" metadata property from
my source file now!

David:
You are correct. I realise that the behaviour of my variable is
confusing. My plan was to get things working first, then worry about
making the configuration more logical.

I know there are plenty of existing examples. I also know how to use
find(1). The problem was that I could not find any examples of what I
was trying to do: extract text from a "meta" element in the "header"
section of a source file. I did search for a suitable example, but
could not find one. That is why I decided to ask on this list.
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
Brolin Empey wrote:
>
> David:
> I copied the "common" skin because the documentation I read about
> creating a new skin said to do so.

Thanks, we we need to remember to update such docs
when we fix it to use Locationmap.

> Brian:
> Thank you so much! :D
> pelt-brolin is successfully using the "rev_id" metadata property from
> my source file now!

Great.

> David:
> You are correct. I realise that the behaviour of my variable is
> confusing. My plan was to get things working first, then worry about
> making the configuration more logical.

Fair enough.

> I know there are plenty of existing examples. I also know how to use
> find(1).

My hints were intended to reach others too, not just you.

> The problem was that I could not find any examples of what I
> was trying to do: extract text from a "meta" element in the "header"
> section of a source file.

Earlier we suggested using the "header/version" element, and
the FAQ talks about that. So following its processing
would give the general idea.

> I did search for a suitable example, but
> could not find one. That is why I decided to ask on this list.

Good, and your questions probably help others
to do similar things.

-David
Re: using Subversion keyword substitution instead of published date in skin navstrip - using Forrest 0.8 [ In reply to ]
I found a problem: my site has a page containing a contact form.
Because it uses HTML form elements, the contact form page uses an HTML
source file instead of xdocs. The problem is that the "rev_id"
metadata property does not seem to be used with the contact form page.
The static HTML page that Forrest (Cocoon) generates does contain a
"rev_id" metadata property, but the property's value is blank.

Here is the relevant part of the HTML source for the contact form page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>...</title>
<meta name="rev_id" content="$Id$">
</head>

I also tried with xdocs syntax for the "rev_id" property, but this did
not work either.

The xdocs syntax is:

<meta name="rev_id">$Id$</meta>

Can I use a metadata property with an HTML source file? If yes, how?

Thanks,
Brolin