How should we derive a window name from a file link?

Folks on a number of projects such as Window Manager, window names etc… I am pulling together a suite of solutions for using and managing multiple wikis and links to content within wikis in the browser. I think I may be there now, but I need to resolve one last question (I think).

I want to be able to generate a default window name from any URL for example at tiddlywiki.com we may simply use the domain to set the llink target field. All links below tiddlytwiki.com will open in the same window.

  • his is an adequate solution but may not be appropriate when folders are used in the path, although subdomains are ok.
  • often the real filename of a wiki like this on the internet, is index.html so adds little value to include the filename.

The problem arises when using wikis at file addresses. eg file:///I:/TW5%20Intranet/!Working/details-macro-development-wiki.html

  • I could make the window name into details-macro-development-wiki but since it may be a link to a file I should include .html
  • can I assume the filename is unique and not bother including the file path in the window name?
    • Eg details-macro-development-wiki.html
    • Or use TW5%20Intranet.!Working.details-macro-development-wiki.html?
      • Which is a bit long and could be a lot longer.

Why,

  • We can collect links from all over the internet and I would like to take any random link and by default open it in a named tab, so multiple links to the same location open that same tab. R-click allows open in new window anyway.

I can manage this for wikis under my control but not other types of links.

Pretty clearly you cannot if you want this to run on arbitrary systems. Heck, I probably have many hundreds – even thousands – of files named index.html on my machine, a substantial number of them which hold instances of TiddlyWiki. (It makes for nicer urls, such as http://example.com/My/Path/ instead of http://example.com/My/Path/wiki.html.

I think if you want a general purpose solution, then you need to do this. If it’s only for your internal use, and you can guarantee uniqueness of file names across paths, then do as you choose.

  • agreed, thanks for helping me by concluding the similar.

I do want that to be possible arbitrary systems AND on top of “managed systems” ideally with human readable window names.

  • Interesting, I don’t have many, at least at FILE:// addresses. I tend to give wikis at least searchable names.
  • Interestingly if accessible by domain name the combination of domain folder is unique, but there may be an argument except for select domains to set the window.name to only the domain.
  • I am trying to make a global solution and can generate links containing the window.name for any address using a bookmarklet.

TiddlyWiki in particular

I have realised whilst building and testing this solution that if the window name is to come from a local file tiddlywiki and hence the Topic raised, we do have more control from within our wiki.

This means for local tiddlywikis at least we may do the following;

  • Control the link that opens the wiki, which can itself be obtained from the wiki
  • Configure a preferred window.name in each wiki
  • Now in all references to the wiki we can use a link crafted to use the window name so configured.
  • However if it is loaded and no window.name is set, either issue a warning and/or
    • set the window name from the configuration setting.
    • offer to configure a window name.

A more advanced method I have explored and is possible, is for a FILE wiki to register it is open and its windown.name in local storage then on subsequent loads see it is already open in another window or tab and enter a read only, no saving mode.

  • I expect I will do this one day but I don’t want to “the make perfect an enemy of the good”

Another approach may be to first generate the appropriate long window name but then somehow compress it with a deterministic algorithm. As long as this is repeatable, then for user readability prefix it with something eg; GTD_aw35bfao78

  • As long as our wikis can reverse this we can just store the full path and determine the window.name

See also Browser bug bear, losing the window.name