2015-01-18 18:39:00 +00:00
created: 20150117152607000
2024-03-10 10:41:09 +00:00
modified: 20240229155550000
2015-01-11 19:04:14 +00:00
tags: $:/tags/Macro
2018-04-24 21:08:20 +00:00
title: $:/editions/tw5.com/doc-macros
2024-03-10 10:41:09 +00:00
code-body: yes
2018-04-24 21:08:20 +00:00
type: text/vnd.tiddlywiki
2015-01-11 19:04:14 +00:00
2024-03-10 10:41:09 +00:00
\whitespace trim
\function .concat(1,2,3,4,5) [[$(1)$$(2)$$(3)$$(4)$$(5)$]substitute[]]
\function .word(_) [["]] [<_>] =[["]] +[join[]]
\procedure .def(_) <dfn class="doc-def"><<_>></dfn>
\procedure .em(_) <em class="doc-em"><<_>></em>
\procedure .strong(_) <strong class="doc-strong"><<_>></strong>
\procedure .place(_) <code class="doc-place"><<_>></code>
\procedure .preamble(_) <dl><dd class="doc-preamble"><<_>></dd></dl>
\procedure .tid(_) <code class="doc-tiddler"><<_>></code>
\procedure .tag(_) <code class="doc-tag"><<_>></code>
\procedure .field(_) <code class="doc-field"><<_>></code>
\procedure .value(_) <code class="doc-value"><<_>></code>
\procedure .op(_) <code class="doc-operator"><<_>></code>
\procedure .var(_) <code class="doc-var"><<_>></code>
\procedure .wid(_) <code class="doc-widget"><$macrocall $name=".concat" 1="$" 2=<<_>>/></code>
\procedure .attr(_) <code class="doc-attr"><<_>></code>
\procedure .param(_) <code class="doc-param"><<_>></code>
\procedure .tiddler-fields(tiddler)
<$tiddler tiddler=<<tiddler>>>
<div class="doc-tiddler-fields">
<h2>
<$link>
<span class="tc-tiddler-title-icon">{{||$:/core/ui/TiddlerIcon}}</span><$text text=<<currentTiddler>>/>
</$link>
</h2>
<table class="tc-view-field-table">
<tbody>
<$list filter="[all[current]fields[]sort[title]] -title" template="$:/core/ui/TiddlerFieldTemplate" variable="listItem"/>
</tbody>
</table>
</div>
</$tiddler>
\end
2015-02-24 16:41:16 +00:00
2024-03-10 10:41:09 +00:00
\function .mtitle(_) [<_>] Macro +[join[ ]]
\function .otitle(_) [<_>] Operator +[join[ ]]
\function .vtitle(_) [<_>] Variable +[join[ ]]
2015-01-18 18:39:00 +00:00
2024-03-10 10:41:09 +00:00
\procedure .link(_,to) <$link to=<<to>> ><<_>></$link>
\procedure .clink(_,to) <span class="doc-clink"><$link to=<<to>>><<_>></$link></span>
\procedure .dlink(_,to) <$link to=<<to>>><$macrocall $name=".def" _=<<_>>/></$link>
\procedure .dlink-ex(_,to) <a href=<<to>> class="tc-tiddlylink-external" target="_blank" rel="noopener noreferrer"><$macrocall $name=".def" _=<<_>>/></a>
\procedure .flink(to) <$macrocall $name=".link" _=`<<.field {{$(to)$!!caption}}>>` to=<<to>>/>
\procedure .mlink(_) <$link to={{{ [.mtitle<_>] }}}><$macrocall $name=".var" _=<<_>>/> </$link>
\procedure .mlink2(_,to) <$link to=<<to>>><$macrocall $name=".var" _=<<_>>/> </$link>
\procedure .olink(_) <$link to={{{ [.otitle<_>] }}}><$macrocall $name=".op" _=<<_>>/> </$link>
\procedure .olink2(_,to) <$link to={{{ [.otitle<to>] }}}><$macrocall $name=".op" _=<<_>>/> </$link>
\procedure .vlink(_) <$link to={{{ [.vtitle<_>] }}}><$macrocall $name=".var" _=<<_>>/> </$link>
\procedure .vlink2(_,to) <$link to=<<to>>><$macrocall $name=".var" _=<<_>>/></$link>
\procedure .wlink(to) <$link to=<<to>> > <$macrocall $name=".wid" _={{{ [<to>get[caption]] }}}> </$link>
\procedure .wlink2(_,to) <$link to=<<to>> ><<_>></$link>
2015-01-18 18:39:00 +00:00
2024-03-10 10:41:09 +00:00
\procedure .key(_) <span class="doc-key"><<_>></span>
\procedure .keys(_) <span class="doc-key"><<_>></span>
\procedure .tab(_) <span class="doc-tab"><$transclude $tiddler=<<_>> $field=caption ><<_>></$transclude></span>
\procedure .sidebar-tab(_) <$macrocall $name=".tab" _=`$:/core/ui/SideBar/$(_)$`/>
\procedure .more-tab(_) <$macrocall $name=".tab" _=`$:/core/ui/MoreSideBar/$(_)$`/>
\procedure .info-tab(_) <$macrocall $name=".tab" _=`$:/core/ui/TiddlerInfo/$(_)$`/>
\procedure .controlpanel-tab(_) <$macrocall $name=".tab" _=`$:/core/ui/ControlPanel/$(_)$`/>
\procedure .advancedsearch-tab(_) <$macrocall $name=".tab" _=`$:/core/ui/AdvancedSearch/$(_)$`/>
\procedure .toc-tab() <$macrocall $name=".tab" _="TableOfContents"/>
\procedure .example-tab(_) <span class="doc-tab"><<_>></span>
\procedure .doc-tabs()
2023-04-04 17:00:04 +00:00
<$macrocall $name="tabs"
2024-03-10 10:41:09 +00:00
tabsList="[tag<currentTiddler>description[tab]]"
default={{{ [tag<currentTiddler>first[]] }}}
explicitState={{{ [<currentTiddler>addprefix[$:/state/tab/]] }}}
class={{{ [[doc-tabs]] [<currentTiddler>encodeuricomponent[]escapecss[]addprefix[doc-tabs-]] +[join[ ]] }}} />
2023-04-04 17:00:04 +00:00
\end
2024-03-10 10:41:09 +00:00
\procedure .doc-tab-link(text, target, tooltip:"", class:"")
2023-04-04 17:00:04 +00:00
<!-- figure out where the addressed doc-tabs are -->
<$tiddler tiddler={{{ [<currentTiddler>search:text[.doc-tabs]] :else[<currentTiddler>tags[]search:text[.doc-tabs]first[]] :else[<currentTiddler>] }}} >
2024-03-10 10:41:09 +00:00
<$button class={{{ [[tc-btn-invisible tc-tiddlylink]] [<class>] +[join[ ]] }}}
set={{{ [<currentTiddler>addprefix[$:/state/tab/]] }}}
setTo=<<target>>
tooltip=<<tooltip>>>
<<text>>
2023-04-04 17:00:04 +00:00
<!-- if tiddler with tabs is open, scroll to tabs, otherwise open that tiddler (relevant from within tab subtiddlers) -->
<$list filter="[[$:/StoryList]contains<currentTiddler>]" variable="ignore" emptyMessage="<$action-navigate />">
<$action-sendmessage $message="tm-scroll" selector={{{ [<currentTiddler>encodeuricomponent[]addprefix[.doc-tabs-]] }}} />
</$list>
<$action-sendmessage $message="tm-scroll" selector={{{ [<currentTiddler>encodeuricomponent[]escapecss[]addprefix[.doc-tabs-]] }}} />
</$button>
</$tiddler>
\end
2024-03-10 10:41:09 +00:00
\procedure .widget-attr-link(text, target)
2023-04-04 17:00:04 +00:00
<$macrocall $name=".doc-tab-link"
2024-03-10 10:41:09 +00:00
text={{{ [[<code class="doc-attr">]] [<text>] [[</code>]] +[join[]] }}}
class="doc-tab-link"
target=<<target>>
tooltip={{{ [[Show more information about the ']] [<text>] [[' attribute]] +[join[]] }}} />
2023-04-04 17:00:04 +00:00
\end
2024-03-10 10:41:09 +00:00
\procedure .button(_) <span class="doc-button"><$transclude $tiddler=`$:/core/ui/Buttons/$(_)$` $field="caption" ><<_>></$transclude></span>
2015-01-18 18:39:00 +00:00
2024-03-10 10:41:09 +00:00
\procedure .icon(_) <span class="doc-icon"><$transclude $tiddler=<<_>>/></span>
2019-10-13 14:35:36 +00:00
2024-03-10 10:41:09 +00:00
\procedure .infoBox(text:"", title, icon:"$:/core/images/info-button", class, iconSize:"1.4rem")
\function _f.tipClass() [[doc-icon-block]] [<class>!is[blank]then<class>] +[join[ ]]
<div class=<<_f.tipClass>>>
<%if [<title>!is[blank]] %><div>''<<title>>''</div><% endif %>
<div class="doc-block-icon"><$transclude $tiddler=<<icon>> size=<<iconSize>>/></div>
<<text>>
</div>
\end
2015-02-26 16:32:00 +00:00
2024-03-10 10:41:09 +00:00
\procedure .note(_:"", title:"Note", icon:"$:/core/images/info-button", class:"doc-note", iconSize:"22pt")
<$macrocall $name=".infoBox" text=<<_>> title=<<title>> icon=<<icon>> class=<<class>> iconSize=<<iconSize>>/>
\end
2015-02-24 16:41:16 +00:00
2024-03-10 10:41:09 +00:00
\procedure .tip(_:"", title:"Tip" , icon:"$:/core/images/tip", class:"doc-tip", iconSize:"22pt")
<$macrocall $name=".infoBox" text=<<_>> title=<<title>> icon=<<icon>> class=<<class>> iconSize=<<iconSize>>/>
\end
\procedure .warning(_:"", title:"Warning", icon:"$:/core/images/warning", class:"doc-warning", iconSize:"22pt")
<$macrocall $name=".infoBox" text=<<_>> title=<<title>> icon=<<icon>> class=<<class>> iconSize=<<iconSize>>/>
\end
\procedure .state-prefix() $:/state/editions/tw5.com/
\procedure .lorem()
2015-02-24 16:41:16 +00:00
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end
2024-03-10 10:41:09 +00:00
\procedure .toc-lorem()
2015-02-24 16:41:16 +00:00
This is an example tiddler. See [[Table-of-Contents Macros (Examples)]].
<<.lorem>>
\end
2024-03-10 10:41:09 +00:00
\procedure .example(n,eg,egvar)
<$let eg={{{ [<egvar>!is[blank]getvariable[]] :else[<eg>] }}}>
2015-02-24 16:41:16 +00:00
<div class="doc-example">
2024-03-10 10:41:09 +00:00
<$macrocall $name="copy-to-clipboard-above-right" src=<<eg>>/>
<$codeblock code=<<eg>>/>
<$list filter=`[title<.state-prefix>addsuffix{!!title}addsuffix[/]addsuffix[$(n)$]]` variable=".state">
<$reveal state=<<.state>> type="nomatch" text="show">
<dl>
<dd><$button set=<<.state>> setTo="show">Try it</$button></dd>
</dl>
</$reveal>
<$reveal state=<<.state>> type="match" text="show">
<dl>
<dd><$button set=<<.state>> setTo="">Hide</$button></dd>
</dl>
<blockquote class="doc-example-result">
<<eg>>
</blockquote>
</$reveal>
</$list>
</div>
</$let>
2018-04-24 21:08:20 +00:00
\end
2024-03-10 10:41:09 +00:00
\procedure .bad-example(eg)
2022-01-09 14:30:22 +00:00
<table class="doc-bad-example">
2024-03-10 10:41:09 +00:00
<tbody>
<tr class="evenRow">
<td>
<span class="tc-small-gap-right" style="font-size:1.5em;">⚠</span>
Warning:<br> Don't do it this way!
</td>
<td>
<$transclude $variable="eg" $mode="block"/>
</td>
</tr>
</tbody>
2022-01-09 14:30:22 +00:00
</table>
\end
2024-03-10 10:41:09 +00:00
\procedure .link-badge(text,link,colour)
<a href=<<link>> class="doc-link-badge" style.background-color=<<colour>> target="_blank" rel="noopener noreferrer">
<$text text=<<text>>/>
</a>
2021-12-06 16:59:07 +00:00
\end
2024-03-10 10:41:09 +00:00
<!-- TODO use $:/palette colour settings -->
\procedure .link-badge-added(link,colour:#ffe246) <$macrocall $name=".link-badge" text="added" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-addendum(link,colour:#fcc84a) <$macrocall $name=".link-badge" text="addendum" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-extended(link,colour:#f9a344) <$macrocall $name=".link-badge" text="extended" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-fixed(link,colour:#ffa86d) <$macrocall $name=".link-badge" text="fixed" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-here(link,colour:#d88e63) <$macrocall $name=".link-badge" text="here" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-hide(link,colour:#9d959f) <$macrocall $name=".link-badge" text="hide" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-improved(link,colour:#7593c7) <$macrocall $name=".link-badge" text="improved" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-modified(link,colour:#7f99c9) <$macrocall $name=".link-badge" text="modified" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-removed(link,colour:#a9aabc) <$macrocall $name=".link-badge" text="removed" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-renamed(link,colour:#b4b995) <$macrocall $name=".link-badge" text="renamed" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-updated(link,colour:#91ba66) <$macrocall $name=".link-badge" text="updated" link=<<link>> colour=<<colour>>/>
\procedure .banner-credits(credit,url)
<img src=<<url>> width="140" style="float:left;margin-right:0.5em;"/>
<<credit>>
<div style="clear:both;"/>
2021-12-09 11:56:31 +00:00
\end
2024-03-10 10:41:09 +00:00
\procedure .contributors(usernames)
2022-07-14 12:49:23 +00:00
<ol class="doc-github-contributors">
2024-03-10 10:41:09 +00:00
<$list filter="[enlist<usernames>sort[]]" variable="username">
<li>
<a href={{{ [[https://github.com/]addsuffix<username>] }}} class="tc-tiddlylink-external" target="_blank" rel="noopener noreferrer">
<img src={{{ [[https://github.com/]addsuffix<username>addsuffix[.png?size=64]] }}} width="64" height="64"/>
<span class="doc-github-contributor-username">
@<$text text=<<username>>/>
</span>
</a>
</li>
</$list>
2022-07-14 12:49:23 +00:00
</ol>
\end