Diego Mesa

2018-02-12 18:14:42 UTC

Hey all,

While working on my Spaced Repetition/Anki system, I've developed this

general link-list macro which might be useful. Its purpose is to take a

subfilter, eg: "tag[Flash Card]", sort them someway, eg: created, an ending

link (eg: "Results"), and create a series of links from one tiddler to the

next, all the way to the end. The "next" tiddler in the link is saved in a

field, whose name you can also specify.

Right now, it also has the list navigation built in (action-navigate),

though Im sure we can just add an additional actions parameter to this

macro in the future.

\define createAndShowLinkedList(subfilter lastlink sortby:created

linkfieldname:next)

<!-- for the n many cards, we return n-1 -->

<$formula-vars counter="count([$subfilter$])-1">

<!-- iter goes from 0 to n-2 -->

<$list filter="[range<counter>butlast[]]" variable="iter">

<!-- arrays need to be accessed from 1 to n -->

<$formula-vars current="nth([$subfilter$sort[$sortby$]], <<iter>> +

1)" next="nth([$subfilter$sort[$sortby$]], <<iter>> + 2)">

<$action-setfield $tiddler=<<current>> $field=$linkfieldname$

$value=<<next>>/>

<!--<Current: <<current>>, Next: <<next>> <br/> -->

</$formula-vars>

</$list>

<!-- take last element with no forward link -->

<$list filter="[range<counter>last[]]" variable="iter">

<$formula-vars current="nth([$subfilter$sort[$sortby$]], <<iter>> +

1)">

<$action-setfield $tiddler=<<current>> $field=$linkfieldname$

$value=$lastlink$/>

</$formula-vars>

</$list>

</$formula-vars>

<!-- begin list navigation -->

<$list filter="[$subfilter$sort[$sortby$]first[]]">

<$action-navigate $to=<<currentTiddler>>/>

</$list>

\end

It currently uses Evan's excellent formula plugin. I'm pretty sure someone

could do all of the counting, adding, etc without it, but Im not sure how

to get the *range* using just core features. I was thinking of trying to

make this my first core PR, but I couldnt see a way around the use of range.

If anyone has any feedback, critcisms, etc please let me know!

Best,

Diego

While working on my Spaced Repetition/Anki system, I've developed this

general link-list macro which might be useful. Its purpose is to take a

subfilter, eg: "tag[Flash Card]", sort them someway, eg: created, an ending

link (eg: "Results"), and create a series of links from one tiddler to the

next, all the way to the end. The "next" tiddler in the link is saved in a

field, whose name you can also specify.

Right now, it also has the list navigation built in (action-navigate),

though Im sure we can just add an additional actions parameter to this

macro in the future.

\define createAndShowLinkedList(subfilter lastlink sortby:created

linkfieldname:next)

<!-- for the n many cards, we return n-1 -->

<$formula-vars counter="count([$subfilter$])-1">

<!-- iter goes from 0 to n-2 -->

<$list filter="[range<counter>butlast[]]" variable="iter">

<!-- arrays need to be accessed from 1 to n -->

<$formula-vars current="nth([$subfilter$sort[$sortby$]], <<iter>> +

1)" next="nth([$subfilter$sort[$sortby$]], <<iter>> + 2)">

<$action-setfield $tiddler=<<current>> $field=$linkfieldname$

$value=<<next>>/>

<!--<Current: <<current>>, Next: <<next>> <br/> -->

</$formula-vars>

</$list>

<!-- take last element with no forward link -->

<$list filter="[range<counter>last[]]" variable="iter">

<$formula-vars current="nth([$subfilter$sort[$sortby$]], <<iter>> +

1)">

<$action-setfield $tiddler=<<current>> $field=$linkfieldname$

$value=$lastlink$/>

</$formula-vars>

</$list>

</$formula-vars>

<!-- begin list navigation -->

<$list filter="[$subfilter$sort[$sortby$]first[]]">

<$action-navigate $to=<<currentTiddler>>/>

</$list>

\end

It currently uses Evan's excellent formula plugin. I'm pretty sure someone

could do all of the counting, adding, etc without it, but Im not sure how

to get the *range* using just core features. I was thinking of trying to

make this my first core PR, but I couldnt see a way around the use of range.

If anyone has any feedback, critcisms, etc please let me know!

Best,

Diego

--

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 ***@googlegroups.com.

Visit this group at https://groups.google.com/group/tiddlywiki.

To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/776d405c-c5e3-46a1-8318-1eb41cc2f623%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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 ***@googlegroups.com.

Visit this group at https://groups.google.com/group/tiddlywiki.

To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/776d405c-c5e3-46a1-8318-1eb41cc2f623%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.