TiddlyWiki5 icon indicating copy to clipboard operation
TiddlyWiki5 copied to clipboard

get-tiddler-html route conflicts with other routes

Open Arlen22 opened this issue 6 years ago • 9 comments

Because there is no sorting done in the route handlers, the get-tiddler-html route conflicts with other routes because the route order cannot be specified and is not predicted before-hand. Currently they are loaded in alphabetical file order which puts it after the core routes but before any other plugin or custom routes. This makes it hard to add routes that do not have a subpath in them (specifically, that have a slash in the middle). Can we change this route to /static/* like it used to be in some builds? Or some alternative? Or can we just institute a list filter so we can use the list-before and list-after field or something like that?

Arlen22 avatar Jul 29 '19 18:07 Arlen22

Hi @Arlen22 single tiddler display mode is a somewhat experimental proof of concept at this point, and we should clean it up. I'd prefer reverting to a /static/ prefix.

Jermolene avatar Jul 30 '19 12:07 Jermolene

Using the list mechanism for the routing would be highly useful, but that's a separate issue I guess. I'll investigate that part when I have time.

Arlen22 avatar Jul 31 '19 15:07 Arlen22

Hi @Arlen22 you may have noticed that the module mechanism in TW5 doesn't use any features of the tiddler store (e.g. tags), instead just using a single "module-type" field. This is a visible artefact of a subtlety of the module implementation: it is possible to build TW5 with all the JS modules out-of-band (in a simple script block), without exposing any of them as tiddlers (the bootprefix sets up $tw.modules so that code run before the main boot file can add modules). That was done right at the beginning so that a future online version of TW5 could harden security by disallowing JS modules as tiddlers. There's a few more things that would need to be done to make that support practical, but I'd be reluctant to do anything to compromise future support for it.

Overall, having to carefully order routes seems brittle and archaic; I'd prefer to avoid overlapping routes entirely.

Jermolene avatar Jul 31 '19 15:07 Jermolene

Wow, I didn't know that. That's actually a really good idea and should have some very practical implications for TW Cloud. I like the idea as I've also been trying to figure out if it is possible to webpack the Javascript modules or at least make a custom code file that imports them in a webpack-like bundle as Javascript rather than JSON. If I can accomplish that then I can possibly use Closure Compiler or something similar to minify the entire thing.

Arlen22 avatar Jul 31 '19 16:07 Arlen22

So I spent a few hours playing with the idea, and here is the result: https://github.com/Jermolene/TiddlyWiki5/compare/master...Arlen22:compile-modules

You can try it out by running node tiddlywiki.js editions/server --listen. I haven't tried the browser side yet.

Webpack in production mode minifies the entire Javascript to 665KB, and that includes boot.js.

We do still need to load the all the tiddlers as text separately.

Arlen22 avatar Jul 31 '19 20:07 Arlen22

@Arlen22 ... Is this issue still valid, or is it outdated already?

pmario avatar Dec 01 '25 14:12 pmario

Per Jeremy's comment about this being a feature not a bug, I guess not.

Arlen22 avatar Dec 01 '25 16:12 Arlen22

My bad, I did not properly understand what this was when I closed this. So Jeremy did not say this was a feature.

It is still a problem, however the problem is restricted to root level paths. Any mount with at least two slashes (including the leading slash) will not have this problem. So you can't use /anything, but you can use /something/anything.

Arlen22 avatar Dec 01 '25 23:12 Arlen22

If it is still an issue, imo it should be re-opened, so we do not forget about it.

pmario avatar Dec 02 '25 10:12 pmario