Tiddler Titles vs unique IDs

555 views
Skip to first unread message

Diego Mesa

unread,
May 21, 2018, 2:39:56 PM5/21/18
to TiddlyWiki
Hey all,

I can't seem to find an older long thread where this was discussed at length (google groups :L). Either way, it might be helpful to generate a newer thread which summarizes a couple main directions/opinions on this topic. 

I thought a good idea (by Tony I believe) is for a tiddler to have a uniqueID be its creation timestamp. On top of this, I thought it would be natural to use like this:

[[Tiddler Title]]  ----- save tiddler ----- remains in the tiddler text - behaves as usual.

[[#TiddlerTitle]] ----- save tiddler ----- the text in the tiddler body gets replaced with the tiddlers uniqueID. For readability, when that tiddler is opened again, [[#TiddlerTitle] is replaced by [[#WHATEVER_THE_CURRENT_TITLE_IS]]. In this fashion, it operates as an anchor (similar to excel) saying link to this tiddler, regardless of its current/future title. 

What other ideas/approaches were discussed that can be summarized and briefly discussed? 

Best,
Diego

TonyM

unread,
May 21, 2018, 7:36:34 PM5/21/18
to TiddlyWiki
Diego,

I quick start would be possible, if we stick to macros so that in Wiki Text we would use something like

<<idl #uniqueID>>

I am using idl to mean IDLink

We could have different parameters or macros that provide text of the title, link or transclusion.

With some smart macros we could have

<<idl UNIQUEID>>  Display the tiddler with the unique ID current title as text
<<idl [[UNIQUEID]]>> Display the tiddler with the unique ID current title as a link to that tiddler
<<idl {{UNIQUEID}}>> Transclude the tiddler with the unique ID text here

Then to support this have edit Toolbar items to insert one of the above with a unique id found using a current title search, a new excise tool that returns the macro reference to the Unique ID
 
I believe with the above complete we should be able to make use of the benefits of unique ID's without core or syntax changes.

What do you think, are there missing features?.

Regards
Tony

TonyM

unread,
May 21, 2018, 8:50:26 PM5/21/18
to TiddlyWiki
Diego,

My idea was to copy the created date to the unique ID field then ensure it is unique, Thus the created date remains true to its name and we can forget that the unique ID even came from a date. Though this is not an easy to read value. We could perhaps derive a unique ID in another format to save in the tiddler. Converting the Decimal date to Hexadecimal as an example. All it needs is a repeatable algorithm that generates a unique result and by seeding it with the created date we get close to that from the get go. 

Regards
Tony

Diego Mesa

unread,
May 21, 2018, 9:14:25 PM5/21/18
to TiddlyWiki
Hey Tony, 

Thanks for your reply! I wanted to avoid someone having to type the uniqueID at all. In my design above, you would just type the current title and if you include the # before it, its uniqueID is placed instead of the title. However, Im open to all ideas. How you envision <<idl as it relates to Mario's unilink?

Diego

TonyM

unread,
May 21, 2018, 9:52:31 PM5/21/18
to TiddlyWiki
Diego,

I need to review the idea in relation to uni-link but the idea would be to effectively to use the UniqueID field as an alias to the tiddler (whatever its title). Which if working well we would not need to use the above macro equivalents.

Then you simply refer to the alias of the uniqueID and it returns links etc.. to the current title.
 
Regards
Tony

TonyM

unread,
May 21, 2018, 10:21:39 PM5/21/18
to TiddlyWiki
Just adding more details to the design concept for feedback

We could create a new "New Tiddler" button that creates tiddlers with the unique ID, and have a toggle that makes that button appear on any tiddler which does not yet have a uniquID
The UniqueID can be at first = the created date, then we test to see if any other tiddler shares the same crated date (very unlikely) but if true increment it by 1 until it is unique (effectively adding milliseconds) then save the value as the uniqueID in that tiddler.

Not that it is likely but now the tiddler is free to have its created date changed, because the UniqueID is separate. If one somehow created a new tiddler with the original crated date, again very unlikely the increment process will ensure its new UniqueID is in fact unique.

There are many advantages to the above, the only disadvantage is you need to have a tiddler with the unique ID before you can link to it with the uniqueID, so that we may need a custom excise tool.

Regards
Tony

Reto

unread,
Jun 1, 2018, 2:51:42 AM6/1/18
to TiddlyWiki
Just my 2 cents on the topic since I am working with unique ids since a few years. I developed my own functions within TWC but maybe the concept and experience might be interesting.

What was my motivation to introduce unique ids? Mainly because I wanted to be able to change the title of tiddlers.

How do I generate the id? I use this timestamp format >"YYYY0MM0DD0hh0mm0ss". Whenever an id is generated it is checked whether the id already exists. If yes the nummer is simply inreased by one.

When is the id generated? I use custom buttons to create tiddlers which sets a field "unique_id" using a generate function.

How are tiddlers with unique ids displayed on other tiddlers / is linked to them? There's a macro with the parameter "unique id" which returns the title with underlying link to the tiddler. I mainly use lists, e.g. tiddlers filtered for certain tags, and in the output the macro is used to make it a readable and clickable entry. A bit clumsy is whenever I want to add a direct link. For this purpose there is a button that can be used in the target tiddler. This opens a popup with the complete syntax which may be copied and pasted.

TonyM

unread,
Jun 1, 2018, 7:02:52 PM6/1/18
to TiddlyWiki
Reto,

Thanks for sharing that, good to know using a date as the unique id is practical.

When I build my solution I will see if I and fill the gaps with the uni link plugin.

Regards
Yony

TonyM

unread,
Jun 2, 2018, 5:26:56 AM6/2/18
to TiddlyWiki
Reto,

Are you able to share the method you use to increment the date time. I belive milliseconds MMM can now be added to date time stamps.

Of course I will share back my solution that you may be able to use some features.

Regards
Tony

Reto

unread,
Jun 5, 2018, 7:12:26 AM6/5/18
to tiddl...@googlegroups.com
Nothing fancy here (I am not much of a JS programmer):

   function generateUniqueId(uniqueId) {
      /* Returns a unique number based on date and time */
      /* If the passed value is 0 then the function generates a new unique id */
      /* If the passed value is not 0 then the function checks if the value ist unique */
      var notUnique= 0;
      /* Generate the unique number */
      if(uniqueId == 0) {
         uniqueId = new Date().formatString(config.options.extendedBrainFormatUniqueId);
      }
      /* check if not already in use */
      do {
         if(checkUniqueId(uniqueId)) {
            uniqueId = parseInt(uniqueId) + 1;
            notUnique = 1;
         } else {
            //alert(uniqueId + " is unique");
            notUnique = 0;
         }
      } while(notUnique);
      return uniqueId;
   };

config.options.extendedBrainFormatUniqueId = "YYYY0MM0DD0hh0mm0ss";

TonyM

unread,
Jun 5, 2018, 9:18:05 PM6/5/18
to TiddlyWiki
Reto,

Thanks but I do not have enough knowledge to implement this in TW5, have you a finished solution I could use and modify?

Reto

unread,
Jun 6, 2018, 3:17:19 AM6/6/18
to TiddlyWiki
That is TWC code ... I didn't migrate this to TW5. As far as I know in TW5 modules may used for JavaScript:

https://tiddlywiki.com/#Modules

Have no experience with TW5. Sorry.

ChristianB

unread,
Mar 12, 2020, 10:30:21 PM3/12/20
to TiddlyWiki
Here is the same result ( ie creating a unique ID )  using wiki macro rather than use javascript

\define createUniqueID(field: "id")
<$wikify name="timestamp" text="""<$macrocall $name="now" format="YYYY0MM0DD0hh0mm0ssXXX" />""" output=text >
<$set name="fieldCount" filter="[search:$field$<timestamp>count[]]" >
<<timestamp>><<fieldCount>>
</$set>
</$wikify>
\end


Reply all
Reply to author
Forward
0 new messages