It is nice to have a button in empty story river or on the sidebar, on lick shows a random tiddler. I have such a button in TW-Scripts and Mehregan. The button uses the computer time as seed and its output is deterministic, so it does not generate a real random number, but is very handy for our daily use and has no performance impact.
This solution is pure WikiText, no JavaScript.
\define randomTiddler(filter, label)
<$let seed=<<now XXX>>
minNum = 1
maxNum = {{{ [subfilter<__filter__>count[]] }}}
randNum = {{{ [<maxNum>subtract<minNum>multiply<seed>divide[999]add<minNum>round[]] }}}
>
<$link to={{{ [subfilter<__filter__>nth<randNum>] :else[subfilter<__filter__>first[]] }}}>$label$</$link>
</$let>
\end
Logic
If we linearly map [0, 999]
into [alpha:1, beta:n]
where alpha
is the first tiddler and beta
is the number of tiddlers to be used for random display! from mathematics we have
x
in [0, 999]
(this will be generated by now
macro)
y
in [alpha, beta]
(this is the numbers we like)
then y= (beta - alpha) / 999 * x + alpha
To give a try
- download Random Tiddler Macro.json (743 Bytes)
- drag and drop on https://tiddlywiki.com/
- open Test and click on
Random Tiddler
References
- https://groups.google.com/g/tiddlywiki/c/GuQ0EMKfZaM/m/WCo26CxqAwAJ
- Using Randomness in TiddlyWiki - Discussion - Talk TW
- Scripts in Tiddlywiki — codes, macros, and solutions in TW (credits go to @twMat)
Please add your alternative solution to this thread.