mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Added support for JPEG and PNG bitmap tiddlers
This commit is contained in:
parent
ecabcd676b
commit
ecfbaaa564
@ -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);
|
||||
|
34
js/BitmapParser.js
Normal file
34
js/BitmapParser.js
Normal file
@ -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 '<img src=\"data:' + tiddler.fields.type + ';base64,' + tiddler.fields.text + '\">';})";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
var BitmapParser = function() {
|
||||
};
|
||||
|
||||
BitmapParser.prototype.parse = function() {
|
||||
return new BitmapParseTree();
|
||||
};
|
||||
|
||||
exports.BitmapParser = BitmapParser;
|
||||
|
||||
})();
|
@ -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) {
|
||||
|
BIN
tiddlywiki5/tiddlers/Motovun Jack.jpg
Normal file
BIN
tiddlywiki5/tiddlers/Motovun Jack.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
3
tiddlywiki5/tiddlers/Motovun Jack.jpg.meta
Normal file
3
tiddlywiki5/tiddlers/Motovun Jack.jpg.meta
Normal file
@ -0,0 +1,3 @@
|
||||
title: Motovun Jack.jpg
|
||||
type: image/jpg
|
||||
source: http://www.flickr.com/photos/jermy/6292279493/in/photostream
|
@ -7,6 +7,8 @@ tiddler: TiddlyWikiArchitecture.tid
|
||||
tiddler: TiddlyWikiInternals.tid
|
||||
tiddler: NewWikiTextFeatures.tid
|
||||
|
||||
tiddler: Motovun Jack.jpg
|
||||
|
||||
tiddler: SiteTitle.tid
|
||||
tiddler: SiteSubtitle.tid
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user