[TW5] NodeJS beyond simply serving tiddlywikis

492 views
Skip to first unread message

TonyM

unread,
Oct 6, 2017, 10:06:36 PM10/6/17
to TiddlyWiki
Folks,

Sorry about the narrative approach to this Question, it is in part because I am still climbing the TW5 learning curve hill/mountain. It relates to more advanced uses of NodeJS, but not core or plugin development (necessarily).

Background
I have implemented most tiddlywiki Hosting platforms as I learn more and Prepare for Firefox 57. I have NodeJS running on my Windows Desktop, My Synology NAS, My Mac Mini, Android phone and tablet. all Great stuff. TiddlyServer also allows me "serve" both TiddlyWiki files (including those I can also host through ISS WebDav, and Node Installs off the same address and Port.

Now I indend to migrate a 17Mb TWC into multiple TW5's, build my own plugins (later), Tiddler Bundles, TiddlyWIki Solutions and editions.

I have a lot of ideas so if someone wants an interesting project just ask.

I have done a rudimentary search and not found any documentation for using the multi-file tiddler structure of Node JS such that it may be able to support me on this journey into tiddlywiki as an environment, and even then what I find documentation is more about contributing to the core, or serious plugin development, something I hope to do one day, but I know my limitations. For now I want to see how I can exploit the NodeJS solution to help manage a complex environment.

I have explored and continue to explore drag and drop, import export, bundles and building (rudimentary) plugins. However I have now a multitude of File based tiddlywikis and there are management issues. In fact some of the solutions I plan to develop relate to managing multiple file based tiddlywikis. But I expect NodeJS may help me.

The Question(s)

  • Can anyone point me to some resources on using NodeJS in more sophisticated ways?
  • Is what I am thinking possible?
    1. Can I create a set of structured folders that NodeJS will search to build TiddlyWiki editions, such that I can place shared tiddlers or plugins in a one or more locations that some editions use and not others?
    2. Imagine for example I have say project related TiddlyWikis and Task Management TiddlyWikis, could both point to plugins and Tiddlers they Share, but other editions do not?
    3. or a Folder of Snipit tiddlers the Editor uses that all Wikis can access,
    4. if I updated a plugin or shared tiddler could the different wikis now all see the update?
    5. Using this method could I have a tiddler store of Tiddlers that acted like a message queue that other wikis could use and respond to?
    6. Could I have a library of plugins I collect that I can selectively refer to?
Because I do not know what I don't know, this Question is very broad, perhaps once I have a little more detail I can start new threads on particular methods.

Please note: I have a very systematic way of looking at things and love re-usability, de-duplication, maximising possibilities and minimsing compromise.

Thank in Advance
Tony

Jed Carty

unread,
Oct 7, 2017, 4:25:26 AM10/7/17
to TiddlyWiki
I am working on setting up a system similar to what you are describing.

As far as resources, I am not sure where to point you as most of what I have figured out I have done by trial and error.

In order:

1) Yes, TiddlyServer makes this pretty straight forward
2) Yes, using tiddlywiki.info files lets you define which plugins to have in a wiki
3) Maybe, I think so. I am trying to figure this part out myself.
4) Yes, but you probably have to restart the server after you make updates to a plugin
5) I don't know, that is a good thing to look into. I do have some other methods for inter-wiki communication that may work better.
6) Yes, this is closely related to 2

Sorry for the very brief answers, I am hoping to write up how to set everything up nicely once I get it worked out myself.

TonyM

unread,
Oct 7, 2017, 7:48:47 PM10/7/17
to TiddlyWiki
Jed,

Thanks for the info, perhaps we can build an informal documentation together.

Surely others here have gone down this path already.

Regards
Tony

Arlen Beiler

unread,
Oct 7, 2017, 11:19:11 PM10/7/17
to TiddlyWiki
I can partly answer one question. You can load tiddlers from other wikis. This is separate from how you load plugins. 

Tiddlywiki.info files can reference other data folders and tiddlywiki can import those tiddlers as well. I kind of wish it would import them as a plugin, though. It just imports them straight, although there is a read-only option to prevent changes from accidentally syncing to the master wiki. The tw5.com editions do this, for example. That's an example of one that is not readonly.

The code is in boot.js if you are so inclined. It is in the if($tw.node) section. Search for tiddlywiki.info or loadWikiFolder, I think. Just thought I'd throw that in in case any of you are serious coders. I hope it's documented on tiddlywiki.com, but I don't know. I know there is something if you search for "node".

Hope that helps. It's off the top of my head before I roll over and go to sleep, so sorry if I'm not much help :). In order for changes to propagate from the parent wiki, you have to reload the child wiki (adding ?reload=true to the URL in TiddlyServer, or just restarting it). I use it in my own TiddlyServer setup.

The tiddlywiki.info file also let's you specify the plugins and themes for each edition (aka data folder).  

Arlen 

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d3548cbb-580f-4bcb-85d9-5e64c73eed7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jed Carty

unread,
Oct 8, 2017, 7:11:55 AM10/8/17
to TiddlyWiki
I got it to load tiddlers from another wiki, that part is pretty straight forward. I haven't gotten external images to work but it is easy to use .meta files to add external media to an otherwise blank wiki and then include that in another wiki.

Jed Carty

unread,
Oct 8, 2017, 10:11:46 AM10/8/17
to TiddlyWiki
I am going to try and write this up somewhere nicer with instructions that hopefully won't require much knowledge.

For those of you who are comfortable with node here is my setup:

I am using the node version of tiddlywiki and I have it installed globally, and I have TiddlyServer cloned from the GitHub repo.

For plugins I have a folder that holds all my plugins, in my case this is /home/inmysocks/TiddlyWiki/Plugins, this is set up the same as the normal plugin folders are, so each plugin.info is in a sub-folder like 'OokTech/BookMarks' and the tiddlers are organised normally from there.

I have another folder that holds all my wikis, /home/inmysocks/TiddlyWiki/Wikis, then each wiki gets a sub folder there that holds the tiddlywiki.info file and has the tiddlers subfolder like normal.

Making everything play together nicely comes from the setup files, settings.json for TiddlyServer and the various tiddlywiki.info files for each wiki. I am hoping to make a utility that will help automate their creation but for now it is all manual.

For TiddlyServer I have the tree organised to point to all of the wiki folders like normal, there isn't anything special that I do in settings.json. To start TiddlyServer I have a bash script (I am not sure what you would use in windows, it has been a long time since I used windows, do .bat files still exist?). Here is the bash script I use:

#!/bin/bash

export TIDDLYWIKI_PLUGIN_PATH="/home/inmysocks/TiddlyWiki/Plugins"
cd
~/TiddlyServer
node server
.js
pause

Then in each tiddlywiki.info file for plugins I can just list the plugins like normal, like "/OokTech/Bookmarks" for my bookmarks plugin located at "/home/inmysocks/TiddlyWiki/Plugins/OokTech/Bookmarks", and this works for any of the wikis served by TiddlyServer regardless of where they are on my computer.

Sharing tiddlers between different wikis takes a bit more setup.

To make tiddlers from one wiki available in another wiki you edit the tiddlywiki.info file for the wiki you want the tiddlers in. Add an includeWikis section to the tiddlywiki.info file like the plugin section. Here is an example:

"includeWikis":[{
"path": "/home/inmysocks/TiddlyWiki/Wikis/WikiName",
"read-only": "true"
}]

I haven't found a way to selectively include tiddlers in another wiki, so I found it best to have a bunch of small single purpose wikis that pull in tiddlers from others instead of having a few big ones. TiddlyServer makes that easy.

One way to have wikis that are just specific bits of content is to create the tiddlers in one wiki and save them to another one using $:/config/FileSystemPaths, this is made simpler by having the different wikis grouped together like I do. Then in the $:/config/FileSystemPaths tiddler in one wiki you can put a filter like 

[tag[Other Wiki]addprefix[../../Other Wiki/tiddlers/]]

which will have any tiddlers tagged with 'Other Wiki' and save them in the tiddlers folder for another wiki.

One example of how this can be useful is having a wiki that is used for entering and saving bookmarks and then each bookmark tiddler can be saved to another wiki folder which can then be included as read-only in multiple other wikis. This can be used to have something like multi-user wikis. The downside is that the server needs to be restarted in order to update with the new files. Luckly adding ?reload=true to the end of the url when using TiddlyServer.

This can address 1, 2, 3, 4 (with reloading) and 6

I think that 5 would require changes to the server side.

TonyM

unread,
Oct 8, 2017, 6:45:58 PM10/8/17
to TiddlyWiki
Jed,

Thanks Jed (PS I have a Nephew Jed) so much for that comprehensive answer, you have thrown a lot of light on this, By confirming some of my speculation you help me proceed knowing something is achievable, not me just dreaming again. It is great to get an overview from someone who has done it, and gets what I am looking for.

My Long term goal is to provide a resource for the tiddlywiki enthusiast and developer to build an environment that helps manage a number of tiddlywiki instances and shared tiddlers and Plugins. But for myself to start with.

On "5" Using this method could I have a tiddler store of Tiddlers that acted like a message queue that other wikis could use and respond to?

It looks like this is already workable except requiring the reload, I would love to hear some of your ideas on inter-wiki communication. It seems to me folders with JSON or TID files (Bundles included) with fixed names may be enough with the development of some in wiki ways to load them, then use tags or fields to identify tiddlers destined for the reading wiki and ignore the rest. I already have a skeleton of a process that includes identifying the source wiki (less clear to me in a NodeJS implementation you have outlined).

I will collate your notes (others in this thread) and my own to build a resource that remains at the "usage and configuration level", and perhaps separately for the advanced development process.

Ultimately I plan to publish this at http://tiddlywiki.psat.com.au

Thanks once again
Tony

Lin Onetwo

unread,
Apr 13, 2020, 11:14:02 AM4/13/20
to TiddlyWiki
Hi, Tony

I achieve "use several location to store tiddlers" today.

I'm now saving my private tiddlers in a folder A, which is a git repo that can push to a Github private repo.

And some another tiddlers is in another folder B, which will push to another public github repo.

I use https://tiddlywiki.com/#Customising%20Tiddler%20File%20Naming to place tiddlers tagged with a "private" tag to be store to the folder A. See https://wiki.onetwo.ren/#%24%3A%2Fconfig%2FFileSystemPaths for example.

在 2017年10月7日星期六 UTC+8上午10:06:36,TonyM写道:
Reply all
Reply to author
Forward
0 new messages