1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Added support for plugins in the wiki directory

This commit is contained in:
Jeremy Ruston 2012-05-04 18:24:54 +01:00
parent 6b39ce10d0
commit afc4824307
4 changed files with 35 additions and 12 deletions

View File

@ -51,7 +51,8 @@ $tw.config = $tw.config || {};
// Constants
$tw.config.root = $tw.config.root || "$:"; // Root for module titles (eg, "$:/kernel/boot.js")
$tw.config.moduleSubDir = $tw.config.moduleSubDir || "./modules";
$tw.config.bootModuleSubDir = $tw.config.bootModuleSubDir || "./modules";
$tw.config.wikiPluginsSubDir = $tw.config.wikiPluginsSubDir || "./plugins";
// File extensions
$tw.config.fileExtensions = {
@ -549,6 +550,7 @@ Load all the plugins from the plugins directory
$tw.plugins.loadPlugins = function(filepath,basetitle,excludeRegExp) {
basetitle = basetitle || "$:/plugins";
excludeRegExp = excludeRegExp || /^\.DS_Store$|.meta$/;
if(path.existsSync(filepath)) {
var stat = fs.statSync(filepath);
if(stat.isDirectory()) {
var files = fs.readdirSync(filepath);
@ -562,6 +564,7 @@ $tw.plugins.loadPlugins = function(filepath,basetitle,excludeRegExp) {
$tw.plugins.loadTiddlersFromFile(filepath,basetitle);
}
}
}
/*
Execute the module named 'moduleName'. The name can optionally be relative to the module named 'moduleRoot'
@ -599,7 +602,10 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
}
// Load plugins from the plugins directory
$tw.plugins.loadPlugins(path.resolve($tw.boot.bootPath,$tw.config.moduleSubDir));
$tw.plugins.loadPlugins(path.resolve($tw.boot.bootPath,$tw.config.bootModuleSubDir));
// Load any plugins in the wiki plugins directory
$tw.plugins.loadPlugins(require("path").resolve($tw.boot.wikiPath,$tw.config.wikiPluginsSubDir));
// End of if(!$tw.isBrowser)
}

View File

@ -13,7 +13,6 @@ This is the main application logic for both the client and server
exports.startup = function() {
var modules,n,m,f;
// Set up additional global objects
$tw.plugins.applyMethods("global",$tw);
// Wire up plugin modules

View File

@ -0,0 +1,15 @@
/*\
title: $:/tiddlywiki/plugins/demoplugin/demoplugin.js
type: application/javascript
module-type: demo
A demo plugin
\*/
(function(){
/*jslint node: true, browser: true */
"use strict";
})();

View File

@ -8,3 +8,6 @@ shadow: shadows/templates/*.tid
shadow: shadows/tiddlycss/*.tid
#jslib: lib/jquery.js
#jslib: lib/bootstrap/js/bootstrap.js
pluginmodule: plugins/*.js
pluginmodule: plugins/demoplugin/*.js