mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-23 15:36:52 +00:00
Refactored shadow tiddlers to not be in a separate store
Shortly there will be a flag to mark them
This commit is contained in:
parent
7c382c5f43
commit
e2ea8ff436
39
core/boot.js
39
core/boot.js
@ -208,8 +208,8 @@ $tw.plugins.registerPlugin = function(name,moduleType,moduleExports) {
|
|||||||
Register all plugin module tiddlers
|
Register all plugin module tiddlers
|
||||||
*/
|
*/
|
||||||
$tw.plugins.registerPluginModules = function() {
|
$tw.plugins.registerPluginModules = function() {
|
||||||
for(var title in $tw.wiki.shadows.tiddlers) {
|
for(var title in $tw.wiki.tiddlers) {
|
||||||
var tiddler = $tw.wiki.shadows.getTiddler(title);
|
var tiddler = $tw.wiki.getTiddler(title);
|
||||||
if(tiddler.fields.type === "application/javascript" && tiddler.fields["module-type"] !== undefined) {
|
if(tiddler.fields.type === "application/javascript" && tiddler.fields["module-type"] !== undefined) {
|
||||||
$tw.plugins.registerPlugin(title,tiddler.fields["module-type"],$tw.modules.execute(title));
|
$tw.plugins.registerPlugin(title,tiddler.fields["module-type"],$tw.modules.execute(title));
|
||||||
}
|
}
|
||||||
@ -319,12 +319,9 @@ $tw.Tiddler.fieldPlugins = $tw.plugins.getPluginsByTypeAsHashmap("tiddlerfield")
|
|||||||
/////////////////////////// Barebones wiki store
|
/////////////////////////// Barebones wiki store
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Construct a wiki store object. Options are:
|
Construct a wiki store object
|
||||||
shadows: optional value to use as the wiki store for shadow tiddlers
|
|
||||||
*/
|
*/
|
||||||
$tw.Wiki = function(options) {
|
$tw.Wiki = function() {
|
||||||
options = options || {};
|
|
||||||
this.shadows = options.shadows !== undefined ? options.shadows : new $tw.Wiki({shadows: null});
|
|
||||||
this.tiddlers = {};
|
this.tiddlers = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -345,8 +342,6 @@ $tw.Wiki.prototype.getTiddler = function(title) {
|
|||||||
var t = this.tiddlers[title];
|
var t = this.tiddlers[title];
|
||||||
if(t instanceof $tw.Tiddler) {
|
if(t instanceof $tw.Tiddler) {
|
||||||
return t;
|
return t;
|
||||||
} else if(this.shadows) {
|
|
||||||
return this.shadows.getTiddler(title);
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -511,17 +506,17 @@ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/dom","
|
|||||||
$tw.plugins.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerPlugins);
|
$tw.plugins.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerPlugins);
|
||||||
|
|
||||||
// Load the JavaScript system tiddlers from the DOM
|
// Load the JavaScript system tiddlers from the DOM
|
||||||
$tw.wiki.shadows.addTiddlers(
|
$tw.wiki.addTiddlers(
|
||||||
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("pluginModules"))
|
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("pluginModules"))
|
||||||
);
|
);
|
||||||
$tw.wiki.shadows.addTiddlers(
|
$tw.wiki.addTiddlers(
|
||||||
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("bootKernelPrefix"))
|
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("bootKernelPrefix"))
|
||||||
);
|
);
|
||||||
$tw.wiki.shadows.addTiddlers(
|
$tw.wiki.addTiddlers(
|
||||||
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("bootKernel"))
|
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("bootKernel"))
|
||||||
);
|
);
|
||||||
// Load the stylesheet tiddlers from the DOM
|
// Load the stylesheet tiddlers from the DOM
|
||||||
$tw.wiki.shadows.addTiddlers(
|
$tw.wiki.addTiddlers(
|
||||||
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("styleArea"))
|
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("styleArea"))
|
||||||
);
|
);
|
||||||
// Load the main store tiddlers from the DOM
|
// Load the main store tiddlers from the DOM
|
||||||
@ -529,7 +524,7 @@ $tw.wiki.addTiddlers(
|
|||||||
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("storeArea"))
|
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("storeArea"))
|
||||||
);
|
);
|
||||||
// Load the shadow tiddlers from the DOM
|
// Load the shadow tiddlers from the DOM
|
||||||
$tw.wiki.shadows.addTiddlers(
|
$tw.wiki.addTiddlers(
|
||||||
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("shadowArea"))
|
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("shadowArea"))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -551,8 +546,7 @@ $tw.boot.wikiPath = process.cwd();
|
|||||||
/*
|
/*
|
||||||
Load the tiddlers contained in a particular file (and optionally the accompanying .meta file)
|
Load the tiddlers contained in a particular file (and optionally the accompanying .meta file)
|
||||||
*/
|
*/
|
||||||
$tw.loadTiddlersFromFile = function(file,fields,wiki) {
|
$tw.loadTiddlersFromFile = function(file,fields) {
|
||||||
wiki = wiki || $tw.wiki;
|
|
||||||
var ext = path.extname(file),
|
var ext = path.extname(file),
|
||||||
extensionInfo = $tw.config.fileExtensions[ext],
|
extensionInfo = $tw.config.fileExtensions[ext],
|
||||||
data = fs.readFileSync(file).toString(extensionInfo ? extensionInfo.encoding : "utf8"),
|
data = fs.readFileSync(file).toString(extensionInfo ? extensionInfo.encoding : "utf8"),
|
||||||
@ -564,16 +558,15 @@ $tw.loadTiddlersFromFile = function(file,fields,wiki) {
|
|||||||
tiddlers = [$tw.utils.parseFields(metadata,tiddlers[0])];
|
tiddlers = [$tw.utils.parseFields(metadata,tiddlers[0])];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiki.addTiddlers(tiddlers);
|
$tw.wiki.addTiddlers(tiddlers);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Load all the plugins from the plugins directory
|
Load all the plugins from the plugins directory
|
||||||
*/
|
*/
|
||||||
$tw.loadTiddlersFromFolder = function(filepath,basetitle,excludeRegExp,wiki) {
|
$tw.loadTiddlersFromFolder = function(filepath,basetitle,excludeRegExp) {
|
||||||
basetitle = basetitle || "$:/plugins";
|
basetitle = basetitle || "$:/plugins";
|
||||||
excludeRegExp = excludeRegExp || /^\.DS_Store$|.meta$/;
|
excludeRegExp = excludeRegExp || /^\.DS_Store$|.meta$/;
|
||||||
wiki = wiki || $tw.wiki.shadows;
|
|
||||||
if(path.existsSync(filepath)) {
|
if(path.existsSync(filepath)) {
|
||||||
var stat = fs.statSync(filepath);
|
var stat = fs.statSync(filepath);
|
||||||
if(stat.isDirectory()) {
|
if(stat.isDirectory()) {
|
||||||
@ -583,19 +576,19 @@ $tw.loadTiddlersFromFolder = function(filepath,basetitle,excludeRegExp,wiki) {
|
|||||||
// If so, process the files it describes
|
// If so, process the files it describes
|
||||||
var pluginInfo = JSON.parse(fs.readFileSync(filepath + "/tiddlywiki.plugin").toString("utf8"));
|
var pluginInfo = JSON.parse(fs.readFileSync(filepath + "/tiddlywiki.plugin").toString("utf8"));
|
||||||
for(var p=0; p<pluginInfo.tiddlers.length; p++) {
|
for(var p=0; p<pluginInfo.tiddlers.length; p++) {
|
||||||
$tw.loadTiddlersFromFile(path.resolve(filepath,pluginInfo.tiddlers[p].file),pluginInfo.tiddlers[p].fields,wiki);
|
$tw.loadTiddlersFromFile(path.resolve(filepath,pluginInfo.tiddlers[p].file),pluginInfo.tiddlers[p].fields);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If not, read all the files in the directory
|
// If not, read all the files in the directory
|
||||||
for(var f=0; f<files.length; f++) {
|
for(var f=0; f<files.length; f++) {
|
||||||
var file = files[f];
|
var file = files[f];
|
||||||
if(!excludeRegExp.test(file)) {
|
if(!excludeRegExp.test(file)) {
|
||||||
$tw.loadTiddlersFromFolder(filepath + "/" + file,basetitle + "/" + file,excludeRegExp,wiki);
|
$tw.loadTiddlersFromFolder(filepath + "/" + file,basetitle + "/" + file,excludeRegExp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(stat.isFile()) {
|
} else if(stat.isFile()) {
|
||||||
$tw.loadTiddlersFromFile(filepath,{title: basetitle},wiki);
|
$tw.loadTiddlersFromFile(filepath,{title: basetitle});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -649,7 +642,7 @@ $tw.loadTiddlersFromFolder(path.resolve($tw.boot.wikiPath,$tw.config.wikiPlugins
|
|||||||
// Load shadow tiddlers from wiki shadows directory
|
// Load shadow tiddlers from wiki shadows directory
|
||||||
$tw.loadTiddlersFromFolder(path.resolve($tw.boot.wikiPath,$tw.config.wikiShadowsSubDir));
|
$tw.loadTiddlersFromFolder(path.resolve($tw.boot.wikiPath,$tw.config.wikiShadowsSubDir));
|
||||||
// Load tiddlers from wiki tiddlers directory
|
// Load tiddlers from wiki tiddlers directory
|
||||||
$tw.loadTiddlersFromFolder(path.resolve($tw.boot.wikiPath,$tw.config.wikiTiddlersSubDir),null,null,$tw.wiki);
|
$tw.loadTiddlersFromFolder(path.resolve($tw.boot.wikiPath,$tw.config.wikiTiddlersSubDir));
|
||||||
|
|
||||||
// End of if(!$tw.browser)
|
// End of if(!$tw.browser)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ Command.prototype.subcommands.tiddlers = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Command.prototype.subcommands.shadows = function() {
|
Command.prototype.subcommands.shadows = function() {
|
||||||
var tiddlers = this.commander.wiki.shadows.getTiddlers();
|
var tiddlers = this.commander.wiki.getShadowTitles();
|
||||||
this.output.write("Wiki contains these shadow tiddlers:\n");
|
this.output.write("Wiki contains these shadow tiddlers:\n");
|
||||||
for(var t=0; t<tiddlers.length; t++) {
|
for(var t=0; t<tiddlers.length; t++) {
|
||||||
this.output.write(tiddlers[t] + "\n");
|
this.output.write(tiddlers[t] + "\n");
|
||||||
|
@ -17,17 +17,15 @@ exports.info = {
|
|||||||
params: {
|
params: {
|
||||||
filter: {byPos: 0, type: "filter"},
|
filter: {byPos: 0, type: "filter"},
|
||||||
as: {byPos: 1, type: "text"},
|
as: {byPos: 1, type: "text"},
|
||||||
shadow: {byPos: 2, type: "text"},
|
|
||||||
removePrefix: {byName: true, type: "text"}
|
removePrefix: {byName: true, type: "text"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.executeMacro = function() {
|
exports.executeMacro = function() {
|
||||||
var as = this.params.as || "text/plain",
|
var as = this.params.as || "text/plain",
|
||||||
wiki = this.hasParameter("shadow") ? this.wiki.shadows : this.wiki,
|
|
||||||
t;
|
t;
|
||||||
if(this.hasParameter("filter")) {
|
if(this.hasParameter("filter")) {
|
||||||
var titles = wiki.filterTiddlers(this.params.filter),
|
var titles = this.wiki.filterTiddlers(this.params.filter),
|
||||||
result = [];
|
result = [];
|
||||||
if(this.hasParameter("removePrefix")) {
|
if(this.hasParameter("removePrefix")) {
|
||||||
for(t=0; t<titles.length; t++) {
|
for(t=0; t<titles.length; t++) {
|
||||||
|
@ -100,11 +100,7 @@ exports.deleteTiddler = function(title) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.tiddlerExists = function(title) {
|
exports.tiddlerExists = function(title) {
|
||||||
if(this.tiddlers[title]) {
|
return !!this.tiddlers[title];
|
||||||
return true;
|
|
||||||
} else if (this.shadows) {
|
|
||||||
return this.shadows.tiddlerExists(title);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.addTiddler = function(tiddler) {
|
exports.addTiddler = function(tiddler) {
|
||||||
@ -210,7 +206,7 @@ exports.getOrphanTitles = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.getShadowTitles = function() {
|
exports.getShadowTitles = function() {
|
||||||
return this.shadows ? this.shadows.getTiddlers() : [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the named cache object for a tiddler. If the cache doesn't exist then the initializer function is invoked to create it
|
// Return the named cache object for a tiddler. If the cache doesn't exist then the initializer function is invoked to create it
|
||||||
|
@ -6,18 +6,18 @@ type: text/x-tiddlywiki-html
|
|||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||||
<meta name="application-name" content="TiddlyWiki" />
|
<meta name="application-name" content="TiddlyWiki" />
|
||||||
<meta name="generator" content="TiddlyWiki" />
|
<meta name="generator" content="TiddlyWiki" />
|
||||||
<meta name="tiddlywiki-version" content="<<include "$:/core/version.txt" text/plain shadow:yes>>" />
|
<meta name="tiddlywiki-version" content="<<include "$:/core/version.txt" text/plain>>" />
|
||||||
<meta name="format-detection" content="telephone=no">
|
<meta name="format-detection" content="telephone=no">
|
||||||
<meta name="copyright" content="
|
<meta name="copyright" content="
|
||||||
<<include "$:/core/copyright.txt" text/plain shadow:yes>>
|
<<include "$:/core/copyright.txt" text/plain>>
|
||||||
" />
|
" />
|
||||||
<title><<tiddler target:$:/shadows/title>></title>
|
<title><<tiddler target:$:/shadows/title>></title>
|
||||||
<!----------- This is a Tiddlywiki file. The points of interest in the file are marked with this pattern ----------->
|
<!----------- This is a Tiddlywiki file. The points of interest in the file are marked with this pattern ----------->
|
||||||
<div id="styleArea">
|
<div id="styleArea">
|
||||||
<<include "[type[text/css]]" application/x-tiddler-css shadow:yes>>
|
<<include "[type[text/css]]" application/x-tiddler-css>>
|
||||||
</div>
|
</div>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<<include "PageTemplate" text/html shadow:yes>>
|
<<include "PageTemplate" text/html>>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -6,32 +6,32 @@ type: text/x-tiddlywiki-html
|
|||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||||
<meta name="application-name" content="TiddlyWiki" />
|
<meta name="application-name" content="TiddlyWiki" />
|
||||||
<meta name="generator" content="TiddlyWiki" />
|
<meta name="generator" content="TiddlyWiki" />
|
||||||
<meta name="tiddlywiki-version" content="<<include "$:/core/version.txt" text/plain shadow:yes>>" />
|
<meta name="tiddlywiki-version" content="<<include "$:/core/version.txt" text/plain>>" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||||
<meta name="format-detection" content="telephone=no">
|
<meta name="format-detection" content="telephone=no">
|
||||||
<meta name="copyright" content="
|
<meta name="copyright" content="
|
||||||
<<include "$:/core/copyright.txt" text/plain shadow:yes>>
|
<<include "$:/core/copyright.txt" text/plain>>
|
||||||
" />
|
" />
|
||||||
<title><<include "$:/wiki/title" text/plain>></title>
|
<title><<include "$:/wiki/title" text/plain>></title>
|
||||||
<!----------- This is a Tiddlywiki file. The points of interest in the file are marked with this pattern ----------->
|
<!----------- This is a Tiddlywiki file. The points of interest in the file are marked with this pattern ----------->
|
||||||
<div id="styleArea">
|
<div id="styleArea">
|
||||||
<<include "[type[text/css]]" application/x-tiddler-css shadow:yes>>
|
<<include "[type[text/css]]" application/x-tiddler-css>>
|
||||||
</div>
|
</div>
|
||||||
<!----------- Raw markup ----------->
|
<!----------- Raw markup ----------->
|
||||||
<<include "[tag[$:/shadow/rawMarkup]]" text/plain shadow:yes>>
|
<<include "[tag[$:/shadow/rawMarkup]]" text/plain>>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!----------- Static content for Google and browsers without JavaScript ----------->
|
<!----------- Static content for Google and browsers without JavaScript ----------->
|
||||||
<noscript>
|
<noscript>
|
||||||
<div id="splashArea" style="display:none;">
|
<div id="splashArea" style="display:none;">
|
||||||
<<include "$:/templates/StaticContent" text/html shadow:yes>>
|
<<include "$:/templates/StaticContent" text/html>>
|
||||||
</div>
|
</div>
|
||||||
</noscript>
|
</noscript>
|
||||||
<!----------- Miscellaneous shadow tiddlers ----------->
|
<!----------- Miscellaneous shadow tiddlers ----------->
|
||||||
<div id="shadowArea" style="display:none;">
|
<div id="shadowArea" style="display:none;">
|
||||||
<<include "[!type[text/css]] -[type[application/javascript]has[module-type]] -[[$:/core/boot.js]] -[[$:/core/bootprefix.js]]" application/x-tiddler-html-div shadow:yes>>
|
<<include "[!type[text/css]] -[type[application/javascript]has[module-type]] -[[$:/core/boot.js]] -[[$:/core/bootprefix.js]]" application/x-tiddler-html-div>>
|
||||||
</div>
|
</div>
|
||||||
<!----------- Ordinary tiddlers ----------->
|
<!----------- Ordinary tiddlers ----------->
|
||||||
<div id="storeArea" style="display:none;">
|
<div id="storeArea" style="display:none;">
|
||||||
@ -39,15 +39,15 @@ type: text/x-tiddlywiki-html
|
|||||||
</div>
|
</div>
|
||||||
<!----------- Boot kernel prologue ----------->
|
<!----------- Boot kernel prologue ----------->
|
||||||
<div id="bootKernelPrefix" style="display:none;">
|
<div id="bootKernelPrefix" style="display:none;">
|
||||||
<<include "$:/core/bootprefix.js" application/javascript shadow:yes>>
|
<<include "$:/core/bootprefix.js" application/javascript>>
|
||||||
</div>
|
</div>
|
||||||
<!----------- Plugin modules ----------->
|
<!----------- Plugin modules ----------->
|
||||||
<div id="pluginModules" style="display:none;">
|
<div id="pluginModules" style="display:none;">
|
||||||
<<include "[type[application/javascript]has[module-type]]" application/x-tiddler-module shadow:yes>>
|
<<include "[type[application/javascript]has[module-type]]" application/x-tiddler-module>>
|
||||||
</div>
|
</div>
|
||||||
<!----------- Boot kernel ----------->
|
<!----------- Boot kernel ----------->
|
||||||
<div id="bootKernel" style="display:none;">
|
<div id="bootKernel" style="display:none;">
|
||||||
<<include "$:/core/boot.js" application/javascript shadow:yes>>
|
<<include "$:/core/boot.js" application/javascript>>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user