A problem with the foot little plugin

126 views
Skip to first unread message

Luis Gonzalez

unread,
Mar 10, 2020, 7:49:33 AM3/10/20
to tiddl...@googlegroups.com
I've added to my foot plugin the option of collapse tiddlers. It shows a little chevron icon on the view toolbar.
If you click on the "chevron up" icon the tiddler collapses (the top tiddler above). If you click the "chevron down" icon the tiddler expands.

There is a problem: the tiddler status is stored in the field "hide-body" in the same tiddler, so if you collapse/expand a tiddler the tiddlywiki
is marked as not saved.

How can I store the status of each tiddler (it is not the same for all tiddlers, so each tiddler has its own status) so that Tiddlywiki does not mark it as not saved?


foot plugin.html

Eric Shulman

unread,
Mar 10, 2020, 11:22:12 AM3/10/20
to tiddl...@googlegroups.com
On Tuesday, March 10, 2020 at 4:49:33 AM UTC-7, Luis Gonzalez wrote:
I've added to my foot plugin the option of collapse tiddlers. It shows a little chevron icon on the view toolbar.
If you click on the "chevron up" icon the tiddler collapses (the top tiddler above). If you click the "chevron down" icon the tiddler expands.

The TWCore already has a "fold/unfold" button that can be shown in the View Toolbar.  How does your button differ?
 
There is a problem: the tiddler status is stored in the field "hide-body" in the same tiddler, so if you collapse/expand a tiddler the tiddlywiki
is marked as not saved.
How can I store the status of each tiddler (it is not the same for all tiddlers, so each tiddler has its own status) so that Tiddlywiki does not mark it as not saved?

The TWCore definition for $:/core/ui/Buttons/fold refers to a variable, <<folded-state>>, which is defined in $:/core/ui/ViewTemplate as:

\define folded-state()
$
:/state/folded/$(currentTiddler)$
\end

This variable uses the value of $(currentTiddler)$ to construct a unique "$:/state/folded/..." tiddler title, so that the folded/unfolded state of a given tiddler is stored separately.  This avoids the problem you are having where changing the state changes the "modified" field of the affected tiddler.

Note that any changes to "$:/state..." tiddlers do NOT mark the document as "dirty" (i.e., needing to be saved).  This is defined in $:/config/SaverFilter, via the "-[prefix[$:/state/]]" filter syntax.

However, even though changes to $:/state tiddlers don't mark the document as dirty, the $:/state tiddlers themselves are still saved when you save the document, so that their values are preserved across separate browser sessions.

As of TW5.1.22 (currently pre-release), you can suppress the *saving* of the $:/state/folded/... tiddlers by defining a global variable, $(publishFilter)$ by creating a tiddler (e.g., "$:/config/PublishFilter" -- or any other name you like), tagged with "$:/tags/Macro" that contains:
\define publishFilter() -[prefix[$:/state/folded]]

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)

Ste Wilson

unread,
Mar 11, 2020, 6:33:26 AM3/11/20
to TiddlyWiki
Hi Luis,
I did give this a try and like!
One small thing, on reload my wiki had changed language and my default tiddler had also been changed!

Thanks for the plugin :)

Ste
Reply all
Reply to author
Forward
0 new messages