mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 15:42:59 +00:00 
			
		
		
		
	Start making themes switchable
Separately switch in ordinary plugins and themes. Change the convention for plugin information to use dashes rather than camel case.
This commit is contained in:
		
							
								
								
									
										20
									
								
								boot/boot.js
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								boot/boot.js
									
									
									
									
									
								
							| @@ -639,22 +639,22 @@ $tw.Wiki.prototype.addTiddlers = function(tiddlers) { | |||||||
| /* | /* | ||||||
| Extract constituent tiddlers from plugin tiddlers so that we can easily access them in getTiddler() | Extract constituent tiddlers from plugin tiddlers so that we can easily access them in getTiddler() | ||||||
| */ | */ | ||||||
| $tw.Wiki.prototype.unpackPluginTiddlers = function() { | $tw.Wiki.prototype.unpackPluginTiddlers = function(pluginType) { | ||||||
| 	// Collect up the titles of all the plugin tiddlers | 	// Collect up the titles of all the plugin tiddlers | ||||||
| 	var self = this, | 	var self = this, | ||||||
| 		pluginInfoList = []; | 		pluginInfoList = []; | ||||||
| 	$tw.utils.each(this.tiddlers,function(tiddler,title,object) { | 	$tw.utils.each(this.tiddlers,function(tiddler,title,object) { | ||||||
| 		if(tiddler.fields.type === "application/json" && tiddler.hasField("plugin")) { | 		if(tiddler.fields.type === "application/json" && tiddler.hasField("plugin") && tiddler.fields["plugin-type"] === pluginType) { | ||||||
| 			pluginInfoList.push(tiddler); | 			pluginInfoList.push(tiddler); | ||||||
| 		} | 		} | ||||||
| 	}); | 	}); | ||||||
| 	// Sort the titles by the `pluginPriority` field | 	// Sort the titles by the `plugin-priority` field | ||||||
| 	pluginInfoList.sort(function(a,b) { | 	pluginInfoList.sort(function(a,b) { | ||||||
| 		if("pluginPriority" in a.fields && "pluginPriority" in b.fields) { | 		if("plugin-priority" in a.fields && "plugin-priority" in b.fields) { | ||||||
| 			return a.fields.pluginPriority - b.fields.pluginPriority; | 			return a.fields["plugin-priority"] - b.fields["plugin-priority"]; | ||||||
| 		} else if("pluginPriority" in a.fields) { | 		} else if("plugin-priority" in a.fields) { | ||||||
| 			return -1; | 			return -1; | ||||||
| 		} else if("pluginPriority" in b.fields) { | 		} else if("plugin-priority" in b.fields) { | ||||||
| 			return +1; | 			return +1; | ||||||
| 		} else if(a.fields.title < b.fields.title) { | 		} else if(a.fields.title < b.fields.title) { | ||||||
| 			return -1; | 			return -1; | ||||||
| @@ -1039,8 +1039,8 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) { | |||||||
| 			type: "application/json", | 			type: "application/json", | ||||||
| 			plugin: "yes", | 			plugin: "yes", | ||||||
| 			text: JSON.stringify(pluginInfo,null,4), | 			text: JSON.stringify(pluginInfo,null,4), | ||||||
| 			pluginPriority: pluginInfo.pluginPriority, | 			"plugin-priority": pluginInfo["plugin-priority"], | ||||||
| 			pluginType: pluginInfo.pluginType || "plugin" | 			"plugin-type": pluginInfo["plugin-type"] || "plugin" | ||||||
| 		} | 		} | ||||||
| 		return fields; | 		return fields; | ||||||
| 	} else { | 	} else { | ||||||
| @@ -1206,7 +1206,7 @@ $tw.boot.startup = function() { | |||||||
| 	// Load tiddlers | 	// Load tiddlers | ||||||
| 	$tw.loadTiddlers(); | 	$tw.loadTiddlers(); | ||||||
| 	// Unpack plugin tiddlers | 	// Unpack plugin tiddlers | ||||||
| 	$tw.wiki.unpackPluginTiddlers(); | 	$tw.wiki.unpackPluginTiddlers("plugin"); | ||||||
| 	// Register typed modules from the tiddlers we've just loaded | 	// Register typed modules from the tiddlers we've just loaded | ||||||
| 	$tw.wiki.defineTiddlerModules(); | 	$tw.wiki.defineTiddlerModules(); | ||||||
| 	// And any modules within plugins | 	// And any modules within plugins | ||||||
|   | |||||||
| @@ -89,8 +89,10 @@ exports.startup = function() { | |||||||
| 		document.addEventListener("tw-clear-password",function(event) { | 		document.addEventListener("tw-clear-password",function(event) { | ||||||
| 			$tw.crypto.setPassword(null); | 			$tw.crypto.setPassword(null); | ||||||
| 		}); | 		}); | ||||||
|  | 		// Unpack the current theme tiddlers | ||||||
|  | 		$tw.wiki.unpackPluginTiddlers("theme"); | ||||||
| 		// Apply stylesheets | 		// Apply stylesheets | ||||||
| 		var stylesheetTiddlers = $tw.wiki.filterTiddlers("[tag[$:/tags/stylesheet]]"); | 		var stylesheetTiddlers = $tw.wiki.filterTiddlers("[is[shadow]tag[$:/tags/stylesheet]]"); | ||||||
| 		$tw.utils.each(stylesheetTiddlers,function(title,index) { | 		$tw.utils.each(stylesheetTiddlers,function(title,index) { | ||||||
| 			// Stylesheets don't refresh, yet | 			// Stylesheets don't refresh, yet | ||||||
| 			var parser = $tw.wiki.parseTiddler(title), | 			var parser = $tw.wiki.parseTiddler(title), | ||||||
|   | |||||||
| @@ -3,6 +3,6 @@ | |||||||
| 	"description": "TiddlyWiki5 core plugin", | 	"description": "TiddlyWiki5 core plugin", | ||||||
| 	"author": "JeremyRuston", | 	"author": "JeremyRuston", | ||||||
| 	"version": "0.0.0", | 	"version": "0.0.0", | ||||||
| 	"coreVersion": ">=5.0.0", | 	"core-version": ">=5.0.0", | ||||||
| 	"pluginPriority": "0" | 	"plugin-priority": "0" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,5 +3,5 @@ | |||||||
| 	"description": "File system synchronisation", | 	"description": "File system synchronisation", | ||||||
| 	"author": "JeremyRuston", | 	"author": "JeremyRuston", | ||||||
| 	"version": "0.0.0", | 	"version": "0.0.0", | ||||||
| 	"coreVersion": ">=5.0.0" | 	"core-version": ">=5.0.0" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,5 +3,5 @@ | |||||||
| 	"description": "Adds support for HTML5 full screen mode", | 	"description": "Adds support for HTML5 full screen mode", | ||||||
| 	"author": "JeremyRuston", | 	"author": "JeremyRuston", | ||||||
| 	"version": "0.0.0", | 	"version": "0.0.0", | ||||||
| 	"coreVersion": ">=5.0.0" | 	"core-version": ">=5.0.0" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,5 +3,5 @@ | |||||||
| 	"description": "Jasmine test framework plugin for TiddlyWiki5", | 	"description": "Jasmine test framework plugin for TiddlyWiki5", | ||||||
| 	"author": "JeremyRuston", | 	"author": "JeremyRuston", | ||||||
| 	"version": "0.0.0", | 	"version": "0.0.0", | ||||||
| 	"coreVersion": ">=5.0.0" | 	"core-version": ">=5.0.0" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,5 +3,5 @@ | |||||||
| 	"description": "Loads tiddlers from an old-style TiddlyWiki 2.x.x recipe file", | 	"description": "Loads tiddlers from an old-style TiddlyWiki 2.x.x recipe file", | ||||||
| 	"author": "JeremyRuston", | 	"author": "JeremyRuston", | ||||||
| 	"version": "0.0.0", | 	"version": "0.0.0", | ||||||
| 	"coreVersion": ">=5.0.0" | 	"core-version": ">=5.0.0" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,5 +3,5 @@ | |||||||
| 	"description": "Strips //# comments from JavaScript source", | 	"description": "Strips //# comments from JavaScript source", | ||||||
| 	"author": "JeremyRuston", | 	"author": "JeremyRuston", | ||||||
| 	"version": "0.0.0", | 	"version": "0.0.0", | ||||||
| 	"coreVersion": ">=5.0.0" | 	"core-version": ">=5.0.0" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,5 +3,5 @@ | |||||||
| 	"description": "Support for saving changes to Tahoe-LAFS", | 	"description": "Support for saving changes to Tahoe-LAFS", | ||||||
| 	"author": "JeremyRuston", | 	"author": "JeremyRuston", | ||||||
| 	"version": "0.0.0", | 	"version": "0.0.0", | ||||||
| 	"coreVersion": ">=5.0.0" | 	"core-version": ">=5.0.0" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,5 +3,5 @@ | |||||||
| 	"description": "TiddlyWeb and TiddlySpace components", | 	"description": "TiddlyWeb and TiddlySpace components", | ||||||
| 	"author": "JeremyRuston", | 	"author": "JeremyRuston", | ||||||
| 	"version": "0.0.0", | 	"version": "0.0.0", | ||||||
| 	"coreVersion": ">=5.0.0" | 	"core-version": ">=5.0.0" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,6 +3,6 @@ | |||||||
| 	"description": "A simple, plain layout", | 	"description": "A simple, plain layout", | ||||||
| 	"author": "JeremyRuston", | 	"author": "JeremyRuston", | ||||||
| 	"version": "0.0.0", | 	"version": "0.0.0", | ||||||
| 	"coreVersion": ">=5.0.0", | 	"core-version": ">=5.0.0", | ||||||
| 	"pluginType": "theme" | 	"plugin-type": "theme" | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jeremy Ruston
					Jeremy Ruston