diff --git a/boot/boot.js b/boot/boot.js index 01fe38ca6..7d0bfa7e2 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -992,6 +992,29 @@ $tw.modules.define("$:/boot/tiddlerdeserializer/tid","tiddlerdeserializer",{ return [fields]; } }); +$tw.modules.define("$:/boot/tiddlerdeserializer/tids","tiddlerdeserializer",{ + "application/x-tiddlers": function(text,fields) { + var tiddlers = [], + split = text.split(/\r?\n\r?\n/mg); + if(split.length >= 2) { + fields = $tw.utils.parseFields(split[0],fields); + var lines = split[1].split(/\r?\n/mg); + for(var t=0; t= 2) { + var tiddler = $tw.utils.extend({},fields); + tiddler.title = (tiddler.title || "") + parts[0]; + tiddler.text = parts[1]; + tiddlers.push(tiddler); + } + } + } + } + return tiddlers; + } +}); $tw.modules.define("$:/boot/tiddlerdeserializer/txt","tiddlerdeserializer",{ "text/plain": function(text,fields,type) { fields.text = text; @@ -1479,6 +1502,7 @@ $tw.boot.startup = function(options) { // Add file extension information $tw.utils.registerFileType("text/vnd.tiddlywiki","utf8",".tid"); $tw.utils.registerFileType("application/x-tiddler","utf8",".tid"); + $tw.utils.registerFileType("application/x-tiddlers","utf8",".tids"); $tw.utils.registerFileType("application/x-tiddler-html-div","utf8",".tiddler"); $tw.utils.registerFileType("text/vnd.tiddlywiki2-recipe","utf8",".recipe"); $tw.utils.registerFileType("text/plain","utf8",".txt"); diff --git a/editions/tw5.com/tiddlers/deserializers/MultiTiddlerFiles.tid b/editions/tw5.com/tiddlers/deserializers/MultiTiddlerFiles.tid new file mode 100644 index 000000000..6e84f2326 --- /dev/null +++ b/editions/tw5.com/tiddlers/deserializers/MultiTiddlerFiles.tid @@ -0,0 +1,30 @@ +created: 20140209143652456 +tags: deserializers dev +title: MultiTiddlerFiles + +MultiTiddlerFiles allow multiple tiddlers to be concisely represented in a single text file. + +The goals of this format are: + +* To be easy to type and easy to read +* Optimised for single line strings +* To allow common fields or tags to be shared within groups of tiddlers +* To be simple to process with external tools + +MultiTiddlerFiles have the extension `tids`. The file is structured as a block of shared fields followed by a blank line. The rest of the file is a sequence of comments and tiddlers. Tiddlers are specified by their title, followed by a colon, at least one space character, and then the rest of the line is the text field for the tiddler. + +For axample: + +``` +title: $:/lingo/ControlPanel/ +tags: strings +modifier: JoeBloggs + +Basics/Caption: Basics +# This is a comment +Basics/Version: ~TiddlyWiki Version +``` + +This example defines two tiddlers, ''"""$:/lingo/ControlPanel/Basics/Caption"""'' and ''"""$:/lingo/ControlPanel/Basics/Version"""''. + +If a `title` field is specified in the header then it is treated as a prefix for the individual tiddlers defined in the title.