-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathWiki Listing Folding.tid
193 lines (180 loc) · 5.37 KB
/
Wiki Listing Folding.tid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
title: $:/plugins/OokTech/Bob/Folding Wiki Listing
caption: Folding Wiki Listing
tags: $:/tags/Macro
\define thisFoldingWikiListingMakeState() $:/state/FoldingWikiList/$(currentTiddler)$/$(WikiPrefix)$$(WikiName)$
\define thisFoldingWikiListingMakeURL() /$(PROXYPREFIX)$$(WikiPrefix)$$(WikiName)$
\define thisFoldingWikiListingMakeWikiListingTab()
<$action-setfield
$tiddler='$:/plugins/OokTech/Bob/SideBarTab'
tags='$:/tags/SideBar'
text='{{$:/plugins/OokTech/Bob/Wiki Listing}}'
caption='Wikis'
/>
\end
\define thisFoldingWikiListingRemoveWikiListingTab()
<$action-setfield
$tiddler='$:/plugins/OokTech/Bob/SideBarTab'
text=''
/>
<$action-deletetiddler
$tiddler='$:/plugins/OokTech/Bob/SideBarTab'
/>
\end
\define thisFoldingWikiListingInnerList()
<$vars wikiNameSlash={{{ [<WikiName>addsuffix<Sep>] }}}>
<$list
filter='[subfilter<InputList>removeprefix<WikiPrefix>prefix<WikiNameSlash>splitbefore<Sep>] +[sort[]]'
variable=WikiName
>
<$list
filter="[<WikiName>suffix<Sep>]"
variable=unused
>
<$list
filter="[<WikiName>]"
variable=InnerWikiName
>
<li>
<!-- Button for collapsing this part -->
<$button
class='tc-btn-invisible'
>
<$reveal
state=<<thisFoldingWikiListingMakeState>>
text='show'
type='match'
>
{{$:/core/images/chevron-down}}
<$action-setfield
$tiddler=<<thisFoldingWikiListingMakeState>>
text=hide
/>
</$reveal>
<$reveal
state=<<thisFoldingWikiListingMakeState>>
text='show'
type='nomatch'
>
{{$:/core/images/chevron-right}}
<$action-setfield
$tiddler=<<thisFoldingWikiListingMakeState>>
text=show
/>
</$reveal>
</$button>
<!-- The text for the current entry -->
<$set
name=TEMP
filter='[<InnerWikiName>removesuffix<Sep>]'
>
<$list
filter="[subfilter<InputList>removeprefix<WikiPrefix>splitbefore<Sep>prefix<TEMP>suffix<TEMP>limit[1]]"
emptyMessage="""
<!-- Parts of paths to wikis that aren't wiki names -->
<<__notexist__>>
"""
variable=unused
>
<!-- Wikis that exist and are part of paths to other wikis -->
<<__exist__>>
</$list>
</$set>
<!-- Recurse for the next level -->
<$reveal
state=<<thisFoldingWikiListingMakeState>>
text='show'
type='match'
>
<$set
name=WikiName
value=""
>
<$set
name=WikiPrefix
filter='[<WikiPrefix>addsuffix<InnerWikiName>]'
>
<ul>
<<thisFoldingWikiListingInnerList>>
</ul>
</$set>
</$set>
</$reveal>
</li>
</$list>
</$list>
<$list
filter='[<WikiName>!suffix<Sep>] -[subfilter<InputList>removeprefix<WikiPrefix>splitbefore<Sep>prefix<WikiName>suffix<Sep>removesuffix<Sep>]'
variable=WikiName
>
<li>
<<__exist__>>
</li>
</$list>
</$list>
</$vars>
\end
\define existsTemplate()
<a
href=<<thisFoldingWikiListingMakeURL>>
target='_blank'
>
<$text
text=<<WikiName>>
/>
</a>
^^<span style='font-size:8pt;'>
(<$button
class='tc-btn-invisible'
>
Unload
<$action-websocketmessage
$type='unloadWiki'
wikiName=<<WikiName>>
/>
</$button>)
</span>^^
\end
\define doesntExistTemplate()
<$text
text=<<InnerWikiName>>
/>
\end
\define foldingTree(source:'[list[$:/state/ViewableWikis]search:title{$:/temp/wikisearch}] -RootWiki' sep:'/' exist:"<<existsTemplate>>" notexist:"<<doesntExistTemplate>>")
Wiki Search: <$edit-text tiddler='$:/temp/wikisearch' tag=input placeholder='type to search wikis'/>
<$vars
InputList=<<__source__>>
Sep=<<__sep__>>
PROXYPREFIX={{{ [[$:/ServerIP]get[proxyprefix]addsuffix[/]minlength[2]] }}}
>
<ul
class='folding-list'
>
<li>
[ext[Root Wiki|/]]
</li>
<$list
filter='[subfilter<InputList>splitbefore<Sep>removesuffix<Sep>][subfilter<InputList>splitbefore<Sep>!suffix<Sep>] +[sort[]] +[limit[1]]'
variable=WikiName
emptyMessage='No child wikis listed.'
>
<$set
name=WikiPrefix
value=''
>
<<thisFoldingWikiListingInnerList>>
</$set>
</$list>
</ul>
</$vars>
\end
! Folding Tree List
This was originally made to list the different wikis that I manage with Bob.
And I forgot that the core `tree` macro existed, although I needed some
features that the core macro doesn't have, like templating each entry.
!! Parameters
|!Name |!Description |!Default |
|!source |The input titles to use while making the tree. To get the same output as from the core macro use `[is[system]]` |`[list[$:/state/ViewableWikis]]` |
|!sep |The separator used to distinguish different levels of the tree. |`/` |
|!exist |A template to use when an item in the tree exists. |`<<existsTemplate>>` |
|!notexist |A template to use when an item in the tree doesn't exist (it is part of the path to another item) |`<<doesntExistTemplate>>` |
<<foldingTree>>