Plugin or macro for toggling $:/tags/Stylesheet tags between two stylesheets?

67 views
Skip to first unread message

David Gifford

unread,
Mar 3, 2017, 5:23:18 PM3/3/17
to TiddlyWiki
Hi all

I have two stylesheets, one for editing and one for publishing. Is there a plugin or macro that creates one button that when pressed, adds the $:/tags/Stylesheet tag from one of them and adds the $:/tags/Stylesheet tag to the other? Then when pushed again, does the reverse?

I am sure this is already a thing, a link would be sufficient.

Thanks in advance for your help.

Dave

PMario

unread,
Mar 3, 2017, 6:12:18 PM3/3/17
to TiddlyWiki
Hi David,

You could use a theme. Themes are basically plugins and switching the theme switches the style sheets. ...

The TW plugin mechanism allows you to define dependencies. So you can say

edit-theme -> "dependents": ["$:/themes/tiddlywiki/snowwhite"]  ... and contains the changes needed for the edit mode
publish-theme -> "dependents": ["$:/themes/tiddlywiki/snowwhite"]  ... and contains the changes needed for publishing

hope that makes it clear
-mario

Eric Shulman

unread,
Mar 3, 2017, 6:19:40 PM3/3/17
to TiddlyWiki
On Friday, March 3, 2017 at 2:23:18 PM UTC-8, David Gifford wrote:
I have two stylesheets, one for editing and one for publishing. Is there a plugin or macro that creates one button that when pressed, adds the $:/tags/Stylesheet tag from one of them and adds the $:/tags/Stylesheet tag to the other? Then when pushed again, does the reverse?

Here's a general method I've used for toggling between styles, based on a single checkbox control:

1) Let's assume the two stylesheet tiddlers are named [[EditorStylesheet]] and [[PublishedStylesheet]]

2) Remove the $:/tags/Stylesheet tag from *both* of those stylesheet tiddlers.

3) Create a tiddler, [[CommonStylesheet]], tagged with "$:/tags/Stylesheet", containing:
<$reveal state="$:/state/allowedit" type="match" text="">
   {{PublishedStylesheet}}
</$reveal>
<$reveal state="$:/state/allowedit" type="nomatch" text="">
   {{EditorStylesheet}}
</$reveal>

4) Place the following checkbox control anywhere you like:
<$checkbox tiddler="$:/state/allowedit" field="text"
   checked="yes" unchecked="" default="">
   allow editing
</$checkbox>

The checkbox toggles a $:/state value between "" and "yes" to control which styles are transcluded in the [[CommonStylesheet]].

Note: [[CommonStylesheet]] could also contain other "common" CSS directives that are shared between both Editor and Published styles, thus allowing those "stylesheets" to contain only the differences between the two modes of viewing.

enjoy,
-e
Eric Shulman
TiddlyTools: Small Tools for Big Ideas (tm)
InsideTiddlyWiki: The Missing Manuals

David Gifford

unread,
Mar 3, 2017, 7:25:09 PM3/3/17
to tiddl...@googlegroups.com
Thanks guys! Eric's trick should do the...trick...

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/KTiNEaxPRL8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/a257f548-e750-43bc-86a6-5a7593abc3a6%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
David Gifford
Christian Reformed World Missions, Mexico City

Reply all
Reply to author
Forward
0 new messages