Macro for exporting multiple tiddlers as zip file

59 views
Skip to first unread message

Mark S.

unread,
Jul 8, 2020, 7:04:30 PM7/8/20
to TiddlyWiki
I was thinking of export options for NoteWritey, when I remembered that TW 5.1.23 will have a new zip plugin update. In fact, it actually works now in 5.1.22 if you drag and drop  in the jszip plugin from the prerelease. Well, I think it does.

As you may know, when you try to export multiple tiddlers in the "tid" format, you only get one tiddler as output. With the following code, you can export multiple tiddlers packed into a zip file which you can then extract using your favorite zip manager.

I'm sure over time people will come up with much more clever uses for the zip plugin, but in the meantime, here's a first stab. The macro takes a filter, and output name, and title for the button.


\define ziptid(filter: "[all[tiddlers]]" , output: "tiddlers.zip" , title:"Make Zip")
<$button> $title$
<$vars ziptid="$:/temp/zip">
<$action-sendmessage $message="tm-zip-create" $param=<<ziptid>>/>

<$vars sys="$:/" >
<$list filter="""
$filter$""">
<$vars fname={{{[<currentTiddler>split<sys>join[_]split[/]join[_]addsuffix[.tid]] }}} >
<$action-sendmessage $message="
tm-zip-render-file" $param=<<ziptid>> filename=<<fname>> tiddler=<<currentTiddler>> template="$:/core/templates/tid-tiddler" mode="block" output="text/plain"/>
</$vars>
</$list>
</$vars>
<$action-sendmessage $message="
tm-zip-download" $param=<<ziptid>> filename="""$output$"""/>

</$vars>
</$button>
\end

<<ziptid "
[tag[Learning]]" "Learning.zip" "Zip Learning">>


TW Tones

unread,
Jul 8, 2020, 8:03:17 PM7/8/20
to TiddlyWiki
Mark,

Thanks for sharing. 

This solution of yours works well, I was playing with the zip function as well, It has a lot of potential.
  • Its easier to email zips than html etc...
  • On a read only wiki a user undertakes a survey and on completion presses a button to zip their answers which they email to the people undertaking the survey
  • A special import process could collate multiple responses rather than overwrite them.
  • Ideally we could click to email with the zip attached without download.
I think a Zip exporter would also make sense but it exposes a gap, you can export the current tiddler, OR export all from the PageControl Export button, but no buttons allow us to select or provide additional information before actioning them.So its hard to pass a filter into them. The only choice is to go to Advanced Search Filter.

Input accepting buttons would be a nice little project.

Thanks again for this.
Regards
Tony
Reply all
Reply to author
Forward
0 new messages