Hello,

After a long pause from TiddlyWiki, I came back to simplify my tool 
(https://groups.google.com/d/msg/tiddlywiki/DiowJLeoJbw/igirhRHYAQAJ) of 
creating solid links to tiddlers with the help of a "link button" in the 
View Toolbar. The tool functions through the id field and it is really easy 
to use.

a) If you want to create a link to the tiddler named *Present tiddler title* 
(created 
*20190208203055849*) AND having no "id" field value, just click the "link 
button" in the View Toolbar of this tiddler. This will set the "id field" 
to "*2019-02-08-Present tiddler title-22:30:55-849ms*" AND will copy *<<linkto 
"2019-02-08-Present tiddler title-22:30:55-849ms">>* to clipboard. Now, you 
can paste this macro into some other tiddler to get a a direct link to *Present 
tiddler title*. If the id value would appear to be not unique (e.g., if you 
clone a tiddler), the macro will provide the link to the oldest tiddler 
which has the above mentioned id.   

b) If "Present tiddler title" already HAS an id field value (assume it is 
equal to *any_preferably_unique_id_591*), clicking the "link button" in the 
View Toolbar will copy *<<linkto "any_preferably_unique_id_591">> *to 
clipboard.


To try out the tool, create a tiddler (tagged with *$:/tags/Macro* and 
*$:/tags/ViewToolbar*) with the following body text:


\define linkto(idvar1) 
<$list filter="[field:id[$idvar1$]!has[draft.of]limit[1]]"/>
\end

\define linkto2(idvar)
<<linkto "$idvar$">>
\end

\define id_value() $(cr_date)$-$(curr_title)$-$(cr_time)$-$(cr_msec)$ms

\define link_via_id(check_id, copy_id, if_no_id)
<$list filter="$check_id$ +[limit[1]]" name=act emptyMessage=<<$if_no_id$>>>
<<$copy_id$>>
</$list>
\end

\define copy_id() 
<$action-sendmessage $message="tm-copy-to-clipboard" $param=<<linkto2 
"$(idvar)$">>/>
\end

\define if_no_id() 
<$action-setfield $tiddler=<<currentTiddler>> id=<<id_value>>/>
<$action-sendmessage $message="tm-copy-to-clipboard" $param=<<linkto2 
"$(id_value)$">>/>
\end


<$button tooltip="Set id (if no id field exists) & copy a link" aria-label="Set 
id (if no id field exists) & copy a link" class=<<tv-config-toolbar-class>>>
<$wikify name=cr_date text='<$view  tiddler=<<currentTiddler>> 
field="created" format="date" template="YYYY-0MM-0DD"/>'>
<$wikify name=cr_time text='<$view  tiddler=<<currentTiddler>> 
field="created" format="date" template="0hh:0mm:0ss"/>'>
<$wikify name=cr_msec text='<$view  tiddler=<<currentTiddler>> 
field="created" format="date" template="XXX"/>'>
<$set name="curr_title" tiddler=<<currentTiddler>> field="title">
<$set name="idvar" tiddler=<<currentTiddler>> field="id"> 
<<link_via_id "[title[$(currentTiddler)$]has[id]]" copy_id if_no_id>>
</$set>
</$set>
</$wikify>
</$wikify>
</$wikify>
{{$:/core/images/link}} 
</$button>

You can provide this tiddler with the following fields:
caption: *{{$:/core/images/link}} (Set id) & copy a link*
description: *Set the id field (if it does not exist) of this tiddler and 
copy a link to clipboard*

By the way, I don't know how to make the caption show up, as long as the 
"link button" is put under *More actions* in the View Toolbar..  

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f1756e95-bbea-4679-90c7-27401daad53b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to