From feab75a6d1723cd6db5912b2902f0ec33c550fb6 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Fri, 24 May 2019 12:06:11 +0100 Subject: [PATCH] Add support for preloading plugins by path instead of name --- boot/boot.js | 15 +++++++++++---- .../nodejs/Using TiddlyWiki on Node.js.tid | 7 ++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index fada4014d..0f9aabd2b 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -2044,10 +2044,17 @@ $tw.loadTiddlersNode = function() { $tw.wiki.addTiddler($tw.loadPluginFolder($tw.boot.corePath)); // Load any extra plugins $tw.utils.each($tw.boot.extraPlugins,function(name) { - var parts = name.split("/"), - type = parts[0]; - if(parts.length === 3 && ["plugins","themes","languages"].indexOf(type) !== -1) { - $tw.loadPlugins([parts[1] + "/" + parts[2]],$tw.config[type + "Path"],$tw.config[type + "EnvVar"]); + if(name.charAt(0) === "+") { // Relative path to plugin + var pluginFields = $tw.loadPluginFolder(name.substring(1));; + if(pluginFields) { + $tw.wiki.addTiddler(pluginFields); + } + } else { + var parts = name.split("/"), + type = parts[0]; + if(parts.length === 3 && ["plugins","themes","languages"].indexOf(type) !== -1) { + $tw.loadPlugins([parts[1] + "/" + parts[2]],$tw.config[type + "Path"],$tw.config[type + "EnvVar"]); + } } }); // Load the tiddlers from the wiki directory diff --git a/editions/tw5.com/tiddlers/nodejs/Using TiddlyWiki on Node.js.tid b/editions/tw5.com/tiddlers/nodejs/Using TiddlyWiki on Node.js.tid index e76bb68e5..577cdb016 100644 --- a/editions/tw5.com/tiddlers/nodejs/Using TiddlyWiki on Node.js.tid +++ b/editions/tw5.com/tiddlers/nodejs/Using TiddlyWiki on Node.js.tid @@ -1,5 +1,5 @@ created: 20131219100520659 -modified: 20190412170813209 +modified: $tw.loadPluginFolder(name.substring(1)); tags: [[TiddlyWiki on Node.js]] title: Using TiddlyWiki on Node.js type: text/vnd.tiddlywiki @@ -14,14 +14,14 @@ tiddlywiki --verbose --load mywiki.html --rendertiddler ReadMe ./readme.html Running `tiddlywiki` from the command line boots the TiddlyWiki kernel, loads the core plugins and establishes an empty wiki store. It then sequentially processes the command line arguments from left to right. The arguments are separated with spaces. -<<.from-version "5.1.20">> First, there can be zero or more plugin references identified by the prefix `+`. These plugins are loaded in addition to any specified in the [[TiddlyWikiFolder|TiddlyWikiFolders]]. +<<.from-version "5.1.20">> First, there can be zero or more plugin references identified by the prefix `+` for plugin names or `++` for a path to a plugin folder. These plugins are loaded in addition to any specified in the [[TiddlyWikiFolder|TiddlyWikiFolders]]. The next argument is the optional path to the [[TiddlyWikiFolder|TiddlyWikiFolders]] to be loaded. If not present, then the current directory is used. The commands and their individual arguments follow, each command being identified by the prefix `--`. ``` -tiddlywiki [+] [] [-- [[,]]] +tiddlywiki [+ | ++] [] [-- [[,]]] ``` For example: @@ -29,6 +29,7 @@ For example: ``` tiddlywiki --version tiddlywiki +plugins/tiddlywiki/filesystem +plugins/tiddlywiki/tiddlyweb mywiki --listen +tiddlywiki ++./mygreatplugin mywiki --listen ``` <<.from-version "5.1.18">> Commands such as the ListenCommand that support large numbers of parameters can use NamedCommandParameters to make things less unwieldy. For example: