Embed a ZIP for download?

368 views
Skip to first unread message

Stephan Hradek

unread,
Feb 23, 2015, 2:14:17 AM2/23/15
to tiddl...@googlegroups.com
I was wondering how this could be achieved.

It seems to be possible to import a zip file into a TiddlyWiki. But how would I make it downloadable?

The background: I've created a small "application" (just around 8KB as a zip) I want to make available for download. At the same time I want to provide the documentation on the site and thought that TiddlyWiki would be a good tool for this documentation.

PMario

unread,
Feb 23, 2015, 2:54:49 AM2/23/15
to tiddl...@googlegroups.com
So you want to distribute the application within the documentation?
If you open the docs, it should be possible to say. save the zip from a file tw. right?
-m

Stephan Hradek

unread,
Feb 23, 2015, 3:13:17 AM2/23/15
to tiddl...@googlegroups.com
Am Montag, 23. Februar 2015 08:54:49 UTC+1 schrieb PMario:
So you want to distribute the application within the documentation?

I want to host the TiddlyWiki on (e.g.) tiddlyspot. As a sideefect yes, the documentation would contain the zip in a "saveable" form.

PMario

unread,
Feb 23, 2015, 3:31:22 AM2/23/15
to tiddl...@googlegroups.com
If you use eg: github to host 2 different files, you can use a simple download link in TW and you don't have the mess with converting zip to base64 and back.

If you use the github release feature [1][2], they will create a zip with your program and the docs contained in a single zip file. So you get free hosting and free release processing, free issue handling and free source control.

have fun!
-mario

[1] https://github.com/Jermolene/TiddlyWiki5/releases
[2] https://help.github.com/articles/creating-releases/

Stephan Hradek

unread,
Feb 23, 2015, 3:36:26 AM2/23/15
to tiddl...@googlegroups.com


Am Montag, 23. Februar 2015 09:31:22 UTC+1 schrieb PMario:
If you use eg: github to host 2 different files, you can use a simple download link in TW

At the moment I have difficulties using GIT. My browsers are no longer supported by them and the commandline also is very reluctant :(



and you don't have the mess with converting zip to base64 and back.

But this seems to happen automatically when I drop a zip onto my TiddlyWiki.

Andreas Hahn

unread,
Feb 23, 2015, 3:48:56 AM2/23/15
to tiddl...@googlegroups.com
Hey Stephan,

at the moment TW is incapable of handling binary files (i.e. zip files).
Unless you want to make big changes to various parts of the core, I
suggest you do the following:

1. Convert your .zip into a base64 string
2. Place it inside a plain text tiddler (for reference)
3. Place a specially crafted link pointing to the url:
"data:application/zip;base64,<BASE64CODE>"

That should initiate a file dowload onClick is is currently the easiest
way of doing it. Of course you can imagine writing a widget that reads
the tiddler and crafts such a link,
clicks it and removes the link (that is how the download saver does it),
but you can manually craft the link as well.

/Andreas

Stephan Hradek

unread,
Feb 23, 2015, 4:01:21 AM2/23/15
to tiddl...@googlegroups.com
Thanks Andreas - So Mario is right with his hint that I need to convert to base 64.

Andreas Hahn

unread,
Feb 23, 2015, 4:06:00 AM2/23/15
to tiddl...@googlegroups.com
Yes, it is unfortunately it is the only way to do it, without editing core source code.

I btw use powershell with a function I found online[1], that makes it kinda easy to do (since it even copies it to the clipboard).

/Andreas

[1] https://mnaoumov.wordpress.com/2013/06/20/how-to-reach-unreachable-or-copy-files-to-rdp/


Am 23.02.2015 um 10:01 schrieb Stephan Hradek:
Thanks Andreas - So Mario is right with his hint that I need to convert to base 64.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Stephan Hradek

unread,
Feb 23, 2015, 4:35:57 AM2/23/15
to tiddl...@googlegroups.com


Am Montag, 23. Februar 2015 10:06:00 UTC+1 schrieb Andreas Hahn:
Yes, it is unfortunately it is the only way to do it, without editing core source code.

I btw use powershell with a function I found online[1], that makes it kinda easy to do (since it even copies it to the clipboard).

I think I have something similar for jEdit.

Jeremy Ruston

unread,
Feb 23, 2015, 5:58:26 AM2/23/15
to TiddlyWiki
Hi Stephan

Just to be clear, TW5 does indeed support binary tiddlers (images being a good example). You can drag a ZIP file into TW and the right thing happens. The limitation at the moment is that there's no built-in way to download the file afterwards. You can use something like the following code to create a download link for a binary tiddler:

\define download-inner(title)
<a href=<<makedatauri """$(text)$""" """$(type)$""">> download="download">Download "$title$"</a>
\end

\define download(title)
<$set name="type" value={{$title$!!type}}>
<$set name="text" value={{$title$!!text}}>
<<download-inner "$title$">>
</$set>
</$set>
\end

<<download "Motovun Jack.pdf.zip">>

However, the .ZIP file extension needs to be registered in boot.js before this will work:

$tw.utils.registerFileType("application/zip","base64",".zip");

I've commited ZIP support here:


Best wishes

Jeremy.






--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.



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

Andreas Hahn

unread,
Feb 23, 2015, 6:15:14 AM2/23/15
to tiddl...@googlegroups.com
Hi Jeremy,

thanks for the change in boot.js. I have a question though:

Wouldn't it be possible to handle all unkown MIME types as binary data ?
That would ensure that people could for example embed word or excel files or a bunch of other file types (at the expense of some txt/ascii based formats). I am not sure if that is a good idea, or if that is possible to implement since most other systems seem to access contentTypeInfo as hashmap.

/Andreas

Jeremy Ruston

unread,
Feb 23, 2015, 6:21:19 AM2/23/15
to TiddlyWiki
Hi Andreas

Wouldn't it be possible to handle all unkown MIME types as binary data ?
That would ensure that people could for example embed word or excel files or a bunch of other file types (at the expense of some txt/ascii based formats). I am not sure if that is a good idea, or if that is possible to implement since most other systems seem to access contentTypeInfo as hashmap.

Interesting. I think you're right, defaulting to base64 format might well be better. As you say, the downside would only be that unknown text formats would be unnecessarily base64 encoded. I've made a ticket:


I've also made a ticket for adding a download link for binary tiddlers:


Best wishes

Jeremy

PMario

unread,
Feb 23, 2015, 9:46:54 AM2/23/15
to tiddl...@googlegroups.com
On Monday, February 23, 2015 at 12:15:14 PM UTC+1, Andreas Hahn wrote:
Wouldn't it be possible to handle all unkown MIME types as binary data ?

I think, this would be a good idea, if users wouldn't use it in the wrong way, which will cause support on our side.
 
That would ensure that people could for example embed word or excel files or a bunch of other file types (at the expense of some txt/ascii based formats). I am not sure if that is a good idea,

While embedding unknown data as base64 is ok. Including an uncompressed word or excel file into a html document imo is an incredibly bad idea. So I vote for a  zip, gzip only approach.

-mario

PMario

unread,
Feb 23, 2015, 9:49:48 AM2/23/15
to tiddl...@googlegroups.com
On Monday, February 23, 2015 at 10:01:21 AM UTC+1, Stephan Hradek wrote:
Thanks Andreas - So Mario is right with his hint that I need to convert to base 64.

Ouch! Any doubt about this? :))
-m
Reply all
Reply to author
Forward
0 new messages