You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by do...@cocoon.apache.org on 2004/11/27 22:57:37 UTC

[Cocoon Wiki] New: CocoonCLIAndRelativeURI

   Date: 2004-11-27T13:57:37
   Editor: KajKandler <Ka...@conficio.com>
   Wiki: Cocoon Wiki
   Page: CocoonCLIAndRelativeURI
   URL: http://wiki.apache.org/cocoon/CocoonCLIAndRelativeURI

   no comment

New Page:

==  Page title (cookbook approach, tutorial , ...) ==
- TARGET-AUDIENCE: beginner '''*advanced*''' expert[[BR]]
- COCOON-RELEASES: 2.1.4[[BR]]
- DOCUMENT-STATUS: '''*draft*''' reviewed released[[BR]]
----

=== What you will get from this page ===
The ability to generate static Websites that are independent of their context. Due to this independence they can be run on a Servlet Engine (Tomcat/Jetty) in a context (i.e. http://<test-server>/<your-context>/first-level/index.html), as well as generated to the root of a website (i.e. http://your-web-server/first-level/index.html)
=== Your basic skills ===
Cocoon sitemap, CSS, Forrest Menu system, based on LinkRewriter
=== Technical prerequisites ===
Cocoon 2.1.4 or newer, LinkRewriter sytem like in the LinkRwriter example
=== Links to other information sources ===

=== The Issue ===
You want to address static resources like ''/resources/theme/main.css'' and ''/resources/images/logo.png'' in your website. However, you don't want to modify your main sitemap.xmap and route these absolute Request to the appropriate project sitemap (because I have more than one of these for different projects).

=== The solution(s) (I came up with) ===

First, use the LinkRewrite mechanism from Forrest and address these things using ''site:main.css'' and ''site:logo.png'' with  
your site.xml file looking like this
{{{
<resources href="resources/">
	<images href="images/">
		<logo.png href="logo.png"/>
	</images>
	<theme href="theme/">
		<main.css href="main.css"/>
	</theme>
</resources>
}}}
If you want to add such references in the ''xslt transformations'', then you need to make sure you make the LinkRewriting Transformation last.

This leaves resources in the CSS files like 
{{{
.back_xxx {
	BACKGROUND-IMAGE: url(/resources/images/background.png);
}
}}}
out in the dark. The LinkRewriter does operate on attributes of xml elements. Therefore, I can't just transform my stylesheet with it. But stylesheets allow relative URLs (and interprets them relative to the stylesheet location). Now my stylesheet looks like this
{{{
.back_xxx {
	BACKGROUND-IMAGE: url(../images/background.png);
}
}}}
This is acceptable, because the stylesheet is itself a single (static)resource.

Comments are welcome!
----
===  page metadata ===
- AUTHOR:KajKandler[[BR]]
- AUTHOR-CONTACT: mailto:KajKandler_delete_me_@conficio.com[[BR]]
- REVIEWED-BY:[[BR]]
- REVIEWER-CONTACT:[[BR]]