diff --git a/js/App.js b/js/App.js index b864c5877..d2006decc 100644 --- a/js/App.js +++ b/js/App.js @@ -16,6 +16,7 @@ var WikiStore = require("./WikiStore.js").WikiStore, WikiTextParser = require("./WikiTextParser.js").WikiTextParser, JavaScriptParser = require("./JavaScriptParser.js").JavaScriptParser, SVGParser = require("./SVGParser.js").SVGParser, + BitmapParser = require("./BitmapParser.js").BitmapParser, Navigators = require("./Navigators.js").Navigators, StoryNavigator = require("./StoryNavigator.js").StoryNavigator; @@ -30,6 +31,10 @@ var App = function() { store: this.store })); this.store.registerParser("image/svg+xml",new SVGParser()); + var bitmapParser = new BitmapParser(); + this.store.registerParser("image/jpg",bitmapParser); + this.store.registerParser("image/jpeg",bitmapParser); + this.store.registerParser("image/png",bitmapParser); // Register the standard tiddler serializers and deserializers tiddlerInput.register(this.store); tiddlerOutput.register(this.store); diff --git a/js/BitmapParser.js b/js/BitmapParser.js new file mode 100644 index 000000000..21690b2d4 --- /dev/null +++ b/js/BitmapParser.js @@ -0,0 +1,34 @@ +/*\ +title: js/BitmapParser.js + +Compiles bitmap images into JavaScript functions that render them in HTML + +\*/ +(function(){ + +/*jslint node: true */ +"use strict"; + +// The parse tree is degenerate +var BitmapParseTree = function() { + this.dependencies = []; +}; + +BitmapParseTree.prototype.compile = function(type) { + if(type === "text/html") { + return "(function (tiddler,store,utils) {return '';})"; + } else { + return null; + } +}; + +var BitmapParser = function() { +}; + +BitmapParser.prototype.parse = function() { + return new BitmapParseTree(); +}; + +exports.BitmapParser = BitmapParser; + +})(); diff --git a/js/FileRetriever.js b/js/FileRetriever.js index a19a24f1a..f0abe090c 100644 --- a/js/FileRetriever.js +++ b/js/FileRetriever.js @@ -19,7 +19,17 @@ var fs = require("fs"), var FileRetriever = exports; var fileRequest = function fileRequest(filepath,callback) { - fs.readFile(filepath,"utf8", callback); + fs.readFile(filepath, function (err,data) { + if(err) { + callback(err); + } else { + if([".jpg",".jpeg",".png"].indexOf(path.extname(filepath)) !== -1) { + callback(err,data.toString("base64")); + } else { + callback(err,data.toString("utf8")); + } + } + }); }; var httpRequest = function(fileurl,callback) { diff --git a/tiddlywiki5/tiddlers/Motovun Jack.jpg b/tiddlywiki5/tiddlers/Motovun Jack.jpg new file mode 100644 index 000000000..5a593c4ed Binary files /dev/null and b/tiddlywiki5/tiddlers/Motovun Jack.jpg differ diff --git a/tiddlywiki5/tiddlers/Motovun Jack.jpg.meta b/tiddlywiki5/tiddlers/Motovun Jack.jpg.meta new file mode 100644 index 000000000..b281504ce --- /dev/null +++ b/tiddlywiki5/tiddlers/Motovun Jack.jpg.meta @@ -0,0 +1,3 @@ +title: Motovun Jack.jpg +type: image/jpg +source: http://www.flickr.com/photos/jermy/6292279493/in/photostream diff --git a/tiddlywiki5/tiddlers/split.recipe b/tiddlywiki5/tiddlers/split.recipe index 55b10636e..8df533fba 100644 --- a/tiddlywiki5/tiddlers/split.recipe +++ b/tiddlywiki5/tiddlers/split.recipe @@ -7,6 +7,8 @@ tiddler: TiddlyWikiArchitecture.tid tiddler: TiddlyWikiInternals.tid tiddler: NewWikiTextFeatures.tid +tiddler: Motovun Jack.jpg + tiddler: SiteTitle.tid tiddler: SiteSubtitle.tid diff --git a/tiddlywiki5/tiddlywiki5.recipe b/tiddlywiki5/tiddlywiki5.recipe index 859930cc6..91e50f4c3 100644 --- a/tiddlywiki5/tiddlywiki5.recipe +++ b/tiddlywiki5/tiddlywiki5.recipe @@ -18,6 +18,7 @@ jsmodule: ../js/TiddlerInput.js jsmodule: ../js/TiddlerOutput.js jsmodule: ../js/WikiStore.js jsmodule: ../js/SVGParser.js +jsmodule: ../js/BitmapParser.js jsmodule: ../js/WikiTextParser.js jsmodule: ../js/WikiTextRules.js jsmodule: ../js/WikiTextParseTree.js