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:
Jeremy Ruston 2013-04-28 22:52:26 +01:00
parent 3b8354d1e1
commit 17cfd57390
11 changed files with 24 additions and 22 deletions

View File

@ -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()
*/
$tw.Wiki.prototype.unpackPluginTiddlers = function() {
$tw.Wiki.prototype.unpackPluginTiddlers = function(pluginType) {
// Collect up the titles of all the plugin tiddlers
var self = this,
pluginInfoList = [];
$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);
}
});
// Sort the titles by the `pluginPriority` field
// Sort the titles by the `plugin-priority` field
pluginInfoList.sort(function(a,b) {
if("pluginPriority" in a.fields && "pluginPriority" in b.fields) {
return a.fields.pluginPriority - b.fields.pluginPriority;
} else if("pluginPriority" in a.fields) {
if("plugin-priority" in a.fields && "plugin-priority" in b.fields) {
return a.fields["plugin-priority"] - b.fields["plugin-priority"];
} else if("plugin-priority" in a.fields) {
return -1;
} else if("pluginPriority" in b.fields) {
} else if("plugin-priority" in b.fields) {
return +1;
} else if(a.fields.title < b.fields.title) {
return -1;
@ -1039,8 +1039,8 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) {
type: "application/json",
plugin: "yes",
text: JSON.stringify(pluginInfo,null,4),
pluginPriority: pluginInfo.pluginPriority,
pluginType: pluginInfo.pluginType || "plugin"
"plugin-priority": pluginInfo["plugin-priority"],
"plugin-type": pluginInfo["plugin-type"] || "plugin"
}
return fields;
} else {
@ -1206,7 +1206,7 @@ $tw.boot.startup = function() {
// Load tiddlers
$tw.loadTiddlers();
// Unpack plugin tiddlers
$tw.wiki.unpackPluginTiddlers();
$tw.wiki.unpackPluginTiddlers("plugin");
// Register typed modules from the tiddlers we've just loaded
$tw.wiki.defineTiddlerModules();
// And any modules within plugins

View File

@ -89,8 +89,10 @@ exports.startup = function() {
document.addEventListener("tw-clear-password",function(event) {
$tw.crypto.setPassword(null);
});
// Unpack the current theme tiddlers
$tw.wiki.unpackPluginTiddlers("theme");
// 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) {
// Stylesheets don't refresh, yet
var parser = $tw.wiki.parseTiddler(title),

View File

@ -3,6 +3,6 @@
"description": "TiddlyWiki5 core plugin",
"author": "JeremyRuston",
"version": "0.0.0",
"coreVersion": ">=5.0.0",
"pluginPriority": "0"
"core-version": ">=5.0.0",
"plugin-priority": "0"
}

View File

@ -3,5 +3,5 @@
"description": "File system synchronisation",
"author": "JeremyRuston",
"version": "0.0.0",
"coreVersion": ">=5.0.0"
"core-version": ">=5.0.0"
}

View File

@ -3,5 +3,5 @@
"description": "Adds support for HTML5 full screen mode",
"author": "JeremyRuston",
"version": "0.0.0",
"coreVersion": ">=5.0.0"
"core-version": ">=5.0.0"
}

View File

@ -3,5 +3,5 @@
"description": "Jasmine test framework plugin for TiddlyWiki5",
"author": "JeremyRuston",
"version": "0.0.0",
"coreVersion": ">=5.0.0"
"core-version": ">=5.0.0"
}

View File

@ -3,5 +3,5 @@
"description": "Loads tiddlers from an old-style TiddlyWiki 2.x.x recipe file",
"author": "JeremyRuston",
"version": "0.0.0",
"coreVersion": ">=5.0.0"
"core-version": ">=5.0.0"
}

View File

@ -3,5 +3,5 @@
"description": "Strips //# comments from JavaScript source",
"author": "JeremyRuston",
"version": "0.0.0",
"coreVersion": ">=5.0.0"
"core-version": ">=5.0.0"
}

View File

@ -3,5 +3,5 @@
"description": "Support for saving changes to Tahoe-LAFS",
"author": "JeremyRuston",
"version": "0.0.0",
"coreVersion": ">=5.0.0"
"core-version": ">=5.0.0"
}

View File

@ -3,5 +3,5 @@
"description": "TiddlyWeb and TiddlySpace components",
"author": "JeremyRuston",
"version": "0.0.0",
"coreVersion": ">=5.0.0"
"core-version": ">=5.0.0"
}

View File

@ -3,6 +3,6 @@
"description": "A simple, plain layout",
"author": "JeremyRuston",
"version": "0.0.0",
"coreVersion": ">=5.0.0",
"pluginType": "theme"
"core-version": ">=5.0.0",
"plugin-type": "theme"
}