Built-in URL shortener

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.

I still don’t really have a good sense of when and where to make work a plugin. I have one I’m hoping to finish this weekend, and it probably can be distributed as a single JSON list of tiddlers. But I want to finish the content before I worry too much about packaging.

And note that there is already a plugin version, published yesterday, in response to this:

1 Like