Refactored shadow tiddlers to not be in a separate store

Shortly there will be a flag to mark them
print-window-tiddler
Jeremy Ruston 2012-06-06 12:07:33 +01:00
rodzic 7c382c5f43
commit e2ea8ff436
6 zmienionych plików z 33 dodań i 46 usunięć

Wyświetl plik

@ -208,8 +208,8 @@ $tw.plugins.registerPlugin = function(name,moduleType,moduleExports) {
Register all plugin module tiddlers
*/
$tw.plugins.registerPluginModules = function() {
for(var title in $tw.wiki.shadows.tiddlers) {
var tiddler = $tw.wiki.shadows.getTiddler(title);
for(var title in $tw.wiki.tiddlers) {
var tiddler = $tw.wiki.getTiddler(title);
if(tiddler.fields.type === "application/javascript" && tiddler.fields["module-type"] !== undefined) {
$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
/*
Construct a wiki store object. Options are:
shadows: optional value to use as the wiki store for shadow tiddlers
Construct a wiki store object
*/
$tw.Wiki = function(options) {
options = options || {};
this.shadows = options.shadows !== undefined ? options.shadows : new $tw.Wiki({shadows: null});
$tw.Wiki = function() {
this.tiddlers = {};
};
@ -345,8 +342,6 @@ $tw.Wiki.prototype.getTiddler = function(title) {
var t = this.tiddlers[title];
if(t instanceof $tw.Tiddler) {
return t;
} else if(this.shadows) {
return this.shadows.getTiddler(title);
} else {
return null;
}
@ -511,17 +506,17 @@ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/dom","
$tw.plugins.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerPlugins);
// Load the JavaScript system tiddlers from the DOM
$tw.wiki.shadows.addTiddlers(
$tw.wiki.addTiddlers(
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("pluginModules"))
);
$tw.wiki.shadows.addTiddlers(
$tw.wiki.addTiddlers(
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("bootKernelPrefix"))
);
$tw.wiki.shadows.addTiddlers(
$tw.wiki.addTiddlers(
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("bootKernel"))
);
// Load the stylesheet tiddlers from the DOM
$tw.wiki.shadows.addTiddlers(
$tw.wiki.addTiddlers(
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("styleArea"))
);
// Load the main store tiddlers from the DOM
@ -529,7 +524,7 @@ $tw.wiki.addTiddlers(
$tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("storeArea"))
);
// Load the shadow tiddlers from the DOM
$tw.wiki.shadows.addTiddlers(
$tw.wiki.addTiddlers(
$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)
*/
$tw.loadTiddlersFromFile = function(file,fields,wiki) {
wiki = wiki || $tw.wiki;
$tw.loadTiddlersFromFile = function(file,fields) {
var ext = path.extname(file),
extensionInfo = $tw.config.fileExtensions[ext],
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])];
}
}
wiki.addTiddlers(tiddlers);
$tw.wiki.addTiddlers(tiddlers);
};
/*
Load all the plugins from the plugins directory
*/
$tw.loadTiddlersFromFolder = function(filepath,basetitle,excludeRegExp,wiki) {
$tw.loadTiddlersFromFolder = function(filepath,basetitle,excludeRegExp) {
basetitle = basetitle || "$:/plugins";
excludeRegExp = excludeRegExp || /^\.DS_Store$|.meta$/;
wiki = wiki || $tw.wiki.shadows;
if(path.existsSync(filepath)) {
var stat = fs.statSync(filepath);
if(stat.isDirectory()) {
@ -583,19 +576,19 @@ $tw.loadTiddlersFromFolder = function(filepath,basetitle,excludeRegExp,wiki) {
// If so, process the files it describes
var pluginInfo = JSON.parse(fs.readFileSync(filepath + "/tiddlywiki.plugin").toString("utf8"));
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 {
// If not, read all the files in the directory
for(var f=0; f<files.length; f++) {
var file = files[f];
if(!excludeRegExp.test(file)) {
$tw.loadTiddlersFromFolder(filepath + "/" + file,basetitle + "/" + file,excludeRegExp,wiki);
$tw.loadTiddlersFromFolder(filepath + "/" + file,basetitle + "/" + file,excludeRegExp);
}
}
}
} 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
$tw.loadTiddlersFromFolder(path.resolve($tw.boot.wikiPath,$tw.config.wikiShadowsSubDir));
// 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)
}

Wyświetl plik

@ -59,7 +59,7 @@ Command.prototype.subcommands.tiddlers = 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");
for(var t=0; t<tiddlers.length; t++) {
this.output.write(tiddlers[t] + "\n");

Wyświetl plik

@ -17,17 +17,15 @@ exports.info = {
params: {
filter: {byPos: 0, type: "filter"},
as: {byPos: 1, type: "text"},
shadow: {byPos: 2, type: "text"},
removePrefix: {byName: true, type: "text"}
}
};
exports.executeMacro = function() {
var as = this.params.as || "text/plain",
wiki = this.hasParameter("shadow") ? this.wiki.shadows : this.wiki,
t;
if(this.hasParameter("filter")) {
var titles = wiki.filterTiddlers(this.params.filter),
var titles = this.wiki.filterTiddlers(this.params.filter),
result = [];
if(this.hasParameter("removePrefix")) {
for(t=0; t<titles.length; t++) {

Wyświetl plik

@ -100,11 +100,7 @@ exports.deleteTiddler = function(title) {
};
exports.tiddlerExists = function(title) {
if(this.tiddlers[title]) {
return true;
} else if (this.shadows) {
return this.shadows.tiddlerExists(title);
}
return !!this.tiddlers[title];
};
exports.addTiddler = function(tiddler) {
@ -210,7 +206,7 @@ exports.getOrphanTitles = 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

Wyświetl plik

@ -6,18 +6,18 @@ type: text/x-tiddlywiki-html
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="application-name" 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="copyright" content="
<<include "$:/core/copyright.txt" text/plain shadow:yes>>
<<include "$:/core/copyright.txt" text/plain>>
" />
<title><<tiddler target:$:/shadows/title>></title>
<!----------- This is a Tiddlywiki file. The points of interest in the file are marked with this pattern ----------->
<div id="styleArea">
<<include "[type[text/css]]" application/x-tiddler-css shadow:yes>>
<<include "[type[text/css]]" application/x-tiddler-css>>
</div>
</head>
<body>
<<include "PageTemplate" text/html shadow:yes>>
<<include "PageTemplate" text/html>>
</body>
</html>

Wyświetl plik

@ -6,32 +6,32 @@ type: text/x-tiddlywiki-html
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="application-name" 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="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="format-detection" content="telephone=no">
<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>
<!----------- This is a Tiddlywiki file. The points of interest in the file are marked with this pattern ----------->
<div id="styleArea">
<<include "[type[text/css]]" application/x-tiddler-css shadow:yes>>
<<include "[type[text/css]]" application/x-tiddler-css>>
</div>
<!----------- Raw markup ----------->
<<include "[tag[$:/shadow/rawMarkup]]" text/plain shadow:yes>>
<<include "[tag[$:/shadow/rawMarkup]]" text/plain>>
</head>
<body>
<!----------- Static content for Google and browsers without JavaScript ----------->
<noscript>
<div id="splashArea" style="display:none;">
<<include "$:/templates/StaticContent" text/html shadow:yes>>
<<include "$:/templates/StaticContent" text/html>>
</div>
</noscript>
<!----------- Miscellaneous shadow tiddlers ----------->
<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>
<!----------- Ordinary tiddlers ----------->
<div id="storeArea" style="display:none;">
@ -39,15 +39,15 @@ type: text/x-tiddlywiki-html
</div>
<!----------- Boot kernel prologue ----------->
<div id="bootKernelPrefix" style="display:none;">
<<include "$:/core/bootprefix.js" application/javascript shadow:yes>>
<<include "$:/core/bootprefix.js" application/javascript>>
</div>
<!----------- Plugin modules ----------->
<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>
<!----------- Boot kernel ----------->
<div id="bootKernel" style="display:none;">
<<include "$:/core/boot.js" application/javascript shadow:yes>>
<<include "$:/core/boot.js" application/javascript>>
</div>
</body>
</html>