How (on earth) does TiddlyWiki implement saving in Internet Explorer?

328 views
Skip to first unread message

Rick Smith

unread,
May 22, 2015, 3:14:07 PM5/22/15
to tiddly...@googlegroups.com
Hi there.

For the life of me, I can't figure it out from the source code!

I just assumed that TiddlyWiki simply used the default page saving mechanism of each browser (the equivalent of just manually choosing "Save page as..." in the browser menu).

However, Firefox and Chrome allow dynamic (Javascript) source code alterations to be saved in this way, but Internet Explorer doesn't (it just saves the version of the HTML file that existed before the changes were made).

I don't believe TiddlyWiki uses ActiveX for saving with Internet Explorer (as I've tried disabling ActiveX) - although I may be wrong...

So, how DOES TiddlyWiki implement saving in Internet Explorer?

Thanks in advance for any help you guys can give!

Rick.

Andreas Hahn

unread,
May 22, 2015, 5:04:59 PM5/22/15
to tiddly...@googlegroups.com
Hi Rick,

without having the evidence in code to support my claims, from memory, I
recall that the process should work like this:

1) Tiddlywiki renders a tiddler called $:/core/save/all (or similiar)
internally and hands off the result to a saver module (not syncer)
2) The saver module is specially selected depending on the situation,
but for the normal browser-save option is either called "manualdownload"
or just "download"
3) Basically what the download saver-module does is get the rendered
version of a tiddler in a form that fits the data contained (either text
or binary)
4) And it then injects a link into the DOM containing a data-url which
contains all the data that is supposed to be saved and clicks that link
(and then removes it from the DOM)

Depending on the situation, it might employ more sophisticated things
(like the browser's API if existent) to influence the filename for example.

Don't nail me on the specifics, but that should be the general process.
(I am afraid that I don't have the time to actually dig in TW's code
right now, but I can take a look and figure out the details more clearly
later)

Hope this was of some help.

/Andreas

Danielo Rodríguez

unread,
May 23, 2015, 10:29:45 AM5/23/15
to tiddly...@googlegroups.com
When you click save don't you get a new file download? That's the regular way of saving.

Jeremy Ruston

unread,
May 23, 2015, 2:59:13 PM5/23/15
to TiddlyWikiDev
Hi Rick

> I just assumed that TiddlyWiki simply used the default page saving mechanism of each browser (the equivalent of just manually choosing "Save page as..." in the browser menu).

The file/save action isn't available to JavaScript code. As you've discovered, on most browsers it saves a copy of the original document, and doesn't incorporate any "live" changes to the DOM.

The default technique used to save changes is to prompt the browser to download a modified copy of the HTML file. It works pretty well on all HTML5 browsers, but isn't wildly convenient, as it requires several clicks to complete a save.

Here's a simple demo app that shows the technique:


And here's the relevant code inside TW5:


We have various extensions such as TiddlyFox and TiddlyDesktop that provide more efficient ways to save changes, including a plugin for IE called TiddlyIE. See http://tiddlywiki.com for details.

Best wishes

Jeremy.

On Sat, May 23, 2015 at 3:29 PM, Danielo Rodríguez <rdan...@gmail.com> wrote:
When you click save don't you get a new file download? That's the regular way of saving.

--
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 http://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/39563ea4-9918-41d3-b609-231b1545d614%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Danielo Rodríguez

unread,
May 23, 2015, 5:58:13 PM5/23/15
to tiddly...@googlegroups.com
And don't forget the Hta hack. If tiddlywiky is saved as Hta file instead html you can save normally, like a regular file in a normal program.

Rick Smith

unread,
May 25, 2015, 11:28:04 AM5/25/15
to tiddly...@googlegroups.com
Hi Andreas.

Thanks for the reply!

I'm particularly interested in the final stage - i.e. how exactly the browser is commanded to save the (dynamic) changes to the page.

(If you have the time, I posted this on StackOverflow recently, which kind of gives a wider context as to what I've been researching.)

As what is saved is basically an updated version of the whole document, is the dataUrl link that you mentioned in your stage 4 a complete duplicate of the whole document?

From what you write after that, would I be right in guessing that TiddlyWiki then conditionally branches into browser-specific code to do the actual final saving?

The saving can be so easily implemented in some browsers (e.g. with the anchor download attribute in Chrome), but it would be so much more elegant to be able to use the exact same HTML5/CSS3/Javascript code for all browsers!

I'll attempt another plough through the source code following your guidance.

Thanks again for your help!

Kind regards from (not so) sunny Cambridge, England,

Rick.

Rick Smith

unread,
May 25, 2015, 11:45:06 AM5/25/15
to tiddly...@googlegroups.com
Hi Danielo.

Thanks for the replies!

I'll look into the Hta hack - never heard of that before!

Kind regards, Rick.

Rick Smith

unread,
May 25, 2015, 4:30:17 PM5/25/15
to tiddly...@googlegroups.com, jeremy...@gmail.com
Hi Jeremy.

Thanks for the reply!

I haven't had time to thoroughly go through all that you'v mentioned yet, but I'll post a reply as soon as I have.

Kind regards, Rick.
Reply all
Reply to author
Forward
0 new messages