On Wednesday, July 1, 2020 at 5:01:25 AM UTC-7, Saq Imtiaz wrote:
>
> Hmm. If we had something like a history list but with timestamps and
> actually saved it...
The $:/HistoryList is updated whenever you open a tiddler in the story
river.
This is accomplished by the <$navigator> widget called from the
$:/core/ui/PageTemplate:
<$navigator story="$:/StoryList" history="$:/HistoryList"
openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}}
openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}}
relinkOnRename={{$:/config/RelinkOnRename}}>
The code that actually does the work is in
$:/core/modules/widgets/navigator.js:
NavigatorWidget.prototype.addToHistory = function(title,fromPageRect) {
this.wiki.addToHistory(title,fromPageRect,this.historyTitle);
};
and the "wiki.addToHistory" function is defined in $:/core/modules/wiki.js
exports.addToHistory = function(title,fromPageRect,historyTitle) {
var story = new $tw.Story({wiki: this, historyTitle: historyTitle});
story.addToHistory(title,fromPageRect);
};
and the "story.addToHistory" function is defined
in $:/core/modules/story.js:
Story.prototype.addToHistory = function(navigateTo,navigateFromClientRect) {
var titles = $tw.utils.isArray(navigateTo) ? navigateTo : [navigateTo];
// Add a new record to the top of the history stack
var historyList = this.wiki.getTiddlerData(this.historyTitle,[]);
$tw.utils.each(titles,function(title) {
historyList.push({title: title, fromPageRect: navigateFromClientRect});
});
this.wiki.setTiddlerData(this.historyTitle,historyList,{"current-tiddler":
titles[titles.length-1]});
};
so... in this function, we could add code to get the current timestamp and
include it in the object being pushed to the historyList:
Story.prototype.addToHistory = function(navigateTo,navigateFromClientRect) {
var titles = $tw.utils.isArray(navigateTo) ? navigateTo : [navigateTo];
// Add a new record to the top of the history stack
var historyList = this.wiki.getTiddlerData(this.historyTitle,[]);
* var now=$tw.utils.formatDateString(new Date(),"YYYY0MM0DD0hh0mm0ss0XXX");*
$tw.utils.each(titles,function(title) {
historyList.push({title: title, fromPageRect: navigateFromClientRect,*
timestamp:now*});
});
this.wiki.setTiddlerData(this.historyTitle,historyList,{"current-tiddler":
titles[titles.length-1]});
};
(changes shown in bold)
Then, we just need to write some code that accesses the $:/HistoryList JSON
data, and finds the most recent entry for the current tiddler, and then
fetches the timestamp from that entry.
-e
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/99c3c757-bed2-4d41-aabe-019c4c3b051ao%40googlegroups.com.