Built-in URL shortener

I have a feature idea and I have no idea where it sits along the continuum between “What a ridiculous idea; we would never consider that!” and “So many people already suggested this that it’s made it into the core; how did you miss it?”

I would love to have a URL shortener built in. URLs like

https://tiddlywiki.com/#HelloThere:HelloThere%20GettingStarted%20Community

are not horrible, but they’re also not wonderful. And they quickly get worse as we open up additional tiddlers, especially if we add special characters. This is already pretty terrible:

https://tiddlywiki.com/#%24%3A%2FDefaultTiddlers:%24%3A%2FDefaultTiddlers%20%24%3A%2FControlPanel%20HelloThere%20GettingStarted%20Community

But something like one of these would be much cleaner:

https://tiddlywiki.com/#/view/1
https://tiddlywiki.com/?/view/42
https://tiddlywiki.com/-/view/important

For the size wikis I maintain, there would be no reason to use the auto-generated alphanumeric ones like https://tiddlywiki.com/#/view/3aG2jo; sequential integers – and possibly aliases such as important – would be plenty.

To be clear, I’m only considering generating these based on a user action, the same way it happens with permaview. In fact, this feature could build upon the permaview technique. It’s easy enough to imagine storing these inside a single tiddler or in multiple system tiddlers. They really are simply an association between a short id (1, 42, important) and a list of tiddler titles. I don’t have a clue what would be involved in doing the actual work of loading the tiddlers, but it should be easy enough to parse the URL to create these.

So, is this something that’s been done? Has it been considered and rejected? Is it simply ridiculous?

Even if I had the skills, I would not be ready to start implementing this, unless it turns out that it’s trivial (like I found out extending the ViewTemplate actually is.) If it existed, I would happily use it, so if it’s not ridiculous, it’s something I may try one day.

But I’m mostly interested in finding out if this sounds like a good idea.

1 Like

In some ways I have already done this by simply using the permalink to a tiddler mywiki.com in which is the long link you can click on or in some cases an iframe, sure it does not automatically follow the long address but this is actually I nice feature because you can give more info and allow the user to confirm they want to visit the long address.

  • You could use static html tiddlers to present each long link
  • You could use a single shorturl to get to the wiki and provide the tiddler after that
    • Eg short.url/sdfg/#tiddlername
  • If you want to shorten the tiddlername using obscure coding you can create tiddlers with short names but use an alt title to display the easy to read title in tiddlywiki.
  • I think Unicode can be used in many links now and that may provide shortening opportunities eg; mywiki.com/🔗/#sger - untested.

Considering your suggestion I think we would be best publishing a static html or other “file” with each address and think we can modify the template such that it includes a html redirect after N seconds.

  • Although if you have an internet facing node server this “static template” can be done automatically.

I also think that TiddlyWiki needs more friendly urls and more permanent permalinks. Some time ago, a discussion about permalinks was shared here with strategies for them (you should check the forum search for “permalink”), but I have not tested them yet. For the moment, we’re using NanoID to produce unique permalinks in our wikis with TiddlyWikiPharo, which is an external tool. But when I have more time, I plan to make that search myself to get more permanent permalink, share my explorations and maybe see how can we create alias for permaviews.

So, I think that you’re not alone. Stay tuned, I will be sharing my slow advances as the need arises again.

I think I’m talking about something slightly different from what your suggestions imply. I don’t need or want a full-fledged URL shortener. Those exist and I could use them for the same job. What I would like is simply built into my wiki; if you hit a URL with a particular (and simple) format, it will look up somewhere what tiddlers it should open on load. We could easily imagine configuration like:

{
  "1": "HelloThere GettingStarted Community",
  "42": "$:/DefaultTiddlers  $:/ControlPanel HelloThere GettingStarted Community",
  "important": "[[First Tiddler]] [[Second Tiddler]] [[And one more]]"
}

So I’m not looking to redirect to the base url of my wiki, only to the list of tiddlers to open initially. My current project is a medium-to-large software documentation wiki, and I would love it if users could share simple-looking permalinks to various collections of tiddlers. "Hey, you want to do XYZ with the system? These parts should help, https://mywiki.example.com/#/73, or https://mywiki.example.com/#/doing-xyz, and have those open the dozen relevant tiddlers.

There’s a good chance that I wouldn’t be able to use this on my current project, since, while I’m editing with the Node.js version, I’m seriously considering serving it as a static HTML file version, and then users wouldn’t be able to modify anything, even to add a nice url alias. And even if I don’t, end users will see only some non-editable format. But for other projects, this makes a great deal of sense to me.

BTW, your mywiki.com link, or one of (how many?) redirects got caught by something in my stack, thinking it involved a security vunerability. I haven’t bothered chasing it down.

Ok, So you are not so much after a URL shortener but a short cut to open a set of tiddlers in your wiki ?

  • The default tiddlers are somewhat like this, and they can also use filters.
    • I can build a button for you to provide a tiddler/field reference that opens the tiddlers listed at the tiddler/field reference if you want?
    • Using the data tiddler method is a little more complex, but can be done
  • If you have an open all option on a tag pill you can gather the titles to open simply by tagging them eg; the “important” tiddler/field reference, tagging [[First Tiddler]] [[Second Tiddler]] [[And one more]]
    *Ask if you want one

I can speak from a technical point of view here. I agree, a mechanism to customize the URL would be pretty nice.

Tiddlers are key/value stores. They are indexed by the title field which is why everything we do in TiddlyWiki refers to the title the only way a different identifier would work is to have an alternative mechanism.

As is the easiest and error proof way is to refer to the title. But there are alternatives for example you can use a filter in the URL which mean you could use a custom field or even a tag: wiki.html#:[tag[foobar]] (note the : colon) example or by any arbitrary filed #:[field:foo[bar]] (find tiddler with the foo field equal to bar) in fact unknown filters operators assume field name #:[caption[ShortID]] for tiddler with a caption of ShortID. —I just learned that there is a shorter field syntax: #:[{foo!!bar}]

Another enhancement to that could be making a tiddler specific for curating or as a landing page. I tend to make a tiddler that corresponds to my tags so I can provide a summary of the tagged tiddlers and I can also permalink to one tiddler to start with. example

Then you could also make a redirect script that knows how to convert a code to a permalink if you happen to be serving the wiki via a web server. I have a custom Apache .htaccess for this.

And lastly it is possible to add a plugin which taps into the boot system and can convert URL fragments from some ID to tiddlers fro the Story River. I think that is out of scope for this reply.

1 Like

Yes, I found How to customize permalinks? and https://groups.google.com/g/tiddlywiki/c/QOzs3CVtosU/m/XpqE0X_QBQAJ?pli=1. I’m surprised neither of them were suggested alternatives for my new topic.

So, I think that you’re not alone. Stay tuned, I will be sharing my slow advances as the need arises again.

Great. I look forward to seeing them.


I just had an idea for an interesting alternative: Using one of the free shorteners as something of a database. Pass the full url to one of their APIs, get back the shortened version, then use their short tag internally. That is send https://tiddlywiki.com/#%24%3A%2FDefaultTiddlers:%24%3A%2FDefaultTiddlers%20%24%3A%2FControlPanel%20HelloThere%20GettingStarted%20Community to the API at, say, http://bit.ly to get something like http://bit.ly/3XGyl9j, then share the url https://tiddlywiki.com/#/3XGyl9j with the user. If someone visits with that url, simply reverse the process. I don’t know if any of the public shorteners have terms that would allow that usage, but it’s certainly a cheap way to handle this.

Yes, although I would expect the shortcut to be a url that my wiki understands.

Yes, and I should have thought of that. It gives a place to investigate the existing mechanism.

I’m not particularly looking for something I can do personally. I’m much more thinking about users of my (otherwise read-only) wiki sharing collections of open tiddlers in an easy-to-say-out-loud fashion.

Thanks. I’m not to that point yet. Just dreaming.

Lots of good ideas here. And I’m afraid I opened (reopened) a can of worms.

From my perspective, the requirement is probably simpler than others have discussed. I would love to have a technique to alias permaviews in a way that is easy to remember, read aloud, share in chats, etc.

1 Like

Maybe use a plugin to compress the hash part of url into unicode (which is shorter) and unzip it when come back?

A plugin that hijack the navigation behavior may be able to do this.

Sounds like something I should add to my endless list of cool plugins I could make.

2 Likes

:slight_smile:

Is this number 4951 or 4952?

That has the wonderful advantage that nothing would have to be stored in the wiki (or anywhere!)

It wouldn’t really work for my use case, where I really want to be able to tell someone (who knows the documentation a bit) in a phone call, “Just try view seventeen” and they’ll know to to to https://mywiki.example.com/#/17 or some such. But it has some real potential.

A URL hash is a one-way-ticket. If you want to ZIP something you’ll probably create a longer URL as the original one. A ZIP file has some overhead and needs to be base64 and URL encoded to make sense. So IMO not a real alternative

IMO something like that would make sense, but needs to be implemented and it needs to store the configuration within the wiki :confused:

Can you give this a try? It’s a super rudimentary plugin which allows you to:

  • Define views
  • Define a name for the view
  • Define list of tiddlers for the view (as a filter)
  • If you then navigate to this view’s permalink (which is #<view name>) it will close all tiddlers and open the ones defined for that view

It’s not the prettiest, and doesn’t circumvent normal TW hash-opening mechanism, instead it runs after, closes all tiddlers and opens the relevant ones.

I guess now I’ll need to develop it into a real thing.

(Attachment removed – I just went ahead and published it as an actual plugin)


Some screenshots:

Control panel:

Editing a view:

State after opening with hash #1:

2 Likes

I will, but probably tomorrow, as I’m chasing down some other issues today. Thank you for your effort here. I was just looking for discussion and less than a day later there’s an implementation. Very cool!

Yes, and the more I think about it, the less helpful it might be for my current project, which I’d really like to serve as plain HTML. But I think it has potential anyway.

I think the idea is something akin to base64 on steroids, base149186, (or probably some subset of the 149,186 Unicode characters, but that would be the idea.) It’s not a one-way hash but simply an encoding in fewer characters. But that would only work if the initial allowable character set was significantly smaller than the Unicode set. I’ve only seen ASCII codes, and that would probably have some decent compression, but I’m guessing a lot more is available. I probably won’t bother pursuing this myself, as the idea doesn’t meet my own needs. But I could see it, and with some pretty bizarre URLs! :stuck_out_tongue_winking_eye:

Although packaging a solution in a plugin is helpful it is my strong belief one is not necessary for most of the requirements discussed here, it certainly can be done effectively without javascript or additional libraries.

  • I do not have the time to address “Yet another tiddlywiki solution” YATS right now.

A few tips;

  • use a startup action $:/tags/StartupAction
  • Test the url $:/info/url/full and obtain a tiddlername referenced
  • Check if the tiddlername contains a tiddler-list containing a list of tiddlers and open them
    • You may need to look at altering the default tiddlers eg set $:/DefaultTiddlers to the above list
    • Consider using the list field, then this could be populated by tagging tiddlers with your tiddler name.
  • If you want a short name use a short tiddler title - starting with “a” then for neatness use my alt-title package to display the alt-title field as the apparent tiddler title alt-title-display.json (775 Bytes)
    • The link would thus be http://mywiki.com/#a and open the tiddlers in its list.
  • Since this solution needs to open a full tiddlywiki you may create a dedicated wiki eg; short.com then trigger the opening of a new tab using a “permaview” created from your list of tiddler titles.