[tw5] External links on usb

Is there a way to have external links that are in a sense ‘portable’?

I want to store the TW file and the external reference material on a usb drive for access.

Thanks.

Something I’ve never tried, and just tried for fun.

I set my _canonical_uri for an image tiddler with a relative path, relative to the location of the TiddlyWiki file.

So wherever my TiddlyWiki file is, the _canonical_uri = ./CjVeniot/PatrioticMe.jpg seems to work A-1 for that jpeg file.

Same thing for a PDF file I just tested (tiddler’s “Type” = applicaton/pdf).

There are different ways to handle this. If we’re talking images, for instance, the path to your USB might be different on different machines. So being able to change the path in just one place is handy. And being able specify different types of image sources is also handy. For instance, you might have some sources that are on a remote url, some on a usb, and some on CDROM.

Here’s one possible macro

\define img(devtype basename)
<$vars devpath={{{[prefix[ImagePath]suffix[-$devtype$]limit[1]get[text]]}}}>
<$image source={{{[addsuffix<basename>]}}} />
</$vars>
\end

Then if you have your configuration tiddlers in the format ImagePath- where the text has a path like (example ImagePath-files):

./files/

Then you can invoke your image like this

<>

Or, back to your usb, you might have a config tiddler ImagePath-usb with text D:\mydirectory\myimages\ and invoke like

<>

Then when on a different machine, you can change the contents of ImagePath-usb to Z:\mydirectory\myimages\ .

I have an idea for using image tiddlers (e.g. with _canonical_uri) . The advantage of image tiddlers is that if you change the name of a tiddler, you can use relink to change tiddler transclusion automatically. But that’s all for now.

1 Like

Some years ago, I did as Charlie, explains. I am using several different laptops, they all run the same version of Linux Mint. Each of the laptops has 3 usb ports…and find my tiddlywiki usb - and the images and more, using the usb label. finding it at /media/user/label

Do be careful how you setup your canonical uri. Try to use “relative paths” to your external files, and avoid “absolute paths.”

(HTML File Paths)

If you setup absolute paths, they might work well with, say, your Linux laptop, but not work at all on your Windows desktop (i.e. work fine on one device, but not work at all on other ones.)

So relative to the location of the TiddlyWiki file on your USB drive,

  • you might have an image that is up one directory: …\this_image.jpg
  • or in a subdirectory next to your tiddlywiki: .\this_subdirectory\this_image.jpg
  • etc.
    Mind you, I’m going based on general knowledge/experience, nothing specific to TiddlyWiki on a USB drive with external files on the same USB drive, and connecting that USB drive to any number of wildly different devices.