TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
7.97k stars 1.18k forks source link

Several problems with external-attachments plugin #3761

Open bimlas opened 5 years ago

bimlas commented 5 years ago

First, it is only installed in prerelease (the plugin exists since 5.1.15).

Tried out on different platforms without success, so I started to investigate the matter.

Directory based (Node) wiki + Tiddly Desktop

Using Tiddly Desktop on a Node wiki, the document.location.protocol value is crome-extension: (in Chrome it's http:) so run is stopped at the beginning of the hook because the condition is not met.

https://github.com/Jermolene/TiddlyWiki5/blob/e646d207c3aa9e7570fedeb27a6576b4d91ea8d9/plugins/tiddlywiki/external-attachments/startup.js#L28

Even if we fix this, it doesn't know the relative file name because it doesn't know its own directory (document.location.pathname is /html/wiki-folder-window.html).

https://github.com/Jermolene/TiddlyWiki5/blob/e646d207c3aa9e7570fedeb27a6576b4d91ea8d9/plugins/tiddlywiki/external-attachments/startup.js#L29

For the time being, this plugin can't be used with a Node wiki.

Single HTML + Tiddly Desktop

makePathRelative() does not work on Windows because it encodes the colon in sourcepath and has no beginning / sign, thus it always throw makePathRelative: both paths must be absolute:

https://github.com/Jermolene/TiddlyWiki5/blob/e646d207c3aa9e7570fedeb27a6576b4d91ea8d9/plugins/tiddlywiki/external-attachments/startup.js#L55-L63

The method fails even if USE_ABSOLUTE_FOR_DESCENDENTS_TITLE and USE_ABSOLUTE_FOR_NON_DESCENDENTS_TITLE is true.

Jermolene commented 5 years ago

Hi @bimlas I haven't tested the external attachments plugin with a wiki folder, only with standalone wikis. It's a good idea to get it working though. The second problem is indeed fixed by 996ee52.