Extract tiddler titles from $:/HistoryList

59 views
Skip to first unread message

TW Tones

unread,
Jul 1, 2020, 7:17:44 PM7/1/20
to TiddlyWiki
Folks,

I am working on a "cute" macro for managing which tiddler has focus in the story river. I make use of the field 

$:/HistoryList!!current-tiddler


But like usual, be it my obsession or otherwise I want to add a few more features and want to access the titles listed in the text field of $:/HistoryList 

You may be aware the $:/HistoryList is a list of tiddler titles like this;
"title": "$:/AdvancedSearch",

I would have thought there was a mechanism already available to extract a list of tiddler titles from this format?

Ideally I need a way already available in the core so I do not need to install additional plugins for make this work.

Have you come across a method to extract titles from the $:/HistoryList ?

Regards
TW Tones

Mat

unread,
Jul 1, 2020, 7:34:20 PM7/1/20
to TiddlyWiki
TW Tones wrote:
I am working on a "cute" macro for managing which tiddler has focus in the story river. I make use of the field 

$:/HistoryList!!current-tiddler


Are you sure it's HistoryList you want and not $:/StoryList!!list  ?

<:-)

TW Tones

unread,
Jul 1, 2020, 8:52:07 PM7/1/20
to TiddlyWiki
Mat,

Yes, I am yet to explore the real meaning of the history list titles, however I take it to be a list of tiddlers with the latest at the top most recently opened below that ...

PROBLEM SOLVED
  • I am keen to capture the record of tiddlers that had focus (opened or navigated to), or who have been given focus (with a button I created). Basically a recently opened rather than a recently modified list.  
  • Not withstanding a desire to do the above, I would also like a way to access tiddler titles contained within such a list, perhaps even find out how to create such a list as well.
  • There may be other opportunities if I can extract the titles
  • I started playing with splitregexp operator in an attempt to parse the content, but had difficulty
Mat,

I managed to solve this by reverting to the split operator, rather than the splitregexp

\define title-string() "title": "
\define end-title() "

<$list filter="[{$:/HistoryList}split<title-string>splitbefore<end-title>removesuffix<end-title>reverse[]]">
<$text text=<<currentTiddler>>/><br>
</
$list>


Now a little more work to remove tiddlers that no longer exist from the list.

Thanks
Tony

Eric Shulman

unread,
Jul 1, 2020, 10:43:05 PM7/1/20
to TiddlyWiki
On Wednesday, July 1, 2020 at 5:52:07 PM UTC-7, TW Tones wrote:
\define title-string() "title": "
\define end-title() "

<$list filter="[{$:/HistoryList}split<title-string>splitbefore<end-title>removesuffix<end-title>reverse[]]">
<$text text=<<currentTiddler>>/><br>
</
$list>
Now a little more work to remove tiddlers that no longer exist from the list.

Just add is[tiddler] to the end of your filter:
<$list filter="[{$:/HistoryList}split<title-string>splitbefore<end-title>removesuffix<end-title>reverse[]is[tiddler]]">

Also, you should note that the $:/HistoryList doesn't exist until you've actually navigated to a tiddler.

Thus, when you first load a document, if there are any tiddlers opened by $:/DefaultTiddlers, you
will want to add those to your generated list of titles by adding the contents of $:/StoryList!!list

...and, since *closing* tiddlers doesn't affect the $:/HistoryList, if you close the initial tiddlers
immediately after loading the document, there still won't be anything in the history, even though
default tiddlers were displayed.  Thus, you will also want to explicitly add the contents of
$:/DefaultTiddlers to the list, so that they will always be included in the result.

Here's the filter that I've used in my own "History" interface at http://TiddlyTools.com/InsideTW:
\define history()    [{$:/HistoryList}split["title": "]splitbefore["]removesuffix["]reverse[]is[tiddler]] [enlist{$:/StoryList!!list}] [enlist{$:/DefaultTiddlers}]

enjoy,
-e

Eric Shulman

unread,
Jul 1, 2020, 11:11:37 PM7/1/20
to tiddl...@googlegroups.com
On Wednesday, July 1, 2020 at 7:43:05 PM UTC-7, Eric Shulman wrote:
Here's the filter that I've used in my own "History" interface at http://TiddlyTools.com/InsideTW:
\define history()    [{$:/HistoryList}split["title": "]splitbefore["]removesuffix["]reverse[]is[tiddler]] [enlist{$:/StoryList!!list}] [enlist{$:/DefaultTiddlers}]

Here's a link to my implementation:


also... there is a "debugger" mode that can be enabled by defining a CSS class in a tiddler tagged with $:/tags/Stylesheet
.authortools { display:inline; }

When that classname is defined, the "History" interface adds a "chevron-down" button that toggles between normal "user"
display and enhanced "author" display, which shows the contents of $:/HistoryList, $:/StoryList!!list, and the resulting
"computed" history.  This can be handy when verifying how the computed history list was constructed.

enjoy,
-e


TW Tones

unread,
Jul 2, 2020, 2:06:14 AM7/2/20
to TiddlyWiki
Eric,

Thanks that is very helpful. 

I followed you link http://tiddlytools.com/InsideTW/#TiddlyTools%2FHistory but don't see anything meaningful, and empty view?

I see value in feeding it with the story list and default tiddlers, however in this case I am trying to show tiddlers someone has opened or focused on. That is which tiddlers the have given attention to.

It would be nice to store the history for the last 20 or so for when you return. That may be the next advance. 

Regards
Tony

Eric Shulman

unread,
Jul 2, 2020, 2:46:26 AM7/2/20
to TiddlyWiki
On Wednesday, July 1, 2020 at 11:06:14 PM UTC-7, TW Tones wrote:
I followed you link http://tiddlytools.com/InsideTW/#TiddlyTools%2FHistory but don't see anything meaningful, and empty view?

The TiddlyTools/History tiddler shows the history *button* (a stylized clock SVG).  Click it to reveal a popup.

1) To add this button to the tiddler menu, tag "TiddlyTools/History" with "$:/tags/ViewToolbar"
2) You will also need to import two stylesheets to make things look right:
   - ".tt-button" - the buttons in the popup panel
   - ".tt-shadowbox" - the popup panel outer frame
   - ".tt-drop-down" - enables inline buttons inside the popup panel
   - classes for common CSS styles, like ".floatright", ".floatleft", etc.

enjoy,
-e

TW Tones

unread,
Jul 2, 2020, 3:32:09 AM7/2/20
to TiddlyWiki
Eric,

Thanks, Very nice. And lots more to learn from http://tiddlytools.com/InsideTW/

Regards
Tony
Reply all
Reply to author
Forward
0 new messages