Moving a tiddlywiki to nodejs

Hi tiddlywiki-ers

I wonder if there is a clean way to export a single html tiddlywiki to multiple tiddler files for use with nodejs?

Many thanks

M

What do you mean by “clean way”?

Hi, it seems as though I could export the tiddlers manually to .tid files but I wondered if there was a plugin (or a command-line tool) that would do this, thanks, M

You need to install the official plugin $:/plugins/tiddlywiki/jszip, then create a new tiddler and save the following into it.

\define renderContent(filter,filename)
  <$action-sendmessage $message="tm-zip-create" $param="$:/state/ZipTiddler"/>
  <$list filter="$filter$">
    <$action-sendmessage $message="tm-zip-render-file" $param="$:/state/ZipTiddler" filename={{{ [<currentTiddler>slugify[]addsuffix[.tid]] }}} tiddler=<<currentTiddler>> template="$:/core/templates/tid-tiddler"/>
  </$list>
  <$action-sendmessage $message="tm-zip-download" $param="$:/state/ZipTiddler" filename="$filename$.zip"/>
\end

<$button actions=<<renderContent filter:"[tags[]!is[system]sort[title]]" filename:"tiddlers">>>
  Export as Zip
</$button>

You can change the filters inside and the filename of the downloaded file. If you need this operation often, you can wrap it into a macro and use it.

Source: https://groups.google.com/g/tiddlywiki/c/5NhT_i1NUxA/m/2a0ttv2SAQAJ

1 Like

a command-line tool

After installing tiddlywiki via npm as explained here https://tiddlywiki.com/static/Installing%20TiddlyWiki%20on%20Node.js.html and creating a new empty NodeJS wiki with

$ tiddlywiki newwiki --init server

you can import a single file wiki like this;

$ tiddlywiki newwiki --load path/to/file.html
3 Likes

The savewikifolder command does a bit more: it creates a complete wiki folder ready to be used, and also deals correctly with plugins and other details. For example:

tiddlywiki --load ./mywiki.html --savewikifolder ./mywikifolder
6 Likes

Hi, thanks @jeremyruston, this is a good solution. I found that I needed to copy a tiddlywiki.info file from another tiddlywiki instance otherwise the server started with errors:

┌──(moonfish㉿localhost)-[~/storage/shared]
└─$ tiddlywiki  playwiki --listen                           

Warning: Plugin(s) required for client-server operation are missing.

"$:/plugins/tiddlywiki/filesystem", "$:/plugins/tiddlywiki/tiddlyweb"

Serving on http://127.0.0.1:8080

Many thanks, M

This app is easy way of using node js wikis with option to import single file wikis

2 Likes

You can add the plugins to a ‘plugins’ section of the generated tiddlywiki.info file:

"plugins": [
	"tiddlywiki/filesystem",
	"tiddlywiki/tiddlyweb"
],

1 Like

There’s always something new to learn!

Somehow I never noticed this. I’ve been doing

mkdir mywiki
tiddlywiki mywiki --init server
tiddlywiki mywiki --load ./path/to/static/wiki.html

It works fine and has not been at all fiddly, but that one-liner is much nicer!

Thanks!

1 Like

lol, I’ve always just created a new server wiki and then imported my old html. Fun to know there’s another way!

1 Like