[dokuwiki] Alternate views/presentations (Re: table of contents)

  • From: Sander Tekelenburg <tekelenb@xxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 4 Aug 2007 23:22:20 +0200

At 11:52 -0400 UTC, on 2007-08-04, Jason Keltz wrote:

[...]

First off, note that the default Wokuwiki template sets a class "toctoggle"
to the TOC. I assume that is used by the javascript-dependant mechanism to
expand the toc. When I toggle it to 'unexpand', only the TOC's heading "Table
of Contents" is printed (which does look rather silly).

> I can't think of what to do in the CSS
> stylesheet for printing to toggle whether the TOC gets printed or not IN
> the print.css.

In principle this should be solved by providing one or more extra Style
Sheets as alternates:

<link rel="stylesheet" href="path/file" type="text/css" media="print"
title="default print presentation">
<link rel="alternate stylesheet" href="path/to/otherfile" type="text/css"
media="print" title="different print presentation">
<link rel="alternate stylesheet" href="path/to/yaotherfile" type="text/css"
media="print" title="yet again different print presentation">

For media="screen" most browsers (I believe IE is the exception, as usual)
provide a mechanism to allow the user to switch to another Style Sheet. As
required by the CSS spec.

However, I doubt that browsers actually provide such a Style Sheet selection
mechanism for print CSS... They like to claim that they support all sorts of
standards, but that's mostly only partly true.

A reasonable way around that might be to not serve the print CSS as a
separate file, but serve all CSS as one file. Serve it as media=all (will be
the default in HTML5), and section parts of it to apply to specific media,
like so:

@media print
{
        .toc {display: none}
}

Any rules that are not within a media specific section will apply to all
media. (For an example: <http://webrepair.org/> uses this approach.)

If you then serve multiple such media=all Style Sheets, with differing print
rules, I would expect that to meet your goal nicely. I'd expect browsers
would give users  access to these Style Sheets through their built-n Style
Sheet selector, and apply the selected Style Sheet's print rules. (I haven't
actually tested it, but it seems likely.)

In fact, it might perhaps be practical if serving all CSS within a single
Style Sheet would be the default Dokuwiki set-up. Has that ever been
considered?

The only problem with this is that most browsers do not allow users to define
that a certain author Style Sheet must always be used at a site. So a
selection other than the default doesn't 'stick' across pages or subsequent
visits. (Could be solved at the server end with cookies ro some such, but
really should be solved by browsers.)


Some other possibilities, that seem far less elegant to me:

- Remove the print style sheet and serve only multiple (alternates) Style
Sheets. Browsers seem to apply treat @media screen as @media all when no
@media print rules override.

But then you'd be removing the current very nice default print Style Sheet
from those users who appreciate it.

- Add one or more templates that provide the different 'views' you want to
provide and hack in some mechanism to let visitors select templates. (Unless
Dokuwiki already offers a mechanism for this? I vaguely recall having
seen/read something like that somewhere)


-- 
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: