felixhayashi / TW5-TiddlyMap

Map drawing and topic visualization for your wiki
http://tiddlymap.org
BSD 2-Clause "Simplified" License
857 stars 132 forks source link

Evaluate $list filters before [[tw-body:link]] #401

Closed dagelf closed 2 years ago

dagelf commented 3 years ago

I have a bunch of nodes with complex $list filter evaluations that add links to specific other nodes based on complex tag interactions, inside templates. Even if I copy these out of the templates, they still do not evaluate.

First prize for me would be if the Edge-type filter [[tw-body:link]] would show all the links generated like this and not just hard coded links. Currently it sees almost none of my links - as most all dynamically generated like that.

A simple example, on a node I have:

<$list filter="[tag[MySite]tag[Router]]">
<$link to={{!!title}}>
<$view field="title"/><br/>
</$link>
</$list>

That lists all the routers tagged with both at MySite and Router. as links in a list. [[tw-body:link]] do not pick up links generated like this.

I am sure I am missing something trivial - but my question is - if it's possible, how? If it's not currently possible, how much work would it be to run these evaluations before [[tw-body:link]] looks for links? I would be happy to jump into the code if necessary.

dagelf commented 3 years ago

It looks like the function to update would be $tw.wiki.getTiddlerLinks(tObj.fields.title); in line 50 here: https://github.com/felixhayashi/TW5-TiddlyMap/blame/17b3bfe6f40a6e42f97cbdbf2c6c6e6c3e78628a/src/plugins/felixhayashi/tiddlymap/js/edgeTypeSubscriber/refEdgeTypeSubscriber/LinkEdgeTypeSubscriber.js#L50

flibbles commented 2 years ago

(I know this is pretty late. I'm working through some backlogged issues.)

$tw.wiki.getTiddlerLinks is a core method which only examines the parseTree of the tiddlers. It's always been a limitation of that core method that it doesn't determine links for each iteration of $list widgets. This same limitation is also evident in the side-panel "missing" and "orphan" and the TiddlerInfo tabs, not just in TiddlyMap. It'd be a request to the core TiddlyWiki project to have getTiddlerLinks to consider $list widgets. They probably won't, because that would only work some of the time. Between $vars $set $let $tiddler, and indirect references, there are a million ways to create links to tiddlers that aren't immediately evident in the parseTreeNode. The only surefire way to find them all would be to do everything short of rendering the tiddler, which is expensive.

For your case (assuming you even still care), I'd recommend making a tw-filter:links edge type which looks identical to the tw-body:link type. You can put your $list widget filters in there, and then have something like the following:

<$list filter={{!!links}}>
<$link><$view field="title"/><br/></$link>
</$list>

Tiddlymap will show your links that way.