Hi Yakov Thanks for that. I've committed a first pass at a saver for AndTidWiki to GitHub and five.tiddlywiki.com, I'd be very grateful if you could give it a go.
The code is here: https://github.com/Jermolene/TiddlyWiki5/commit/1fd59a4bd312ead20251da80dd7bceb52f9c2bb0 Best wishes Jeremy On Sat, Aug 17, 2013 at 11:25 AM, Yakov <[email protected]>wrote: > Hi Jeremy, > > четверг, 15 августа 2013 г., 21:34:50 UTC+4 пользователь Jeremy Ruston > написал: >> >> Hi Yakov >> >> checked that. AndTidWiki changes saveFile function: its test is the >>> following >>> >>> function (fileUrl,content) { >>> return window.twi.saveFile(fileUrl,**content); >>> } >>> >>> so presumably to make TW5 work with ATW, one should use that >>> window.twi.saveFile interface in the TW5 saving engine. >>> >> >> That's great. There's two other things we need to figure out: >> >> 1) How AndTidWiki detects a TiddlyWiki document to determine if it should >> inject it's code (it's possible that it injects it's code into all HTML >> files, not just specifically TiddlyWikis). Right now TW5 is unlikely to be >> detected as a TiddlyWiki file. >> >> I wouldn't expect ATW somehow detect a TW file. And my test somewhat > confirms this: an html > > <html> > <body> > <p><a href="javascript:;" onclick=' > alert(saveFile); > '>let's try</a></p> > </body> > </html> > > shows the save text of saveFile onclick. > > 2) How the fileUrl parameter has been mangled and encoded by the time that >> the saveFile() function is called. >> >> Well, the simplest idea for this is to create a function that copies the > way the path is formed in TWc in saveChanges before it is passed to > saveFile, isn't it? According to the current core code, that would be > > var originalPath = document.location.toString(); // not netscape, > convertUriToUTF8 > is not needed in ATW > > // Remove any location or query part of the URL > var argPos = originalPath.indexOf("?"); > if(argPos != -1) > originalPath = originalPath.substr(0,argPos); > var hashPos = originalPath.indexOf("#"); > if(hashPos != -1) > originalPath = originalPath.substr(0,hashPos); > > // Convert file://localhost/ to file:/// (is not needed in ATW) > if(originalPath.indexOf("file://localhost/") == 0) > originalPath = "file://" + originalPath.substr(16); > > // Convert to a native file format (in ATW, the third > case takes place) > //# "file:///x:/path/path/path..." - pc local file --> > "x:\path\path\path..." > //# "file://///server/share/path/path/path..." - FireFox pc network file > --> "\\server\share\path\path\path..." > //# "file:///path/path/path..." - mac/unix local file --> > "/path/path/path..." > //# "file://server/share/path/path/path..." - pc network file --> > "\\server\share\path\path\path..." > var localPath; > if(originalPath.charAt(9) == ":") // pc local file > localPath = unescape(originalPath.substr(8)).replace(new > RegExp("/","g"),"\\"); > else if(originalPath.indexOf("file://///") == 0) // FireFox pc network file > localPath = "\\\\" + unescape(originalPath.substr(10)).replace(new > RegExp("/","g"),"\\"); > else if(originalPath.indexOf("file:///") == 0) // mac/unix local file > localPath = unescape(originalPath.substr(7)); > else if(originalPath.indexOf("file:/") == 0) // mac/unix local file > localPath = unescape(originalPath.substr(5)); > else // pc network file > localPath = "\\\\" + unescape(originalPath.substr(7)).replace(new > RegExp("/","g"),"\\"); > > return localPath; > > So probably this can be shortened further (cut unnecessary cases, > localhost cut etc). > > A quick hack to determine the answer to (2) would be if you could modify a >> TW classic file to insert "alert(localPath)" just before the call to >> saveFile() in the saveMain() function. Then can you attempt a save under >> AndTidWiki, and note the path that is alerted. Ideally, could you include a >> character like "%" in the filename. >> > > An example of originalPath is "file:///mnt/sdcard/...../atw test.html" > and the corresponding localPath is "/mnt/sdcard/...../atw test.html". > > Best regards, > Yakov. > > >> I'm not sure how to deal with (1); if you can help with (2) I'll create >> an exploratory TW5 saver for AndTidWiki and we can experiment further. >> >> Many thanks, >> >> Jeremy >> >> >>> >>> Best regards, >>> Yakov. >>> >>> четверг, 15 августа 2013 г., 11:13:21 UTC+4 пользователь Jeremy Ruston >>> написал: >>>> >>>> Hi Yakov >>>> >>>> There are two ways that TiddlyWiki can interact with a server: >>>> >>>> 1. By saving the entire file to the server (this is how TiddlySpot >>>> works, and the iPhone/iPad app TWEdit) >>>> 2. By syncing changes to individual tiddlers to the server (this is how >>>> TiddlyWeb/TiddlySpace works) >>>> >>>> I would expect AndTidWiki to work using the first technique. Typically >>>> that would be done by injecting code that overrides the saveChanges >>>> function, or the lower level saveFile/loadFile functions. >>>> >>>> You can see an example of the technique in the source to TiddlyFox. >>>> This is the javascript file that TiddlyFox injects into TiddlyWiki >>>> documents: >>>> >>>> https://github.com/TiddlyWiki/****TiddlyFox/blob/master/content/**** >>>> inject.js<https://github.com/TiddlyWiki/TiddlyFox/blob/master/content/inject.js> >>>> >>>> You can see the internal functions being overridden at lines 50 to 53. >>>> >>>> Best wishes >>>> >>>> Jeremy >>>> >>>> >>>> >>>> >>>> On Thu, Aug 15, 2013 at 12:27 AM, Yakov <yakov.litv...@gmail.**com>wrote: >>>> >>>>> >>>>> >>>>> пятница, 2 августа 2013 г., 14:27:41 UTC+4 пользователь Jeremy Ruston >>>>> написал: >>>>> >>>>>> понедельник, 29 июля 2013 г., 15:43:02 UTC+4 пользователь Arlen >>>>>>> Beiler написал: >>>>>>> >>>>>>>> Using TiddlyWiki5 which I just downloaded in AndTidWiki, I can edit >>>>>>>> fine, but when I try to save it, I get an Internal Javascript Error. >>>>>>>> "Uncaught TypeError: Cannot call method 'getItem' of null". >>>>>>>> >>>>>>>> That's unfortunate. Theoretically it's possible to "emulate" the >>>>>>> saving engine of TWc in TW5 by a plugin, but that's far from my >>>>>>> knowledge >>>>>>> (I haven't researched TW5 core yet, and also don't quite understand how >>>>>>> ATW >>>>>>> and TW interact). >>>>>>> >>>>>> >>>>>> I agree that we should be able to make TW5 work with the existing >>>>>> AndTidWiki app. I don't have an Android device for testing, and have had >>>>>> bad experiences in the past with the poor performance of the Android >>>>>> emulator. So I'd be very grateful if anyone can help with information on >>>>>> the way that AndTidWiki works. >>>>>> >>>>>> Hi Jeremy, >>>>> >>>>> I'm not familiar with how TiddlyWiki interacts with any server side, >>>>> so may be you can help me with that first.. >>>>> >>>>> the chain >>>>> config.macros.saveChanges.**onCl**ick - saveChanges - saveMain - >>>>> saveFile - ... >>>>> doesn't seem to have anything that's "awaiting" server side, so >>>>> >>>>> my only guess on where server side can jump in is >>>>> >>>>> TiddlyWiki.prototype.**allTiddle**rsAsHtml - >>>>> TiddlyWiki.prototype.getSaver - TW21Saver/some other saver - .externalize >>>>> - >>>>> .externalizeTiddler >>>>> >>>>> so is it true that usually server sides create their own SaverBase >>>>> instance with their own externalizeTiddler method and change >>>>> TiddlyWiki.prototype.getSaver and that's how they make TW use some new >>>>> functionality to save? Or is it done somehow else? >>>>> >>>>> Best regards, >>>>> Yakov. >>>>> >>>>> >>>>>> >>>>>> >>>>>>> >>>>>>>> On Mon, Jul 29, 2013 at 4:39 AM, Yakov >>>>>>>> <yakov.litv...@gmail.**com>wrote: >>>>>>>> >>>>>>>>> Hi Leo, >>>>>>>>> >>>>>>>>> by the way, have you tried AndTidWiki? As for now, I only use >>>>>>>>> TiddlyWiki Classic on Android, so don't know if TW5 works with it. As >>>>>>>>> a >>>>>>>>> side note: with AndTidWiki, I only have to add >>>>>>>>> ToggleLeft/RightSidebar [1], >>>>>>>>> add a line-menu on top by changing PageTemplate and a few CSS >>>>>>>>> adjustments, >>>>>>>>> while FireFox needs some more work on styles (in fact, I need to >>>>>>>>> create a >>>>>>>>> plugin which will apply different styles depending on what "browser" >>>>>>>>> opened >>>>>>>>> TW). >>>>>>>>> >>>>>>>>> Best regards, >>>>>>>>> Yakov. >>>>>>>>> >>>>>>>>> [1] http://tiddlytools.com/#**Toggle******RightSidebar%** >>>>>>>>> 20ToggleLeftSideb******ar<http://tiddlytools.com/#ToggleRightSidebar%20ToggleLeftSidebar> >>>>>>>>> >>>>>>>>> вторник, 16 июля 2013 г., 8:54:26 UTC+4 пользователь Leo Staley >>>>>>>>> написал: >>>>>>>>> >>>>>>>>>> Thank you Eric! I didn't know how to do that from my Android. >>>>>>>>>> Firefox didn't install it when I clicked on it like I thought it >>>>>>>>>> should >>>>>>>>>> have. >>>>>>>>>> >>>>>>>>>> After downloading it with another browser (because firefox didn't >>>>>>>>>> let me "save link" on long-press) and opening the file using >>>>>>>>>> firefox, I was >>>>>>>>>> able to install it. >>>>>>>>>> >>>>>>>>>> Sadly though, no "save" button appears under the tools menu. The >>>>>>>>>> button at the top, to download a copy of the page worked once, but >>>>>>>>>> i'm >>>>>>>>>> having trouble doing it again. >>>>>>>>>> >>>>>>>>>> Additionally, when i create a new tiddler, I first have to delete >>>>>>>>>> the existing text in both the title and the main text area, which >>>>>>>>>> takes >>>>>>>>>> some time with an android keyboard. >>>>>>>>>> >>>>>>>>>> Eric, How compatible are most of the items on TiddlyTools with >>>>>>>>>> Tiddly5? Is development still continuing with the current edition of >>>>>>>>>> Tiddlywiki, and if so, in what Capacity? Forgive me for being such a >>>>>>>>>> noob. >>>>>>>>>> >>>>>>>>>> On Monday, July 15, 2013 9:15:47 PM UTC-7, Eric Shulman wrote: >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On Monday, July 15, 2013 9:13:16 PM UTC-7, Leo Staley wrote: >>>>>>>>>>>> >>>>>>>>>>>> More significantly, There was no way to save any changes I >>>>>>>>>>>> made. Took me a while to realize that. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>> As Jeremy noted in his previous post: >>>>>>>>>>> "... install TiddlyFox to save changes locally on the device ( >>>>>>>>>>> https://github.com/TiddlyWiki****** >>>>>>>>>>> /TiddlyFox/raw/master/tiddlyfo******x.xpi<https://github.com/TiddlyWiki/TiddlyFox/raw/master/tiddlyfox.xpi> >>>>>>>>>>> )." >>>>>>>>>>> >>>>>>>>>>> enjoy, >>>>>>>>>>> -e >>>>>>>>>>> Eric Shulman >>>>>>>>>>> TiddlyTools / ELS Design Studios >>>>>>>>>>> >>>>>>>>>>> HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"... >>>>>>>>>>> >>>>>>>>>>> http://www.TiddlyTools.com/#D******onations<http://www.TiddlyTools.com/#Donations> >>>>>>>>>>> >>>>>>>>>>> Professional TiddlyWiki Consulting Services... >>>>>>>>>>> Analysis, Design, and Custom Solutions: >>>>>>>>>>> >>>>>>>>>>> http://www.TiddlyTools.com/#C******ontact<http://www.TiddlyTools.com/#Contact> >>>>>>>>>>> >>>>>>>>>> >>>> >>>> >>>> -- >>>> Jeremy Ruston >>>> mailto:[email protected] >>>> >>> >> >> >> -- >> Jeremy Ruston >> mailto:[email protected] >> > -- Jeremy Ruston mailto:[email protected] -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/tiddlywikidev. For more options, visit https://groups.google.com/groups/opt_out.
