From ecabcd676bfaf2aaf2f5256ecb57b36524b27101 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 12 Jan 2012 19:17:32 +0000 Subject: [PATCH] Added support for SVG tiddlers Which means adding a parser for SVG, even though it doesn't actually do any parsing at the moment --- docs/High Level Architecture.graffle | Bin 0 -> 3934 bytes docs/High Level Architecture.svg | 3 ++ docs/High Level Architecture.svg.meta | 3 ++ js/App.js | 4 ++- js/SVGParser.js | 34 ++++++++++++++++++ js/macros/tiddler.js | 2 +- tiddlywiki5/styles.css | 4 +++ .../tiddlers/TiddlyWikiArchitecture.tid | 2 ++ tiddlywiki5/tiddlywiki5.recipe | 2 ++ 9 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 docs/High Level Architecture.graffle create mode 100644 docs/High Level Architecture.svg create mode 100644 docs/High Level Architecture.svg.meta create mode 100644 js/SVGParser.js diff --git a/docs/High Level Architecture.graffle b/docs/High Level Architecture.graffle new file mode 100644 index 0000000000000000000000000000000000000000..045a7cfe231dd1c50aaa7b4de84a202b78e21f79 GIT binary patch literal 3934 zcmV-k525fMiwFP!000030PS5{cbm8ter|t-PF~K#BsO5cxRZ8PZf(+&CYji2rd@fF zLAKRkL_yfiboIX<32g38oK8tFqpa2Xwk2((y+3_yq^;dQzD;c~L!OU`^Lk5eNm~Fp zCb6(He!X=yc)Me4{qg4I?tc!?4+ftuj(}@ppMs04{nL{Ju(i`}@42px+U>)^A-Fg_ z=??&_quo9_+X7n?O5IoO_Iy5XK`zxY$&?HF?F)~%$fI|stg;7N= zYhjbVdHG`Z7TvwsGbx^-Q+S8G6URc|cH8`0_9J#E8YAzGwA)_3T^3<&V-r$V<;SSz zxDfO_$ltu!^{K}$`3=*sMWzlOdn9mM=j`1(4~|AQVjAzZ7eXm{xns0C9d-e-*3~pM zC9>OIRvsx4P_k!z349tiK7zK7+Dn0bXx{Qx9gDT-POurvEiQi{#wGmaZ?PWVzf0Rd z`mqhZ8?w3$bVL2|Bcm^uKd_-+EZQe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>b$m3?9N9?X^N0kou zcZ`ExZ|6Xhds0`^W#dpljG)3J$QfN2p951=!HeuhazC8p4$ zp&I-KJ>p+`CdIRL=vP>n&*soE(Id-VIrwXUlDm|9uKvnLM-Ii_eck?XT_$*q9Y)4i zBl|(%d8{YGo=i-sJXjGHIQr&7hq-su!-) + +2012-01-12 18:59ZCanvas 1Layer 1Manages a collection of tiddlers. Plumbs in representation conversion and cachingWikiStoreInitialisation and bootstrappingAppParses TiddlyWiki-style macro parameters into a JavaScript structureArgParserAbstracts differences between file system and HTTPFileRetrieverParses JavaScript code into a parse treeJavaScriptParserRepresents JavaScript code in a tree structure. Has methods to compile a tree back into textual JavaScriptJavaScriptParseTreeOpen source JavaScript parsing enginePEG.JSParser for the JavaScript language provided as an example by PEG.JSjavascript.pegjsCollection of objects that know how to navigate to a new tiddlerNavigatorsA navigator that implements TiddlyWiki's classic navigation behaviourStoryNavigatorRepresents a TiddlyWiki recipe. Has methods to load a recipe and its tiddlers, and to cook the output of the recipeRecipeRepresents a tiddler as an immutable collection of fieldsTiddlerFunctions know how to write tiddlers to various data formatsTiddlerOutputFunctions that know how to read tiddlers from various data formatsTiddlerInputRagtag of small utility functions for manipulating strings and datesUtilsParses wiki text into a parse treeWikiTextParserRepresents a wiki text parse tree. Has methods to compile the parse tree into a JavaScript functionWikiTextParseTreeIndividual wiki text parsing rulesWikiTextRulesmacrosechoinfolisttiddlerversionviewnode.jsbrowserImplements node.js module loading in the browserBootLoader diff --git a/docs/High Level Architecture.svg.meta b/docs/High Level Architecture.svg.meta new file mode 100644 index 000000000..826b3d964 --- /dev/null +++ b/docs/High Level Architecture.svg.meta @@ -0,0 +1,3 @@ +title: High Level Architecture.svg +modifier: JeremyRuston +type: image/svg+xml diff --git a/js/App.js b/js/App.js index a77763beb..b864c5877 100644 --- a/js/App.js +++ b/js/App.js @@ -15,6 +15,7 @@ var WikiStore = require("./WikiStore.js").WikiStore, tiddlerOutput = require("./TiddlerOutput.js"), WikiTextParser = require("./WikiTextParser.js").WikiTextParser, JavaScriptParser = require("./JavaScriptParser.js").JavaScriptParser, + SVGParser = require("./SVGParser.js").SVGParser, Navigators = require("./Navigators.js").Navigators, StoryNavigator = require("./StoryNavigator.js").StoryNavigator; @@ -24,10 +25,11 @@ var App = function() { this.isBrowser = typeof window !== "undefined"; // Create the main store this.store = new WikiStore(); - // Register the wikitext parser + // Register the wikitext parser and the SVG parser this.store.registerParser("text/x-tiddlywiki",new WikiTextParser({ store: this.store })); + this.store.registerParser("image/svg+xml",new SVGParser()); // Register the standard tiddler serializers and deserializers tiddlerInput.register(this.store); tiddlerOutput.register(this.store); diff --git a/js/SVGParser.js b/js/SVGParser.js new file mode 100644 index 000000000..d2d95c09a --- /dev/null +++ b/js/SVGParser.js @@ -0,0 +1,34 @@ +/*\ +title: js/SVGParser.js + +Compiles SVG images into JavaScript functions that render them in HTML + +\*/ +(function(){ + +/*jslint node: true */ +"use strict"; + +// The parse tree is degenerate +var SVGParseTree = function() { + this.dependencies = []; +}; + +SVGParseTree.prototype.compile = function(type) { + if(type === "text/html") { + return "(function (tiddler,store,utils) {return tiddler.fields.text;})"; + } else { + return null; + } +}; + +var SVGParser = function() { +}; + +SVGParser.prototype.parse = function() { + return new SVGParseTree(); +}; + +exports.SVGParser = SVGParser; + +})(); diff --git a/js/macros/tiddler.js b/js/macros/tiddler.js index fa9088d8f..715ba419c 100644 --- a/js/macros/tiddler.js +++ b/js/macros/tiddler.js @@ -30,7 +30,7 @@ exports.macro = { return store.renderText(targetTiddler.fields.type,text,type,tiddler.fields.title); } else { // There's no parameterisation, so we can just render the target tiddler directly - return store.renderTiddler(type,params.target,tiddler.fields.title); + return store.renderTiddler(type,params.target); } } }; diff --git a/tiddlywiki5/styles.css b/tiddlywiki5/styles.css index 389e1ea60..3a9c7e012 100644 --- a/tiddlywiki5/styles.css +++ b/tiddlywiki5/styles.css @@ -94,3 +94,7 @@ a.linkInternalResolves { a.linkInternalMissing { font-style: italic; } + +svg { + width: 100%; +} diff --git a/tiddlywiki5/tiddlers/TiddlyWikiArchitecture.tid b/tiddlywiki5/tiddlers/TiddlyWikiArchitecture.tid index ea8c0522b..aa02abcad 100644 --- a/tiddlywiki5/tiddlers/TiddlyWikiArchitecture.tid +++ b/tiddlywiki5/tiddlers/TiddlyWikiArchitecture.tid @@ -9,6 +9,8 @@ TiddlyWiki is based on the idea of making information more useful by modelling i Tiddlers use a special wikitext notation that concisely represents text formatting and hypertext features. A cornerstone of wikitext is the ability to combine and embed tiddlers in various ways. +<> + !! Content Types TiddlyWiki uses MIME types to indicate how the text of tiddlers should be interpreted. It uses standard MIME types such as {{{text/plain}}} and {{{text/html}}}, as well as these non-standard types for TiddlyWiki-specific formats: diff --git a/tiddlywiki5/tiddlywiki5.recipe b/tiddlywiki5/tiddlywiki5.recipe index cd5b98b95..859930cc6 100644 --- a/tiddlywiki5/tiddlywiki5.recipe +++ b/tiddlywiki5/tiddlywiki5.recipe @@ -4,6 +4,7 @@ style: styles.css recipe: tiddlers/split.recipe recipe: ../parsers/split.recipe +tiddler: ../docs/High Level Architecture.svg jslib: ../test/tiddlywiki.2.6.5/source/tiddlywiki/jquery/jquery.js @@ -16,6 +17,7 @@ jsmodule: ../js/Tiddler.js jsmodule: ../js/TiddlerInput.js jsmodule: ../js/TiddlerOutput.js jsmodule: ../js/WikiStore.js +jsmodule: ../js/SVGParser.js jsmodule: ../js/WikiTextParser.js jsmodule: ../js/WikiTextRules.js jsmodule: ../js/WikiTextParseTree.js