My first tool: buttons for generating a readable tiddler id and linking to it from other tiddlers

121 views
Skip to first unread message

Vytas

unread,
Apr 30, 2018, 6:30:07 PM4/30/18
to TiddlyWiki
Hi,

Motivated by the discussion (https://groups.google.com/forum/#!topic/tiddlywiki/Y1V7oyBLpSs) about the breakage of tiddler links, I have followed the ideas by Mark S., TonyM, Jeremy and others to create four tiddlers, which you will find attached to this post:

  1. "initiate-id-change" provides a button in ViewToolbar of a tiddler (consider a tiddler with title "First tiddler title" and creation time "20180430183239679"). This button will start a dialog to set the the value of the "id" field for a tiddler under consideration.
  2. "finalize-id-change" provides a modal dialog with a Confirm button which will set the "id" field of "First tiddler title" to "2018-04-30-First tiddler title-21:32:39-679ms". Now, let's say you have changed the title "First tiddler title" to "Actual tiddler title".
  3. "excise-title" provides a button in EditorToolbar (of "Some other tiddler") which will excise the selected tiddler title (e.g. "Actual tiddler title") into a temporary tiddler.
  4. "insert-linktoid" provides another button in EditorToolbar (of "Some other tiddler") which, by making use of the tiddler title stored in a temporary tiddler, will insert a macro <<linktoid "2018-04-30-First tiddler title-21:32:39-679ms">> in the edit-window of "Some other tiddler". In the view-window, the outcome of this macro will be the same as of [[Actual tiddler title]].
Advantages of this method:
  • You can change the title of the tiddler without breaking links to it, as long as you link via id which remain fixed.
  • While IDs are highly readable, their writability is provided by excision and buttons.
Known disadvantages:
  • The assigning of IDs is not completely automatic. For every tiddler you want to link to, you have to press two buttons to generate its ID (you can limit it to one button if you do not want the confirmation step).
  • I have not managed to reduce the production of a link from the selected title to one click of a button. So far, you have to click one button to excise the title and another button to produce the link.
  • The "linktoid" macro provides soft links, so they "are not detected by link-related filter operators such as backlinks, links, all and is".

In this post, for easier access, I will provide the body text of two of the four tiddlers. (I remind that these tiddlers require appropriate tags and fields, which are part of the attached .json files.) 

I would enjoy getting any feedback or ideas how to optimize/improve this tool. Anyway, I hope that it works not only for me :) 

Vytas 
  
----------------------------------------------

The body text of "finalize-id-change":

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


<$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">


You are about to change the 'id' field value of <$link to=<<currentTiddler>>><<currentTiddler>></$link> to:
<p>''<<id_value>>''.</p>
This can break existing links to <$link to=<<currentTiddler>>><<currentTiddler>></$link>.


<p>
<$button tooltip="Set id to this tiddler">
<$action-setfield $tiddler=<<currentTiddler>> id=<<id_value>>/>
<$action-sendmessage $message="tm-close-tiddler" $param="finalize-id-change"/
>
Confirm
</$button>
</
p>


</$set>


</
$wikify>
</$wikify>
</
$wikify>


The body text of "insert-linktoid":

\define linktoid(idvar)
<$list filter="[field:id[$idvar$]!has[draft.of]]"/>
\end


\define linktoid2(idvar)
<<linktoid "$idvar$">>
\end


<$set name="titlevar" tiddler="$:/temporary_tiddler_for_title_storage" field="text">
<$set name="idvar" tiddler=<<titlevar>> field="id">
<$action-sendmessage
 $message
="tm-edit-text-operation"
 $param
="replace-selection"
 text
=<<linktoid2 $(idvar)$>>
/>
<$action-deletetiddler $tiddler="$:/
temporary_tiddler_for_title_storage"/>
</$set>
</$set>
excise-title.json
initiate-id-change.json
finalize-id-change.json
insert-linktoid.json

TonyM

unread,
Apr 30, 2018, 8:09:35 PM4/30/18
to TiddlyWiki
Vytas,

I will look closer today, but I am impressed with your progress. In the a discussion thread we discussed it at a high level approach but you have taken this to implementation.

Can I ask are you using the uni-links plugin with this or not?

Regards
Tonyu

Vytas

unread,
May 1, 2018, 5:50:58 AM5/1/18
to tiddl...@googlegroups.com
Tony, thank you for taking a look at the tool! 

At the moment, I am not using the uni-link plugin. I have checked it: It is a very nice piece of work. However, I do not have much content in my TiddlyWiki, so I haven't had the need the links to display captions / subtitles instead of titles or use aliases so far. Moreover, in the uni-link approach, the role of the immutable id field is taken by the title field, whereas, in my tool, the title field provides tiddler description, which can be changed if it becomes unsuitable. The last part of the statement, however, is not always correct: You should NOT change the title if you use it somewhere as a parameter value (e.g. within the Action-sendmessage widget). My tool just provides a relatively easy method for producing links WITHOUT the necessity to use the title as parameter value.

One more thing I wanted to implement is the hyphenation of the IDs, that is to set id to "2018-04-30-First-tiddler-title-21:32:39-679ms" instead of "2018-04-30-First tiddler title-21:32:39-679ms".
Does anybody have an idea how to transform the value of some variable from "First tiddler title" to "First-tiddler-title"?

Also, as I have written above, I have not managed to have the excision made and a macro inserted with one click of a button. If I try to put the excision action and macro insertion action under one button, the click of this button excises the CURRENTLY selected title to a temporary tiddler and inserts a linktoid macro with an id, calculated from the PREVIOUSLY excised title. The result is as if the order of the two actions would be reversed. So, I have not found a way to get these actions implemented in the right order. Does anybody have an idea, whether/how this could be made?

Reply all
Reply to author
Forward
0 new messages