diff --git a/boot/boot.js b/boot/boot.js index c1356bc32..bdd338c1a 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -1492,6 +1492,39 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) { } }; +/* +name: Name of the plugin to load +paths: array of file paths to search for it +*/ +$tw.loadPlugin = function(name,paths) { + var pathIndex = 0; + do { + var pluginFields = $tw.loadPluginFolder(path.resolve(paths[pathIndex],"./" + name)); + if(pluginFields) { + $tw.wiki.addTiddler(pluginFields); + return; + } + } while(++pathIndex < paths.length); +}; + +/* +plugins: Array of names of plugins (eg, "tiddlywiki/filesystemadaptor") +libraryPath: Path of library folder for these plugins (relative to core path) +envVar: Environment variable name for these plugins +*/ +$tw.loadPlugins = function(plugins,libraryPath,envVar) { + if(plugins) { + var pluginPaths = [path.resolve($tw.boot.corePath,libraryPath)], + env = process.env[envVar]; + if(env) { + Array.prototype.push.apply(pluginPaths,env.split(":")); + } + for(var t=0; t