diff --git a/js/FileStore.js b/js/FileStore.js new file mode 100644 index 000000000..365d5d56f --- /dev/null +++ b/js/FileStore.js @@ -0,0 +1,82 @@ +/*\ +title: js/FileStore.js + +\*/ +(function(){ + +/*jslint node: true */ +"use strict"; + +var retrieveFile = require("./FileRetriever.js").retrieveFile, + fs = require("fs"), + path = require("path"), + url = require("url"), + util = require("util"), + async = require("async"); + +function FileStore(dirpath,store,callback) { + this.dirpath = dirpath; + this.store = store; + this.callback = callback; + var self = this; + // Set up a queue for loading tiddler files + this.loadQueue = async.queue(function(task,callback) { + retrieveFile(task.filepath,self.dirpath,function(err,data) { + if(err) { + callback(err); + } else { + // Use the filepath as the default title and src for the tiddler + var fields = { + title: data.path, + src: data.path + }; + var tiddlers = self.store.deserializeTiddlers(data.extname,data.text,fields); + // Check for the .meta file + if(data.extname !== ".json" && tiddlers.length === 1) { + var metafile = task.filepath + ".meta"; + retrieveFile(metafile,self.dirpath,function(err,data) { + if(err && err.code !== "ENOENT" && err.code !== "404") { + callback(err); + } else { + var fields = tiddlers[0]; + if(!err) { + var text = data.text.split("\n\n")[0]; + if(text) { + fields = self.store.deserializeTiddlers("application/x-tiddler",text,fields)[0]; + } + } + self.store.addTiddler(fields); + callback(null); + } + }); + } else { + self.store.addTiddlers(tiddlers); + callback(null); + } + } + }); + },10); + // Call the callback when all the files are loaded + this.loadQueue.drain = function() { + callback(null); + }; + // Query the folder content to get all the tiddlers + fs.readdir(this.dirpath,function(err,files) { + if(err) { + callback(err); + } else { + for(var t=0; t 1) && (Recipe.compatibilityCheats[marker] === "suppressLeadingNewline")) { var lastLine = out[out.length-1]; diff --git a/readme.md b/readme.md index 76c1a6a45..b008967eb 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,12 @@ -

Welcome to TiddlyWiki5

Welcome to TiddlyWiki5, a reboot of TiddlyWiki, the venerable, reusable non-linear personal web notebook first released in 2004. It is a complete interactive wiki that can run from a single HTML file in the browser or as a powerful node.js application.

TiddlyWiki5 is currently in early beta, which is to say that it is useful but incomplete. You can get involved in the development on GitHub and the discussions on the TiddlyWikiDev Google Group.

Usage

TiddlyWiki5 can be used on the command line to perform an extensive set of operations based on RecipeFiles, TiddlerFiles and TiddlyWikiFiles.

Usage:
+

Welcome to TiddlyWiki5

Welcome to TiddlyWiki5, a reboot of TiddlyWiki, the venerable, reusable non-linear personal web notebook first released in 2004. It is a complete interactive wiki that can run from a single HTML file in the browser or as a powerful node.js application.

TiddlyWiki5 is currently in early beta, which is to say that it is useful but incomplete. You can get involved in the development on GitHub and the discussions on the TiddlyWikiDev Google Group.

Usage

TiddlyWiki5 can be used on the command line to perform an extensive set of operations based on RecipeFiles, TiddlerFiles and TiddlyWikiFiles.

The command line interface for TiddlyWiki5 has been designed to support two distinct usages:

Usage

node tiddlywiki.js <options> -
The command line options are processed sequentially from left to right. Processing pauses during long operations, like loading a recipe file and all the subrecipes and tiddlers that it references, and then resumes with the next command line option in sequence. The following options are available:
--recipe <filepath>Loads a specfied .recipe file
--load <filepath>Load additional tiddlers from 2.x.x TiddlyWiki files (.html), .tiddler, .tid, .json or other files
--savewiki <dirpath>Saves all the loaded tiddlers as a single file TiddlyWiki called index.html and an RSS feed called index.xml in a new directory of the specified name
--savetiddler <title> <filename> [<type>]Save an individual tiddler as a specified MIME type, defaults to text/html
--savetiddlers <outdir>Saves all the loaded tiddlers as .tid files in the specified directory
--savehtml <outdir>Saves all the loaded tiddlers as static, unstyled .html files in the specified directory
--servewiki <port>Serve the cooked TiddlyWiki over HTTP at /
--servetiddlers <port>Serve individual tiddlers over HTTP at /tiddlertitle
--wikitest <dir> [save]Run wikification tests against the tiddlers in the given directory. Include the save flag to save the test result files as the new targets
--dumpstoreDump the TiddlyWiki store in JSON format
--dumprecipeDump the current recipe in JSON format
--verboseverbose output, useful for debugging

Examples

This example loads the tiddlers from a TiddlyWiki HTML file and makes them available over HTTP:
+
The command line options are processed sequentially from left to right. Processing pauses during long operations, like loading a recipe file and all the subrecipes and tiddlers that it references, and then resumes with the next command line option in sequence.

The state that is carried between options is as follows:
  • The set of tiddlers that are currently loaded into memory
  • The recipe file last used to load tiddlers (recipe files are used primarily to manage shadow tiddlers)
  • The TiddlerFileStore used to store the main content tiddlers. This is independent of the current recipe

The following options are available:
--recipe <filepath>Loads a specfied .recipe file
--load <filepath>Load additional tiddlers from 2.x.x TiddlyWiki files (.html), .tiddler, .tid, .json or other files
--store <dirpath>Load a specified TiddlerFileStore
--savewiki <dirpath>Saves all the loaded tiddlers as a single file TiddlyWiki called index.html and an RSS feed called index.xml in a new directory of the specified name
--savetiddler <title> <filename> [<type>]Save an individual tiddler as a specified MIME type, defaults to text/html
--savetiddlers <outdir>Saves all the loaded tiddlers as .tid files in the specified directory
--savehtml <outdir>Saves all the loaded tiddlers as static, unstyled .html files in the specified directory
--servewiki <port>Serve the cooked TiddlyWiki over HTTP at /
--servetiddlers <port>Serve individual tiddlers over HTTP at /tiddlertitle
--wikitest <dir> [save]Run wikification tests against the tiddlers in the given directory. Include the save flag to save the test result files as the new targets
--dumpstoreDump the TiddlyWiki store in JSON format
--dumprecipeDump the current recipe in JSON format
--verboseverbose output, useful for debugging

Examples

This example loads the tiddlers from a TiddlyWiki HTML file and makes them available over HTTP:
node tiddlywiki.js --load mywiki.html --servewiki 127.0.0.1:8000
This example cooks a TiddlyWiki from a recipe:
node tiddlywiki.js --recipe tiddlywiki.com/index.recipe --savewiki tmp/
This example ginsus a TiddlyWiki into its constituent tiddlers:
node tiddlywiki.js --load mywiki.html --savetiddlers tmp/tiddlers -

Notes

--servewiki and --servertiddlers are for different purposes and should not be used together. The former is for TiddlyWiki core developers who want to be able to edit the TiddlyWiki source files in a text editor and view the results in the browser by clicking refresh; it is slow because it reloads all the TiddlyWiki JavaScript files each time the page is loaded. The latter is for experimenting with the new wikification engine.

--wikitest looks for *.tid files in the specified folder. It then wikifies the tiddlers to both "text/plain" and "text/html" format and checks the results against the content of the *.html and *.txt files in the same directory.

Testing

Test Scripts


Three test scripts are provided, each as a Mac OS X *.sh bash script and a Windows *.bat batch file.

  • test.sh/test.bat cooks the main tiddlywiki.com recipe for TiddlyWiki 2.6.5 and compares it with the results of the old build process (ie, running cook.rb and then opening the file in a browser and performing a 'save changes' operation). It also runs a series of wikifications tests that work off the data in test/wikitests/.
  • tw5.sh/tw5.bat builds TiddlyWiki5 as a static HTML file
  • tw5s.sh/tw5s.bat serves TiddlyWiki5 over HTTP on port 8080

Architecture

Overview


The heart of TiddlyWiki can be seen as an extensible representation transformation engine. Given the text of a tiddler and its associated MIME type, the engine can produce a rendering of the tiddler in a new MIME type. Furthermore, it can efficiently selectively update the rendering to track any changes in the tiddler or its dependents.

The most important transformations are from text/x-tiddlywiki wikitext into text/html or text/plain but the engine is used throughout the system for other transformations, such as converting images for display in HTML, sanitising fragments of JavaScript, and processing CSS.

The key feature of wikitext is the ability to include one tiddler within another (usually referred to as transclusion). For example, one could have a tiddler called Disclaimer that contains the boilerplate of a legal disclaimer, and then include it within lots of different tiddlers with the macro call <<tiddler Disclaimer>>. This simple feature brings great power in terms of encapsulating and reusing content, and evolving a clean, usable implementation architecture to support it efficiently is a key objective of the TiddlyWiki5 design.

It turns out that the transclusion capability combined with the selective refreshing mechanism provides a good foundation for building TiddlyWiki's user interface itself. Consider, for example, the StoryMacro in its simplest form:
<<story story:MyStoryTiddler>>
+

Notes

--servewiki and --servetiddlers are for different purposes and should not be used together. The former is for TiddlyWiki core developers who want to be able to edit the TiddlyWiki source files in a text editor and view the results in the browser by clicking refresh; it is slow because it reloads all the TiddlyWiki JavaScript files each time the page is loaded. The latter is for experimenting with the new wikification engine.

--wikitest looks for *.tid files in the specified folder. It then wikifies the tiddlers to both "text/plain" and "text/html" format and checks the results against the content of the *.html and *.txt files in the same directory.

Testing

Test Scripts


Three test scripts are provided, each as a Mac OS X *.sh bash script and a Windows *.bat batch file. In each case they should be run with the current directory set to the directory in which they reside.

  • test.sh/test.bat cooks the main tiddlywiki.com recipe for TiddlyWiki 2.6.5 and compares it with the results of the old build process (ie, running cook.rb and then opening the file in a browser and performing a 'save changes' operation). It also runs a series of wikifications tests that work off the data in test/wikitests/.
  • tw5.sh/tw5.bat builds TiddlyWiki5 as a static HTML file
  • tw5s.sh/tw5s.bat serves TiddlyWiki5 over HTTP on port 8080

Architecture

Overview


The heart of TiddlyWiki can be seen as an extensible representation transformation engine. Given the text of a tiddler and its associated MIME type, the engine can produce a rendering of the tiddler in a new MIME type. Furthermore, it can efficiently selectively update the rendering to track any changes in the tiddler or its dependents.

The most important transformations are from text/x-tiddlywiki wikitext into text/html or text/plain but the engine is used throughout the system for other transformations, such as converting images for display in HTML, sanitising fragments of JavaScript, and processing CSS.

The key feature of wikitext is the ability to include one tiddler within another (usually referred to as transclusion). For example, one could have a tiddler called Disclaimer that contains the boilerplate of a legal disclaimer, and then include it within lots of different tiddlers with the macro call <<tiddler Disclaimer>>. This simple feature brings great power in terms of encapsulating and reusing content, and evolving a clean, usable implementation architecture to support it efficiently is a key objective of the TiddlyWiki5 design.

It turns out that the transclusion capability combined with the selective refreshing mechanism provides a good foundation for building TiddlyWiki's user interface itself. Consider, for example, the StoryMacro in its simplest form:
<<story story:MyStoryTiddler>>
 
The story macro looks for a list of tiddler titles in the tiddler MyStoryTiddler, and displays them in sequence. The subtle part is that subsequently, if MyStoryTiddler changes, the <<story>> macro is selectively re-rendered. So, to navigate to a new tiddler, code merely needs to add the name of the tiddler and a line break to the top of MyStoryTiddler:
var storyTiddler = store.getTiddler("MyStoryTiddler");
 store.addTiddler(new Tiddler(storyTiddler,{text: navigateTo + "\n" + storyTiddler.text}));
 
The mechanisms that allow all of this to work are fairly intricate. The sections below progressively build the key architectural concepts of TiddlyWiki5 in a way that should provide a good basis for exploring the code directly.

Tiddlers

Tiddlers are an immutable dictionary of name:value pairs called fields.

The only field that is required is the title field, but useful tiddlers also have a text field, and some or all of the standard fields modified, modifier, created, creator, tags and type.

Hardcoded in the system is the knowledge that the tags field is a string array, and that the modified and created fields are JavaScript Date objects. All other fields are strings.

The type field identifies the representation of the tiddler text with a MIME type.

WikiStore

Groups of uniquely titled tiddlers are contained in WikiStore objects.

The WikiStore also manages the plugin modules used for macros, and operations like serializing, deserializing, parsing and rendering tiddlers.

Each WikiStore is connected to another shadow store that is used to provide default content. Under usual circumstances, when an attempt is made to retrieve a tiddler that doesn't exist in the store, the search continues into its shadow store (and so on, if the shadow store itself has a shadow store).

WikiStore Events

Clients can register event handlers with the WikiStore object. Event handlers can be registered to be triggered for modifications to any tiddler in the store, or with a filter to only be invoked when a particular tiddler or set of tiddlers changes.

Whenever a change is made to a tiddler, the wikistore registers a nexttick handler (if it hasn't already done so). The nexttick handler looks back at all the tiddler changes, and dispatches any matching event handlers.

Parsing and Rendering

TiddlyWiki parses the content of tiddlers to build an internal tree representation that is used for several purposes:
  • Rendering a tiddler to other formats (e.g. converting wikitext to HTML)
  • Detecting outgoing links from a tiddler, and from them...
  • ...computing incoming links to a tiddler
  • Detecting tiddlers that are orphans with no incoming links
  • Detecting tiddlers that are referred to but missing
The parse tree is built when needed, and then cached by the WikiStore until the tiddler changes.

TiddlyWiki5 uses multiple parsers:
  • Wikitext (text/x-tiddlywiki) in js/WikiTextParser.js
  • JavaScript (text/javascript) in js/JavaScriptParser.js
  • Images (image/png and image/jpg) in js/ImageParser.js
  • JSON (application/json) in js/JSONParser.js
Additional parsers are planned:
  • CSS (text/css)
  • Recipe (text/x-tiddlywiki-recipe)
One global instance of each parser is instantiated in js/App.js and registered with the main WikiStore object.

The parsers are all used the same way:
var parseTree = parser.parse(type,text) // Parses the text and returns a parse tree object
diff --git a/tiddlywiki.js b/tiddlywiki.js
index 5547b30bf..1e05e628c 100644
--- a/tiddlywiki.js
+++ b/tiddlywiki.js
@@ -9,6 +9,7 @@ TiddlyWiki command line interface
 
 var App = require("./js/App.js").App,
 	WikiStore = require("./js/WikiStore.js").WikiStore,
+	FileStore = require("./js/FileStore.js").FileStore,
 	Tiddler = require("./js/Tiddler.js").Tiddler,
 	Recipe = require("./js/Recipe.js").Recipe,
 	tiddlerInput = require("./js/TiddlerInput.js"),
@@ -47,6 +48,7 @@ var parseOptions = function(args,defaultSwitch) {
 
 var switches = parseOptions(Array.prototype.slice.call(process.argv,2),"dummy"),
 	recipe = null,
+	fileStore = null,
 	lastRecipeFilepath = null,
 	currSwitch = 0;
 
@@ -106,6 +108,14 @@ var commandLineSwitches = {
 			});
 		}
 	},
+	store: {
+		args: {min: 1, max: 1},
+		handler: function(args,callback) {
+			fileStore = new FileStore(args[0],app.store,function() {
+				callback(null);
+			});
+		}
+	},
 	savewiki: {
 		args: {min: 1, max: 1},
 		handler: function(args,callback) {
diff --git a/tiddlywiki5/tiddlers/Command Line Sketch.jpg b/tiddlywiki5/store/Command Line Sketch.jpg
similarity index 100%
rename from tiddlywiki5/tiddlers/Command Line Sketch.jpg
rename to tiddlywiki5/store/Command Line Sketch.jpg
diff --git a/tiddlywiki5/tiddlers/Command Line Sketch.jpg.meta b/tiddlywiki5/store/Command Line Sketch.jpg.meta
similarity index 100%
rename from tiddlywiki5/tiddlers/Command Line Sketch.jpg.meta
rename to tiddlywiki5/store/Command Line Sketch.jpg.meta
diff --git a/tiddlywiki5/tiddlers/CommandLineInterface.tid b/tiddlywiki5/store/CommandLineInterface.tid
similarity index 66%
rename from tiddlywiki5/tiddlers/CommandLineInterface.tid
rename to tiddlywiki5/store/CommandLineInterface.tid
index 78f0e6a51..82ab9d424 100644
--- a/tiddlywiki5/tiddlers/CommandLineInterface.tid
+++ b/tiddlywiki5/store/CommandLineInterface.tid
@@ -3,13 +3,25 @@ modifier: JeremyRuston
 
 TiddlyWiki5 can be used on the command line to perform an extensive set of operations based on RecipeFiles, TiddlerFiles and TiddlyWikiFiles.
 
-Usage:
+The command line interface for TiddlyWiki5 has been designed to support two distinct usages:
+* Cooking (or building) old 2.6.x versions of classic TiddlyWiki from the constituent JavaScript components
+* Cooking and serving TiddlyWiki5 itself
+
+!!Usage
 `
 node tiddlywiki.js 
 `
-The command line options are processed sequentially from left to right. Processing pauses during long operations, like loading a [[recipe file|RecipeFiles]] and all the subrecipes and [[tiddlers|TiddlerFiles]] that it references, and then resumes with the next command line option in sequence. The following options are available:
+The command line options are processed sequentially from left to right. Processing pauses during long operations, like loading a [[recipe file|RecipeFiles]] and all the subrecipes and [[tiddlers|TiddlerFiles]] that it references, and then resumes with the next command line option in sequence.
+
+The state that is carried between options is as follows:
+* The set of tiddlers that are currently loaded into memory
+* The recipe file last used to load tiddlers (recipe files are used primarily to manage shadow tiddlers)
+* The TiddlerFileStore used to store the main content tiddlers. This is independent of the current recipe
+
+The following options are available:
 |`--recipe ` |Loads a specfied `.recipe` file |
 |`--load ` |Load additional tiddlers from 2.x.x TiddlyWiki files (`.html`), `.tiddler`, `.tid`, `.json` or other files |
+|`--store ` |Load a specified TiddlerFileStore |
 |`--savewiki ` |Saves all the loaded tiddlers as a single file TiddlyWiki called `index.html` and an RSS feed called `index.xml` in a new directory of the specified name |
 |`--savetiddler  <filename> [<type>]` |Save an individual tiddler as a specified MIME type, defaults to `text/html` |
 |`--savetiddlers <outdir>` |Saves all the loaded tiddlers as `.tid` files in the specified directory |
@@ -34,6 +46,6 @@ This example ginsus a TiddlyWiki into its constituent tiddlers:
 node tiddlywiki.js --load mywiki.html --savetiddlers tmp/tiddlers
 `
 !! Notes
-`--servewiki` and `--servertiddlers` are for different purposes and should not be used together. The former is for TiddlyWiki core developers who want to be able to edit the TiddlyWiki source files in a text editor and view the results in the browser by clicking refresh; it is slow because it reloads all the TiddlyWiki JavaScript files each time the page is loaded. The latter is for experimenting with the new wikification engine.
+`--servewiki` and `--servetiddlers` are for different purposes and should not be used together. The former is for TiddlyWiki core developers who want to be able to edit the TiddlyWiki source files in a text editor and view the results in the browser by clicking refresh; it is slow because it reloads all the TiddlyWiki JavaScript files each time the page is loaded. The latter is for experimenting with the new wikification engine.
 
-`--wikitest` looks for `*.tid` files in the specified folder. It then wikifies the tiddlers to both "text/plain" and "text/html" format and checks the results against the content of the `*.html` and `*.txt` files in the same directory.
\ No newline at end of file
+`--wikitest` looks for `*.tid` files in the specified folder. It then wikifies the tiddlers to both "text/plain" and "text/html" format and checks the results against the content of the `*.html` and `*.txt` files in the same directory.
diff --git a/tiddlywiki5/tiddlers/HelloThere.tid b/tiddlywiki5/store/HelloThere.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/HelloThere.tid
rename to tiddlywiki5/store/HelloThere.tid
diff --git a/tiddlywiki5/tiddlers/High Level Architecture.graffle b/tiddlywiki5/store/High Level Architecture.graffle
similarity index 100%
rename from tiddlywiki5/tiddlers/High Level Architecture.graffle
rename to tiddlywiki5/store/High Level Architecture.graffle
diff --git a/tiddlywiki5/tiddlers/High Level Architecture.svg b/tiddlywiki5/store/High Level Architecture.svg
similarity index 100%
rename from tiddlywiki5/tiddlers/High Level Architecture.svg
rename to tiddlywiki5/store/High Level Architecture.svg
diff --git a/tiddlywiki5/tiddlers/High Level Architecture.svg.meta b/tiddlywiki5/store/High Level Architecture.svg.meta
similarity index 100%
rename from tiddlywiki5/tiddlers/High Level Architecture.svg.meta
rename to tiddlywiki5/store/High Level Architecture.svg.meta
diff --git a/tiddlywiki5/tiddlers/ImageTests.tid b/tiddlywiki5/store/ImageTests.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/ImageTests.tid
rename to tiddlywiki5/store/ImageTests.tid
diff --git a/tiddlywiki5/tiddlers/Introduction.tid b/tiddlywiki5/store/Introduction.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/Introduction.tid
rename to tiddlywiki5/store/Introduction.tid
diff --git a/tiddlywiki5/tiddlers/JackSlider.tid b/tiddlywiki5/store/JackSlider.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/JackSlider.tid
rename to tiddlywiki5/store/JackSlider.tid
diff --git a/tiddlywiki5/tiddlers/MacroInternals.tid b/tiddlywiki5/store/MacroInternals.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/MacroInternals.tid
rename to tiddlywiki5/store/MacroInternals.tid
diff --git a/tiddlywiki5/tiddlers/Main Screen Sketch.jpg b/tiddlywiki5/store/Main Screen Sketch.jpg
similarity index 100%
rename from tiddlywiki5/tiddlers/Main Screen Sketch.jpg
rename to tiddlywiki5/store/Main Screen Sketch.jpg
diff --git a/tiddlywiki5/tiddlers/Main Screen Sketch.jpg.meta b/tiddlywiki5/store/Main Screen Sketch.jpg.meta
similarity index 100%
rename from tiddlywiki5/tiddlers/Main Screen Sketch.jpg.meta
rename to tiddlywiki5/store/Main Screen Sketch.jpg.meta
diff --git a/tiddlywiki5/tiddlers/Motovun Jack.jpg b/tiddlywiki5/store/Motovun Jack.jpg
similarity index 100%
rename from tiddlywiki5/tiddlers/Motovun Jack.jpg
rename to tiddlywiki5/store/Motovun Jack.jpg
diff --git a/tiddlywiki5/tiddlers/Motovun Jack.jpg.meta b/tiddlywiki5/store/Motovun Jack.jpg.meta
similarity index 100%
rename from tiddlywiki5/tiddlers/Motovun Jack.jpg.meta
rename to tiddlywiki5/store/Motovun Jack.jpg.meta
diff --git a/tiddlywiki5/tiddlers/NewWikiTextFeatures.tid b/tiddlywiki5/store/NewWikiTextFeatures.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/NewWikiTextFeatures.tid
rename to tiddlywiki5/store/NewWikiTextFeatures.tid
diff --git a/tiddlywiki5/tiddlers/ReadMe.tid b/tiddlywiki5/store/ReadMe.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/ReadMe.tid
rename to tiddlywiki5/store/ReadMe.tid
diff --git a/tiddlywiki5/tiddlers/RecipeFiles.tid b/tiddlywiki5/store/RecipeFiles.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/RecipeFiles.tid
rename to tiddlywiki5/store/RecipeFiles.tid
diff --git a/tiddlywiki5/tiddlers/SampleData.tid b/tiddlywiki5/store/SampleData.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/SampleData.tid
rename to tiddlywiki5/store/SampleData.tid
diff --git a/tiddlywiki5/tiddlers/SampleJavaScript.tid b/tiddlywiki5/store/SampleJavaScript.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/SampleJavaScript.tid
rename to tiddlywiki5/store/SampleJavaScript.tid
diff --git a/tiddlywiki5/tiddlers/SampleJavaScriptWithError.tid b/tiddlywiki5/store/SampleJavaScriptWithError.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/SampleJavaScriptWithError.tid
rename to tiddlywiki5/store/SampleJavaScriptWithError.tid
diff --git a/tiddlywiki5/tiddlers/ShadowTiddlers.tid b/tiddlywiki5/store/ShadowTiddlers.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/ShadowTiddlers.tid
rename to tiddlywiki5/store/ShadowTiddlers.tid
diff --git a/tiddlywiki5/tiddlers/SiteSubtitle.tid b/tiddlywiki5/store/SiteSubtitle.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/SiteSubtitle.tid
rename to tiddlywiki5/store/SiteSubtitle.tid
diff --git a/tiddlywiki5/tiddlers/SiteTitle.tid b/tiddlywiki5/store/SiteTitle.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/SiteTitle.tid
rename to tiddlywiki5/store/SiteTitle.tid
diff --git a/tiddlywiki5/tiddlers/SliderTests.tid b/tiddlywiki5/store/SliderTests.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/SliderTests.tid
rename to tiddlywiki5/store/SliderTests.tid
diff --git a/tiddlywiki5/tiddlers/Testing.tid b/tiddlywiki5/store/Testing.tid
similarity index 79%
rename from tiddlywiki5/tiddlers/Testing.tid
rename to tiddlywiki5/store/Testing.tid
index f192c396e..b1d391654 100644
--- a/tiddlywiki5/tiddlers/Testing.tid
+++ b/tiddlywiki5/store/Testing.tid
@@ -2,7 +2,7 @@ title: Testing
 
 !Test Scripts
 
-Three test scripts are provided, each as a Mac OS X `*.sh` bash script and a Windows `*.bat` batch file.
+Three test scripts are provided, each as a Mac OS X `*.sh` bash script and a Windows `*.bat` batch file. In each case they should be run with the current directory set to the directory in which they reside.
 
 * `test.sh`/`test.bat` cooks the main tiddlywiki.com recipe for TiddlyWiki 2.6.5 and compares it with the results of the old build process (ie, running cook.rb and then opening the file in a browser and performing a 'save changes' operation). It also runs a series of wikifications tests that work off the data in `test/wikitests/`.
 * `tw5.sh`/`tw5.bat` builds TiddlyWiki5 as a static HTML file
diff --git a/tiddlywiki5/tiddlers/Tiddler Fishes.svg b/tiddlywiki5/store/Tiddler Fishes.svg
similarity index 100%
rename from tiddlywiki5/tiddlers/Tiddler Fishes.svg
rename to tiddlywiki5/store/Tiddler Fishes.svg
diff --git a/tiddlywiki5/tiddlers/Tiddler Fishes.svg.meta b/tiddlywiki5/store/Tiddler Fishes.svg.meta
similarity index 100%
rename from tiddlywiki5/tiddlers/Tiddler Fishes.svg.meta
rename to tiddlywiki5/store/Tiddler Fishes.svg.meta
diff --git a/tiddlywiki5/tiddlers/TiddlerFiles.tid b/tiddlywiki5/store/TiddlerFiles.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/TiddlerFiles.tid
rename to tiddlywiki5/store/TiddlerFiles.tid
diff --git a/tiddlywiki5/tiddlers/TiddlyWiki.tid b/tiddlywiki5/store/TiddlyWiki.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/TiddlyWiki.tid
rename to tiddlywiki5/store/TiddlyWiki.tid
diff --git a/tiddlywiki5/tiddlers/TiddlyWikiArchitecture.tid b/tiddlywiki5/store/TiddlyWikiArchitecture.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/TiddlyWikiArchitecture.tid
rename to tiddlywiki5/store/TiddlyWikiArchitecture.tid
diff --git a/tiddlywiki5/tiddlers/TiddlyWikiInternals.tid b/tiddlywiki5/store/TiddlyWikiInternals.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/TiddlyWikiInternals.tid
rename to tiddlywiki5/store/TiddlyWikiInternals.tid
diff --git a/tiddlywiki5/tiddlers/TypedBlockTests.tid b/tiddlywiki5/store/TypedBlockTests.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/TypedBlockTests.tid
rename to tiddlywiki5/store/TypedBlockTests.tid
diff --git a/tiddlywiki5/tiddlers/UserInterfaceSketches.tid b/tiddlywiki5/store/UserInterfaceSketches.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/UserInterfaceSketches.tid
rename to tiddlywiki5/store/UserInterfaceSketches.tid
diff --git a/tiddlywiki5/tiddlers/VideoTests.tid b/tiddlywiki5/store/VideoTests.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/VideoTests.tid
rename to tiddlywiki5/store/VideoTests.tid
diff --git a/tiddlywiki5/tiddlers/View Switcher Sketch.jpg b/tiddlywiki5/store/View Switcher Sketch.jpg
similarity index 100%
rename from tiddlywiki5/tiddlers/View Switcher Sketch.jpg
rename to tiddlywiki5/store/View Switcher Sketch.jpg
diff --git a/tiddlywiki5/tiddlers/View Switcher Sketch.jpg.meta b/tiddlywiki5/store/View Switcher Sketch.jpg.meta
similarity index 100%
rename from tiddlywiki5/tiddlers/View Switcher Sketch.jpg.meta
rename to tiddlywiki5/store/View Switcher Sketch.jpg.meta
diff --git a/tiddlywiki5/tiddlers/WaysToUseTiddlyWiki.tid b/tiddlywiki5/store/WaysToUseTiddlyWiki.tid
similarity index 100%
rename from tiddlywiki5/tiddlers/WaysToUseTiddlyWiki.tid
rename to tiddlywiki5/store/WaysToUseTiddlyWiki.tid
diff --git a/tiddlywiki5/tiddlywiki5.recipe b/tiddlywiki5/tiddlywiki5.recipe
index b1762408c..036acfb42 100644
--- a/tiddlywiki5/tiddlywiki5.recipe
+++ b/tiddlywiki5/tiddlywiki5.recipe
@@ -2,10 +2,6 @@ template: tiddlywiki5.template.html
 copyright: ../copyright.txt
 style: shadows/css/*.css
 
-tiddler: tiddlers/*.tid
-tiddler: tiddlers/*.jpg
-tiddler: tiddlers/*.png
-tiddler: tiddlers/*.svg
 shadow: shadows/*.tid
 shadow: shadows/templates/*.tid
 #tiddler: http://wikitext.tiddlyspace.com/fractalveg.jpg
diff --git a/tw5.bat b/tw5.bat
index 309879877..a09e26846 100644
--- a/tw5.bat
+++ b/tw5.bat
@@ -1,3 +1,3 @@
 mkdir tmp\tw5
 
-node tiddlywiki.js --recipe tiddlywiki5\tiddlywiki5.recipe --savewiki tmp\tw5 --savetiddler ReadMe readme.md
+node tiddlywiki.js --recipe tiddlywiki5\tiddlywiki5.recipe --store tiddlywiki5\store --savewiki tmp\tw5 --savetiddler ReadMe readme.md
diff --git a/tw5.sh b/tw5.sh
index 3614caa15..7ce4a592c 100755
--- a/tw5.sh
+++ b/tw5.sh
@@ -7,7 +7,7 @@ mkdir -p tmp
 mkdir -p tmp/tw5
 
 # cook TiddlyWiki5
-node tiddlywiki.js --recipe $PWD/tiddlywiki5/tiddlywiki5.recipe --savewiki tmp/tw5 --savetiddler ReadMe readme.md || exit 1
+node tiddlywiki.js --recipe $PWD/tiddlywiki5/tiddlywiki5.recipe --store tiddlywiki5/store --savewiki tmp/tw5 --savetiddler ReadMe readme.md || exit 1
 
 # cook a static version too
 #mkdir -p tmp/tw5/static
diff --git a/tw5s.bat b/tw5s.bat
index e5f9d11b3..b622fbd9e 100644
--- a/tw5s.bat
+++ b/tw5s.bat
@@ -1 +1 @@
-node tiddlywiki.js --recipe tiddlywiki5\tiddlywiki5.recipe --servewiki 8080
+node tiddlywiki.js --recipe tiddlywiki5\tiddlywiki5.recipe --store tiddlywiki5\store --servewiki 8080
diff --git a/tw5s.sh b/tw5s.sh
index b4ec28e37..73d312aca 100755
--- a/tw5s.sh
+++ b/tw5s.sh
@@ -3,4 +3,4 @@
 # serve TiddlyWiki5 over HTTP
 
 # cook TiddlyWiki5
-node tiddlywiki.js --recipe $PWD/tiddlywiki5/tiddlywiki5.recipe --servewiki 8080 || exit 1
+node tiddlywiki.js --recipe $PWD/tiddlywiki5/tiddlywiki5.recipe --store tiddlywiki5/store --servewiki 8080 || exit 1