From d44d948b8adff4b28092a08c15927b2109046091 2014-01-12 21:52:13 From: Paul Ivanov Date: 2014-01-12 21:52:13 Subject: [PATCH] make output code not drop non-mimetype-keyed json --- diff --git a/IPython/html/static/notebook/js/outputarea.js b/IPython/html/static/notebook/js/outputarea.js index 5d1d470..87c7eeb 100644 --- a/IPython/html/static/notebook/js/outputarea.js +++ b/IPython/html/static/notebook/js/outputarea.js @@ -254,6 +254,9 @@ var IPython = (function (IPython) { this.append_output(json, true); }; + var mime_types = ['application/javascript', 'application/json', + 'image/jpeg', 'image/png', 'image/svg+xml', 'text/html', + 'text/latex', 'text/plain']; OutputArea.prototype.convert_mime_types = function (json, data) { if (data === undefined) { @@ -283,6 +286,13 @@ var IPython = (function (IPython) { if (data['application/javascript'] !== undefined) { json.javascript = data['application/javascript']; } + // non-mimetype-keyed metadata used to get dropped here, this code + // re-injects it into the json. + for (x in data){ + if( !(x in mime_types) ) { + json[x] = data[x]; + } + } return json; }; diff --git a/IPython/html/tests/casperjs/test_cases/isolated_svg.js b/IPython/html/tests/casperjs/test_cases/isolated_svg.js index d248a35..0e2aa7a 100644 --- a/IPython/html/tests/casperjs/test_cases/isolated_svg.js +++ b/IPython/html/tests/casperjs/test_cases/isolated_svg.js @@ -21,6 +21,32 @@ casper.notebook_test(function () { + "display_svg(SVG(s2), metadata=dict(isolated=True))\n" ); cell.execute(); + console.log("hello" ); + }); + + this.then(function() { + var fname=this.test.currentTestFile.split('/').pop().toLowerCase(); + this.echo(fname) + this.echo(this.currentUrl) + this.evaluate(function (n) { + IPython.notebook.rename(n); + console.write("hello" + n); + IPython.notebook.save_notebook(); + }, {n : fname}); + this.echo(this.currentUrl) + }); + + this.then(function() { + + url = this.evaluate(function() { + IPython.notebook.rename("foo"); + //$("span#notebook_name")[0].click(); + //$("input")[0].value = "please-work"; + //$(".btn-primary")[0].click(); + return document.location.href; + }) + this.echo("renamed" + url); + this.echo(this.currentUrl); }); this.wait_for_output(0);