mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-10 09:20:26 +00:00
213 lines
7.9 KiB
Plaintext
213 lines
7.9 KiB
Plaintext
title: $:/core/macros/toc
|
|
tags: $:/tags/Macro
|
|
|
|
\whitespace trim
|
|
|
|
<!-- add Custom Icons with v5.2.4 -->
|
|
\procedure toc-open-icon() $:/core/images/down-arrow
|
|
\procedure toc-closed-icon() $:/core/images/right-arrow
|
|
|
|
<!-- v5.3.4 rewrite -->
|
|
\function tf.makeTocState() [[$:/state/toc]addsuffix<path>addsuffix[/]addsuffix<currentTiddler>]
|
|
|
|
<!-- only define -> procedure -->
|
|
\procedure toc-caption()
|
|
<span class="tc-toc-caption tc-tiny-gap-left">
|
|
<$set name="tv-wikilinks" value="no">
|
|
<$transclude field="caption">
|
|
<$view field="title"/>
|
|
</$transclude>
|
|
</$set>
|
|
</span>
|
|
\end
|
|
|
|
<!-- v5.3.4 rewrite -->
|
|
\function tf.newPath() [<path>addsuffix[/]addsuffix<tag>]
|
|
|
|
\procedure toc-body(tag,sort:"",itemClassFilter,exclude,path)
|
|
<ol class="tc-toc">
|
|
<$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`>
|
|
<$let item=<<currentTiddler>> path=<<tf.newPath>> >
|
|
<$set name="excluded" filter="[subfilter<exclude>] [<tag>]">
|
|
<li class=<<tf.toc-getItemClass>>>
|
|
<% if [all[current]toc-link[no]] %>
|
|
<<toc-caption>>
|
|
<% else %>
|
|
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}><<toc-caption>></$link>
|
|
<% endif %>
|
|
<$macrocall $name="toc-body" tag=<<item>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>>/>
|
|
</li>
|
|
</$set>
|
|
</$let>
|
|
</$list>
|
|
</ol>
|
|
\end
|
|
|
|
\procedure toc(tag,sort:"",itemClassFilter:"", exclude)
|
|
<$macrocall $name="toc-body" tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<exclude>>/>
|
|
\end
|
|
|
|
\procedure toc-item(isUnlinked:"")
|
|
<$reveal type="nomatch" stateTitle=<<toc-state>> text="open">
|
|
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep">
|
|
<$transclude tiddler=<<toc-closed-icon>> />
|
|
<% if [<isUnlinked>match[yes]] %>
|
|
<<toc-caption>>
|
|
<% endif %>
|
|
</$button>
|
|
</$reveal>
|
|
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
|
<$button setTitle=<<toc-state>> setTo="close" class="tc-btn-invisible tc-popup-keep">
|
|
<$transclude tiddler=<<toc-open-icon>> />
|
|
<% if [<isUnlinked>match[yes]] %>
|
|
<<toc-caption>>
|
|
<% endif %>
|
|
</$button>
|
|
</$reveal>
|
|
\end
|
|
|
|
\procedure toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
|
<$qualify name="toc-state" title=<<tf.makeTocState>> >
|
|
<li class=<<tf.toc-getItemClass>>>
|
|
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
|
|
<<toc-item>>
|
|
<<toc-caption>>
|
|
</$link>
|
|
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
|
<$macrocall $name="toc-expandable" tag=<<currentTiddler>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<exclude>> path=<<path>>/>
|
|
</$reveal>
|
|
</li>
|
|
</$qualify>
|
|
\end
|
|
|
|
\procedure toc-unlinked-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
|
<!-- helper function -->
|
|
<$qualify name="toc-state" title=<<tf.makeTocState>>>
|
|
<li class=<<tf.toc-getItemClass>>>
|
|
<<toc-item isUnlinked:"yes">>
|
|
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
|
<$macrocall $name="toc-expandable" tag=<<currentTiddler>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<exclude>> path=<<path>>/>
|
|
</$reveal>
|
|
</li>
|
|
</$qualify>
|
|
\end
|
|
|
|
\procedure toc-expandable-empty-message()
|
|
<$macrocall $name="toc-linked-expandable-body" tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>>/>
|
|
\end
|
|
|
|
\procedure toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path)
|
|
<$let path=<<tf.newPath>>>
|
|
<$set name="excluded" filter="[subfilter<exclude>] [<tag>]">
|
|
<ol class="tc-toc toc-expandable">
|
|
<$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`>
|
|
<$list filter="[all[current]toc-link[no]]" emptyMessage=<<toc-expandable-empty-message>> >
|
|
<$macrocall $name="toc-unlinked-expandable-body" tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>> />
|
|
</$list>
|
|
</$list>
|
|
</ol>
|
|
</$set>
|
|
</$let>
|
|
\end
|
|
|
|
\procedure toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
|
<$qualify name="toc-state" title=<<tf.makeTocState>>>
|
|
<li class=<<tf.toc-getItemClass>>>
|
|
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
|
|
<$list filter=`[all[current]tagging[]$(sort)$] -[subfilter<exclude>] +[limit[1]]` variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
|
|
<<toc-item>>
|
|
</$list>
|
|
<<toc-caption>>
|
|
</$link>
|
|
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
|
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<exclude>> path=<<path>>/>
|
|
</$reveal>
|
|
</li>
|
|
</$qualify>
|
|
\end
|
|
|
|
<!-- As of v5.3.4 the following function is only used by "Tabbed" tocs -->
|
|
\function tf.toc-getItemClass() [<selectedTiddler>get[text]match<currentTiddler>then[toc-item-selected]else[toc-item]]
|
|
|
|
\procedure toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
|
<$qualify name="toc-state" title=<<tf.makeTocState>> >
|
|
<li class=<<tf.toc-getItemClass>>>
|
|
<$list filter=`[all[current]tagging[]$(sort)$] -[subfilter<exclude>] +[limit[1]]`
|
|
variable="ignore"
|
|
emptyMessage="""<$button class="tc-btn-invisible">{{$:/core/images/blank}}</$button><span class="toc-item-muted"><<toc-caption>></span>"""
|
|
>
|
|
<<toc-item isUnlinked:"yes">>
|
|
</$list>
|
|
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
|
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<exclude>> path=<<path>>/>
|
|
</$reveal>
|
|
</li>
|
|
</$qualify>
|
|
\end
|
|
|
|
\procedure toc-selective-expandable-empty-message()
|
|
<$macrocall $name="toc-linked-selective-expandable-body" tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>>/>
|
|
\end
|
|
|
|
\procedure toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path)
|
|
<$let tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> path=<<tf.newPath>>>
|
|
<$set name="excluded" filter="[subfilter<exclude>] [<tag>]">
|
|
<ol class="tc-toc toc-selective-expandable">
|
|
<$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`>
|
|
<$list filter="[all[current]toc-link[no]]" variable="ignore" emptyMessage=<<toc-selective-expandable-empty-message>> >
|
|
<$macrocall
|
|
$name="toc-unlinked-selective-expandable-body"
|
|
tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>>
|
|
/>
|
|
</$list>
|
|
</$list>
|
|
</ol>
|
|
</$set>
|
|
</$let>
|
|
\end
|
|
|
|
\procedure toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude)
|
|
<$tiddler tiddler={{{ [<selectedTiddler>get[text]] }}}>
|
|
<div class="tc-tabbed-table-of-contents">
|
|
<$linkcatcher to=<<selectedTiddler>>>
|
|
<div class="tc-table-of-contents">
|
|
<!-- v5.3.4 itemClassFilter has been replaced by tf.toc-getItemClass -->
|
|
<$macrocall
|
|
$name="toc-selective-expandable"
|
|
tag=<<tag>>
|
|
sort=<<sort>>
|
|
itemClassFilter="[all[current]] -[<selectedTiddler>get[text]]"
|
|
exclude=<<exclude>>
|
|
/>
|
|
</div>
|
|
</$linkcatcher>
|
|
<div class="tc-tabbed-table-of-contents-content">
|
|
<$reveal stateTitle=<<selectedTiddler>> type="nomatch" text="">
|
|
<$transclude mode="block" tiddler=<<template>>>
|
|
<h1><<toc-caption>></h1>
|
|
<$transclude mode="block">$missingText$</$transclude>
|
|
</$transclude>
|
|
</$reveal>
|
|
<$reveal stateTitle=<<selectedTiddler>> type="match" text="">
|
|
<<unselectedText>>
|
|
</$reveal>
|
|
</div>
|
|
</div>
|
|
</$tiddler>
|
|
\end
|
|
|
|
\procedure toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude)
|
|
<$linkcatcher to=<<selectedTiddler>>>
|
|
<$macrocall
|
|
$name="toc-tabbed-external-nav"
|
|
tag=<<tag>>
|
|
sort=<<sort>>
|
|
selectedTiddler=<<selectedTiddler>>
|
|
unselectedText=<<unselectedText>>
|
|
missingText=<<missingText>>
|
|
template=<<template>>
|
|
exclude=<<exclude>>
|
|
/>
|
|
</$linkcatcher>
|
|
\end
|