diff --git a/js/App.js b/js/App.js index 114e41b77..3ce39d266 100644 --- a/js/App.js +++ b/js/App.js @@ -26,8 +26,8 @@ var App = function() { this.store = new WikiStore(); // Register the parsers this.store.registerParser("text/x-tiddlywiki",new WikiTextParser({store: this.store})); - this.store.registerParser("application/json",new JSONParser()); - var imageParser = new ImageParser(); + this.store.registerParser("application/json",new JSONParser({store: this.store})); + var imageParser = new ImageParser({store: this.store}); this.store.registerParser("image/svg+xml",imageParser); this.store.registerParser("image/jpg",imageParser); this.store.registerParser("image/jpeg",imageParser); diff --git a/js/HTML.js b/js/HTML.js index cf3426854..e483f8121 100644 --- a/js/HTML.js +++ b/js/HTML.js @@ -42,7 +42,7 @@ var utils = require("./Utils.js"); Constructs an HTMLParseTree from a tree of nodes. A single node or an array of nodes can be passed. As a shortcut, the constructor can be called as an ordinary function without the new keyword, in which case -it automatically returns the `text/html` rendering of the tree. +it by default returns the `text/html` rendering of the tree. */ var HTML = function(tree,type) { if(this instanceof HTML) { @@ -110,6 +110,17 @@ HTML.macro = function(name,params,children,dependencies) { return m; }; +/* +Static method to construct a label +*/ +HTML.label = function(type,value,classes) { + classes = (classes || []).slice(0); + classes.push("label"); + return HTML.elem("span",{ + "class": classes + },value); +}; + /* Static method to construct a split label */ diff --git a/js/ImageParser.js b/js/ImageParser.js index 5d7f5f66d..9866e2ab2 100644 --- a/js/ImageParser.js +++ b/js/ImageParser.js @@ -9,41 +9,22 @@ Compiles images into JavaScript functions that render them in HTML /*jslint node: true */ "use strict"; -var utils = require("./Utils.js"); +var WikiTextParseTree = require("./WikiTextParseTree.js").WikiTextParseTree, + HTML = require("./HTML.js").HTML, + utils = require("./Utils.js"); -var ImageRenderer = function(handlerCode) { - /*jslint evil: true */ - this.handler = eval(handlerCode); -}; - -ImageRenderer.prototype.render = function(tiddler,store) { - return this.handler(tiddler,store,utils); -}; - -// The parse tree is degenerate -var ImageParseTree = function(type,text) { - this.type = type; - this.text = text; - this.dependencies = {}; -}; - -ImageParseTree.prototype.compile = function(type) { - if(type === "text/html") { - if(this.type === "image/svg+xml") { - return new ImageRenderer("(function (tiddler,store,utils) {return '';})"); - } else { - return new ImageRenderer("(function (tiddler,store,utils) {return '';})"); - } - } else { - return null; - } -}; - -var ImageParser = function() { +var ImageParser = function(options) { + this.store = options.store; }; ImageParser.prototype.parse = function(type,text) { - return new ImageParseTree(type,text); + var src; + if(this.type === "image/svg+xml") { + src = "data:" + type + "," + encodeURIComponent(text); + } else { + src = "data:" + type + ";base64," + text; + } + return new WikiTextParseTree([HTML.elem("img",{src: src})],{},this.store); }; exports.ImageParser = ImageParser; diff --git a/js/JSONParser.js b/js/JSONParser.js index 163cf974a..89b5fc6d2 100644 --- a/js/JSONParser.js +++ b/js/JSONParser.js @@ -9,47 +9,43 @@ Compiles JSON objects into JavaScript functions that render them in HTML and pla /*jslint node: true */ "use strict"; -var utils = require("./Utils.js"); +var WikiTextParseTree = require("./WikiTextParseTree.js").WikiTextParseTree, + HTML = require("./HTML.js").HTML, + utils = require("./Utils.js"); -var JSONRenderer = function(handlerCode) { - /*jslint evil: true */ - this.handler = eval(handlerCode); +var renderObject = function(obj) { + var children = [],t; + if(obj instanceof Array) { + for(t=0; t

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 or as a powerful node.js application.

Some useful tiddlers for feature testing:
  • ClockTiddler showing automatic refreshing of tiddlers
  • ImageTests showing different ways of embedding images
  • SampleData showing how JSON tiddlers are handled
  • VideoTests showing how different online video formats can be embedded

Technical documentation includes:

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 Google Groups:

https://github.com/Jermolene/TiddlyWiki5
http://groups.google.com/group/TiddlyWikiDev

Bug: this link doesn't work:
HelloThere


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 or as a powerful node.js application.

Some useful tiddlers for feature testing:
  • ClockTiddler showing automatic refreshing of tiddlers
  • ImageTests showing different ways of embedding images
  • SampleData showing how JSON tiddlers are handled
  • VideoTests showing how different online video formats can be embedded

Technical documentation includes:

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 Google Groups:

https://github.com/Jermolene/TiddlyWiki5
http://groups.google.com/group/TiddlyWikiDev

Bug: this link doesn't work:


Usage

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

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
--servewiki <port>Serve the cooked TiddlyWiki over HTTP at /
--servetiddlers <port>Serve individual tiddlers over HTTP at /tiddlertitle
--wikitest <dir>Run wikification tests against the tiddlers in the given directory
--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 diff --git a/tiddlywiki5/tiddlers/HelloThere.tid b/tiddlywiki5/tiddlers/HelloThere.tid index 274f2c47b..3f15ed4ab 100644 --- a/tiddlywiki5/tiddlers/HelloThere.tid +++ b/tiddlywiki5/tiddlers/HelloThere.tid @@ -13,6 +13,7 @@ Technical documentation includes: * [[Testing]] regimen * Details of the CommandLineInterface * Overview of TiddlyWikiArchitecture +** TiddlyWikiInternals ** MacroInternals * Information about TiddlerFiles and RecipeFiles * NewWikiTextFeatures