I don't know if it's helpful, but I just finish writing a "css.xsp" page that does two things:

1. looks in the current page's resource folder for a "style.css" page,

2. looks in the resources folder of each of its ancestor pages, and grabs the first
style.css page it finds.

It then returns these only if they exists as (for example):

<css>
<link rel="stylesheet" type="text/css" href="/lenya/academic_affairs/live/pageone/style.css" /> <link rel="stylesheet" type="text/css" href="/lenya/academic_affairs/live/pageone/pagetwo/style.css" />
</css>

Then I just added a pipeline and aggregated it into XML being fed to page2xhtml.xsl and copied the
contents of /css into the proper place in that template.

It's ugly, but it seems to work. It also has hard coded directory seperators ("/"), so if you're running windows you'll have to swap them out. It's at least an idea of how to handle your multiple stylesheets. I also hard-coded the name of the stylesheet, which would probably be best handed down to the xsp as a parameter from the sitemap. Now why didn't I think of that before?

Our requirements were that each page pick up the global stylesheet, its unique stylesheet, if there was one,
and the stylesheet of its nearest ancestor page, if one existed.

I organized them so the more local stylesheets over-ride the more global stylesheets.

Our idea is like yours, Derek, in that we'll hand edit and place those stylesheets, and in our scheme, we can have whole sections (based on the nearest ancestor stylesheet over-riding parts of the global stylesheet) with different color schemes, backgrounds, etc.

I'm working with 1.2, and I"m guessing that lots of this is taken care of by the templating in 1.4.

Can't wait.

For what it's worth, here's the css.xsp:

=========================

<xsp:page
  language="java"
  xmlns:xsp="http://apache.org/xsp";
  xmlns:input="http://apache.org/cocoon/xsp/input/1.0";
  xmlns:xsp-request="http://apache.org/xsp/request/2.0";
  >

  <xsp:structure>
<xsp:include>org.apache.lenya.cms.publication.Publication</xsp:include>
    <xsp:include>java.io.File</xsp:include>
    <xsp:include>java.lang.String</xsp:include>
  </xsp:structure>

 <css>
 <xsp:logic>
Publication publication = (Publication) <input:get-attribute module="page-envelope" as="object" name="publication"/>; String docid = <input:get-attribute module="page-envelope" as="string" name="document-id"/>;
        /* starts in publication directory */
        File sc = publication.getDirectory();
String rootStr = sc.getPath() + "/resources/" + <input:get-attribute module="page-envelope" as="string" name="area"/>;
        String cssName = "style.css";
        String pattern = "/";
        String dirs[] = null;
        dirs = docid.split(pattern);
        int ancestor = 0;
        
        for (int i = dirs.length - 2; i &gt; -1; i--) {
                String cPath = "";
                for (int j = 0; j &lt; i + 1; j++) {
                        if (!dirs[j].equals("")) {
                        cPath = cPath + dirs[j] + "/";
                        }
                }
                if (!cPath.equals("")) {
                        File css = new File(rootStr + "/" + cPath + cssName);
                        if (css.exists() &amp;&amp; ancestor == 0) {
<xsp:content><link rel="stylesheet" type="text/css"><xsp:attribute name="href"><input:get-attribute module="page-envelope" as="string" name="context-prefix"/>/<input:get-attribute module="page-envelope" name="publication-id" as="string"/>/<input:get-attribute module="page-envelope" as="string" name="area"/>/<xsp:expr>cPath + cssName</xsp:expr></xsp:attribute></link></xsp:content>
                                        ancestor = 1;
                        }
                }
        }
        
        File css = new File(rootStr + docid + "/" + cssName);
                        if (css.exists()) {
<xsp:content><link rel="stylesheet" type="text/css"><xsp:attribute name="href"><input:get-attribute module="page-envelope" as="string" name="context-prefix"/>/<input:get-attribute module="page-envelope" name="publication-id" as="string"/>/<input:get-attribute module="page-envelope" as="string" name="area"/><xsp:expr>docid + "/" + cssName</xsp:expr></xsp:attribute></link></xsp:content>
                }
  </xsp:logic>    
 </css>

</xsp:page>

=========================
On Jan 27, 2006, at 4:46 PM, Derek Harmel wrote:

but be assured, after one or two months of utter confusion, things
become easier. initially, lenya is like shooting sparrows with cannons, as a german proverb says. everything is fiendishly complicated and much
too powerful and generic for simple problems.
but after a month or so, the sparrows are all dead, and when you start
tackling the bigger targets, cannons are actually quite fun to use.

I hope so, I'm slowly learning, which is the problem. I'm not very patient.

is this just a static stylesheet, or do you want your editors to be able
to change it on a page-by-page basis?

Hmm, yes the content in the stylesheet would be static, but I want to
the stylesheet that is loaded to be dynamic and determined by a
pipeline.

Perhaps I didn't explain well enough.  My thought was to enable an
editor to add a stylesheet named "thispage.css" in any content
directory (not through lenya, through access to the filesystem) in
which they needed additional styling.

if it's static, no need to deal with pipelines, just reference it as
href="{$root}/css/yourstyle.css" and put it in
<pub>/resources/shared/css. if you want one stylesheet per page, you
could use "{$root}/css/{$document-id}.css", but this pretty much negates
the idea of content management, since you will want consistent design.

Not entirely, if the page-specific CSS is included before the global
stylesheet (page.css) this shouldn't be too much of a problem.
Additionally, there is likely going to be only one person who will be
doing this, and they will have control of the global stylesheet as
well.  But the motivation for doing this is basically what you talked
about with image alignment.

Using "{$root}/css/{$document-id}.css" would work, but I personally
liked my idea of having the CSS file stored in the same place as the
content, it's a bit more concise.  I also figured this would be a good
execise in using xmaps, but I just don't follow them.  I really do not
understand what the CSS portion of the pipeline in
resources-shared.xmap does (why does the src attribute for map:act not
match the src attribute for map:generate directly below it?).

At some point, I need to figure out how to modify everything so that
my page.css is created dynamically through an XSLT so that I can
change my background-image: url( $url ) depending on my node.

Thank you for your help so far.

--
Derek Harmel
 :: Web Programmer
  :: KCI Technologies
 :: (410) 891-1746
 :: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to