Installing exotic plugins on node.js

The official doc on installaing plugins on node.js is not very clear for plugins not in the official plugin library.

The main problem is how should we GET the plugin? I will take only one example because that’s all my need and haven’t tried anything else. This is TWaddle/LeftBar plugin. It is only available on a tw online as a plugin to drag and drop… not for node! And as for the doc, I’m not sure what to do after that.

So I’ll explain what I’ve done to get it and what how is now the setup.

I have this plugin insalled on a single file tw so from there I exported it via the export menu into a json file. I just use the import tool on the node js then edited my onwn menu and here it is, it is functionnal. I stopped the server and restarted it: everything seems OK.

As for the setup:

  • the tiddliwiki.info file has not been altered, there is no mention relative to this plugin,
  • there is no plugins subfolder,
  • the plugins files are directly into the tiddlers subfolder with name beqinning by $__plugins__TWaddle_LeftBar (I have not played with naming of tiddler files so far).

I can’t see that as described in the tw doc.

So I beg the experts around here for their help! Thanks in advance!

I struggled with this myself recently. The existing documentation is confusing and it didn’t work at all for me until I figured it out by trial and error.

I’m not an expert at this but will write up what has worked for me.

I don’t think your install method is a problem, but may or may not be harder to upgrade? Not sure.

@boris as for the upgrade, I will see as soon as 5.20 is out… not far away!

I shall try --load to see that it’s all the same, but automatically doable.

@jypre my experience is mostly with node in bob.exe, but when you drop a plugin on a wiki it gets installed as a tiddler in that instance of tiddlywiki. If you follow the other instructions, it gets installed in the server and can become available to all wikis in the server. If you are only running one tiddlywiki off node, you would not see any practical difference.

Personally most of my wikis under bob server different purposes and have different plugin combinations so I do not bother to use the server plugin install. As a result I do not know how, but the documentation it not friendly - I would improve it if I did not think it was hard to find the definitive guide that includes explanations rather than only instructions.

Yes your way works.

Some people hope json can work in plugins folder: https://github.com/Jermolene/TiddlyWiki5/issues/2230
We also hope json plugin can be auto expand to plugins folder, but this is not implemented yet https://github.com/Jermolene/TiddlyWiki5/issues/3102#issuecomment-854425469

Hi @linonetwo jus to add that the new --savewikifolder command does unpack plugins into the plugins folder.

Wow, that means I can use the community plugin library to install/update plugins with a single click, and auto-expand them into my plugins folder!

While tw might not support this out of box, I may implement this in TiddlyGit or try PR it into the core if you’d like.

Looking at the help for savewikifolder, I see:

A common usage is to convert a TiddlyWiki HTML file into a wiki folder:

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

S I try just that with mywiki.html as my full tw5 file. It does not work. It says that mywiki.html is void of any tiddlers!

I’m back on this topic because I’ve encountered a problem with the LeftBar plugin. It happens on a brand new empty server edition on node.js (linux arm64, run through docker) where:

  • I create a $:/config/FileSystemPaths tiddlerwhose sole content is [!is[system]slugify[]] (not interesting but deliberately very reduced)
  • I then quit the server and import my plugin with
tiddlywiki mywiki --load plugin.json

(I will copy plugin.json later on this message).

Now’ I start again the server. Thi sandwich icon of LeftBar is or the upper left corner. Then I click into it and the server crashes. See below:

 syncer-server-filesystem: Dispatching 'save' task: $:/plugins/TWaddle/LeftBar/temp 
node:internal/fs/utils:879
  throw new ERR_INVALID_ARG_TYPE(
  ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Object.writeFile (node:fs:2106:5)
    at Object.exports.saveTiddlerToFile ($:/core/modules/utils/filesystem.js:414:6)
    at $:/plugins/tiddlywiki/filesystem/filesystemadaptor.js:85:13
    at FileSystemAdaptor.getTiddlerFileInfo ($:/plugins/tiddlywiki/filesystem/filesystemadaptor.js:72:2)
    at FileSystemAdaptor.saveTiddler ($:/plugins/tiddlywiki/filesystem/filesystemadaptor.js:81:7)
    at SaveTiddlerTask.run ($:/core/modules/syncer.js:597:27)
    at Syncer.processTaskQueue ($:/core/modules/syncer.js:503:9)
    at Function.<anonymous> ($:/core/modules/syncer.js:90:9)
    at $tw.Wiki.exports.dispatchEvent ($:/core/modules/wiki.js:133:13)
    at $:/core/modules/wiki.js:166:10 {
  code: 'ERR_INVALID_ARG_TYPE'
}

I suppose my plugin is not correctly installed. So I was abouts to do it the proper way with --build index and the TIDDLYWIKI_PLUGIN_PATH environment variable. But there is a problem: I don’t know how to get all the individual tiddlers of the plugin. The plugin shows its shadow tiddlers, which I can export as .tid so fine. But what for the core of the tiddler, actual code?

My queston:

  • is my diagnostic of the crash correct?
  • how could I get all the file of a json file of the full plugin?
  • is there an other plugin than LeftBar that is proposing a menu on the left?

Now, my plugin.json file (9.2Kb):

[
    {
        "text": "{\n    \"tiddlers\": {\n        \"$:/plugins/TWaddle/LeftBar/Toggle\": {\n            \"text\": \"\\\\define leftbar-content()\\n<div class=\\\"leftbar-content\\\">\\n\\n{{$:/plugins/TWaddle/LeftBar/Menu}}\\n</div>\\n\\\\end\\n\\n<$list filter=\\\"[title[$:/plugins/TWaddle/LeftBar/temp]!is[tiddler]]\\\" >\\n<$button set=\\\"$:/state/LeftBar\\\" setTo=\\\"show\\\" class=\\\"tc-btn-invisible tc-image-button leftbar-toggle\\\">\\n\\t{{$:/core/images/menu-button}}\\n   \\t<$action-setfield $tiddler=\\\"$:/plugins/TWaddle/LeftBar/temp\\\"\\n\\t\\t$field=\\\"storyleft\\\"\\n        $value={{$:/themes/tiddlywiki/vanilla/metrics/storyleft}}/>\\n\\t<$action-setfield $tiddler=\\\"$:/plugins/TWaddle/LeftBar/temp\\\" \\n\\t\\t$field=\\\"storyright\\\"\\n        $value={{$:/themes/tiddlywiki/vanilla/metrics/storyright}}/>\\n    <$action-setfield $tiddler=\\\"$:/themes/tiddlywiki/vanilla/metrics/storyleft\\\" \\n\\t\\ttext=\\\"/*LeftBar*/ calc({{$:/plugins/TWaddle/LeftBar/Stylesheet!!width}} + {{$:/plugins/TWaddle/LeftBar/temp!!storyleft}})\\\" />\\n\\t<$action-setfield $tiddler=\\\"$:/themes/tiddlywiki/vanilla/metrics/storyright\\\"\\n\\t\\ttext=\\\"/*LeftBar*/ calc({{$:/plugins/TWaddle/LeftBar/temp!!storyright}} + {{$:/themes/tiddlywiki/vanilla/metrics/storyleft}})\\\"/>\\n</$button>\\n</$list>\\n\\n<$list filter=\\\"[title[$:/plugins/TWaddle/LeftBar/temp]is[tiddler]]\\\" >\\n<$button set=\\\"$:/state/LeftBar\\\" setTo=\\\"hide\\\" class=\\\"tc-btn-invisible tc-image-button leftbar-toggle\\\">\\n\\t{{$:/core/images/chevron-left}}\\n\\t<$action-setfield $tiddler=\\\"$:/themes/tiddlywiki/vanilla/metrics/storyleft\\\" \\n\\t\\ttext={{$:/plugins/TWaddle/LeftBar/temp!!storyleft}} />\\n\\t<$action-setfield $tiddler=\\\"$:/themes/tiddlywiki/vanilla/metrics/storyright\\\" \\n\\t\\ttext={{$:/plugins/TWaddle/LeftBar/temp!!storyright}} />\\n\\t<$action-deletetiddler $tiddler=\\\"$:/plugins/TWaddle/LeftBar/temp\\\"/>\\n</$button>\\n</$list>\\n\\n<$list filter=\\\"[title[$:/plugins/TWaddle/LeftBar/temp]is[tiddler]]\\\" >\\n\\t<<leftbar-content>>\\n</$list>\\n<$list filter=\\\"[title[$:/plugins/TWaddle/LeftBar/temp]!is[tiddler]]\\\" >\\n\\t<div class=\\\"leftbar-togglezone\\\">\\n\\t\\t<<leftbar-content>>\\n\\t</div>\\n</$list>\",\n            \"title\": \"$:/plugins/TWaddle/LeftBar/Toggle\",\n            \"tags\": \"$:/tags/PageTemplate\",\n            \"modifier\": \"Mat von TWaddle\",\n            \"modified\": \"20180905121252605\",\n            \"creator\": \"Mat von TWaddle\",\n            \"created\": \"20170430114950811\"\n        },\n        \"$:/plugins/TWaddle/LeftBar/Stylesheet\": {\n            \"text\": \"<pre>button.leftbar-toggle {\\n\\tposition:fixed;\\n\\tz-index: 1200;\\n\\tdisplay:{{!!display}};\\n\\ttop:0px;\\n\\tleft:0px;\\n\\tpadding:0px;\\n\\theight:3em;\\n\\twidth:2em;\\n}\\n.leftbar-toggle svg {\\n\\t<<transition \\\"fill 150ms ease-in-out\\\">>\\n\\tfill: <<colour muted-foreground>>;\\n}\\n.leftbar-toggle:hover svg {\\n\\tfill: <<colour foreground>>;\\n}\\n.leftbar-togglezone {\\n\\tposition:fixed;\\n\\tleft:0;\\n\\ttop:3em;\\n\\tmin-height:50vh;\\n\\twidth:1em;\\n}\\n.leftbar-settingstable {\\n\\tmargin:\\n\\t0 auto;\\n}\\n.leftbar-settingstable,\\n .leftbar-settingstable td {\\n\\tborder:0;\\n}\\n.leftbar-settingstable td:nth-of-type(1) {\\n\\ttext-align:right;\\n\\tvertical-align:top;\\n}\\n.leftbar-content {\\n\\tposition:{{!!position}};\\n\\tmax-width:calc(42px + {{!!width}});\\n\\tleft:0px;\\n\\ttop:3em;\\n\\tpadding:0em 10px 5px 10px;\\n\\tbackground:none;\\n\\tmin-height:50vh;\\n\\tmax-height:85vh;\\n\\toverflow-y:auto;\\n}\\n.leftbar-content .tc-tab-buttons button.tc-tab-selected {\\n\\tbackground-color: <<colour sidebar-tab-background-selected>>;\\n}\\n.leftbar-content .tc-tab-buttons button {\\n\\tbackground-color: <<colour sidebar-tab-background>>;\\n}\\n.leftbar-togglezone .leftbar-content {\\n\\tdisplay:none;\\n\\tposition:fixed;\\n}\\n.leftbar-togglezone:hover .leftbar-content {\\n\\tdisplay:{{$:/plugins/TWaddle/LeftBar/Stylesheet!!hover-to-display-as}};\\n\\tbackground:#f4f4f4;\\n\\t<<box-shadow \\\"1px 1px 5px rgba(0, 0, 0, 0.3)\\\">>\\n }\\n\\n@media (max-width: {{$:/themes/tiddlywiki/vanilla/metrics/sidebarbreakpoint}}) {\\n\\t.leftbar-content  {\\n\\t\\tdisplay:block;\\n\\t\\tbackground:#f4f4f4;\\n\\t\\t<<box-shadow \\\"1px 1px 5px rgba(0, 0, 0, 0.3)\\\">>\\n\\t\\tmax-width:90vw;\\n\\t}\\n\\tbutton.leftbar-toggle {\\n\\t\\tbackground:transparent;\\n\\t\\theight:2em;\\n\\t}\\n\\tbutton.leftbar-toggle svg {\\n\\t\\tbackground:white;\\n\\t}\\n\\tbutton.leftbar-toggle:hover {\\n\\t\\toutline:2px solid lightgray;\\n\\t}\\n}\\n</pre>\\n\",\n            \"width\": \"200px\",\n            \"type\": \"text/vnd.tiddlywiki\",\n            \"title\": \"$:/plugins/TWaddle/LeftBar/Stylesheet\",\n            \"tags\": \"$:/tags/Stylesheet\",\n            \"position\": \"fixed\",\n            \"modifier\": \"Mat von TWaddle\",\n            \"modified\": \"20180905120521378\",\n            \"hover-to-display-as\": \"block\",\n            \"display\": \"block\",\n            \"creator\": \"Mat von TWaddle\",\n            \"created\": \"20170430122213416\"\n        },\n        \"$:/plugins/TWaddle/LeftBar/readme\": {\n            \"text\": \"!!To use\\nEdit the LeftBar contents by editing $:/plugins/TWaddle/LeftBar/Menu\\n\\n!!LeftBar settings\\nAlso found under //Controlpanel> Settings> LeftBar//, unless unchecked here\\n\\n{{$:/plugins/TWaddle/LeftBar/settings}}\\n\\n@@color:silver; /// Mat von TWaddle//@@\",\n            \"title\": \"$:/plugins/TWaddle/LeftBar/readme\",\n            \"modifier\": \"Mat von TWaddle\",\n            \"modified\": \"20180426160512182\",\n            \"creator\": \"Mat von TWaddle\",\n            \"created\": \"20170501015503878\"\n        },\n        \"$:/plugins/TWaddle/LeftBar/icon\": {\n            \"text\": \"{{$:/core/images/menu-button}}\",\n            \"title\": \"$:/plugins/TWaddle/LeftBar/icon\",\n            \"tags\": \"\",\n            \"modifier\": \"Mat von TWaddle\",\n            \"modified\": \"20180426160450511\",\n            \"creator\": \"Mat von TWaddle\",\n            \"created\": \"20170502094251285\"\n        },\n        \"$:/plugins/TWaddle/LeftBar/Menu\": {\n            \"text\": \"Welcome to LeftBar!<br><br>\\nChange the content of this by editing $:/plugins/TWaddle/LeftBar/Menu<br><br> \\nYou can add tablists or whatever you want.<br><br>\\nNote also that you access the menu either by clicking the hamburger or by simply hovering (or tapping) along the left screen edge. If you don't like this behaviour, you can change it in the //Controlpanel > settings// \",\n            \"title\": \"$:/plugins/TWaddle/LeftBar/Menu\",\n            \"tags\": \"\",\n            \"modifier\": \"Mat von TWaddle\",\n            \"modified\": \"20180905122142436\",\n            \"creator\": \"Mat von TWaddle\",\n            \"created\": \"20170502091456621\"\n        },\n        \"$:/plugins/TWaddle/LeftBar/settings\": {\n            \"text\": \"<table class=\\\"leftbar-settingstable\\\">\\n<tr>\\n<td><$edit-text tiddler=\\\"$:/plugins/TWaddle/LeftBar/Stylesheet\\\" field=\\\"width\\\" size=3/></td>\\n<td>''Width'' for LeftBar</td>\\n</tr>\\n<tr>\\n<td>\\n<$checkbox tiddler=\\\"$:/plugins/TWaddle/LeftBar/Stylesheet\\\" field=\\\"display\\\" checked=\\\"block\\\" unchecked=\\\"none\\\" default=\\\"blocked\\\"/>\\n</td>\\n<td>''Toggle button'' - display in left top menu</td>\\n</tr>\\n<tr>\\n<td><$checkbox tiddler=\\\"$:/plugins/TWaddle/LeftBar/Stylesheet\\\" field=\\\"position\\\" checked=\\\"fixed\\\" unchecked=\\\"absolute\\\" default=\\\"fixed\\\"/>\\n</td>\\n<td>''Scroll vs Fix'' - behaviour when activated //via button//<br>(The //hover-activated// content is always in fixed position.)</td>\\n</tr>\\n<tr>\\n<td><$checkbox tiddler=\\\"$:/plugins/TWaddle/LeftBar/settings\\\" tag=\\\"$:/tags/ControlPanel/Settings\\\" /></td>\\n<td>''Ctrlpanel'' - show this table also in //Ctrlpanel>  Settings//</td>\\n</tr>\\n<tr>\\n<td><$checkbox tiddler=\\\"$:/plugins/TWaddle/LeftBar/Stylesheet\\\" field=\\\"hover-to-display-as\\\" checked=\\\"block\\\" unchecked=\\\"none\\\" default=\\\"block\\\"/></td>\\n<td>''Hover to display'' - enable \\\"hover window edge\\\" to display pop-out</td>\\n</tr>\\n</table>\",\n            \"title\": \"$:/plugins/TWaddle/LeftBar/settings\",\n            \"tags\": \"$:/tags/ControlPanel/Settings\",\n            \"modifier\": \"Mat von TWaddle\",\n            \"modified\": \"20180905120536003\",\n            \"list-before\": \"\",\n            \"creator\": \"Mat von TWaddle\",\n            \"created\": \"20170430123149149\",\n            \"caption\": \"LeftBar Settings\"\n        }\n    }\n}",
        "version": "2.1.4",
        "type": "application/json",
        "title": "$:/plugins/TWaddle/LeftBar",
        "plugin-type": "plugin",
        "modifier": "Mat von TWaddle",
        "modified": "20180905142308907",
        "list": "contents readme",
        "description": "LeftBar - a menu type sidebar, on the left",
        "creator": "Mat von TWaddle",
        "created": "20180905142253202",
        "core-version": ">=5.1.16",
        "author": "Mat von TWaddle"
    }
]

well, I can’get t

You have run into a bug in 5.1.23 and earlier that would crash the server trying to write a tiddler with no text field. This happens rarely, but most often when an $action-setfield widget sets a NON-text field on a non-existent tiddler (thus creating it without a text field).

The button in the plugin sets a temp tiddler’s NON-text fields, and that is when the crash is happening. I would recommend using the pre-release on node.

Thank you @joshuafontany , I shall try and report.

But in the present case, is it not first a programming problem? Surely, there should be a little more code in the tiddler of the plugin to make sure that the temp tiddler exist (create it if need be) before modifying an internal field of its?