List of last visited tiddlers

Thanks. That does make a lot of sense. I changed it and it works exactly the same.

I’ve been thinking about this and another alternative is to override the navigator widget. The overridden widget would intercept the navigate events and record the timestamp and then forward the navigate event so the navigator widget can perform its tasks.

That doesn’t address the issue of how to store the information about the visit history in a way which makes it easy to truncate to a certain number of days.

Here is some code which does what I suggest:

\procedure record-and-forward-navigation()
<!-- Forward the navigation event to the real navigator widget -->
<$action-navigate $to=<<event-navigateTo>>/>

<!-- Append the navigated tiddler to the list and also record -->
<!-- the current timestamp. Use 'enlist-raw' and ':all' to avoid -->
<!-- deduplication. The two lists must stay in sync! -->
<$action-listops $tiddler="TimestampedHistory" $field=tiddlers $filter="[enlist:raw{TimestampedHistory!!tiddlers}] :all[<event-navigateTo>]"/>
<$action-listops $tiddler="TimestampedHistory" $field=visited $filter="[enlist:raw{TimestampedHistory!!visited}] :all[<now [UTC]YYYY0MM0DD0hh0mm0ssXXX
>]"/>
\end

\widget $navigator()
<!-- Override the navigator widget to intercept navigate events -->
<$parameters $params="@params">

<$genesis
  $type="$navigator"
  $remappable="no"
  $names="[<@params>jsonindexes[]]"
  $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]">
<$messagecatcher $tm-navigate=<<record-and-forward-navigation>>>
<$slot $name=ts-raw/>
</$messagecatcher>
</$genesis>

</$parameters>
\end

See a demo of the above code at this share site link.

In the demo, I redefine the navigator widget only within a single tiddler. To have it apply to the entire wiki, a tag to mark it global is required.

2 Likes

Wonderful! This working example also shows how to overwrite an intrinsic widget!

Hi @btheado great idea!

What about this slightly off-topic idea:
Do you think the $:/HistoryList might be (ab)used to store the timestamp in a supplemental JSON value?
The record-and-forward procedure could

  • find the newest instance of the navigated tiddler in $:/HistoryList
  • check if it already has a timestamp
  • if not, add a timestamp

This should not interfere with the normal operation of the History. I know it’s a two-edged sword to mess with the HistoryList, but it’s a backwards-compatible mess. :wink:

A possible usage scenario could be to trim a displayed history by time instead of by size. I often have a wiki open over a span of several days (I set the computer to only sleep overnight), so it might make sense to not show older stuff a history list…

@btheado

What’s targeting this?

<$slot $name=ts-raw/>

Something the house cleaner missed? :slight_smile:

Wow. Not that is going to take me some time to wrap my head around. There are a few things there that I’ve never used or studied before. Very interesting! Thanks.

This is how the custom widget can access the body content the user passes in the $navigator

https://tiddlywiki.com/#Custom%20Widgets - see the section on “Accessing Content of Custom Widgets”.

Ah. That’s why there’s no $fill.

Thanks!

Yes it is in fact the default fill for the body of the calling widgets.

We need to improve where this is documented.