Downloading files embedded

92 views
Skip to first unread message

donmor3000

unread,
Apr 27, 2019, 3:42:54 AM4/27/19
to TiddlyWikiDev
The "Download Empty" button in the wiki page does not work in my app. I'm not sure whether this function can be handled by injecting js, just like saving function handled by TiddlyFox or TiddlyDesktop. The button invokes an method in $:/core/modules/widgets/action-sendmessage.js, which will pass an url begins with "blob:" to the browser, but WebView won't support this scheme. I'm now finding a way to change the blob things to a base64 string so that I can decode it to a byte array. Anyone can help? :-)

Jeremy Ruston

unread,
Apr 27, 2019, 9:49:39 AM4/27/19
to TiddlyWikiDev
Hi Donmor

The "Download Empty" button in the wiki page does not work in my app. I'm not sure whether this function can be handled by injecting js, just like saving function handled by TiddlyFox or TiddlyDesktop. The button invokes an method in $:/core/modules/widgets/action-sendmessage.js, which will pass an url begins with "blob:" to the browser, but WebView won't support this scheme. I'm now finding a way to change the blob things to a base64 string so that I can decode it to a byte array. Anyone can help? :-)

Just to be clear, does ordinary saving work in your app? Have you injected a custom saver?

Downloads are handled by the same saver module mechanism that we use for saving, but with the “method” parameter to the saver passed as “download” instead of “save” or “autosave”.

Perhaps you can share some more details of how your app is working at the moment?

Best wishes

Jeremy




--
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/c32330c5-74a7-4aad-9d3f-cee8a11eda6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

donmor3000

unread,
Apr 27, 2019, 11:51:09 AM4/27/19
to TiddlyWikiDev
My app injects a js to TiddlyWiki webview, which is a modified version of scripts inside the desktop app TiddlyDesktop:
var enableSaving = function(doc) {
            var messageBox = doc.createElement("div");
            messageBox.id = "tiddlyfox-message-box";
            doc.body.appendChild(messageBox);
            messageBox.addEventListener("tiddlyfox-save-file",function(event) {
                var message = event.target,
                filepath = message.getAttribute("data-tiddlyfox-path"),
                content = message.getAttribute("data-tiddlyfox-content");
                window.client.saveWiki(filepath,content);
                message.parentNode.removeChild(message);
                var event = doc.createEvent("Events");
                event.initEvent("tiddlyfox-have-saved-file",true,false);
                event.savedFilePath = filepath; message.dispatchEvent(event);
                return false;
            },false);
        };
        enableSaving(document);
It seems that the code provides no downloading interface. The only thing they do is to get the content of current page.

在 2019年4月27日星期六 UTC+8下午9:49:39,Jeremy Ruston写道:
Hi Donmor

The "Download Empty" button in the wiki page does not work in my app. I'm not sure whether this function can be handled by injecting js, just like saving function handled by TiddlyFox or TiddlyDesktop. The button invokes an method in $:/core/modules/widgets/action-sendmessage.js, which will pass an url begins with "blob:" to the browser, but WebView won't support this scheme. I'm now finding a way to change the blob things to a base64 string so that I can decode it to a byte array. Anyone can help? :-)

Just to be clear, does ordinary saving work in your app? Have you injected a custom saver?

Downloads are handled by the same saver module mechanism that we use for saving, but with the “method” parameter to the saver passed as “download” instead of “save” or “autosave”.

Perhaps you can share some more details of how your app is working at the moment?

Best wishes

Jeremy




--
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 tiddly...@googlegroups.com.

Jeremy Ruston

unread,
Apr 27, 2019, 11:55:19 AM4/27/19
to tiddly...@googlegroups.com
Hi Donmor

It seems that the code provides no downloading interface. The only thing they do is to get the content of current page.

That makes sense. For TiddlyDesktop, nw.js does permit the ordinary download mechanism. Sadly, the TiddlyFox saver doesn’t support downloading.

So, there might be a few ways to approach this:

* Research ways to enable the ordinary download mechanism within your web view. You may find https://github.com/Jermolene/FileSavingDemo useful; it’s a minimal test case for TW5’s download saver mechanism
* Inject a new saver module that works similarly to the TiddlyFox one except that it supports downloading as well as saving

Best wishes

Jeremy


在 2019年4月27日星期六 UTC+8下午9:49:39,Jeremy Ruston写道:
Hi Donmor

The "Download Empty" button in the wiki page does not work in my app. I'm not sure whether this function can be handled by injecting js, just like saving function handled by TiddlyFox or TiddlyDesktop. The button invokes an method in $:/core/modules/widgets/action-sendmessage.js, which will pass an url begins with "blob:" to the browser, but WebView won't support this scheme. I'm now finding a way to change the blob things to a base64 string so that I can decode it to a byte array. Anyone can help? :-)

Just to be clear, does ordinary saving work in your app? Have you injected a custom saver?

Downloads are handled by the same saver module mechanism that we use for saving, but with the “method” parameter to the saver passed as “download” instead of “save” or “autosave”.

Perhaps you can share some more details of how your app is working at the moment?

Best wishes

Jeremy




-- 
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 tiddly...@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/c32330c5-74a7-4aad-9d3f-cee8a11eda6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
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.

donmor3000

unread,
May 7, 2019, 3:06:32 AM5/7/19
to TiddlyWikiDev
Thanks a lot! I managed to enable the green button, though it fails if the tiddler in the button is changed.
BTW what kind of public license should I use with my app? Is it OK to use GPLv2? Here's my git url: https://github.com/donmor/Tiddloid

Jeremy Ruston

unread,
May 11, 2019, 12:36:57 PM5/11/19
to TiddlyWikiDev
Hi Donmor

Thanks a lot! I managed to enable the green button, though it fails if the tiddler in the button is changed.

Can you show the relevant code?

BTW what kind of public license should I use with my app? Is it OK to use GPLv2? Here's my git url: https://github.com/donmor/Tiddloid

Yes, but I personally favour BSD because it places fewer obligations on the user and thus improves adoption.

Best wishes

Jeremy


--
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.

donmor3000

unread,
May 12, 2019, 10:08:34 AM5/12/19
to TiddlyWikiDev
<$button class="tc-btn-big-green">
<$action-sendmessage $message="tm-download-file" $param="$:/editions/tw5.com/download-empty" filename="empty.html"/>
Download Empty {{$:/core/images/save-button}}
</$button>
I replaced the param with another tiddler containing binary and it doesn't work.


在 2019年5月12日星期日 UTC+8上午12:36:57,Jeremy Ruston写道:
Hi Donmor

Thanks a lot! I managed to enable the green button, though it fails if the tiddler in the button is changed.

Can you show the relevant code?

BTW what kind of public license should I use with my app? Is it OK to use GPLv2? Here's my git url: https://github.com/donmor/Tiddloid

Yes, but I personally favour BSD because it places fewer obligations on the user and thus improves adoption.

Best wishes

Jeremy


--
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 tiddly...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages