On Feb 15, 6:56 am, Alex Hough <[email protected]> wrote:
> I am put off using themes because I find the workflow more complicated
> than changing stylesheet, PageTemplate and ViewTemplate. Making
> changes to a theme requires a browser refresh where as changes to
> StyleSheet can be seen imediately....
>
> My question is to theme developers : do you have a workflow that could
> help me speed up theme development so that I might start packaging
> things up as themes?

A theme is a tiddler containing a table with specific slice names that
refer to the various tiddlers (or tiddler sections) that define the TW
document appearance (templates and stylesheets).   When the TWCore
setting for <<option txtTheme>> is blank (or undefined) (i.e.
config.options.txtTheme=""), the standard TWCore default appearance is
controlled by *seven* separate tiddlers:

   StyleSheet
   PageTemplate
   ViewTemplate
   EditTemplate
   PageTemplateReadOnly
   ViewTemplateReadOnly
   EditTemplateReadOnly

Editing any of these tiddlers will change the appearance (layout and
styles)... aka, "theme", of your TW document.  This is the familiar
"TW Classic" method of customization and works reasonably well if you
only want a single theme for your document.  Note: the "ReadOnly"
templates do not exist by default.  If present, they are only applied
when the document is viewed in 'readOnly' mode; otherwise, the TWCore
standard templates are used.

You can create alternative templates/stylesheets by copying the TWCore
defaults and adding a prefix (e.g "MyTheme").  For example, you might
create [[MyThemePageTemplate]] and [[MyThemeStyleSheet]] containing
alternative layout and CSS definitions.  Then, to apply the
alternatives, you could 'juggle the tiddlers', renaming the current
PageTemplate and StyleSheet to something like TWCorePageTemplate and
TWCoreStyleSheet, and then removing the "MyTheme" prefix from your
alternatives.

Obviously, this is a VERY awkward, inconvenient, and potentially error-
prone manual procedure.

To address this, the TWCore provides a "theme switching" mechanism
based on a simple 'slice table' definition that lets you specify which
tiddlers (or tiddler sections) contain the desired layout/style
content, so you don't have to rename the customized theme tiddlers to
have them applied by the TWCore.

The TWCore's default theme can be described by this 'bare-
bones' [[DefaultTheme]] definition:
   |StyleSheet|StyleSheet|
   |PageTemplate|PageTemplate|
   |ViewTemplate|ViewTemplate|
   |EditTemplate|EditTemplate|
   |PageTemplateReadOnly|PageTemplateReadOnly|
   |ViewTemplateReadOnly|ViewTemplateReadOnly|
   |EditTemplateReadOnly|EditTemplateReadOnly|
If you set <<option txtTheme>> to "DefaultTheme" you won't see any
change in appearance because each slice refers to the standard TW
template/stylesheet tiddlers.

To apply an alternative theme, you edit the theme slice table so that
it refers to your alternative template/stylesheet tiddlers:
   |StyleSheet|MyThemeStyleSheet|
   |PageTemplate|MyThemePageTemplate|
   |ViewTemplate|ViewTemplate|
   |EditTemplate|EditTemplate|
   |PageTemplateReadOnly|PageTemplateReadOnly|
   |ViewTemplateReadOnly|ViewTemplateReadOnly|
   |EditTemplateReadOnly|EditTemplateReadOnly|

Note: you only need to defines slices for the parts of the theme that
you are overriding.  The rest of the theme will fallback to using the
TWCore defaults.  Thus, to define your custom [[MyTheme]], you
actually only need a slice table like this:
   |StyleSheet|MyThemeStyleSheet|
   |PageTemplate|MyThemePageTemplate|

Of course, manually editing the slice table is still inconvenient and
error-prone, and certainly not suitable for use by non-technical 'end
users'.  Fortunately, to make things even simpler, you can create a
separate theme tiddler, e.g. [[MyTheme]], containing the modified
slice table, and then simply set <<option txtTheme>> to "MyTheme" to
apply your customizations.

As a further user-level enhancement, you can install my plugin:
   http://www.TiddlyTools.com/#SwitchThemePlugin

Then, tag [[DefaultTheme]] and [[MyTheme]] with 'systemTheme', and
embed the <<switchTheme>> macro into your document (e.g., in
[[SideBarOptions]]) and you can quickly and smoothly switch between
themes just by selecting from a droplist of choices!

Lastly, if you don't want the *tiddly-clutter* of having to maintain
separate tiddlers for each custom template/stylesheet, you can use
tiddler *sections* instead of separate tiddlers, and use section
references in the theme slice table, followed by sections with the
actual custom theme definitions, like this:
-------------
|StyleSheet|##StyleSheet|
|PageTemplate|##PageTemplate|
|ViewTemplate|##ViewTemplate|
|EditTemplate|##EditTemplate|
|PageTemplateReadOnly|##PageTemplateReadOnly|
|ViewTemplateReadOnly|##ViewTemplateReadOnly|
|EditTemplateReadOnly|##EditTemplateReadOnly|
!StyleSheet
/*{{{*/
...
/*}}}*/
!PageTemplate
<!--{{{-->
...
<!--}}}-->
!ViewTemplate
<!--{{{-->
...
<!--}}}-->
!EditTemplate
<!--{{{-->
...
<!--}}}-->
!PageTemplateReadOnly
<!--{{{-->
...
<!--}}}-->
!ViewTemplateReadOnly
<!--{{{-->
...
<!--}}}-->
!EditTemplateReadOnly
<!--{{{-->
...
<!--}}}-->
***/
-------------

Take a look at:
   http://www.tiddlytools.com/#DefaultTheme
It defines a theme slicetable that references sections within the same
tiddler, where each section just includes the standard TWCore
templates and stylesheets.  This makes a good starting point for
defining a new theme.  Simply copy DefaultTheme to another name (e.g.,
MyTheme), and then start editing the sections.

Note: the above content is a draft version of material for
"TiddlyTech: An Author's Guide to Customizing TiddlyWiki", the *book*
that I hope to finally get written this year... assuming I have enough
time and funding (hint, hint).

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
----
WAS THIS ANSWER HELPFUL?  IF SO, PLEASE MAKE A DONATION
   http://www.TiddlyTools.com/#Donations
note: donations are directly used to pay for food, rent,
gas, net connection, etc., so please give generously and often!

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
   http://www.TiddlyTools.com/#Contact

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to