Node.js Plugins

Hi,

I’ve been wanting to use the node.js version of tW. specifically, I want to put it on a server, and do things like the following: if I have people Tiddlers, there’s a birthday field for all of them, and today’s someone’s birthday, I should get a notification about that sent by the server.

to that end, I was curious if there was a facility for plugins running in the tiddlywiki commandline process that could access filters/widgets/etc. Basically, what I want to have is plugins which run in the node.js context (rather than the web browser context, when the wiki webpage is loaded), and have them be able to extract information from the wiki so I can do things with that information. Is anything like that possible?

thanks

Hi @wiresong and welcome to the TiddlyWiki community.

If loaded into a Node.js wiki correctly, plugins run both on the server and in the browser. If a plugin only works on one platform or the other, it must check $tw.browser and/or $tw.node to disable itself at runtime.

(By “loaded correctly”, I mean that the plugin must be loaded via the tiddlywiki.info file, or via the plugins subfolder of the wiki folder, as covered in the documentation).

I think the AWS plugin may be a reasonable template for experiments. Although some of its functionality does actually run on the client, it includes some Node.js-only custom commands:

Do outline more of what you’re trying to do and we may be able to point you to better examples.

2 Likes

Hi Jeremy,

thanks for the response. the AWS plugin is actually very useful; I think I can make something with this.

My basic idea was to have notifications for birthdays. Suppose I have a collection of people tiddlers, with a field which specifies their birthday. Ideally, how a plugin would work is this: every day, it filters for people tiddlers, extracts the birthday field for each, and if someone had their birthday that day, it would send me a notification (using Pushover, whatever, it’s an implementation detail).

this is just a representative example, though. The basic idea is to have code that can extract different bits of information from the wiki, and can send me notifications about it (imagine a pre-made schedule for the day, based on task priorities, etc).

I think commands would suffice for this, but does the nodejs server have some timing mechanism I can use? in the browser I’d just use setInterval or something to trigger my code every day, but I’m unsure if there is an equivalent for the server. Otherwise my design would be just to have a command that exposes the requisite information, and I’d write another small program that uses that data.