1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Rearranged core tiddler naming convention

This commit is contained in:
Jeremy Ruston 2012-05-03 21:47:16 +01:00
parent 4ae4a9b041
commit ecd4f45e87
49 changed files with 138 additions and 68 deletions

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/boot.js title: $:/core/boot.js
type: application/javascript type: application/javascript
The main boot kernel for TiddlyWiki. This single file creates a barebones TW environment that is just The main boot kernel for TiddlyWiki. This single file creates a barebones TW environment that is just
@ -56,6 +56,8 @@ $tw.config.pluginSubDir = $tw.config.pluginSubDir || "./modules";
// File extensions // File extensions
$tw.config.fileExtensions = { $tw.config.fileExtensions = {
".tid": {type: "application/x-tiddler", encoding: "utf8"}, ".tid": {type: "application/x-tiddler", encoding: "utf8"},
".txt": {type: "text/plain", encoding: "utf8"},
".html": {type: "text/html", encoding: "utf8"},
".js": {type: "application/javascript", encoding: "utf8"}, ".js": {type: "application/javascript", encoding: "utf8"},
".jpg": {type: "image/jpeg", encoding: "base64"}, ".jpg": {type: "image/jpeg", encoding: "base64"},
".jpeg": {type: "image/jpeg", encoding: "base64"}, ".jpeg": {type: "image/jpeg", encoding: "base64"},
@ -351,13 +353,6 @@ Hashmap of field plugins by plugin name
*/ */
$tw.Wiki.tiddlerDeserializerPlugins = {}; $tw.Wiki.tiddlerDeserializerPlugins = {};
/*
Install any tiddler deserializer plugin modules
*/
$tw.Wiki.installPlugins = function() {
$tw.Wiki.tiddlerDeserializerPlugins = $tw.plugins.getPluginsByTypeAsHashmap("tiddlerdeserializer");
};
/* /*
Extracts tiddlers from a typed block of text, specifying default field values Extracts tiddlers from a typed block of text, specifying default field values
*/ */
@ -374,7 +369,7 @@ $tw.Wiki.prototype.deserializeTiddlers = function(type,text,srcFields) {
fields[f] = srcFields[f] fields[f] = srcFields[f]
}; };
if(deserializer) { if(deserializer) {
return deserializer.deserialize.call(this,text,fields); return deserializer.call(this,text,fields);
} else { } else {
// Return a raw tiddler for unknown types // Return a raw tiddler for unknown types
fields.text = text; fields.text = text;
@ -386,8 +381,7 @@ $tw.Wiki.prototype.deserializeTiddlers = function(type,text,srcFields) {
Register the built in tiddler deserializer plugins Register the built in tiddler deserializer plugins
*/ */
$tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/js","tiddlerdeserializer",{ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/js","tiddlerdeserializer",{
name: "application/javascript", "application/javascript": function(text,fields) {
deserialize: function(text,fields) {
var headerCommentRegExp = /^\/\*\\\n((?:^[^\n]*\n)+?)(^\\\*\/$\n?)/mg, var headerCommentRegExp = /^\/\*\\\n((?:^[^\n]*\n)+?)(^\\\*\/$\n?)/mg,
match = headerCommentRegExp.exec(text); match = headerCommentRegExp.exec(text);
fields.text = text; fields.text = text;
@ -398,8 +392,7 @@ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/js","t
} }
}); });
$tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/tid","tiddlerdeserializer",{ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/tid","tiddlerdeserializer",{
name: "application/x-tiddler", "application/x-tiddler": function(text,fields) {
deserialize: function(text,fields) {
var split = text.indexOf("\n\n"); var split = text.indexOf("\n\n");
if(split !== -1) { if(split !== -1) {
fields = $tw.utils.parseFields(text.substr(0,split),fields); fields = $tw.utils.parseFields(text.substr(0,split),fields);
@ -411,7 +404,7 @@ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/tid","
} }
}); });
// Install the tiddler deserializer plugins so they are immediately available // Install the tiddler deserializer plugins so they are immediately available
$tw.Wiki.installPlugins(); $tw.plugins.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerPlugins);
/////////////////////////// Intermediate initialisation /////////////////////////// Intermediate initialisation
@ -450,8 +443,7 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
Register a deserializer that can extract tiddlers from the DOM Register a deserializer that can extract tiddlers from the DOM
*/ */
$tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/dom","tiddlerdeserializer",{ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/dom","tiddlerdeserializer",{
name: "(DOM)", "(DOM)": function(node) {
deserialize: function(node) {
var extractTextTiddler = function(node) { var extractTextTiddler = function(node) {
var e = node.firstChild; var e = node.firstChild;
while(e && e.nodeName.toLowerCase() !== "pre") { while(e && e.nodeName.toLowerCase() !== "pre") {
@ -500,7 +492,7 @@ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/dom","
} }
}); });
// Install the tiddler deserializer plugin // Install the tiddler deserializer plugin
$tw.Wiki.installPlugins(); $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.shadows.addTiddlers(
@ -526,6 +518,7 @@ var fs = require("fs"),
path = require("path"), path = require("path"),
vm = require("vm"); vm = require("vm");
$tw.boot.bootFile = path.basename(module.filename);
$tw.boot.bootPath = path.dirname(module.filename); $tw.boot.bootPath = path.dirname(module.filename);
/* /*
@ -540,6 +533,7 @@ $tw.plugins.loadTiddlersFromFile = function(file,basetitle) {
data = fs.readFileSync(file).toString(extensionInfo ? extensionInfo.encoding : "utf8"), data = fs.readFileSync(file).toString(extensionInfo ? extensionInfo.encoding : "utf8"),
tiddlers = $tw.wiki.deserializeTiddlers(ext,data,fields), tiddlers = $tw.wiki.deserializeTiddlers(ext,data,fields),
metafile = file + ".meta"; metafile = file + ".meta";
console.log("loadTiddlersFromFile",file,basetitle,tiddlers);
if(ext !== ".json" && tiddlers.length === 1 && path.existsSync(metafile)) { if(ext !== ".json" && tiddlers.length === 1 && path.existsSync(metafile)) {
var metadata = fs.readFileSync(metafile).toString("utf8"); var metadata = fs.readFileSync(metafile).toString("utf8");
if(metadata) { if(metadata) {
@ -552,15 +546,16 @@ $tw.plugins.loadTiddlersFromFile = function(file,basetitle) {
/* /*
Load all the plugins from the plugins directory Load all the plugins from the plugins directory
*/ */
$tw.plugins.loadPlugins = function(filepath,basetitle) { $tw.plugins.loadPlugins = function(filepath,basetitle,excludeRegExp) {
basetitle = basetitle || "$:/plugins"; basetitle = basetitle || "$:/plugins";
excludeRegExp = excludeRegExp || /^\.DS_Store$|.meta$/;
var stat = fs.statSync(filepath); var stat = fs.statSync(filepath);
if(stat.isDirectory()) { if(stat.isDirectory()) {
var files = fs.readdirSync(filepath); var files = fs.readdirSync(filepath);
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(file !== ".DS_Store" && path.extname(file) !== ".meta") { if(!excludeRegExp.test(file)) {
$tw.plugins.loadPlugins(filepath + "/" + file,basetitle + "/" + file); $tw.plugins.loadPlugins(filepath + "/" + file,basetitle + "/" + file,excludeRegExp);
} }
} }
} else if(stat.isFile()) { } else if(stat.isFile()) {
@ -616,7 +611,7 @@ $tw.plugins.registerPlugins();
// Now we can properly install all of our extension plugins // Now we can properly install all of our extension plugins
$tw.Tiddler.installPlugins(); $tw.Tiddler.installPlugins();
$tw.Wiki.installPlugins(); $tw.plugins.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerPlugins);
// Run any startup plugin modules // Run any startup plugin modules
var mainModules = $tw.plugins.moduleTypes["startup"]; var mainModules = $tw.plugins.moduleTypes["startup"];

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/bootprefix.js title: $:/core/bootprefix.js
type: application/javascript type: application/javascript
This file sets up the globals that need to be available when JavaScript modules are executed in the browser. The overall sequence is: This file sets up the globals that need to be available when JavaScript modules are executed in the browser. The overall sequence is:

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/commander.js title: $:/core/modules/commander.js
type: application/javascript type: application/javascript
module-type: global module-type: global

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/commands/dump.js title: $:/core/modules/commands/dump.js
type: application/javascript type: application/javascript
module-type: command module-type: command

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/commands/load.js title: $:/core/modules/commands/load.js
type: application/javascript type: application/javascript
module-type: command module-type: command

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/commands/verbose.js title: $:/core/modules/commands/verbose.js
type: application/javascript type: application/javascript
module-type: command module-type: command

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/commands/version.js title: $:/core/modules/commands/version.js
type: application/javascript type: application/javascript
module-type: command module-type: command

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/commands/wikitest.js title: $:/core/modules/commands/wikitest.js
type: application/javascript type: application/javascript
module-type: command module-type: command

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/config.js title: $:/core/modules/config.js
type: application/javascript type: application/javascript
module-type: config module-type: config

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/dependencies.js title: $:/core/modules/dependencies.js
type: application/javascript type: application/javascript
module-type: global module-type: global

View File

@ -0,0 +1,32 @@
/*\
title: $:/core/modules/deserializers.js
type: application/javascript
module-type: tiddlerdeserializer
Represents the dependencies of a tiddler or a parser node as these fields:
tiddlers: A hashmap of explicitly tiddler titles, with the value `false` if the dependency is skinny, and `true` if it is fat
dependentAll: True if there is an implicit skinny dependency on all available tiddlers
dependentOnContextTiddler: True if the node has a fat dependency on the current context tiddler
\*/
(function(){
/*jslint node: true */
"use strict";
exports["text/plain"] = function(text,fields) {
return [$tw.utils.extendDeepCopy(fields,{
text: text,
type: "text/plain"
})];
};
exports["text/html"] = function(text,fields) {
return [$tw.utils.extendDeepCopy(fields,{
text: text,
type: "text/html"
})];
};
})();

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/button.js title: $:/core/modules/macros/button.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/chooser.js title: $:/core/modules/macros/chooser.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/echo.js title: $:/core/modules/macros/echo.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/edit/edit.js title: $:/core/modules/macros/edit/edit.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/edit/editors/bitmapeditor.js title: $:/core/modules/macros/edit/editors/bitmapeditor.js
type: application/javascript type: application/javascript
module-type: editor module-type: editor

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/edit/editors/texteditor.js title: $:/core/modules/macros/edit/editors/texteditor.js
type: application/javascript type: application/javascript
module-type: editor module-type: editor

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/image.js title: $:/core/modules/macros/image.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/link.js title: $:/core/modules/macros/link.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/list.js title: $:/core/modules/macros/list.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/slider.js title: $:/core/modules/macros/slider.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/story.js title: $:/core/modules/macros/story.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/tiddler.js title: $:/core/modules/macros/tiddler.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/version.js title: $:/core/modules/macros/version.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/video.js title: $:/core/modules/macros/video.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/view.js title: $:/core/modules/macros/view.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/macros/zoomer.js title: $:/core/modules/macros/zoomer.js
type: application/javascript type: application/javascript
module-type: macro module-type: macro

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/parsers/imageparser.js title: $:/core/modules/parsers/imageparser.js
type: application/javascript type: application/javascript
module-type: parser module-type: parser

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/parsers/jsonparser.js title: $:/core/modules/parsers/jsonparser.js
type: application/javascript type: application/javascript
module-type: parser module-type: parser

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/parsers/plaintextparser.js title: $:/core/modules/parsers/plaintextparser.js
type: application/javascript type: application/javascript
module-type: parser module-type: parser

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/parsers/tiddlytextparser.js title: $:/core/modules/parsers/tiddlytextparser.js
type: application/javascript type: application/javascript
module-type: parser module-type: parser

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/parsers/wikitextparser/rules/wikitextrules.js title: $:/core/modules/parsers/wikitextparser/rules/wikitextrules.js
type: application/javascript type: application/javascript
module-type: wikitextrule module-type: wikitextrule

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/parsers/wikitextparser/wikitextparser.js title: $:/core/modules/parsers/wikitextparser/wikitextparser.js
type: application/javascript type: application/javascript
module-type: parser module-type: parser

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/renderer.js title: $:/core/modules/renderer.js
type: application/javascript type: application/javascript
module-type: global module-type: global

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/startup.js title: $:/core/modules/startup.js
type: application/javascript type: application/javascript
module-type: startup module-type: startup
@ -13,6 +13,7 @@ This is the main application logic for both the client and server
exports.startup = function() { exports.startup = function() {
var modules,n,m,f; var modules,n,m,f;
// Set up additional global objects // Set up additional global objects
$tw.plugins.applyMethods("global",$tw); $tw.plugins.applyMethods("global",$tw);
// Wire up plugin modules // Wire up plugin modules
@ -23,6 +24,10 @@ exports.startup = function() {
$tw.plugins.applyMethods("wikimethod",$tw.Wiki.prototype); $tw.plugins.applyMethods("wikimethod",$tw.Wiki.prototype);
$tw.plugins.applyMethods("treeutils",$tw.Tree); $tw.plugins.applyMethods("treeutils",$tw.Tree);
$tw.plugins.applyMethods("treenode",$tw.Tree); $tw.plugins.applyMethods("treenode",$tw.Tree);
// Load up the tiddlers in the root of the core directory
if(!$tw.isBrowser) {
$tw.plugins.loadPlugins($tw.boot.bootPath,"$:/core",/^\.DS_Store$|.meta$|^modules$/);
}
// Set up the wiki store // Set up the wiki store
$tw.wiki.initMacros(); $tw.wiki.initMacros();
$tw.wiki.initEditors(); $tw.wiki.initEditors();
@ -52,7 +57,6 @@ if($tw.isBrowser) {
commander.execute(); commander.execute();
} }
} }
})(); })();

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/tiddler.js title: $:/core/modules/tiddler.js
type: application/javascript type: application/javascript
module-type: tiddlermethod module-type: tiddlermethod

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/tree.js title: $:/core/modules/tree.js
type: application/javascript type: application/javascript
module-type: global module-type: global

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/tree.utils.js title: $:/core/modules/tree.utils.js
type: application/javascript type: application/javascript
module-type: treeutils module-type: treeutils

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/treenodes/element.js title: $:/core/modules/treenodes/element.js
type: application/javascript type: application/javascript
module-type: treenode module-type: treenode

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/treenodes/entity.js title: $:/core/modules/treenodes/entity.js
type: application/javascript type: application/javascript
module-type: treenode module-type: treenode

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/treenodes/macro.js title: $:/core/modules/treenodes/macro.js
type: application/javascript type: application/javascript
module-type: treenode module-type: treenode

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/treenodes/node.js title: $:/core/modules/treenodes/node.js
type: application/javascript type: application/javascript
module-type: treenode module-type: treenode

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/treenodes/raw.js title: $:/core/modules/treenodes/raw.js
type: application/javascript type: application/javascript
module-type: treenode module-type: treenode

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/treenodes/text.js title: $:/core/modules/treenodes/text.js
type: application/javascript type: application/javascript
module-type: treenode module-type: treenode

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/utils.argparser.js title: $:/core/modules/utils.argparser.js
type: application/javascript type: application/javascript
module-type: utils module-type: utils

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/utils.js title: $:/core/modules/utils.js
type: application/javascript type: application/javascript
module-type: utils module-type: utils
@ -13,6 +13,34 @@ This file is a bit of a dumping ground; the expectation is that most of these fu
/*jslint node: true */ /*jslint node: true */
"use strict"; "use strict";
exports.deepCopy = function(object) {
var result,t;
if($tw.utils.isArray(object)) {
// Copy arrays
result = object.slice(0);
} else if(typeof object === "object") {
result = {};
for(t in object) {
if(object[t] !== undefined) {
result[t] = $tw.utils.deepCopy(object[t]);
}
}
} else {
result = object;
}
return result;
};
exports.extendDeepCopy = function(object,extendedProperties) {
var result = $tw.utils.deepCopy(object),t;
for(var t in extendedProperties) {
if(object[t] !== undefined) {
result[t] = $tw.utils.deepCopy(object[t]);
}
}
return result;
};
exports.formatDateString = function (date,template) { exports.formatDateString = function (date,template) {
var t = template.replace(/0hh12/g,$tw.utils.pad($tw.utils.getHours12(date))); var t = template.replace(/0hh12/g,$tw.utils.pad($tw.utils.getHours12(date)));
t = t.replace(/hh12/g,$tw.utils.getHours12(date)); t = t.replace(/hh12/g,$tw.utils.getHours12(date));

View File

@ -1,5 +1,5 @@
/*\ /*\
title: $:/core/wiki.js title: $:/core/modules/wiki.js
type: application/javascript type: application/javascript
module-type: wikimethod module-type: wikimethod

View File

@ -1,10 +1,21 @@
template: tiddlywiki5.template.html template: tiddlywiki5.template.html
copyright: copyright.txt copyright: core/copyright.txt
version: core/version.txt version: core/version.txt
jsbootstart: core/bootprefix.js jsbootstart: core/bootprefix.js
jsbootend: core/boot.js jsbootend: core/boot.js
shadow: core/tiddlywiki5.template.html
title: $:/core/tiddlywiki5.template.html
shadow: core/copyright.txt
title: $:/core/copyright.txt
shadow: core/version.txt
title: $:/core/version.txt
shadow: core/bootprefix.js
title: $:/core/bootprefix.js
shadow: core/boot.js
title: $:/core/boot.js
pluginmodule: core/modules/*.js pluginmodule: core/modules/*.js
pluginmodule: core/modules/commands/*.js pluginmodule: core/modules/commands/*.js
pluginmodule: core/modules/macros/*.js pluginmodule: core/modules/macros/*.js