2017-06-28 16:44:15 +00:00
|
|
|
title: $:/core/macros/tree
|
|
|
|
tags: $:/tags/Macro
|
|
|
|
|
2018-11-19 10:50:09 +00:00
|
|
|
\define leaf-link(full-title, chunk)
|
|
|
|
<$link to=<<__full-title__>>><$text text=<<__chunk__>>/></$link>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\define leaf-node(prefix, chunk)
|
2017-06-28 16:44:15 +00:00
|
|
|
<li>
|
2018-11-19 10:50:09 +00:00
|
|
|
<$list filter="[<__prefix__>addsuffix<__chunk__>is[shadow]] [<__prefix__>addsuffix<__chunk__>is[tiddler]]" variable="full-title">
|
|
|
|
<$list filter="[<full-title>removeprefix<__prefix__>]" variable="chunk">
|
|
|
|
<span>{{$:/core/images/file}}</span> <$macrocall $name="leaf-link" full-title=<<full-title>> chunk=<<chunk>>/>
|
|
|
|
</$list>
|
2017-06-28 16:44:15 +00:00
|
|
|
</$list>
|
|
|
|
</li>
|
|
|
|
\end
|
|
|
|
|
2018-11-19 10:50:09 +00:00
|
|
|
\define branch-node(prefix, chunk)
|
|
|
|
<li>
|
|
|
|
<$set name="reveal-state" value={{{ [[$:/state/tree/]addsuffix<__prefix__>addsuffix<__chunk__>] }}}>
|
|
|
|
<$reveal type="nomatch" stateTitle=<<reveal-state>> text="show">
|
|
|
|
<$button setTitle=<<reveal-state>> setTo="show" class="tc-btn-invisible">
|
|
|
|
{{$:/core/images/folder}} <$text text=<<__chunk__>>/>
|
|
|
|
</$button>
|
2017-06-28 16:44:15 +00:00
|
|
|
</$reveal>
|
2018-11-19 10:50:09 +00:00
|
|
|
<$reveal type="match" stateTitle=<<reveal-state>> text="show">
|
|
|
|
<$button setTitle=<<reveal-state>> setTo="hide" class="tc-btn-invisible">
|
|
|
|
{{$:/core/images/folder}} <$text text=<<__chunk__>>/>
|
|
|
|
</$button>
|
2017-06-28 16:44:15 +00:00
|
|
|
</$reveal>
|
2018-11-19 10:50:09 +00:00
|
|
|
<span>(<$count filter="[all[shadows+tiddlers]removeprefix<__prefix__>removeprefix<__chunk__>] -[<__prefix__>addsuffix<__chunk__>]"/>)</span>
|
|
|
|
<$reveal type="match" stateTitle=<<reveal-state>> text="show">
|
|
|
|
<$macrocall $name="tree-node" prefix={{{ [<__prefix__>addsuffix<__chunk__>] }}}/>
|
2017-06-28 16:44:15 +00:00
|
|
|
</$reveal>
|
2018-11-19 10:50:09 +00:00
|
|
|
</$set>
|
2017-06-28 16:44:15 +00:00
|
|
|
</li>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\define tree-node(prefix)
|
|
|
|
<ol>
|
2018-11-19 10:50:09 +00:00
|
|
|
<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore[/]sort[]!suffix[/]]" variable="chunk">
|
|
|
|
<$macrocall $name="leaf-node" prefix=<<__prefix__>> chunk=<<chunk>>/>
|
2017-06-28 16:44:15 +00:00
|
|
|
</$list>
|
2018-11-19 10:50:09 +00:00
|
|
|
<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore[/]sort[]suffix[/]]" variable="chunk">
|
|
|
|
<$macrocall $name="branch-node" prefix=<<__prefix__>> chunk=<<chunk>>/>
|
2017-06-28 16:44:15 +00:00
|
|
|
</$list>
|
|
|
|
</ol>
|
|
|
|
\end
|
|
|
|
|
2018-11-19 10:50:09 +00:00
|
|
|
\define tree(prefix: "$:/")
|
2017-06-28 16:44:15 +00:00
|
|
|
<div class="tc-tree">
|
2018-11-19 10:50:09 +00:00
|
|
|
<span><$text text=<<__prefix__>>/></span>
|
2017-06-28 16:44:15 +00:00
|
|
|
<div>
|
2018-11-19 10:50:09 +00:00
|
|
|
<$macrocall $name="tree-node" prefix=<<__prefix__>>/>
|
2017-06-28 16:44:15 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
\end
|