Documentation or Examples for Core Themes?

93 views
Skip to first unread message

JohnH

unread,
Feb 17, 2011, 6:54:44 AM2/17/11
to TiddlyWiki
Hi!

Can anyone point me to documentation and/or examples of how to create
a theme for the switchTheme mechanism built in to recent versions of
the TW core? I have done extensive googling but all the references and
examples I can find simply overwrite the relevant shadow tiddlers.
There are lots of hints on Eric's TiddlyTools mega-site, but it is not
clear which bits are Core and which depend Eric's plugins and tweaks.

I'm actually at the moment just trying to have a different
ViewTemplate for readonly mode, automatically switched. From examining
the switchTheme code, this seems to be provided for by creating
ViewTemplateReadOnly, but I tried that and it was not automatically
switched. I surmise I actually have to create and apply a theme for
switchTheme to make this work, but I do not know how to do that. I do
not actually want to have user switchable themes at this point, just
the ability to have the ViewTemplate automatically switch with the
readOnly mode, so Eric's SwitchThemePlugin seems like overkill if I
can do this with Core.

Another approach would be to extend Eric's TaggedTemplateTweak to look
for the ReadOnly suffix in when in readonly mode, but I do not want to
do this if the functionality is already in Core.

- John

Eric Shulman

unread,
Feb 17, 2011, 7:22:45 AM2/17/11
to TiddlyWiki
> Can anyone point me to documentation and/or examples of how to create
> a theme for the switchTheme mechanism built in to recent versions of
> the TW core?

> I'm actually at the moment just trying to have a different
> ViewTemplate for readonly mode, automatically switched. From examining
> the switchTheme code, this seems to be provided for by creating
> ViewTemplateReadOnly, but I tried that and it was not automatically
> switched. I surmise I actually have to create and apply a theme for
> switchTheme to make this work, but I do not know how to do that.

Create a tiddler (e.g., MyTheme), containing this line:
|ViewTemplateReadOnly|ViewTemplateReadOnly|

This defines a "ViewTemplateReadOnly" slice whose value is the name of
the tiddler containing the read-only template definition. In this
example, the tiddler title is the same as the slice name (i.e.,
ViewTemplateReadOnly), but that is not *required*: you could you any
name you want for the alternative, read-only template definition.

Note: in addition to the "ViewTemplateReadOnly" slice, there are other
slice values you *could* define in the theme: "StyleSheet",
"PageTemplate", "ViewTemplate", "EditTemplate", and
"EditTemplateReadOnly". For your purposes, only the
ViewTemplateReadOnly slice needs to be defined. The others will use
the standard default values.

To activate your theme, add the following to a tiddler, tagged with
systemConfig:
config.options.txtTheme="MyTheme";
after you save-and-reload, your theme should be in effect.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
----------
Was this answer useful? If so, please help support TiddlyTools:

TiddlyTools direct contributions: (paypal)
http://www.TiddlyTools.com/#Donate
UnaMesa tax-deductible contributions:
http://about.unamesa.org/Participate (paypal)
TiddlyWiki consulting:
http://www.TiddlyTools.com/#ELSDesignStudios
http://www.TiddlyTools.com/#Contact

JohnH

unread,
Feb 17, 2011, 8:41:51 AM2/17/11
to TiddlyWiki
On Feb 17, 12:22 pm, Eric Shulman <elsdes...@gmail.com> wrote:
>
> Create a tiddler (e.g., MyTheme), containing this line:
> |ViewTemplateReadOnly|ViewTemplateReadOnly|
>

Thanks again Eric, that is very useful.

Strikes me it would be worth considering putting this into
TaggedTemplateTweak so it works automatically when themes are not
used. I.E. determine the tiddler name using all of the current
methods, but then additionally, if in readOnly mode, check for name
+"ReadOnly" before falling back on name. Probably do not want to do
this for theme (slice) names though as it might duplicate the
"ReadOnly" suffix.

Also strikes me as a pity the Core system was not done with sections
rather than slices. This way the entire theme could be packaged in a
single tiddler making distribution and management a lot easier. If I
ever get out of moderation on the dev group (I posted about the
getTiddlerText bug we discussed, but my post has not appeared yet), I
will suggest this option be supported in addition to the slice based
"theme manifest" approach you kindly described.

- John

Eric Shulman

unread,
Feb 17, 2011, 11:06:09 AM2/17/11
to TiddlyWiki
> > Create a tiddler (e.g., MyTheme), containing this line:
> > |ViewTemplateReadOnly|ViewTemplateReadOnly|

> Also strikes me as a pity the Core system was not done with sections
> rather than slices. This way the entire theme could be packaged in a
> single tiddler making distribution and management a lot easier.

The theme's slice table can refer to sections in the same tiddler:

[[MyTheme]]:
----------------------
|StyleSheet|MyTheme##StyleSheet|
|ViewTemplate|MyTheme##ViewTemplate|
|ViewTemplateReadOnly|MyTheme##ViewTemplateReadOnly|
|EditTemplate|MyTheme##EditTemplate|
|EditTemplateReadOnly|MyTheme##EditTemplateReadOnly|
!StyleSheet
... CSS here ...
!PageTemplate
... HTML here ...
!ViewTemplate
... HTML here ...
!ViewTemplateReadOnly
... HTML here ...
!EditTemplate
... HTML here ...
!EditTemplateReadOnly
... HTML here ...
----------------------

That's it. One tiddler. Of course, you still have to set
config.options.txtTheme="MyTheme", but that is (and should remain) a
separate configuration action (i.e., *using* a theme vs. *defining* a
theme).

enjoy,
-e

JohnH

unread,
Feb 17, 2011, 11:45:41 AM2/17/11
to TiddlyWiki
On Feb 17, 4:06 pm, Eric Shulman <elsdes...@gmail.com> wrote:
> > > Create a tiddler (e.g., MyTheme), containing this line:
> > > |ViewTemplateReadOnly|ViewTemplateReadOnly|
> > Also strikes me as a pity the Core system was not done with sections
> > rather than slices. This way the entire theme could be packaged in a
> > single tiddler making distribution and management a lot easier.
>
> The theme's slice table can refer to sections in the same tiddler:
>

Ah - of course. That's neat!

But now I want to be able to write:
--------------------
include <<tiddler ##sect>>
!sect
The section text.
--------------------
To refer to a section in the same file (so it does not break when you
rename the tiddler). And of course the same for slices.

But thanks again,
J.

Eric Shulman

unread,
Feb 17, 2011, 1:08:32 PM2/17/11
to TiddlyWiki
> But now I want to be able to write:
> --------------------
> include <<tiddler ##sect>>
> !sect
> The section text.
> --------------------
> To refer to a section in the same file (so it does not break when you
> rename the tiddler). And of course the same for slices.

http://www.TiddlyTools.com/#SectionLinksPlugin

extends the core handling for section references in several ways, one
of which is to allow an *implied* tiddler title, so the
"##sectionnname" will automatically reference a section in the current
tiddler.

Note: you *can* write an equivalent section reference without the
plugin, by using an 'evaluated parameter' to construct a fully-
qualified "TiddlerName##sectionname", like this:

<<tiddler
{{story.findContainingTiddler(place).getAttribute("tiddler")
+"##sectionname"}}>>

Of course, this syntax is considerably more verbose and technical than
the implied tiddler name syntax provided by the plugin. In addition,
evaluated parameters are disabled by default when using TiddlySpace,
so this method does not work for documents hosted there, unless you
also set:
config.evaluateMacroParameters="full";
in a tiddler tagged with 'systemConfig'

Also note: SectionLinksPlugin only extends the handling for
"##sectionname", but not for "::slicename". However, it should be
very easy to add that to the existing code. I'll post a follow-up
when an updated plugin is available.

enjoy,
-e
Message has been deleted

JohnH

unread,
Feb 18, 2011, 6:47:54 AM2/18/11
to TiddlyWiki
On Feb 17, 6:08 pm, Eric Shulman <elsdes...@gmail.com> wrote:

> http://www.TiddlyTools.com/#SectionLinksPlugin

> extends the core handling for section references in several ways, one
> of which is to allow an *implied* tiddler title, so the
> "##sectionnname" will automatically reference a section in the current
> tiddler.

That is very neat and is certainly going straight into my template!

But I cannot immediately see how to apply that to the Core Themes
issue as that is recovering the link as text and only resolving it
later. Perhaps the best solution would be to define a new macro
<<here>> which resolves to the name of the containing tiddler, then I
can write:

[[MyTheme]]:
----------------------
|StyleSheet|<<here>>##StyleSheet|
!StyleSheet
... CSS here ...
----------------------

On a related matter, I tried to extend your valuable advice in your
first reply as follows:

[[MyTheme]]:
----------------------
|ViewTemplateReadOnly|ViewTemplateReadOnly|
|CollapsedTemplateReadOnly|CollapsedTemplateReadOnly|
----------------------

But disappointment resulted! Any chance you will add theme support for
your CollapsedTiddlersPlugin? Incidently, examining the code I
discovered I could achieve what I wanted by creating
'WebCollapsedTemplate', so it is not an immediate problem (for me
anyway).

J.

maf1729

unread,
Oct 13, 2013, 2:13:18 AM10/13/13
to tiddl...@googlegroups.com

is ColorPalette intentionally left out of the list of shadow tiddlers in a systemTheme ?

PMario

unread,
Oct 13, 2013, 1:38:11 PM10/13/13
to tiddl...@googlegroups.com, john.t...@googlemail.com
On Friday, February 18, 2011 12:47:54 PM UTC+1, JohnH wrote:
But I cannot immediately see how to apply that to the Core Themes
issue as that is recovering the link as text and only resolving it
later. Perhaps the best solution would be to define a new macro
<<here>> which resolves to the name of the containing tiddler, then I
can write:

 
Just wite it like this and it will work. you don't need a makro here ...

[[MyTheme]]:
----------------------
|StyleSheet|##StyleSheet|
!StyleSheet
... CSS here ...

-m
Reply all
Reply to author
Forward
0 new messages