mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Added support for plugins in the wiki directory
This commit is contained in:
parent
6b39ce10d0
commit
afc4824307
@ -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,17 +550,19 @@ Load all the plugins from the plugins directory
|
||||
$tw.plugins.loadPlugins = function(filepath,basetitle,excludeRegExp) {
|
||||
basetitle = basetitle || "$:/plugins";
|
||||
excludeRegExp = excludeRegExp || /^\.DS_Store$|.meta$/;
|
||||
var stat = fs.statSync(filepath);
|
||||
if(stat.isDirectory()) {
|
||||
var files = fs.readdirSync(filepath);
|
||||
for(var f=0; f<files.length; f++) {
|
||||
var file = files[f];
|
||||
if(!excludeRegExp.test(file)) {
|
||||
$tw.plugins.loadPlugins(filepath + "/" + file,basetitle + "/" + file,excludeRegExp);
|
||||
if(path.existsSync(filepath)) {
|
||||
var stat = fs.statSync(filepath);
|
||||
if(stat.isDirectory()) {
|
||||
var files = fs.readdirSync(filepath);
|
||||
for(var f=0; f<files.length; f++) {
|
||||
var file = files[f];
|
||||
if(!excludeRegExp.test(file)) {
|
||||
$tw.plugins.loadPlugins(filepath + "/" + file,basetitle + "/" + file,excludeRegExp);
|
||||
}
|
||||
}
|
||||
} else if(stat.isFile()) {
|
||||
$tw.plugins.loadTiddlersFromFile(filepath,basetitle);
|
||||
}
|
||||
} else if(stat.isFile()) {
|
||||
$tw.plugins.loadTiddlersFromFile(filepath,basetitle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
15
rabbithole/tw5.com/plugins/demoplugin/demoplugin.js
Normal file
15
rabbithole/tw5.com/plugins/demoplugin/demoplugin.js
Normal 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";
|
||||
|
||||
|
||||
})();
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user