mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-11-01 08:03:00 +00:00 
			
		
		
		
	Add support for TIDDLYWIKI_EDITION_PATH
This commit is contained in:
		
							
								
								
									
										48
									
								
								boot/boot.js
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								boot/boot.js
									
									
									
									
									
								
							| @@ -1492,19 +1492,48 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) { | |||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | /* | ||||||
|  | name: Name of the plugin to find | ||||||
|  | paths: array of file paths to search for it | ||||||
|  | Returns the path of the plugin folder | ||||||
|  | */ | ||||||
|  | $tw.findLibraryItem = function(name,paths) { | ||||||
|  | 	var pathIndex = 0; | ||||||
|  | 	do { | ||||||
|  | 		var pluginPath = path.resolve(paths[pathIndex],"./" + name) | ||||||
|  | 		if(fs.existsSync(pluginPath) && fs.statSync(pluginPath).isDirectory()) { | ||||||
|  | 			return pluginPath; | ||||||
|  | 		} | ||||||
|  | 	} while(++pathIndex < paths.length); | ||||||
|  | 	return null; | ||||||
|  | }; | ||||||
|  |  | ||||||
| /* | /* | ||||||
| name: Name of the plugin to load | name: Name of the plugin to load | ||||||
| paths: array of file paths to search for it | paths: array of file paths to search for it | ||||||
| */ | */ | ||||||
| $tw.loadPlugin = function(name,paths) { | $tw.loadPlugin = function(name,paths) { | ||||||
| 	var pathIndex = 0; | 	var pluginPath = $tw.findLibraryItem(name,paths); | ||||||
| 	do { | 	if(pluginPath) { | ||||||
| 		var pluginFields = $tw.loadPluginFolder(path.resolve(paths[pathIndex],"./" + name)); | 		var pluginFields = $tw.loadPluginFolder(pluginPath); | ||||||
| 		if(pluginFields) { | 		if(pluginFields) { | ||||||
| 			$tw.wiki.addTiddler(pluginFields); | 			$tw.wiki.addTiddler(pluginFields); | ||||||
| 			return; |  | ||||||
| 		} | 		} | ||||||
| 	} while(++pathIndex < paths.length); | 	} | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | /* | ||||||
|  | libraryPath: Path of library folder for these plugins (relative to core path) | ||||||
|  | envVar: Environment variable name for these plugins | ||||||
|  | Returns an array of search paths | ||||||
|  | */ | ||||||
|  | $tw.getLibraryItemSearchPaths = function(libraryPath,envVar) { | ||||||
|  | 	var pluginPaths = [path.resolve($tw.boot.corePath,libraryPath)], | ||||||
|  | 		env = process.env[envVar]; | ||||||
|  | 	if(env) { | ||||||
|  | 		Array.prototype.push.apply(pluginPaths,env.split(":")); | ||||||
|  | 	} | ||||||
|  | 	return pluginPaths; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -1514,11 +1543,7 @@ envVar: Environment variable name for these plugins | |||||||
| */ | */ | ||||||
| $tw.loadPlugins = function(plugins,libraryPath,envVar) { | $tw.loadPlugins = function(plugins,libraryPath,envVar) { | ||||||
| 	if(plugins) { | 	if(plugins) { | ||||||
| 		var pluginPaths = [path.resolve($tw.boot.corePath,libraryPath)], | 		var pluginPaths = $tw.getLibraryItemSearchPaths(libraryPath,envVar); | ||||||
| 			env = process.env[envVar]; |  | ||||||
| 		if(env) { |  | ||||||
| 			Array.prototype.push.apply(pluginPaths,env.split(":")); |  | ||||||
| 		} |  | ||||||
| 		for(var t=0; t<plugins.length; t++) { | 		for(var t=0; t<plugins.length; t++) { | ||||||
| 			$tw.loadPlugin(plugins[t],pluginPaths); | 			$tw.loadPlugin(plugins[t],pluginPaths); | ||||||
| 		} | 		} | ||||||
| @@ -1671,7 +1696,8 @@ $tw.boot.startup = function(options) { | |||||||
| 			contentTypeInfo: Object.create(null), // Map type to {encoding:,extension:} | 			contentTypeInfo: Object.create(null), // Map type to {encoding:,extension:} | ||||||
| 			pluginsEnvVar: "TIDDLYWIKI_PLUGIN_PATH", | 			pluginsEnvVar: "TIDDLYWIKI_PLUGIN_PATH", | ||||||
| 			themesEnvVar: "TIDDLYWIKI_THEME_PATH", | 			themesEnvVar: "TIDDLYWIKI_THEME_PATH", | ||||||
| 			languagesEnvVar: "TIDDLYWIKI_LANGUAGE_PATH" | 			languagesEnvVar: "TIDDLYWIKI_LANGUAGE_PATH", | ||||||
|  | 			editionsEnvVar: "TIDDLYWIKI_EDITION_PATH" | ||||||
| 		} | 		} | ||||||
| 	}); | 	}); | ||||||
| 	if(!$tw.boot.tasks.readBrowserTiddlers) { | 	if(!$tw.boot.tasks.readBrowserTiddlers) { | ||||||
|   | |||||||
| @@ -34,7 +34,7 @@ Command.prototype.execute = function() { | |||||||
| 	for(var editionIndex=0; editionIndex<editions.length; editionIndex++) { | 	for(var editionIndex=0; editionIndex<editions.length; editionIndex++) { | ||||||
| 		var editionName = editions[editionIndex]; | 		var editionName = editions[editionIndex]; | ||||||
| 		// Check the edition exists | 		// Check the edition exists | ||||||
| 		var editionPath = path.resolve($tw.boot.corePath,$tw.config.editionsPath) + path.sep + editionName; | 		var editionPath = $tw.findLibraryItem(editionName,$tw.getLibraryItemSearchPaths($tw.config.editionsPath,$tw.config.editionsEnvVar)); | ||||||
| 		if(!$tw.utils.isDirectory(editionPath)) { | 		if(!$tw.utils.isDirectory(editionPath)) { | ||||||
| 			return "Edition '" + editionName + "' not found"; | 			return "Edition '" + editionName + "' not found"; | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jermolene
					Jermolene