FND suggested that I post this to the TiddlyWikiDev group. Apparently I've found an odd use for the TiddlyWiki codebase that is inconsistent with the current code modularization. FND thought it would be worth describing the situation as it might suggest some useful code refactoring.

I'm using tiddlywiki's file save code to support the tw-inspired application I announced a couple days ago---see Dido---a tiddlywikified database application <https://groups.google.com/forum/#topic/tiddlywikidev/uGn7XCqBz5A/discussion> . Although apparently twFile.js is supposed to supersede FileSystem.js, due to the current tw design I am using _both_ twFile.js and FileSystem.js . I'm using $.twFile to do the actual save, but have to invoke getLocalPath and its subroutines from FileSystem.js to identify the save path. I'm also faced with having to copy the entire getLocalPath function out of FileSystem.js so that I can eliminate the first line, which relies on tiddlywiki's entire configuration system (config.options) to look up a single parameter that I'd rather just set myself. Obviously I'd prefer to use just the modern twFile.js code, but it's missing functionality I need to save files.

A second issue I ran into was an inability to effectively support a "Save As" file dialog. "Save" works fine, as tw already knows the file path. In fact, tw can save to any specified file path. The problem is that there is no implementation of an interface for specifying that file path. If I want to implement "load" I can do so by leveraging the built-in browser interface for specifying a file to upload---I just introduce a form with a "choose file" button, the browser takes care of the interaction, and I pull the file path out of the form. But I know of no analogous way to get access to the information produced by the browser's "save as" dialog---it only seems to be possible to trigger that dialog via a server download, and there's no way I can see to capture the necessary file path information on the client. If anyone has a way around this, I'd love to know. If not, I'd love to see it addressed in future tw development.



-------- Original Message --------
Subject:        Re: [twdev] Dido---a tiddlywikified database application
Date:   Thu, 16 Dec 2010 19:15:13 +0100
From:   FND <[email protected]>
To:     David Karger <[email protected]>



 dido requires both files. it's using $.twFile to do the actual save,
 but it's using getLocalPath from FileSystem.js to identify the save
 path. [...] I wish that code had factored a little differently.

That's very interesting - you might be the first one to use the code in
such capacity. It would be great if you could post those concerns to the
dev group*, then we could aim to refactor the code for improved reusability.

 A related issue [...] is finding some nice way to support "Save As"
 and not just "Save".  I can't find any way to run a file-save dialog
 that lets the user select a directory then enter a new file name.
 All that the browser offers natively is a file _load_ dialog, which
 only works for preexisting files.

There are some browser restrictions, but IIRC they mostly block access
to parent directories - so different filenames should be possible. In
fact, the test suite does create a new file:
http://trac.tiddlywiki.org/browser/Trunk/core/test/js/LoadingSaving.js?rev=12337#L35

Best to bring this up on the dev group as well.


-- Fred


*http://groups.google.com/group/TiddlyWikiDev/

--
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywikidev?hl=en.

Reply via email to