mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2025-12-15 15:10:30 -08:00
57 lines
2.3 KiB
Text
57 lines
2.3 KiB
Text
title: $:/core/macros/tree
|
|
tags: $:/tags/Macro
|
|
|
|
\define leaf-node(chunk,title)
|
|
\whitespace trim
|
|
<li>
|
|
<span>{{$:/core/images/file}}</span> 
|
|
<$link to=<<__title__>>><$text text=<<__chunk__>>/></$link>
|
|
</li>
|
|
\end
|
|
|
|
\define branch-node(prefix,chunk,separator: "/",field: "title")
|
|
\whitespace trim
|
|
<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>
|
|
</$reveal>
|
|
<$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>
|
|
</$reveal>
|
|
 
|
|
<span>(<$count filter="[all[shadows+tiddlers]get<__field__>removeprefix<__prefix__>removeprefix<__chunk__>] -[<__prefix__>addsuffix<__chunk__>]"/>)</span>
|
|
<$reveal type="match" stateTitle=<<reveal-state>> text="show">
|
|
<$macrocall $name="tree-node" prefix={{{ [<__prefix__>addsuffix<__chunk__>] }}} separator=<<__separator__>> field=<<__field__>>/>
|
|
</$reveal>
|
|
</$set>
|
|
</li>
|
|
\end
|
|
|
|
\define tree-node(prefix,separator: "/",field: "title")
|
|
\whitespace trim
|
|
<ol>
|
|
<$list filter="[all[shadows+tiddlers]get<__field__>prefix<__prefix__>removeprefix<__prefix__>splitbefore<__separator__>sort[]!suffix<__separator__>]" variable="chunk">
|
|
<$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]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>
|
|
</ol>
|
|
\end
|
|
|
|
\define tree(prefix: "$:/",separator: "/",field: "title")
|
|
\whitespace trim
|
|
<div class="tc-tree">
|
|
<span><$text text=<<__prefix__>>/></span>
|
|
<div>
|
|
<$macrocall $name="tree-node" prefix=<<__prefix__>> separator=<<__separator__>> field=<<__field__>>/>
|
|
</div>
|
|
</div>
|
|
\end
|