Hmm...

David Crossley wrote:

Ross Gardler wrote:
CFAS Webmaster wrote:
All,

I'm submitting this to the dev list because I *think* this is new behaviour in 0.8. I haven't tried it again with 0.7 as this machine is a bit low on disk space.

I have an HTML file that I'm processing through Forrest, http://www.cfas.org/Committees/Application.html if you're interested. It included a Javascript file in a <script> tag. Unfortunately Forrest is trying to process the tag contents and replace them.

That is not really what is happening. Cocoon is looking
in the standard places and not finding the specified resource.

The error message is this:

X [0] Committees/dues.js BROKEN: /home/kronenpj/src/svn/forrest/main/webapp/./resources/scripts/Committees/dues.js (No such file or directory)

While it's true that the ./resources/scripts/Committees/dues.js file doesn't exist, that's not how I'm referencing it in the HTML file. The tag is this in the source, in the Committees subdirectory:

<script src="dues.js" language="javascript" type="text/javascript"></script>

While I can place the Javascript file into Forrest's resources/scripts/Committees, that's not where I feel it belongs. I would like to know what piece within Forrest to change to make it comply, if that's possible.

"How to include additional Javascript and CSS files?"
http://forrest.apache.org/docs/faq.html#javascript
I saw that, but it feels like it's talking specifically about including Javascript for the old skin stuff.

Don't forget that you need the special URL /skin/dues.js
or perhaps /skin/Committees/dues.js to match.
I'd just point out that this isn't part of a skin, nor does it do anything like that. This may be a case of a legacy-name for the /skin/ directory, but...

However, if this is "legacy html" (i.e. you cannot
edit the sources), then add the javascript to the
default resources/scripts/ directory. The trouble will
then be that Cocoon will use relative references from
there so it will look in resources/scripts/Committees/
and resources/scripts/Committees/sub-dir/ ... yuk.
Fortunately it's not legacy HTML, just a page that uses an included javascript file. Agreed - Yuk. That would place this file in the Forrest tree even though it's specific to a site, which is not in the Forrest tree anywhere.

You can see that default match at main/webapp/resources.xmap
line 153 ...
<!-- @deprecated -->
<map:match pattern="**.js">
<map:read src="resources/scripts/{1}.js" mime-type="application/x-javascript" />
</map:match>

I wonder if we should change that so that it first
looked in sub-directories and then looked at the
top-level of resources/scripts/
That would be nice for me, but is it the "right" thing to do for the general case?

That says "deprecated". I wonder why. Supposedly
because now the main technique is that skin-specific
method described in the FAQ. However this is still
needed for legacy html.

BTW, how will this be handled with Dispatcher?
Would it still use the technique described in the FAQ?

Otherwise Paul, as always you can over-ride any
match as Ross describes below.
I'd take you up on that, but it doesn't work. I think I've found the "right place" for it, but it doesn't change the behavior.

...
<map:pipelines>
 <map:pipeline>
...
   <map:match pattern="dues.js">
<map:read src="{project:content}/Committees/dues.js" mime-type="text/plain"/>
   </map:match>
 </map:pipeline>
</map:pipelines>

If map:match pattern... is placed almost anywhere else in the file it doesn't validate. No matter where it's placed, it doesn't change the behavior of Cocoon. :(

-Paul

-David

Don't touch the Forrest core files (unless you feel your modification would be useful to a wider audience).

If you don't like the location Forrest wants to put scripts then simply write a match in your project sitemap to intercept this request. Something like:

<map:match pattern="dues.js">
 <map:read src="{project:content}/foo/bar/dues.js" .../>
</map:match>

Ross