Path and Title Shortener

How to have a path/title shortener in TiddlyWiki? This is similar to URL shortener (e.g. Shortened URL (shorturl.at))

Usecase:
There are templates developed by community members where they are distributed in Plugins where titles are very long. If there is a path/title shortener we use can use them easier.

Examples 1

Instead of : {{myTiddler || $:/plugins/this-publisher/that-plugin/templates/pretty}}

user can use just: {{myTiddler || su.pretty }}

here su is just a suggested prefix like https://shorturl. when using shortener url.

Examples 2

Instead of : <$list filter="[tag[myTags]]" template="$:/plugins/this-publisher/that-plugin/templates/pretty" />

user can use just <$list filter="[tag[myTags]]" template="su.pretty" />

here su is just a suggested prefix like https://shorturl. when using shortener url.

Remarks

  • It is known that one can create a new tiddler (e.g. pretty) with short title and put {{$:/plugins/this-publisher/that-plugin/templates/pretty}} as text . Then use renamed/aliases template like {{myTiddler || pretty }}
    • This is not good because of maintainability and the manual work
  • It is known that plugin developers can include template like pretty without namespace.
    • This is not recommended and will cause if several plugins share the same name as pretty
  • This may be solved using alises, so a tiddler with a very long title can have aliases. But this is not supported by TiddlyWiki yet.

Here’s some previous discussion of this idea, in case it inspires any new ideas! I thought @pmario took an interesting approach in post #16 and #17 in particular; I’m not sure whether he developed it any further.

1 Like

I think #17 was the final thought, but I did not develop anything. I did have a short look again, if it can be resolved using wikitext. It may be, but it’s complex. A new operator expand eg: [<shortTitle>expand[configTiddler]] should do the trick.

1 Like

You might want to investigate some previous work by @maurycy based on discussions in #5331.

1 Like

I suppose it depends on why you want the shorter links

  • To give you shortlinks to share but not readable like bit.ly etc
  • To take a long title and reduce it to a shorter readable and meaningful link

I have made a solution that works surprisingly well, create a second tiddler with the short title that masquerades as its original tiddler.

  • Following the short link opens what looks like the full tiddler.
  • With relink in place you can rename either title but it’s wise not to let published short names renamed because “the link is out there” and should remain

I can understand the desire. IMO there are 2 things we need to know:

A)
It has to be very clear: Title-shortening trades compatibility for convenience.

The reason, why plugins and the TW $:/core have a somewhat “bulky” naming scheme $:/plugins/<publisher>/<plugin-name>/<tiddler/title> is to avoid naming problems.

The core is “bulky” so users can use “simple” naming, without the “fear” to cause naming problems with the $:/core and 3rd-party plugins.

B)
It adds a performance overhead

In your “Example 1” both transclusion strings are valid. So there is and never will be an indicator, that su.pretty is a shortened tiddler title.

Title detection will look like this: (simplified)

  1. Some core function needs to test if the template tiddler exists
  2. If it exists → show it → Done
    3.0 If it does not exist atm it fails silently → Done
  3. Now it needs to look up the template and create the “long title”
  4. With the long title goto 2.

So instead of 3 steps worst case and 2 steps best case – It now has: 6 steps worse case and 5 steps best case. – That’s a significant difference even with highly simplified “steps”.

So the “syntax” needs to be much more “specific”, so the $:/core does know early, that it gets a “shortend” title. So we can dirctly start at step 3) for a “short title”

IMO the only manageable way to go is, that the TW parser can already “lengthen” the title. Since the parse-tree is cached, the “new code” would only need to be “executed” once.

If the shortening is done at render-time where will be a lot of different widgets involved. So imo it would be a huge change.

Just some brainstorming

@Mohammad and @pmario it is my belief that this question is effectively solved already, and at most could be tweaked to be even more functional.

How?

Thus either with a click or using another mechanism we create the tiddler su.pretty and that contains {{||$:/plugins/this-publisher/that-plugin/templates/pretty}}.

Using it;

Thus transcluding {{myTiddler || su.pretty }} returns the content of the long title tiddler.

  • using my masquerade solution opening su.pretty or using a link for example https://tiddlywiki.com/su.pretty will open the tiddler but it will “look like” $:/plugins/this-publisher/that-plugin/templates/pretty
  • A mechanism to ensure the content of su.pretty to be updated if the long title changes but lock the short title so it cant be renamed would be helpful.
    • because if one publishes the “short link” https://tiddlywiki.com/su.pretty on the internet, in emails etc… you want it to remain valid.
    • An alternative is to instead publish a link containing a search mechanism

Html has a range of redirect methods, we may be able to incorporate these into the way tiddlywiki works

  • PHP Redirects should work even to different tiddler addresses in tiddlywiki.

The code does not work as requested in the OP. But if su.pretty contains this transclusion: {{||$:/plugins/this-publisher/that-plugin/templates/pretty}} – It does work as expected by the OP. eg:

  • Create a tiddler: x with text: {{||$:/core/ui/TagTemplate}}
  • Create a new tiddler: test with text: {{aaaa||x}}

It creates a tag-pill

Corrected in my above post, thanks @pmario

However there are choices to be made here, do you want to use the tags etc… on the pretty tiddler or the original?