For the second part, I now have a draft based on what I've learned from the TiddlyFox sources, see it below the main post. I invite you to comment it, correct where I'm wrong, fill the gaps, especially about TW5.
Best regards,
Yakov.
== first draft of "how to support TW saving" docs ==
To support TW saving, it is to be desided:
1. how to recognize a TW?
2. when to inject new JS?
3. what JS to inject (and where)?
(and also the "protocol" and the "back-end logic" stuff)
How to recognize a TW?
First, let's note that the simplest implementation can omit TW recognition: just ask whether to inject JS or inject it into every html "served" with the saver app.
Looking at TiddlyFox code, it seems the following procedure is ok:
This surely can give false positives which seems to be ok; this also doesn't support "pure store" format.
When (and where) to inject new JS?
this section is to be written yet. Notes:
What JS to inject (and where)?
For now, I'm describing some existing approaches instead of a "canonical" one to be proposed.
TiddlyFox overwrites window.mozillaSaveFile and window.mozillaLoadFile with new implementations and also sets window.convertUriToUTF8 and window.convertUnicodeToFileFormat to plain s => s functions (needed for TWc before 2.9.2). This works for TWC and seems to be enough for bare loading/saving functionality. One thing to add here is overwriting the config.options.chkHttpReadOnly option if TW is served via http(s): instead of file: scheme.
A similar set of changes is implemented in tiddly-node-saver, it's simpler (window.saveFile is -overwritten-, loading is not implemented at all, chkHttpReadOnly is set to false). Actually window.saveFile is not overwritten but rather defined and I suspect it relies on the following definition in TWC core:
window.saveFile = window.saveFile || function(fileUrl,content)
which substituted this:
function saveFile(fileUrl,content)
in 2.7.0 which is a quite sane limitation.
I haven't quite figured the approach of TiddlyDesktop yet.
Unlike most solutions for local usages only, MTS is supposed to be used on servers as well as locally, that's why it is more strict and currently doesn't support saving arbitrary files. Instead, it injects "return saveOnlineChanges();" into saveChanges (and also inject the definitions before "function saveMain(" and changes the default value of chkHttpReadOnly, but now I see this should be refactored since there are better approaches).
As for TW5, I'm not really sure about the exact stack, but it seems for saving, a handler of the "tiddlywiki-save-file" custom event should be added. The handler should expect the "event" (first argument) to have .path and .content properties which should hold (local?) path to the file to save and (UTF-8?) content string of the file. Not sure if some sort of "file-save-success" event is supported to notify the core that the file was actually saved (and TiddlyFox actually has a bug to always report that TW was saved, even if it was on a USB storage which was removed before saving, because the injected saver always returns true).
Further considerations
There's a number of topics that should be covered as well, mostly after those above are, but some of them will affect architecture and hence should be considered anyway (can affect the core, especially in case of TWC; I'm ready to adapt it to better architecture):
====
Looks like that's all I've gathered for now. Again, contributions are very much welcome.
I'll start with TiddlyFox since it is still used by many users (with either FireFox 56- or Pale Moon, WaterFox and other FF forks). One thing about it is building the xpi: I've read about building it a little and the crucial quesion is: is it still possible to create signed xpi, or updating TiddlyFox is impossible in principle?
If it's not, I'd only like to ask Jeremy to add 2.x tags to the repo and attach xpi files to the github releases; or add me to the repo and I'll do that myself. Otherwise, I'd like to contribute a bit more and have some more questions.
Next and the main point of this thread is: both TWC and TW5 have many supporting solutions (native apps, servers, browser plugins etc) for saving but I'm not aware of docs that describe how actually one supports saving (and may be more functionality) of both TWC and TW5. For instance, MainTiddlyServer could be extended a bit so that it fits the php server gap, but I (as a developer of TWC extensions, MTS and maintainer of the core) am not really aware of how to support TW5 correctly; likewise, the aTW saver for Android supports only TW5 (as far as I know), but I'd like to participate and support TWC as well, yet I still didn't even get an answer about the app status (and I suspect Simon may be reluctant to support TWC without nice docs describing that). Finally, it seems every time one tries to support saving in their software, they invent some new implementation which (this diversity) is difficult to follow and the ecosystem is quite difficult to maintain.
Thus, it seems to me that we really need 2 things:
- nice docs describing how to support saving of TWC, TW5 (and, in perpective, more features like image uploading and more)
- core libraries in different languages (js for browser plugins? js for node, PHP, Java/Android, Swift/iOS, may be more) which one can use for developing new solutions
Now this thread is mostly about the first part, the docs (and by the way saving is not the only thing which would be nice to document; think, for example, of the .tid format which is not described anywhere, at least Jeremy wrote so some months ago).
My proposal consists of 2 parts:
- create a repo in the TiddlyWiki org @github (I'd like to be a member to contribute)
- start building docs
For the second part, I now have a draft based on what I've learned from the TiddlyFox sources, see it below the main post. I invite you to comment it, correct where I'm wrong, fill the gaps, especially about TW5.
This surely can give false positives which seems to be ok; this also doesn't support "pure store" format.
- MainTiddlyServer injects JS bits into the TWC code before serving it and strips those back when saves "the whole thing" (it can also send save increments); some modifications (like support of incremental saving) are made as hijacks which are done in loadPlugins so that the store is ready
- server-side implementations (that inject JS into TW so that user doesn't have to install a plugin into TW) also need to decide where to inject JS, see next section
- not sure whether TiddlyFox adds JS on load or eariler (probably the latter)
- neither I am sure of the exact moment tiddly-node-saver uses although the approach looks interesting
- same for TiddlyDesktop overwriting
As for TW5, I'm not really sure about the exact stack, but it seems for saving, a handler of the "tiddlywiki-save-file" custom event should be added. The handler should expect the "event" (first argument) to have .path and .content properties which should hold (local?) path to the file to save and (UTF-8?) content string of the file. Not sure if some sort of "file-save-success" event is supported to notify the core that the file was actually saved (and TiddlyFox actually has a bug to always report that TW was saved, even if it was on a USB storage which was removed before saving, because the injected saver always returns true).
Further considerations
There's a number of topics that should be covered as well, mostly after those above are, but some of them will affect architecture and hence should be considered anyway (can affect the core, especially in case of TWC; I'm ready to adapt it to better architecture):
- sync vs async saving
- full saving vs sending changes, shortcuts for backuping (sending full file to backup vs sending "copy file A into B" message)
- protocol layer (shouldn't necessarily be uniform, but recommendations can facilitate development of new tools)
- streaming changes via websockets and sync editing
- security consideratinos
- server logic (authorization & roles, ..)
- federation (including content from other TWs, saving it back)
- advanced features (image uploading, integration with git etc)
====
Looks like that's all I've gathered for now. Again, contributions are very much welcome.
--
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 tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/e4526996-ad42-45fd-af38-caac660cc07c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thus, it seems to me that we really need 2 things:
- nice docs describing how to support saving of TWC, TW5 (and, in perpective, more features like image uploading and more)
- core libraries in different languages (js for browser plugins? js for node, PHP, Java/Android, Swift/iOS, may be more) which one can use for developing new solutions
Do you mean docs for writing an app for handling saving of TiddlyWikis? Or for building a serverside for TiddlyWikis? Or do you mean docs for how the saving mechanisms work?
I think we are indeed missing docs for the .tid file format, but probably only because it’s so basic. Are you running into a problem with it?
I'll start with TiddlyFox since it is still used by many users (with either FireFox 56- or Pale Moon, WaterFox and other FF forks). One thing about it is building the xpi: I've read about building it a little and the crucial quesion is: is it still possible to create signed xpi, or updating TiddlyFox is impossible in principle?Mozilla was responsible for signing the extension as part of the process of uploading it; I don’t think there’s ever been a way for anyone else to sign it and have it accepted by recent versions of Firefox. But I don’t know much about it, it may be worth asking on the Mozilla dev mailing lists.
No problem with adding you to the repo.
Syncing is the easier to explain of the two: TWC has plugins that let it sync changes to TiddlyWeb, a venerable Python-based TiddlyWiki serverside we developed at Osmosoft. I’ve not tested it recently, but those plugins should also enable TWC to save back to a TW5 server.
TW5 supports saving in two completely different ways: saving the entire HTML file versus syncing individual tiddlers to a server.
In TW5, saving is modular: there are eleven built into the core:
Next and the main point of this thread is: both TWC and TW5 have many supporting solutions (native apps, servers, browser plugins etc) for saving but I'm not aware of docs that describe how actually one supports saving (and may be more functionality) of both TWC and TW5. For instance, MainTiddlyServer could be extended a bit so that it fits the php server gap, but I (as a developer of TWC extensions, MTS and maintainer of the core) am not really aware of how to support TW5 correctly; likewise, the aTW saver for Android supports only TW5 (as far as I know), but I'd like to participate and support TWC as well, yet I still didn't even get an answer about the app status (and I suspect Simon may be reluctant to support TWC without nice docs describing that). Finally, it seems every time one tries to support saving in their software, they invent some new implementation which (this diversity) is difficult to follow and the ecosystem is quite difficult to maintain.
[TW5 2 saving ways]
In TW5, saving is modular: there are eleven built into the core:
- andtidwiki - for saving within the AndTidWiki Android app
- beaker - for saving within Beaker Browser
- download - for the fallback HTML5 compatible download saver
- fsosaver - for the Internet Explorer ActiveX saver
- manualdownload - a version of the download saver for older browsers that don’t support the necessary HTML5 features
- msdownload - a version of the download saver for older Microsoft browsers
- put - for saving to WebDav servers
- tiddlyfox - for saving under TiddlyFox
- tiddlyie - for saving to the Internet Explorer TiddlyIE extension
- twedit - for saving within TWEdit, an old iPad/iPhone app for TiddlyWiki
- upload - for saving to TiddlySpot, or a PHP server running the upload script
The TiddlyFox saver talks to TiddlyFox via a hidden DIV and custom events.TiddlyFox itself has different handling for TW5 and TWC. For TW5, it uses the hidden DIV and custom events, and things are reasonably elegant. For TWC, TiddlyFox has to inject overrides to the saving functions which then set up the hidden DIV and handle the custom events.
In TW5, saving is modular: there are eleven built into the core:
So each of them implements both "full-TW-saving" and "syncing"?
Hi YakovI'll start with TiddlyFox since it is still used by many users (with either FireFox 56- or Pale Moon, WaterFox and other FF forks). One thing about it is building the xpi: I've read about building it a little and the crucial quesion is: is it still possible to create signed xpi, or updating TiddlyFox is impossible in principle?Mozilla was responsible for signing the extension as part of the process of uploading it; I don’t think there’s ever been a way for anyone else to sign it and have it accepted by recent versions of Firefox. But I don’t know much about it, it may be worth asking on the Mozilla dev mailing lists.
/bags/system/tiddlers?select=tag:systemConfig;sort=-modified/bags/{{ user }}/tiddlers
Syncing is the easier to explain of the two: TWC has plugins that let it sync changes to TiddlyWeb, a venerable Python-based TiddlyWiki serverside we developed at Osmosoft. I’ve not tested it recently, but those plugins should also enable TWC to save back to a TW5 server.
Sounds interesting. This is namely two-way syncing or one-way saving of separate tiddlers?
/bags/system/tiddlers?select=tag:systemConfig;sort=-modified/bags/{{ userBBB }}/tiddlers
/bags/{{ userME }}/tiddlersIn other words, can it be used for simultaneous editing of different tiddlers by different users so that they see the changes made by others without reloading TW?
Is syncing tiddler-wise?
Meaning that it can be used for what I've just described but cannot be used for simulteneous editing one same tiddler by different users?
By the way, why saving the whole HTML is not easier to explain: is it very different from what TWC uses for ordinary saving?
in the latest release of TiddlyWiki Classic I've fixed the upgrading engine and now it's time to deal with saving more consistently. That's where I'd like not only to ask about some dev aspects but also discuss some conventions and create docs for consistent support of saving both TWC and TW5.
tiddlyfox.js ... outdated, but the mechanism is the same
Second question is: why all the savers call the callback with null as the first (and only) argument? I guess, it's a placeholder for some specific design, could somebody clarify it?
Finally, and that's my main current concern, I'd like to discuss the events system. The thing is, as far as I can see, "tiddlyfox" saver only relies on the tiddlyfox-have-saved-file event fired on successful saving, it doesn't listen to any ~tiddlyfox-have-failed-to-save-file event.
And hence Timimi doesn't implement firing such events. Which is not nice in some cases (say, you have a TW on a removable USB storage device, you remove it, then press save, and don't get any notification about saving actually failed) and for some applications (well, that's needed at least in TWC upgrading engine which displays the stage/status of the procedure). So I'd like to propose introducing such an event. But since Timimi is designed for TW5 in the first place, I'd like to discuss the design of the event with you so that Rizwan have a reference and can participate the discussion too.
Now, tiddlyfox-have-failed-to-save-file is definitely not a nice name, because TiddlyFox is both outdated and doesn't fire such an event. So it should be something more abstract, I think. Like tiddlywiki-saver-have-failed-to-save-file or something shorter like tiddlywiki-saver-fail. Ideally, such an event should hold some values that help identify the cause of a fail (folder doesn't exist, permission denied, .., unknown), presumably in a form of some codes (unknown = 0, folder doesn't exist = 1, ...) so that localization is possible. A second thought is: if such new event is introduced, perhaps new events should be used for saving-request and saving-succeeded too (both old and new events should be fired for backward compability): I'd propose tiddlyfox-have-saved-file → tiddlywiki-saver-success and tiddlyfox-save-file → tiddlywiki-saver-request. So that we have:
init saving: tiddlywiki-saver-request (+ tiddlyfox-save-file for backward compatibility)
saving succeeded: tiddlywiki-saver-success (+ tiddlyfox-have-saved-file for backward compatibility)
saving failed: tiddlywiki-saver-fail
Perhaps an even better choise would be to give names for arbitrary IO operations (saving, loading, saving binaries etc) which could be:
init saving: tiddlywiki-backend-save-request (+ tiddlyfox-save-file for backward compatibility)
saving succeeded: tiddlywiki-backend-save-success (+ tiddlyfox-have-saved-file for backward compatibility)
saving failed: tiddlywiki-backend-save-fail
and can further be extended to things like
tiddlywiki-backend-load-request, -success, -fail
etc
What do you think?
PS1 I think the scope of docs which I proposed in this thread is actually "TiddlyWiki interoperability and data formats".
PS2 Besides multiline fields, there's another issue about .tid format, namely convention regarding filenames (say, tiddler name contains * which is not allowed in filenames – what should be the .tid filename? Obviously, the convention should describe a reversible convertion (without ambiguities).
среда, 10 апреля 2019 г., 12:37:38 UTC+3 пользователь PMario написал:On Sunday, March 24, 2019 at 3:58:40 PM UTC+1, Yakov wrote:...in the latest release of TiddlyWiki Classic I've fixed the upgrading engine and now it's time to deal with saving more consistently. That's where I'd like not only to ask about some dev aspects but also discuss some conventions and create docs for consistent support of saving both TWC and TW5.Some basic info about savers can be found here: https://tiddlywiki.com/dev/#SaverIf you have a closer look at the implementations- tiddlyfox.js ... outdated, but the mechanism is the same.- beaker.js ... new saver using the dat-project- put.js ... WebDav PUT saver.IMO this info should be enough to create your own simple saver. ... I think the upload.js used a php server side.If a "save action" is triggered, the core uses the saver.canSave() info to check if the saver can be used at all. saver.info() returns the saver capabilities and the priority.If several savers are able to provide the needed save action, the saver with the highest priority wins. ... ATM "There can be only one!"have fun!mario
--
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 tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/4592137f-a8e6-442f-82fe-f96ab88599e9%40googlegroups.com.