A problem with the foot little plugin

瀏覽次數:119 次
跳到第一則未讀訊息

Luis Gonzalez

未讀,
2020年3月10日 清晨7:49:332020/3/10
收件者: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

未讀,
2020年3月10日 上午11:22:122020/3/10
收件者: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

未讀,
2020年3月11日 清晨6:33:262020/3/11
收件者: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
回覆所有人
回覆作者
轉寄
0 則新訊息