SelectStyleSheet Plugin ignoring my web templates in read only mode

5 views
Skip to first unread message

dave h

unread,
Jan 22, 2008, 1:51:31 PM1/22/08
to TiddlyWiki
I'm having a problem which is similar to that described in a previous
thread :

http://groups.google.com/group/TiddlyWiki/browse_thread/thread/64c44855f9e84487/d6ca14d6d2e25918?#d6ca14d6d2e25918

I finally migrated from the old, and now deprecated, WebTemplateTweak
because of the problems it had with IE. (Until now those issues
haven't been a problem for me).

As recommended I Installed the latest version of the SelectStyleSheet
Plugin (4.4.3) to replace it - unfortunately when the resulting page
is viewed online the Web versions of the templates (which remove a
number of unwanted functions for online viewing) are ignored.

I wondered if this was an issue with the latest version of Tiddlywiki
so I created a test page using version 2.2.0. but it has exactly the
same problem. I've put this test version up here :

http://booth7.ftml.net/test.html

I'm now a bit baffled. Any suggestions very gratefully received.

Dave Hartley

Eric Shulman

unread,
Jan 22, 2008, 5:02:25 PM1/22/08
to TiddlyWiki, jer...@osmosoft.com, mjbu...@gmail.com
> As recommended I Installed the latest version of the SelectStyleSheet
> Plugin (4.4.3) to replace it - unfortunately when the resulting page
> is viewed online the Web versions of the templates (which remove a
> number of unwanted functions for online viewing) are ignored.

The problem is that TW2.3.0 introduced a new "switchTheme()" function
that is invoked AFTER plugins are loaded, and this new core code
prevents SelectStylesheetPlugin from being able to take over the
'notification' handlers that allow the plugin code to load the
alternative Web* templates at startup.

In fact, this core change causes the plugin to get a FATAL error
during initial startup, which then HANGS, completely prevents the
document from loading!

Until I can figure out a good way to work around this new core change,
I've had to disable the auto-notify handling for the plugin. As a
result, the default [[StyleSheet]] is always loaded at startup, even
though the desired theme IS still selected. Of course, this also
affects the automatic switching to Web* templates at startup,
producing the effect you reported.

Unfortunately, because the core code occurs after ALL plugins are
loaded, this problem will also impact any other plugins that attempt
to select templates at startup.

I don't have a solution worked out yet... please be patient...

-e

dave h

unread,
Jan 22, 2008, 7:56:47 PM1/22/08
to TiddlyWiki

On Jan 22, 10:02 pm, Eric Shulman <elsdes...@gmail.com> wrote:

> Until I can figure out a good way to work around this new core change,
> I've had to disable the auto-notify handling for the plugin. As a
> result, the default [[StyleSheet]] is always loaded at startup, even
> though the desired theme IS still selected. Of course, this also
> affects the automatic switching to Web* templates at startup,
> producing the effect you reported.

Many thanks for the explanation. It hadn't occurred to me I needed to
use an earlier version of the plugin.

Google searches turned up a copy of version 4.4.1 and also a copy of
tiddlywiki 2.2.6. Everything's now working fine (even seemingly in
IE). I guess the moral is to back up older versions of things more
carefully.

> I don't have a solution worked out yet... please be patient...

Hmmm, what would progress be without unadvertised features :) I'm more
than happy to revert and wait for a solution. This plugin is easily
the simplest way of publishing a streamlined online interface.

cheers,
dave

Andrew Lister

unread,
Jan 24, 2008, 10:14:38 AM1/24/08
to TiddlyWiki
FYI, the problem seems to be browser dependent. Probably you're aware
of this already, but just in case: I'm having problems with the
following web page in Safari only, not FF or Camino:

http://post.queensu.ca/~lister/Homepage/Index.htm

It loads fine in FF and Camino, but hangs in Safari. I've confirmed
that it's SelectStyleSheet by removing plugins.

Andrew

Andrew Lister

unread,
Jan 24, 2008, 10:16:16 AM1/24/08
to TiddlyWiki
I should have added that I'm using Safari 3.0.4, Firefox 2.0.0.11, and
Camino 1.5.4

dave h

unread,
Jan 24, 2008, 2:24:04 PM1/24/08
to TiddlyWiki
Tried your page out - it hangs in Safari 3.0.4 for Windows and also in
Internet Explorer. I see the page uses Tiddlywiki 2.3.0 and
SelectStyleSheet plugin 1.4.1 so I assume this is the incompatability
with 2.3.0 that Eric explained.

FWIW the reverted version of my test page at http://booth7.ftml.net/test.html
which uses Tiddlywiki 2.2.6 seems to be readable by Safari.

dave

Eric Shulman

unread,
Jan 24, 2008, 3:08:45 PM1/24/08
to TiddlyWiki
SelectStylesheetPlugin has been completely re-written. It is now MUCH
smaller (only 6K instead of 17K!) and uses the new core functionality,
story.switchTheme(), which reads and applies 'themes' whose definition
are stored in tiddler slice tables.

Note that, while this new code provides virtually the same features as
the previous code, the plugin has also been RENAMED to
"SwitchThemePlugin" to avoid confusion with the now-obsolete
SelectStylesheetPlugin, which does not work properly in TW2.3.0 or
above.

But, not to worry... despite the radically different internal
operation of this new plugin, converting your existing stylesheets
into 'themes', is as easy as embedding a few slice definitions into
each stylesheet tiddler. Please read the plugin documentation for
more information and examples.

Get the "new, improved" plugin (v5.0.0) here:
http://www.TiddlyTools.com/#SwitchThemePlugin
http://www.TiddlyTools.com/#SwitchThemePluginInfo

Note: I have retired the old SelectStylesheetPlugin (v.4.4.3) from
distribution so it can take a well deserved rest after providing over
two and a half years of utility to the TW community. While I will
continue to support specific questions this plugin, I will not be
providing any fixes or upgrades to it. Users of
SelectStylesheetPlugin are strongly encouraged to upgrade to TW2.3 and
SwitchThemePlugin as soon as practical.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

dave h

unread,
Jan 24, 2008, 6:02:29 PM1/24/08
to TiddlyWiki
On Jan 24, 8:08 pm, Eric Shulman <elsdes...@gmail.com> wrote:
> SelectStylesheetPlugin has been completely re-written. It is now MUCH
> smaller (only 6K instead of 17K!) and uses the new core functionality,
> story.switchTheme(), which reads and applies 'themes' whose definition
> are stored in tiddler slice tables.

Wow. Many thanks for this.

A couple of questions if I may.

In SwitchThemePluginInfo I assume the

|StyleSheet|MyTheme|
***/

needs an opening /***

Does the

|WebPageTemplate|MyWebPageTemplate|
|WebViewTemplate|MyWebViewTemplate|
|WebEditTemplate|MyWebEditTemplate|

need to be in a separate slice table from that defining the normal
custom templates ?

If a tiddlywiki is unmodified in offline use and only uses custom
templates for online display does it matter if there is only a renamed
version of the standard stylesheet with a slice table added at the top
in the form

/***
|StyleSheet|MyTheme|
***/

and a slice table associating the web templates

/***
|WebPageTemplate|MyWebPageTemplate|
|WebViewTemplate|MyWebViewTemplate|
|WebEditTemplate|MyWebEditTemplate|
***/

dave

Eric Shulman

unread,
Jan 24, 2008, 6:33:39 PM1/24/08
to TiddlyWiki
> In SwitchThemePluginInfo I assume the
> |StyleSheet|MyTheme|
> ***/
> needs an opening /***

Yup... editing typo... fixed and updated.

> Does the
> |WebPageTemplate|MyWebPageTemplate|
> |WebViewTemplate|MyWebViewTemplate|
> |WebEditTemplate|MyWebEditTemplate|
> need to be in a separate slice table from that defining the normal
> custom templates ?

Nope. Any slice table will do... you could have them separate if you
like... and they can be anywhere in the tiddler.

> If a tiddlywiki is unmodified in offline use and only uses custom
> templates for online display does it matter if there is only a renamed
> version of the standard stylesheet with a slice table added at the top
> in the form
>...

If I understand the question correctly, the short answer is: no
problem!

If you specify Web*Template slices, they are only applied when
readOnly is true (i.e, viewing via http:)... and any template slices
you omit fallback to using the appropriate defaults. The precedence
for which template is used follows these rules:

1st: if readOnly and a Web*Template slice is defined, use that
specified template
2nd: if not readOnly or there is no Web*Template slice but there IS a
regular (non-Web) template slice, use that specified template
3rd: otherwise, use default Page/View/Edit template

enjoy,
-e

Andrew Lister

unread,
Jan 24, 2008, 9:08:00 PM1/24/08
to TiddlyWiki
Thanks very much, Eric. The swith-over to the new system was fairly
straightforward, no problems so far.

Andrew

dave h

unread,
Jan 24, 2008, 9:09:40 PM1/24/08
to TiddlyWiki
Many thanks for your answers.

My first attempt at applying the plugin is here
http://booth7.ftml.net/test2.html

If the button in the default tiddler is pressed the theme is invoked,
the defined WebTemplates kick in, and the cookie once set the change
remains sticky for that browser on that machine.

My problem is getting the theme to load automatically online when the
page is opened.

I renamed my stylesheet 'Haemoglobin', tagged it 'theme' and added the
following to it

/***
|StyleSheet|Haemoglobin|
***/

/***
|PageTemplate|MyPageTemplate|
|ViewTemplate|MyViewTemplate|
|EditTemplate|MyEditTemplate|
|WebPageTemplate|MyWebPageTemplate|
|WebViewTemplate|MyWebViewTemplate|
***/

I then renamed PageTemplate, ViewTemplate, EditTemplate,
WebPageTemplate and WebViewTemplate accordingly by prepending them
with 'My' to match the slice table.

I'm probably being a bit thick and have missed something crucial.

Or have I got this upside down ? Should I have defined the online
versions of the templates to be the regular templates (so that they
display online) and invoke the theme offline with a button in order to
enable editing ?

dave

Eric Shulman

unread,
Jan 24, 2008, 9:58:36 PM1/24/08
to TiddlyWiki
> My first attempt at applying the plugin is herehttp://booth7.ftml.net/test2.html
> My problem is getting the theme to load automatically online when the
> page is opened.
>
> I renamed my stylesheet 'Haemoglobin',
...
> I'm probably being a bit thick and have missed something crucial.

yeah... but that's OK... you'll get it eventually :-)

First, it is NOT necessary to rename any of your tiddlers to define
the theme slices... (the "My...Template" text in the documentation is
just an *example*... you should use whatever template names you want!)

Suppose your stylesheet is named "S"
and your custom WebPageTemplate is named "PT"
and your custom WebViewTemplate is named "VT"

Then, define the theme slices this way:
/***
|StyleSheet|S|
|WebPageTemplate|PT|
|WebViewTemplate|VT|
***/

Put this theme definition in [[StyleSheet]] so that it will be applied
by default, even for first time visitors.... and you don't have to
"select" the author vs. reader theme... it happens automatically!

When viewed locally (offline) your document will use the styles
defined in [[S]], with the standard Page/View/Edit templates,
providing 'author-level' access to features.

When viewed online (with readOnly mode enabled), your document will
use those same styles from [[S]], but will use [[PT]] as the page
template, and [[VT]] as the view template... automatically providing
'reader-level' access to a reduced set of features!!

HTH,
Reply all
Reply to author
Forward
0 new messages