This commit is contained in:
Anders Hagen Jarmund 2025-12-02 14:33:55 +01:00 committed by GitHub
commit ea3b527b06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,22 +1,15 @@
title: $:/core/macros/tree title: $:/core/macros/tree
tags: $:/tags/Macro tags: $:/tags/Macro
\define leaf-link(full-title,chunk,separator: "/") \define leaf-node(chunk,title)
<$link to=<<__full-title__>>><$text text=<<__chunk__>>/></$link>
\end
\define leaf-node(prefix,chunk)
\whitespace trim \whitespace trim
<li> <li>
<$list filter="[<__prefix__>addsuffix<__chunk__>is[shadow]] [<__prefix__>addsuffix<__chunk__>is[tiddler]]" variable="full-title"> <span>{{$:/core/images/file}}</span>&#32;
<$list filter="[<full-title>removeprefix<__prefix__>]" variable="chunk"> <$link to=<<__title__>>><$text text=<<__chunk__>>/></$link>
<span>{{$:/core/images/file}}</span>&#32;<$macrocall $name="leaf-link" full-title=<<full-title>> chunk=<<chunk>>/>
</$list>
</$list>
</li> </li>
\end \end
\define branch-node(prefix,chunk,separator: "/") \define branch-node(prefix,chunk,separator: "/",field: "title")
\whitespace trim \whitespace trim
<li> <li>
<$set name="reveal-state" value={{{ [[$:/state/tree/]addsuffix<__prefix__>addsuffix<__chunk__>] }}}> <$set name="reveal-state" value={{{ [[$:/state/tree/]addsuffix<__prefix__>addsuffix<__chunk__>] }}}>
@ -31,32 +24,34 @@ tags: $:/tags/Macro
</$button> </$button>
</$reveal> </$reveal>
&#32; &#32;
<span>(<$count filter="[all[shadows+tiddlers]removeprefix<__prefix__>removeprefix<__chunk__>] -[<__prefix__>addsuffix<__chunk__>]"/>)</span> <span>(<$count filter="[all[shadows+tiddlers]get<__field__>removeprefix<__prefix__>removeprefix<__chunk__>] -[<__prefix__>addsuffix<__chunk__>]"/>)</span>
<$reveal type="match" stateTitle=<<reveal-state>> text="show"> <$reveal type="match" stateTitle=<<reveal-state>> text="show">
<$macrocall $name="tree-node" prefix={{{ [<__prefix__>addsuffix<__chunk__>] }}} separator=<<__separator__>>/> <$macrocall $name="tree-node" prefix={{{ [<__prefix__>addsuffix<__chunk__>] }}} separator=<<__separator__>> field=<<__field__>>/>
</$reveal> </$reveal>
</$set> </$set>
</li> </li>
\end \end
\define tree-node(prefix,separator: "/") \define tree-node(prefix,separator: "/",field: "title")
\whitespace trim \whitespace trim
<ol> <ol>
<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore<__separator__>sort[]!suffix<__separator__>]" variable="chunk"> <$list filter="[all[shadows+tiddlers]get<__field__>prefix<__prefix__>removeprefix<__prefix__>splitbefore<__separator__>sort[]!suffix<__separator__>]" variable="chunk">
<$macrocall $name="leaf-node" prefix=<<__prefix__>> chunk=<<chunk>> separator=<<__separator__>>/> <$list filter="[all[shadows+tiddlers]has<__field__>sort[]] :filter[get<__field__>removeprefix<__prefix__>match<chunk>]" variable="title">
<$macrocall $name="leaf-node" prefix=<<__prefix__>> chunk=<<chunk>> title=<<title>> separator=<<__separator__>>/>
</$list> </$list>
<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore<__separator__>sort[]suffix<__separator__>]" variable="chunk"> </$list>
<$macrocall $name="branch-node" prefix=<<__prefix__>> chunk=<<chunk>> separator=<<__separator__>>/> <$list filter="[all[shadows+tiddlers]get<__field__>prefix<__prefix__>removeprefix<__prefix__>splitbefore<__separator__>sort[]suffix<__separator__>]" variable="chunk">
<$macrocall $name="branch-node" prefix=<<__prefix__>> chunk=<<chunk>> separator=<<__separator__>> field=<<__field__>>/>
</$list> </$list>
</ol> </ol>
\end \end
\define tree(prefix: "$:/",separator: "/") \define tree(prefix: "$:/",separator: "/",field: "title")
\whitespace trim \whitespace trim
<div class="tc-tree"> <div class="tc-tree">
<span><$text text=<<__prefix__>>/></span> <span><$text text=<<__prefix__>>/></span>
<div> <div>
<$macrocall $name="tree-node" prefix=<<__prefix__>> separator=<<__separator__>>/> <$macrocall $name="tree-node" prefix=<<__prefix__>> separator=<<__separator__>> field=<<__field__>>/>
</div> </div>
</div> </div>
\end \end