Discussion of Zwiki's StyleSheets.

per-page styles

In my experimental ZWiki, which I would like to evolve into something I can use to create a web site easily, I needed more control over display.

To do this, I changed the python code to insert <style type="text/css"> tags based on page properties.

When a page gets rendered, if it has a property called page_style, or any of its parents (i.e. ZWiki page parents, any of the ones you see in the header menu) has such a property, the text from that property goes inside the STYLE tags as the page gets rendered.

So for example, in my experimental wiki, I changed the header style to NOT unerline anchors, and to not resize the BIG attribute:

With those two lines in the page_style property of FrontPage, all pages show the header links in the same font and not underlined.

Nice! Can you post your patch ? --SM

Yea, I can, how do I do that? But really it is not quite working yet. Currently only the top level style gets used. Children page styles are ignored (they aren't supposed to be, its a bug somewhere). Anyway, I could post it with this bug, its not much code, so it might be obvious what stupid thing I did to make it only partly work...

Should I just diff the code and put it here?

Here's the code, ZWikiPage.py:

 <                 #
 <                 # if the page has a style, use it
 <                 # inherit styles from ancestors 
 <                 #
 <                 ancestors = self.get_ancestors()
 <                 style = ''
 <                 for pages in ancestors:
 <                     for page_name in pages:
 <                         if isinstance(page_name,StringType):
 <                             page = getattr(self.aq_parent, page_name)
 <                             if page and hasattr(page, 'page_style'):
 <                                 for l in page.page_style:
 <                                     style = style + l + '\n'
 <                 # set the style if one was created
 <                 if len(style):
 <                     hdr = '<style type="text/css">' + style + '</style>' + hdr

a ZwikiModification hmm.. don't know how to make it show up OK above, but the diff looks right if you do "edit page"

What about having UserSpecificStyles??

saving a few things from GeneralDiscussion -

Simon Michael <simon@joyful.com>, 2002/04/30 18:00 GMT (via mail):
zwiki@zwiki.org (JosYule) writes:
> Just checked out the StyleSheet? page, after looking into the FrontPage's
> issues wrt excerpting these discussions. I was wondering where everyone is
> with moving from hardcoded STYLE="blah:blah" to using a global CSS? It would
> see to me to simplify some of the presentation issues (conformity, same look
> available everywhere, etc). Also, if there is an interest in supporting user
> defined styles, this could be more easily accomplished using CSS. There are
> things in CSS that older browser do not support, but for most case's, it
> degrades gracefully (so hard-core Lynx users need not fret! :). Anyway, seeing
> that you like to tweak the look everyonce and a while, it might be easier to
> define some CSS classes, that can then be applied - this might be especially
> useful for the tracker and front-page, where people might want to change its
> look...
> ---
> forwarded from http://zwiki.org/GeneralDiscussion

Simon Michael <simon@joyful.com>, 2002/04/30 18:01 GMT (via mail):
Simon Michael <simon@joyful.com> writes:
> The ability to use global CSS for a wiki seems like a must. Is it simply a
> matter of adding an embedded or linked stylesheet to standard_wiki_header,
> and then using the styles in the various page elements ?
> Also, could we improve the user skin selection by switching stylesheets,
> instead of checking a bunch of useroptions ?
> StyleSheet? adds the refinement of per-page stylesheets. Which might be
> useful, I'd like to see the UI first.

Simon Michael <simon@joyful.com>, 2002/04/30 18:01 GMT (via mail):
Simon Michael <simon@joyful.com> writes:
> Oh, I guess it's a ZMI-only thing. So if I needed that I would just
> implement it in standard_wiki_header, rather than in the product code.

2002/09/11 16:22 GMT (via web):
I really would like to use style-sheet and i already did in Zwiki-0.9.9. - But Zwiki-0.9.9 had standard_wiki_header and standard_wiki_footer so it was possible to enter a dtml-var css_style_sheet in the standard_wiki_header.

I edited ZWikiPage.py and added a property page_style to FrontPage, as suggested above, but it had no effect yet.

This patch is for ZWiki-0.10.0, isn't it?

I wanted to spend some endevour into it before asking and so i tried to understand the code, but i am new to python and to the ZWiki code, please be patient if i'm wrong. I looked for hdr and it only exists in the new line of the patch:

  'hdr = '<style type="text/css">' + style + '</style>' + hdr'

But even if i changed it to:

  header = '<style type="text/css">' + style + '</style>' + header 

it showed no change in layout and in the html source. I hope i inserted the patch at the right place and with the right indention, but if not the script would throw an error, right?

Do you have an idea what's wrong or what i could try next, please?


Simon Michael, 2002/09/11 17:03 GMT (via mail):

> I really would like to use style-sheet and i already did in
> Zwiki-0.9.9. - But Zwiki-0.9.9 had standard_wiki_header and
> standard_wiki_footer so it was possible to enter a 'dtml-var
> css_style_sheet' in the standard_wiki_header.

Florian - well that should still work, but have you worked around Issue0228 ?

2002/09/11 17:40 GMT (via web):
Simon - thanks, i got it! cu.-FloK *(added some comments to #228 zwiki 0.10.0 ignores standard_wiki_header/standard_wiki_footer DTML methods)*

DeanGoodmanson, 2002/12/09 04:07 GMT (via web):
CSS thoughts

A nice implementation and overview of StyleSheets can be found here: http://tonka.research.techbc.ca/laura/protoTools/laurazWiki/StyleSheets

This seems to be the top page when searching for CSS, should we create a ZwikiCSS? page?

SimonMichael, 2003/03/22 04:59 GMT
Cf http://zwiki.org/CustomizationFAQ#How%20do%20I%20edit%20the%20style%20sheets%20?

simple step 1? --DeanGoodmanson, 2003/03/23 02:00 GMT
For all of the fancy implementation discussion here I can't make out a resolution.

standard_wiki_header, standard_wiki_footer overriding are simple concepts, except creating them from the source files always seems to cause users to stumble. Currently (I believe) this is a requirement for adding a stylesheet to zwiki.

I would like the following line added to standard_wiki_header (and it's zpt counterpart) for a simple addition of a stylesheet:

 <dtml-if standard_wiki_stylesheet><link rel="stylesheet" type="text/css" href="standard_wiki_stylesheet" /></dtml-if>

With this the faq will simply read "Place your stylesheet contents into a dtml-method named "standard_wiki_stylesheet".

Note: change it to standard_wiki_css if you'd like, but I expect confusion with standardwiki.css, standard_wiki.css, etc.

simple step 1? --SimonMichael, 2003/03/23 04:49 GMT
Yes, that was my problem too. :) Thanks for the clear recommendation, that looks like a good first step. The stuff above is about per-page styles, acquired from parents; something to try later.

I thought a little about where this needs to go. Currently we have the default skin with both standard_wiki_header.dtml and wikipage.pt, the zwiki_cmf skin, and perhaps soon a new plone skin. I think the latter two can fend for themselves for now, at least with plone they already have configurable styles. So I'll add this to the first two.

testing --SimonMichael, 2003/03/23 05:44 GMT
I've called it wiki_stylesheet for the moment. In this site's page template, I put:

 <link tal:condition="here/wiki_stylesheet|nothing" 
 rel="stylesheet" type="text/css" href="wiki_stylesheet" />

and this gets included but has no effect in my browser (phoenix). Including the styles on every page worked:

 <span tal:replace="structure here/wiki_stylesheet|nothing"></span>

But for fun I've changed this to:

 <span tal:replace="structure here/WikiStylesheet/text|nothing"></span>

so we can play with styles on WikiStylesheet?.

more testing --SimonMichael, 2003/03/23 06:59 GMT
The CSS & Zope howto describes some details that would make linked stylesheets work.

However, I like having the stylesheet embedded so we can do nifty DTML tricks at page view time. I also like having it in the wiki. I think StyleSheet? is a natural page to use. wikipage now embeds StyleSheet?'s text as the stylesheet, up to the first horizontal rule.


subscribe -- Tue, 12 Aug 2003 08:42:59 +0000 reply
Er, hey, Dean, are you subscribed to this page? I just clicked on subscribe to check and got:

 The proxy server could not handle the request GET /ZwikiStyleSheets/subscribeform.

 Reason: Document contains no data

Just a passing thing? =}


CSS strategies -- Tue, 12 Aug 2003 09:13:42 +0000 reply
OK, so that long posting I just made to GD on CSS-ing Zwiki should probably have been posted here. But the way I'd start would be with defining divs (elements), the main parts of the layout, and the basic styles for paras, headers, etc. (selectors), and then classes. (I find the terminology of "elements" and "selectors" pretty baffling, BTW, so I just talk around them.)

It looks to me like your following the CMF strategy, with shade1 and shade2. But one of the first things I learned from Plone was skip the stylesheet properties tab and go straight for the style sheets (and then I learned a lot from Limi's CSS). I wonder whether people really find it useful? I broke my head against for about 2 weeks, trying to sort out what was what, and was about to give up on the CMF altogether, before I discovered Plone.

W/a default style style sheet, you could have divs called "header" and "footer" and set the color there. For the text area, a comment would identify it as the background for search and comment. And for me, "newPageLink" (instead of just "new") is worth the extra letters, for clarity.

Oh, perhaps we should rename this page ZwikiStyleSheets or ZwikiCSSstrategy or ???


CSS strategies --DeanGoodmanson, Tue, 12 Aug 2003 20:36:50 +0000 reply
Currently digesting your comments. "newPageLink" does sound good, along with ZwikiStyleSheets?.

I'm subscribed to the whole wiki-digest mode, and GD for instamatic updates, so caught this entry in the afternoon where your GD post I caught this morning.

CSS strategies --Simon Michael, Wed, 13 Aug 2003 20:04:23 +0000 reply

Oh, perhaps we should rename this page ZwikiStyleSheets or

+1 from me. Good work CSS team. I feel another important step forward would be to nail down how Zwiki finds it's stylesheet.. this was left in an unfinished state.

earlier comment --Simon Michael, Wed, 13 Aug 2003 20:06:28 +0000 reply
Forwarding to ZwikiStyleSheets? for context:

Sorry for the lagtime in replying, Dean! I wanted to check out the default style sheet and give it some thought. But I see there isn't a default style sheet! =}

I think the way to go would be to first move all the formatting into a simple, plain vanilla default style sheet, with divs replacing tables to the extent possible. This would of course need to be coordinated with work on the zwiki skins for Plone. I'd be curious what Limi's thoughts on this would be.

Jordan's done an impressive job of CSS-ing the existing code for the commonplacebook skin, which I see is now working w/the current version of zwiki. Using classes on tables might be an interim step, w/his code (design simplified) as a starting point? But it might make more sense to untable the code at the same time. I'll post specific commments to ZwikiStyleSheets? (maybe this whole thing should have been posted there?).

Part of the reason I've been tentative about this is that I don't know what discussion there's been of CSS. Is the reason it hasn't been done simply that no CSS freaks have stepped forward? Or, is it something else?

I'd like to help but I'm getting crunched with work for fall so don't want to offer too much. Still, I think it's important (and I am a CSS freak!) A little history and perspective, including Limi's and Jordan's thoughts on this, would be great.


p.s. Sorry for bouncing mail over the weekend, Simon. My domain renewal had, er, a hiccup. =} -- forwarded from http://zwiki.org/GeneralDiscussion

CSS strategies --laura trippi, Thu, 14 Aug 2003 21:07:24 +0000 reply

Oh, perhaps we should rename this page ZwikiStyleSheets or

+1 from me.

Just to confirm: ZwikiStyleSheets? in this case (not WikiStyleSheets?) b/c it's specific to this wiki engine, yes?

But, I don't seem to be able to rename pages here.

would be to nail down how Zwiki finds it's stylesheet.. this was left in an unfinished state.

Where is the discussion of this archived? I'm trying to cull/thread together existing discussion of CSS...


CSS strategies --SimonMichael, Fri, 15 Aug 2003 01:32:32 +0000 reply

But, I don't seem to be able to rename pages here.

What happens - can't see page name in edit form, or page management form, as per FAQ ? You get a login prompt when you try to rename ?

Yes ZwikiStyleSheets? seems right to me. Unless you want to go with StyleSheets. Maybe later.

Where is the discussion of this archived? I'm trying to cull/thread together existing discussion of CSS...

Awesome. This stuff is all over the place. It looks like StyleSheets has been the core page until now.

CSS strategies --SimonMichael, Fri, 15 Aug 2003 01:35:27 +0000 reply
PS we haven't done much of this yet, but I think you should feel free to throw away old discussion that you don't think adds value today.