diff --git a/boot/boot.js b/boot/boot.js index 7110f9ce8..8d2d877c1 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -62,14 +62,22 @@ $tw.utils.isDate = function(value) { Iterate through all the own properties of an object or array. Callback is invoked with (element,title,object) */ $tw.utils.each = function(object,callback) { - var f; + var next,f; if(object) { if(Object.prototype.toString.call(object) == "[object Array]") { - object.forEach(callback); + for (f=0; f 0) || (diff[0] === 0 && diff[1] > 0) || - (diff[0] === 0 && diff[1] === 0 && diff[2] > 0) || - (diff[0] === 0 && diff[1] === 0 && diff[2] === 0); + (diff[0] === 0 && diff[1] === 0 && diff[2] > 0); }; /* @@ -390,12 +397,20 @@ $tw.utils.registerFileType = function(type,encoding,extension,options) { $tw.config.contentTypeInfo[type] = {encoding: encoding, extension: extension, flags: options.flags || [], deserializerType: options.deserializerType || type}; }; +/* +Given an extension, always access the $tw.config.fileExtensionInfo +using a lowercase extension only. +*/ +$tw.utils.getFileExtensionInfo = function(ext) { + return ext ? $tw.config.fileExtensionInfo[ext.toLowerCase()] : null; +} + /* Given an extension, get the correct encoding for that file. defaults to utf8 */ $tw.utils.getTypeEncoding = function(ext) { - var extensionInfo = $tw.config.fileExtensionInfo[ext], + var extensionInfo = $tw.util.getFileExtensionInfo(ext), type = extensionInfo ? extensionInfo.type : null, typeInfo = type ? $tw.config.contentTypeInfo[type] : null; return typeInfo ? typeInfo.encoding : "utf8"; @@ -413,7 +428,7 @@ $tw.utils.evalGlobal = function(code,context,filename) { contextValues.push(value); }); // Add the code prologue and epilogue - code = "(function(" + contextNames.join(",") + ") {(function(){\n" + code + ";})();\nreturn exports;\n})\n"; + code = "(function(" + contextNames.join(",") + ") {(function(){\n" + code + "\n;})();\nreturn exports;\n})\n"; // Compile the code into a function var fn; if($tw.browser) { @@ -930,7 +945,7 @@ $tw.Wiki = function(options) { }; - // Test for the existence of a tiddler + // Test for the existence of a tiddler (excludes shadow tiddlers) this.tiddlerExists = function(title) { return !!$tw.utils.hop(tiddlers,title); }; @@ -1130,9 +1145,9 @@ $tw.Wiki.prototype.deserializeTiddlers = function(type,text,srcFields) { srcFields = srcFields || Object.create(null); var deserializer = $tw.Wiki.tiddlerDeserializerModules[type], fields = Object.create(null); - if(!deserializer && $tw.config.fileExtensionInfo[type]) { + if(!deserializer && $tw.utils.getFileExtensionInfo(type)) { // If we didn't find the serializer, try converting it from an extension to a content type - type = $tw.config.fileExtensionInfo[type].type; + type = $tw.utils.getFileExtensionInfo(type).type; deserializer = $tw.Wiki.tiddlerDeserializerModules[type]; } if(!deserializer && $tw.config.contentTypeInfo[type]) { @@ -1379,7 +1394,7 @@ Load the tiddlers contained in a particular file (and optionally extract fields */ $tw.loadTiddlersFromFile = function(filepath,fields) { var ext = path.extname(filepath), - extensionInfo = $tw.config.fileExtensionInfo[ext], + extensionInfo = $tw.utils.getFileExtensionInfo(ext), type = extensionInfo ? extensionInfo.type : null, typeInfo = type ? $tw.config.contentTypeInfo[type] : null, data = fs.readFileSync(filepath,typeInfo ? typeInfo.encoding : "utf8"), @@ -1529,7 +1544,7 @@ $tw.getLibraryItemSearchPaths = function(libraryPath,envVar) { var pluginPaths = [path.resolve($tw.boot.corePath,libraryPath)], env = process.env[envVar]; if(env) { - Array.prototype.push.apply(pluginPaths,env.split(":")); + Array.prototype.push.apply(pluginPaths,env.split(path.delimiter)); } return pluginPaths; }; @@ -1899,6 +1914,35 @@ $tw.boot.isStartupTaskEligible = function(taskModule) { return true; }; +/* +Global Hooks mechanism which allows plugins to modify default functionality +*/ +$tw.hooks = $tw.hooks || { names: {}}; + +/* +Add hooks to the hashmap +*/ +$tw.hooks.addHook = function(hookName,definition) { + if($tw.utils.hop($tw.hooks.names,hookName)) { + $tw.hooks.names[hookName].push(definition); + } + else { + $tw.hooks.names[hookName] = [definition]; + } +}; + +/* +Invoke the hook by key +*/ +$tw.hooks.invokeHook = function(hookName, value) { + if($tw.utils.hop($tw.hooks.names,hookName)) { + for (var i = 0; i < $tw.hooks.names[hookName].length; i++) { + value = $tw.hooks.names[hookName][i](value); + } + } + return value; +}; + /////////////////////////// Main boot function to decrypt tiddlers and then startup $tw.boot.boot = function() { diff --git a/boot/bootprefix.js b/boot/bootprefix.js index bff9a2aa2..ae0712d4e 100644 --- a/boot/bootprefix.js +++ b/boot/bootprefix.js @@ -20,9 +20,15 @@ $tw = $tw || Object.create(null); $tw.boot = $tw.boot || Object.create(null); // Detect platforms -$tw.browser = typeof(window) !== "undefined" ? {} : null; -$tw.node = typeof(process) === "object" ? {} : null; -$tw.nodeWebKit = $tw.node && global.window && global.window.nwDispatcher ? {} : null; +if(!("browser" in $tw)) { + $tw.browser = typeof(window) !== "undefined" ? {} : null; +} +if(!("node" in $tw)) { + $tw.node = typeof(process) === "object" ? {} : null; +} +if(!("nodeWebKit" in $tw)) { + $tw.nodeWebKit = $tw.node && global.window && global.window.nwDispatcher ? {} : null; +} // Set default boot tasks $tw.boot.tasks = { diff --git a/core/language/en-GB/Buttons.multids b/core/language/en-GB/Buttons.multids index cd37e963f..1c3830a7b 100644 --- a/core/language/en-GB/Buttons.multids +++ b/core/language/en-GB/Buttons.multids @@ -3,7 +3,7 @@ title: $:/language/Buttons/ AdvancedSearch/Caption: advanced search AdvancedSearch/Hint: Advanced search Cancel/Caption: cancel -Cancel/Hint: Cancel editing this tiddler +Cancel/Hint: Discard changes to this tiddler Clone/Caption: clone Clone/Hint: Clone this tiddler Close/Caption: close @@ -56,8 +56,8 @@ Permaview/Caption: permaview Permaview/Hint: Set browser address bar to a direct link to all the tiddlers in this story Refresh/Caption: refresh Refresh/Hint: Perform a full refresh of the wiki -Save/Caption: save -Save/Hint: Save this tiddler +Save/Caption: ok +Save/Hint: Store changes to this tiddler SaveWiki/Caption: save changes SaveWiki/Hint: Save changes StoryView/Caption: storyview diff --git a/core/language/en-GB/ControlPanel.multids b/core/language/en-GB/ControlPanel.multids index e39598c83..6c8d989fa 100644 --- a/core/language/en-GB/ControlPanel.multids +++ b/core/language/en-GB/ControlPanel.multids @@ -56,7 +56,7 @@ Saving/TiddlySpot/Backups: Backups Saving/TiddlySpot/Description: These settings are only used when saving to http://tiddlyspot.com or a compatible remote server Saving/TiddlySpot/Filename: Upload Filename Saving/TiddlySpot/Heading: ~TiddlySpot -Saving/TiddlySpot/Hint: //The server URL defaults to `http://.tiddlyspot.com/store.cgi` and can be changed to use a custom server address// +Saving/TiddlySpot/Hint: //The server URL defaults to `http://.tiddlyspot.com/store.cgi` and can be changed to use a custom server address, e.g. `http://me.com/store.php`.// Saving/TiddlySpot/Password: Password Saving/TiddlySpot/ServerURL: Server URL Saving/TiddlySpot/UploadDir: Upload Directory @@ -94,3 +94,5 @@ Toolbars/PageControls/Caption: Page Toolbar Toolbars/PageControls/Hint: Choose which buttons are displayed on the main page toolbar Toolbars/ViewToolbar/Caption: View Toolbar Toolbars/ViewToolbar/Hint: Choose which buttons are displayed for tiddlers in view mode +Tools/Download/Full/Caption: Download full wiki + diff --git a/core/language/en-GB/Filters.multids b/core/language/en-GB/Filters.multids index 652b78f3c..45f8991fc 100644 --- a/core/language/en-GB/Filters.multids +++ b/core/language/en-GB/Filters.multids @@ -11,3 +11,4 @@ SystemTiddlers: System tiddlers ShadowTiddlers: Shadow tiddlers OverriddenShadowTiddlers: Overridden shadow tiddlers SystemTags: System tags +TypedTiddlers: Non wiki-text tiddlers \ No newline at end of file diff --git a/core/language/en-GB/GettingStarted.tid b/core/language/en-GB/GettingStarted.tid index 37253b1f0..99ae6bd10 100644 --- a/core/language/en-GB/GettingStarted.tid +++ b/core/language/en-GB/GettingStarted.tid @@ -1,13 +1,14 @@ title: GettingStarted -Welcome to TiddlyWiki, the non-linear personal web notebook. +\define lingo-base() $:/language/ControlPanel/Basics/ +Welcome to ~TiddlyWiki and the ~TiddlyWiki community -To get started, first verify that you can save changes successfully - see http://tiddlywiki.com/ for detailed instructions. +Before you start storing important information in ~TiddlyWiki it is important to make sure that you can reliably save changes. See http://tiddlywiki.com/#GettingStarted for details -Then you can: +!! Set up this ~TiddlyWiki -* Create new tiddlers using the 'plus' button in the sidebar -* Visit the [[control panel|$:/ControlPanel]] using the 'cog' button in the sidebar to customise your wiki -** Stop this message appearing by changing the default tiddlers under the ''Basics'' tab -* Save changes using the 'download' button in the sidebar -* Learn more about [[WikiText|http://tiddlywiki.com/static/WikiText.html]] +|<$link to="$:/SiteTitle"><> |<$edit-text tiddler="$:/SiteTitle" default="" tag="input"/> | +|<$link to="$:/SiteSubtitle"><> |<$edit-text tiddler="$:/SiteSubtitle" default="" tag="input"/> | +|<$link to="$:/DefaultTiddlers"><> |<>
<$edit-text tag="textarea" tiddler="$:/DefaultTiddlers"/>
//<>// | + +See the [[control panel|$:/ControlPanel]] for more options. diff --git a/core/language/en-GB/Help/rendertiddlers.tid b/core/language/en-GB/Help/rendertiddlers.tid index 158872f23..cb982efb3 100644 --- a/core/language/en-GB/Help/rendertiddlers.tid +++ b/core/language/en-GB/Help/rendertiddlers.tid @@ -4,7 +4,7 @@ description: Render tiddlers matching a filter to a specified ContentType Render a set of tiddlers matching a filter to separate files of a specified ContentType (defaults to `text/html`) and extension (defaults to `.html`). ``` ---rendertiddlers