[TW5] How to close tiddlers by tag?

341 views
Skip to first unread message

Siniy-Kit

unread,
Oct 11, 2015, 4:57:32 AM10/11/15
to TiddlyWiki
In old version of the main TW5 site was many examples, but now I can't find them. I want to make   <$button message="tm-close-tiddler" ><> and close all tiddlers with the tag  $:/TOC . Is it possible?

Tobias Beer

unread,
Oct 11, 2015, 5:10:14 AM10/11/15
to tiddl...@googlegroups.com
Hi Siniy-Kit,

You can use the ActionSendMessageWidget in a list...

<$button>
<$list filter="[tag[$:/TOC]]">
<$action-sendmessage $message="tm-close-tiddler"/>
</$list>
close all tagged $:/TOC
</$button>

Be careful when using the ActionDeleteTiddlerWidget, it will do its job silently...

<$button>
<$list filter="[tag[$:/TOC]]">
<$action-deletetiddler $tiddler=<
<currentTiddler>>/>
</$list>
empty TOC
</$button>

Best wishes,

— tb

Siniy-Kit

unread,
Oct 11, 2015, 5:45:14 AM10/11/15
to TiddlyWiki
Thank you Tobias! And is it posiible to make operation
<$list filter="[tag[$:/TOC]]">
<$action-sendmessage $message="tm-close-other-tiddlers"/>
</$list>

every time when any tiddler opening?  For example, can I put this code to $:/core/modules/storyviews/zoomin.js ?


воскресенье, 11 октября 2015 г., 12:10:14 UTC+3 пользователь Tobias Beer написал:

Danielo Rodríguez

unread,
Oct 11, 2015, 6:23:22 AM10/11/15
to TiddlyWiki


El domingo, 11 de octubre de 2015, 11:10:14 (UTC+2), Tobias Beer escribió:
Hi Siniy-Kit,

You can use the ActionSendMessageWidget in a list...

Since when is this possible? The last time I checked was not possible to use action widgets inside list widgets. 

Danielo Rodríguez

unread,
Oct 11, 2015, 6:24:38 AM10/11/15
to TiddlyWiki


El domingo, 11 de octubre de 2015, 11:45:14 (UTC+2), Siniy-Kit escribió:
Thank you Tobias! And is it posiible to make operation
<$list filter="[tag[$:/TOC]]">
<$action-sendmessage $message="tm-close-other-tiddlers"/>
</$list>

Please be aware that this does not makes any sense. You will close all the tiddlers except one on the first iteration of the list, then you will close that tiddler when the second tiddler on the list calls the "close others" 

Siniy-Kit

unread,
Oct 11, 2015, 7:08:30 AM10/11/15
to TiddlyWiki
you're right :(  tm-close-other-tiddlers close all except one.  And is it possible to close other tiddlers by the tag? And do this action every time, when any tiddler is open?
I put 1000 goods to my experimental  tw5-shop http://novye-podarki.ru/heeg1000.html   and it works slow if dom tree grows.  So I want to remove branches I don't use.





воскресенье, 11 октября 2015 г., 13:24:38 UTC+3 пользователь Danielo Rodríguez написал:

Tobias Beer

unread,
Oct 11, 2015, 7:19:25 AM10/11/15
to tiddl...@googlegroups.com
Hi Siniy-Kit,
 
...every time when any tiddler opening? 
For example, can I put this code to $:/core/modules/storyviews/zoomin.js ?

Mhhh, while there is this...


...it actually leaves the dom full of open, but not visible tiddlers.

To develop a better single-page-mode,

The core should provide a hook for a better single-page-mode implementation (there?),
e.g. some $:/config/filters/single-page-close that specifies a filter
whereas all tiddlers that match it are closed when TiddlyWiki navigates to a tiddler, e.g. via link.

Alterntatively there could be a default (cached) link template
that you can modify with the above button code.

Best wishes,

— tb

Jeremy Ruston

unread,
Oct 11, 2015, 7:23:22 AM10/11/15
to tiddl...@googlegroups.com
Hi Siniy-Kit

I put 1000 goods to my experimental  tw5-shop http://novye-podarki.ru/heeg1000.html   and it works slow if dom tree grows.  So I want to remove branches I don't use.

Are you using the “zoomin” storyview? If so, the problem is that it doesn’t actually remove tiddlers when you navigate away from them; previously opened tiddlers stay rendered, but hidden from the display. You can see what’s going on if you navigate between a few tiddlers in “zoomin” storyview and then switch to “classic” storyview.

The trouble is that storyviews are not able to close tiddlers in the story; they just get an opportunity to react to list items being added and removed by the list widget.

I think the best solution for single tiddler applications like this is to adopt a new story mechanism, where instead of having a list of tiddlers making up the story, there is a single tiddler. Navigation simple replaces that tiddler.

It’s actually the same mechanism you can see in the tabbed single page view:


One way of doing it would be to add a new PageTemplate segment that displays above the main TW page. The segment would transclude your sidebars/headings, and then use a tiddler like `$:/_CurrentTiddler` to keep track of the tiddler that should be displayed. Using the linkcatcher widget (as demonstrated in the example above) you could ensure that navigation just replaces the value of `$:/_CurrentTiddler` with the target tiddler.

In the end, the new segment would contain the entire custom UI of your application. The native TW UI would become your development workbench, not seen by ordinary users.

Best wishes

Jeremy





воскресенье, 11 октября 2015 г., 13:24:38 UTC+3 пользователь Danielo Rodríguez написал:


El domingo, 11 de octubre de 2015, 11:45:14 (UTC+2), Siniy-Kit escribió:

Please be aware that this does not makes any sense. You will close all the tiddlers except one on the first iteration of the list, then you will close that tiddler when the second tiddler on the list calls the "close others" 

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/adcf5756-c96c-4bb2-af9d-5d8af746120b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Danielo Rodríguez

unread,
Oct 11, 2015, 7:28:14 AM10/11/15
to TiddlyWiki


El domingo, 11 de octubre de 2015, 13:08:30 (UTC+2), Siniy-Kit escribió:
you're right :(  tm-close-other-tiddlers close all except one.  And is it possible to close other tiddlers by the tag? And do this action every time, when any tiddler is open?
I put 1000 goods to my experimental  tw5-shop http://novye-podarki.ru/heeg1000.html   and it works slow if dom tree grows.  So I want to remove branches I don't use.

I'm not sure what are you looking for, but there are some projects where I want to "simulate" navigation.

For example, opening a FAQ section, where each FAQ question is a tiddler. What I usually do is first close all the tiddlers, then, open all the FAQ tiddlers. Is that what you want? 

Evolena

unread,
Oct 11, 2015, 8:02:15 AM10/11/15
to tiddl...@googlegroups.com
Le dimanche 11 octobre 2015 12:23:22 UTC+2, Danielo Rodríguez a écrit :

Since when is this possible? The last time I checked was not possible to use action widgets inside list widgets. 

Since the 28th January on Github, so released the 17th April with the 5.1.8 (but it doesn't appear clearly in the release note...):
https://github.com/Jermolene/TiddlyWiki5/pull/1396

Siniy-Kit

unread,
Oct 11, 2015, 8:03:04 AM10/11/15
to TiddlyWiki
Jeremy said, that when we use zoom-in, all tiddlers (we pass through) are not removed from the dom, they  only get "display: none;"  So invisible  dom tree grows and grows and TW5 works slower and slower.
so I need to modify zoomin.js to make it remove from DOM if tiddler has tag $:/TOC, if tiddler don't have this tag it must stay in DOM in standart "display: none;"

now we have
 if(self.currentTiddlerDomNode !== prevCurrentTiddler) {
    prevCurrentTiddler
.style.display = "none";
   
}

I want something like "if (prevCurrentTiddle.tag=.....){  prevCurrentTiddler.remove();  } else {prevCurrentTiddler.style.display = "none";}




 
воскресенье, 11 октября 2015 г., 14:28:14 UTC+3 пользователь Danielo Rodríguez написал:

Tobias Beer

unread,
Oct 11, 2015, 9:07:17 AM10/11/15
to TiddlyWiki
 Hi Jeremy,
 
I think the best solution for single tiddler applications like this is to adopt a new story mechanism, where instead of having a list of tiddlers making up the story, there is a single tiddler. Navigation simple replaces that tiddler.

What would speak against extending navigator.js with a single-page-mode, where...


...simply empties the storylist before adding any new tiddler?

Sure, this will run a few superfluous operations when we actually perform actions that would open multiple tiddlers, but anyone wanting single-page-mode wouldn't use those much... or be able to adapt the navigator widget call to cater for not closing things by calling tm-navigate with some preserve option.

Best wishes,

— tb

Matabele

unread,
Oct 11, 2015, 9:27:05 AM10/11/15
to TiddlyWiki
Hi

It is possible to take 'snapshots' of the story river, then restore the saved snapshots back to the story. I used this technique here.

I you open the sidebar, there is a tab titled 'Stories' which saves a snapshot with a button click. There are various options for the UI's to restore the saved story -- in the sidebar I have used a select widget -- in the pull over menu I use lists of links (with a macro.)

regards

Siniy-Kit

unread,
Oct 12, 2015, 2:31:38 AM10/12/15
to TiddlyWiki
Hi, Tobias. I understood what you mean. I deleted opened tiddler from DOM, and then I try to open it again I saw an empty screen, because navigator.js try to find it in history and make  display:block;, but don't find it. if  I don't want to modify core, is it possible to put a little script to the  top of the tiddler  and to run it when tiddler is opened?
and I want to close all tiddlers except current [tag[$:/TOC]!is[current]]

 

воскресенье, 11 октября 2015 г., 12:10:14 UTC+3 пользователь Tobias Beer написал:
Hi Siniy-Kit,

Tobias Beer

unread,
Oct 12, 2015, 2:44:15 AM10/12/15
to tiddl...@googlegroups.com
Hi Siniy-Kit,

Hi, Tobias. I understood what you mean. I deleted opened tiddler from DOM, and then I try to open it again I saw an empty screen, because navigator.js try to find it in history and make  display:block;, but don't find it. if  I don't want to modify core, is it possible to put a little script to the  top of the tiddler  and to run it when tiddler is opened?
and I want to close all tiddlers except current [tag[$:/TOC]!is[current]]

Without looking at what you tried exactly and how it's a bit difficult to tell what could be done differently.

Assuming you talk about NavigatorWidget.prototype.addToStory() now...

If you only want to remove any tiddlers matching a given filter, you need to...
  • perhaps persist that filter as a config somewhere so as to not have it hard-wired in your core modifications
    • read that filter via remove = $tw.wiki.getTextReference("$:/config/RemoveOnOpenFilter")
  • run that filter against the store via tids = $tw.wiki.filterTiddlers(remove)
  • check all items in the history against titles matching that filter
  • splice out any that match
  • set the history to the thus trimmed array
  • eventually append the title you wanted to open in the first place
Best wishes,

— tb

Siniy-Kit

unread,
Oct 12, 2015, 8:55:23 AM10/12/15
to TiddlyWiki
this way is not easy.... Can we get data from the field "list" of the "$:/StoryList" tiddler? and remove from "list" all tiddlers with tag $:/TOC except current?

понедельник, 12 октября 2015 г., 9:44:15 UTC+3 пользователь Tobias Beer написал:

Matabele

unread,
Oct 12, 2015, 9:25:13 AM10/12/15
to TiddlyWiki
Hi

Single page navigation can be achieved like this (here presented as a list.)

<ul>
<$list filter="[tag[TableOfContents]]">
<li><$button set="$:/StoryList!!list" setTo=<<currentTiddler>> class="tc-btn-invisible">
{{!!title}}
</$button>
</li>
</$list>
</ul>

Place the code in a tab in the sidebar to try this out -- adapt to your needs.

regards

Tobias Beer

unread,
Oct 12, 2015, 10:09:20 AM10/12/15
to tiddl...@googlegroups.com
Hi Metabele,

I think it needs to be...

\define current() [[$(currentTiddler)$]]


<ul>
<$list filter="[tag[TableOfContents]]">
<li><$button set="$:/StoryList!!list" setTo=<<current>> class="tc-btn-invisible">
<$view field="title"/>
</$button></li>
</$list>
</
ul>

I can already hear the next question: How can I make a toc with that? ;-)

Best wishes,

— tb

Matabele

unread,
Oct 12, 2015, 10:30:31 AM10/12/15
to TiddlyWiki
Hi

A button to clear the story can be made something like this:

<$button set="$:/StoryList!!list" setTo={{$:/HistoryList!!current-tiddler}}>
Clear All Tiddlers Except Current Tiddler
</$button>

This works fine with CamelCase titles -- to work with titles with spaces, the string needs to be stringified first. Not sure how to do this with core functionality.

regards

On Monday, 12 October 2015 14:55:23 UTC+2, Siniy-Kit wrote:

Matabele

unread,
Oct 12, 2015, 10:47:22 AM10/12/15
to TiddlyWiki
Hi

OK -- here's a quick hack (this works because there is only one title in the string 'current tiddler'.)

\define stringify()  [[$(string)$]]

<$set name="string" value= {{$:/HistoryList!!current-tiddler}}>
<$button set="$:/
StoryList!!list" setTo=<<stringify>>>

Clear All Tiddlers Except Current Tiddler
</$button></$set>

regards

On Monday, 12 October 2015 14:55:23 UTC+2, Siniy-Kit wrote:

Tobias Beer

unread,
Oct 12, 2015, 10:52:34 AM10/12/15
to tiddl...@googlegroups.com
Hi Metabele,

I think the point is, Siniy-Kit doesn't want any buttons, he just wants the behavior, afaics.

Best wishes,

— tb

Matabele

unread,
Oct 12, 2015, 11:22:03 AM10/12/15
to tiddl...@googlegroups.com

Hi

Any button code can be added to any link -- if the desired behaviour is to clear background tiddlers periodically, then the code could be added to each 'category' button (or some such.)

I am assuming that the current tiddler was opened by a button in the first instance -- seems like using single page navigation buttons (links) is the best approach. Keeping a whole lot of hidden tiddlers in the background, then having to clear them, doesn't appear to serve any function.

regards

Siniy-Kit

unread,
Oct 12, 2015, 4:04:04 PM10/12/15
to TiddlyWiki
the easiest way was to convert links to buttons in TOC macro, and my menu.  

<$button class="tc-btn-invisible"><$list filter="[tag[$:/TOC]]"><$action-sendmessage $message="tm-close-tiddler"/></$list><$action-navigate $to=<<currentTiddler>> /> <$view field="title"/>  </$button>

behavior was very difficult for me. and the result shop with 1000 goods.  http://novye-podarki.ru/heeg1001.html I don't know how to make it faster.


понедельник, 12 октября 2015 г., 18:22:03 UTC+3 пользователь Matabele написал:

Tobias Beer

unread,
Oct 13, 2015, 7:42:25 AM10/13/15
to tiddl...@googlegroups.com
Hi Siniy-Kit,
 
I don't know how to make it faster.

This might help...

<$button class="tc-btn-invisible">
<$list filter="[list[$:/StoryList!!list]tag[$:/TOC]]">
  <$action-sendmessage $message="tm-close-tiddler"/>
</$list>
<$action-navigate $to=<<currentTiddler>> />
<$view field="title"/>
</$button>

 Best wishes,

— tb

Siniy-Kit

unread,
Oct 14, 2015, 8:12:13 AM10/14/15
to TiddlyWiki
Thank you, Tobias! I put you code. while using tm-close-tiddler happens strange things. all tiddlers become display: block , so I see all tiddlers open.... http://novye-podarki.ru/heeg1001.html






вторник, 13 октября 2015 г., 14:42:25 UTC+3 пользователь Tobias Beer написал:

Tobias Beer

unread,
Oct 14, 2015, 1:33:16 PM10/14/15
to tiddl...@googlegroups.com
Hey Siniy-Kit,

I just saw a nasty line-break introduced by the google groups splitting...

<<currentTiddler>>

into...

<
<currentTiddler>>

Please check if you perhaps copied that over.

Also, I'm not sure how to do anything in your wiki except click links. :D

Best wishes,

— tb

Siniy-Kit

unread,
Oct 21, 2015, 3:28:04 AM10/21/15
to TiddlyWiki
Hi, Tobias! I understood the problem. if we close tiddlers (by tag) in zoom-in view, we make tiddlers "under" closed tiddlers visible. it is good if we close  only one top tiddler, but bad if we close a group of tiddlers.  

is it possible to deactivate this mechanism?  is it possible to modify $:/StoryList!!list by  $action-setfield  widget and remove from it tiddlers with tag $:/TOC ?

среда, 14 октября 2015 г., 20:33:16 UTC+3 пользователь Tobias Beer написал:

BJ

unread,
Oct 21, 2015, 6:05:38 AM10/21/15
to TiddlyWiki

which release of tw5 are you using? there was a fix to the zoom mode in  5.1.9

all the best
BJ

Siniy-Kit

unread,
Oct 23, 2015, 6:45:34 AM10/23/15
to TiddlyWiki
Thank you BJ.  in new version everything work good.

среда, 21 октября 2015 г., 13:05:38 UTC+3 пользователь BJ написал:
Reply all
Reply to author
Forward
0 new messages