diff --git a/boot/boot.js b/boot/boot.js index bb06047b3..d6647884d 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -2002,6 +2002,7 @@ $tw.boot.startup = function(options) { $tw.utils.registerFileType("text/x-bibtex","utf8",".bib",{deserializerType:"application/x-bibtex"}); $tw.utils.registerFileType("application/x-bibtex","utf8",".bib"); $tw.utils.registerFileType("application/epub+zip","base64",".epub"); + $tw.utils.registerFileType("application/octet-stream","base64",".octet-stream"); // Create the wiki store for the app $tw.wiki = new $tw.Wiki(); // Install built in tiddler fields modules diff --git a/core/modules/parsers/binaryparser.js b/core/modules/parsers/binaryparser.js new file mode 100644 index 000000000..ebfd2beec --- /dev/null +++ b/core/modules/parsers/binaryparser.js @@ -0,0 +1,29 @@ +/*\ +title: $:/core/modules/parsers/binaryparser.js +type: application/javascript +module-type: parser + +The video parser parses a video tiddler into an embeddable HTML element + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +var BINARY_WARNING_MESSAGE = "$:/core/ui/BinaryWarning"; + +var BinaryParser = function(type,text,options) { + this.tree = [{ + type: "transclude", + attributes: { + tiddler: {type: "string", value: BINARY_WARNING_MESSAGE} + } + }]; +}; + +exports["application/octet-stream"] = BinaryParser; + +})(); + diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 0f4219ac3..e73ed8362 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -785,6 +785,14 @@ exports.initParsers = function(moduleType) { } } }); + // Use the generic binary parser for any binary types not registered so far + if($tw.Wiki.parsers["application/octet-stream"]) { + Object.keys($tw.config.contentTypeInfo).forEach(function(type) { + if(!$tw.utils.hop($tw.Wiki.parsers,type) && $tw.config.contentTypeInfo[type].encoding === "base64") { + $tw.Wiki.parsers[type] = $tw.Wiki.parsers["application/octet-stream"]; + } + }); + } }; /* @@ -847,7 +855,7 @@ exports.parseTextReference = function(title,field,index,options) { } if(field === "text" || (!field && !index)) { if(tiddler && tiddler.fields) { - return this.parseText(tiddler.fields.type || "text/vnd.tiddlywiki",tiddler.fields.text,options); + return this.parseText(tiddler.fields.type,tiddler.fields.text,options); } else { return null; }