Export to folder name? feature or workaround required.

63 views
Skip to first unread message

TW Tones

unread,
Jul 26, 2020, 11:51:37 PM7/26/20
to TiddlyWiki
Folks,


Background

If you supply a filename to the export process it will use that filename to save the file, eg JSON file.

If you add a path into the filename given to the export/save file
C:\Data\TW5\TW5 Intranet\MyBundles\Working\myfile

This get's sanitised? to 
C__Data_TW5_TW5 Intranet_MyBundles_Working_myfile.json

You must respond to the save dialogue, so export can not occur to a local folder unless a user intervention occurs.

If however when the save dialogue appears you paste the foldername in front of the filename you can save to the desired location, however this is fiddly and demands forethought and multiple steps.

The Question
Is it possible to allow the full path and filename to be passed to the save file dialogue, such that if known, the path will be used to save the file?
Perhaps the import process as well?

Why?
  • This would allow known folders to be recorded in tiddlywiki for known folder/files and allow this information to be used to simplify export/saving to various locations. 
  • It would allow a default file location to be set for saving exported files and perhaps even wikis (If the browser permits selecting the location only)
  • We could encourage in a LAN environment that exported files saved wikis, are saved in a known location unless changed.
  • We may be able to do the same for the import function so we could import from our local tiddlywiki tools folder without having to search or select the folder.
Finer details
  • Even TiddlyDesktop, that has access to the local file system, the export still sanitises the name as above, surely we can override this limitation there, if no where else?
  • I am aware of apps such as the Office 365 Suite that can save to and remember where the file was when opened in the browser, so it is possible.
  • The same would be good for URL's of a server able to receive the exported file and save it, or to access an online "library of files", if the import and export allowed an address to be given
  • It is fine for the interactive open or save dialogue to intervene forcing a conscious selection by the user to reduce the security risk, the save mechanisium will only work if the browser permits save to any location (Not only downloads).
  • You can only save to where the interactive user has rights to save, I believe windows, for one, may resist saving to the system folder unless overridden.
This may require a PR but I am asking here first in case someone has an answer.

Regards
TW Tones

TW Tones

unread,
Jul 27, 2020, 12:20:49 AM7/27/20
to TiddlyWiki
Post script,

If the file already exists in the folder/file path, then an additional user intervention is required to overwrite the original.

Regards
TW Tones

PMario

unread,
Jul 27, 2020, 8:26:30 AM7/27/20
to tiddl...@googlegroups.com
On Monday, July 27, 2020 at 5:51:37 AM UTC+2, TW Tones wrote:
  • I am aware of apps such as the Office 365 Suite that can save to and remember where the file was when opened in the browser, so it is possible.
I'm pretty sure it's not possible to remember it within the app, What you see here is the browser system file dialogs, that are part of the Os.

Workflow is: - There is a File open dialog, where the user selects the directory and opens a file.
 - You manipulate this file
 - You want to save the file. .... The OS dialog remembers the "open from" position and uses it as the default location to save to.

If you test this with 2 different files from 2 different locations, I'm pretty sure, the OS dialog points to the wrong lactation if you switch from file 1 to file 2.

If that's not the case, I'd be very interested in a howto, that shows 2 different "save to" locations, depending on the file / tab you want to save.


As you can see, there is no way to specify a user directory. There is some info about the sanitation with underlines. ..

-mario

Mark S.

unread,
Jul 27, 2020, 12:34:56 PM7/27/20
to TiddlyWiki

On Firefox/Linux, it seems to remember the path per webpage. So it uses the last path used for that web page. If I switch to a different web page where I've saved to somewhere else, it remembers that.

But, in any event, that's under the browser's control -- not the app's.

TW Tones

unread,
Jul 27, 2020, 10:33:05 PM7/27/20
to TiddlyWiki
Mark and Mario

I have being ill, especially yesterday and not so attentive to the forum. 

In response to your suggestions please understand the following; However, I found a "good" work around.
  • I understand these workflows, where the current folder is retained in the OS so open and download can be the same folder. I make use of these a lot.
  • However I am more interested in recording various filenames and locations, folder locations, in my tiddlywiki so I do not need to remember them. In fact keep a directory of locations.
  • Ideally I could then save files to these locations without too many additional steps, and definitely not having to remember the destination path.
  • With tiddlydesktop I can open or launch a file at any location on the drive so the stored full path can be made use of, the trick is adding the path to the download process.
In my original post the conversion to the sanitised path/filename, Is the sanitisation tiddlywiki's work rather than the browser?

However I discovered a simple and usable workaround.

Add the following action inside the export button definition
<$action-sendmessage $message="tm-copy-to-clipboard" $param=<<path>>/>

Then call the export button with path set correctly
<$wikify name=path text="""<<path>>""">
<$macrocall $name=exportButton exportFilter={{!!package-filter}} baseFilename={{!!filename}}/>
</$wikify>

  • Now when saving the file you can either select the location to which to save the file, such as the current folder, browse to the correct location or hit "home" and "paste" (ctrl-v), to prefix the filename with the stored path (now in the clipboard).
  • It has the advantage of not pre-judging the filename extension you use with the export button.
  • An example tiddler that works on tiddlywiki.com attached
Additional observation
  • After using the above method to paste the path, and saving the current path is set to that last saved path
  • So if you hit export and then past the path name (over the filename) the dialogue changes to that path
    • You can then chose the file to replace
  • If you export again it returns to the last used folder

What do you think?

Regards
TW Tones
Test export.json

Mark S.

unread,
Jul 27, 2020, 11:24:42 PM7/27/20
to TiddlyWiki
 I believe this tiddler


describes how names are generated. So it's not a browser-side thing -- except for the directory name. If the application could specify the path, then it could overwrite stuff down in c:\windows\system32 .

I've experimented with using "copy to clipboard", especially in conjunction with the default save mechanism. But I didn't really pursue it, because the other save mechanisms are so much easier to work with.

Hope you feel better soon!

TW Tones

unread,
Jul 28, 2020, 12:05:21 AM7/28/20
to TiddlyWiki
Mark,

Thanks for that reference, Its a great lead. I wonder if on single file wikis changing this will 1. work, 2. have no impact except when exporting.
I imagine there is a danger if one imports this tiddler into a node wiki, that it will stuff it up?

As noted earlier the c drive root is protected on windows, using the save dialogue, I just tried to save to c:\windows\system32 and it also returns this;

Snag_1a21197c.png

With antho being my user folder.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages