##// END OF EJS Templates
support display_pub metadata in js frontend
MinRK -
Show More
@@ -178,9 +178,11 b' var IPython = (function (IPython) {'
178 json.stream = content.name;
178 json.stream = content.name;
179 } else if (msg_type === "display_data") {
179 } else if (msg_type === "display_data") {
180 json = this.convert_mime_types(json, content.data);
180 json = this.convert_mime_types(json, content.data);
181 json.metadata = this.convert_mime_types({}, content.metadata);
181 } else if (msg_type === "pyout") {
182 } else if (msg_type === "pyout") {
182 json.prompt_number = content.execution_count;
183 json.prompt_number = content.execution_count;
183 json = this.convert_mime_types(json, content.data);
184 json = this.convert_mime_types(json, content.data);
185 json.metadata = this.convert_mime_types({}, content.metadata);
184 } else if (msg_type === "pyerr") {
186 } else if (msg_type === "pyerr") {
185 json.ename = content.ename;
187 json.ename = content.ename;
186 json.evalue = content.evalue;
188 json.evalue = content.evalue;
@@ -273,7 +275,7 b' var IPython = (function (IPython) {'
273 }
275 }
274 s = s + '\n';
276 s = s + '\n';
275 var toinsert = this.create_output_area();
277 var toinsert = this.create_output_area();
276 this.append_text(s, toinsert);
278 this.append_text(s, {}, toinsert);
277 this.element.append(toinsert);
279 this.element.append(toinsert);
278 }
280 }
279 };
281 };
@@ -310,7 +312,7 b' var IPython = (function (IPython) {'
310
312
311 // If we got here, attach a new div
313 // If we got here, attach a new div
312 var toinsert = this.create_output_area();
314 var toinsert = this.create_output_area();
313 this.append_text(text, toinsert, "output_stream "+subclass);
315 this.append_text(text, {}, toinsert, "output_stream "+subclass);
314 this.element.append(toinsert);
316 this.element.append(toinsert);
315 };
317 };
316
318
@@ -331,12 +333,16 b' var IPython = (function (IPython) {'
331 for(var type_i in OutputArea.display_order){
333 for(var type_i in OutputArea.display_order){
332 var type = OutputArea.display_order[type_i];
334 var type = OutputArea.display_order[type_i];
333 if(json[type] != undefined ){
335 if(json[type] != undefined ){
336 var md = {};
337 if (json.metadata && json.metadata[type]) {
338 md = json.metadata[type];
339 };
334 if(type == 'javascript'){
340 if(type == 'javascript'){
335 if (dynamic) {
341 if (dynamic) {
336 this.append_javascript(json.javascript, element, dynamic);
342 this.append_javascript(json.javascript, md, element, dynamic);
337 }
343 }
338 } else {
344 } else {
339 this['append_'+type](json[type], element);
345 this['append_'+type](json[type], md, element);
340 }
346 }
341 return;
347 return;
342 }
348 }
@@ -344,14 +350,14 b' var IPython = (function (IPython) {'
344 };
350 };
345
351
346
352
347 OutputArea.prototype.append_html = function (html, element) {
353 OutputArea.prototype.append_html = function (html, md, element) {
348 var toinsert = $("<div/>").addClass("output_subarea output_html rendered_html");
354 var toinsert = $("<div/>").addClass("output_subarea output_html rendered_html");
349 toinsert.append(html);
355 toinsert.append(html);
350 element.append(toinsert);
356 element.append(toinsert);
351 };
357 };
352
358
353
359
354 OutputArea.prototype.append_javascript = function (js, container) {
360 OutputArea.prototype.append_javascript = function (js, md, container) {
355 // We just eval the JS code, element appears in the local scope.
361 // We just eval the JS code, element appears in the local scope.
356 var element = $("<div/>").addClass("output_subarea");
362 var element = $("<div/>").addClass("output_subarea");
357 container.append(element);
363 container.append(element);
@@ -375,7 +381,7 b' var IPython = (function (IPython) {'
375 };
381 };
376
382
377
383
378 OutputArea.prototype.append_text = function (data, element, extra_class) {
384 OutputArea.prototype.append_text = function (data, md, element, extra_class) {
379 var toinsert = $("<div/>").addClass("output_subarea output_text");
385 var toinsert = $("<div/>").addClass("output_subarea output_text");
380 // escape ANSI & HTML specials in plaintext:
386 // escape ANSI & HTML specials in plaintext:
381 data = utils.fixConsole(data);
387 data = utils.fixConsole(data);
@@ -389,7 +395,7 b' var IPython = (function (IPython) {'
389 };
395 };
390
396
391
397
392 OutputArea.prototype.append_svg = function (svg, element) {
398 OutputArea.prototype.append_svg = function (svg, md, element) {
393 var toinsert = $("<div/>").addClass("output_subarea output_svg");
399 var toinsert = $("<div/>").addClass("output_subarea output_svg");
394 toinsert.append(svg);
400 toinsert.append(svg);
395 element.append(toinsert);
401 element.append(toinsert);
@@ -423,25 +429,37 b' var IPython = (function (IPython) {'
423 };
429 };
424
430
425
431
426 OutputArea.prototype.append_png = function (png, element) {
432 OutputArea.prototype.append_png = function (png, md, element) {
427 var toinsert = $("<div/>").addClass("output_subarea output_png");
433 var toinsert = $("<div/>").addClass("output_subarea output_png");
428 var img = $("<img/>").attr('src','data:image/png;base64,'+png);
434 var img = $("<img/>").attr('src','data:image/png;base64,'+png);
435 if (md['height']) {
436 img.attr('height', md['height']);
437 }
438 if (md['width']) {
439 img.attr('width', md['width']);
440 }
429 this._dblclick_to_reset_size(img);
441 this._dblclick_to_reset_size(img);
430 toinsert.append(img);
442 toinsert.append(img);
431 element.append(toinsert);
443 element.append(toinsert);
432 };
444 };
433
445
434
446
435 OutputArea.prototype.append_jpeg = function (jpeg, element) {
447 OutputArea.prototype.append_jpeg = function (jpeg, md, element) {
436 var toinsert = $("<div/>").addClass("output_subarea output_jpeg");
448 var toinsert = $("<div/>").addClass("output_subarea output_jpeg");
437 var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg);
449 var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg);
450 if (md['height']) {
451 img.attr('height', md['height']);
452 }
453 if (md['width']) {
454 img.attr('width', md['width']);
455 }
438 this._dblclick_to_reset_size(img);
456 this._dblclick_to_reset_size(img);
439 toinsert.append(img);
457 toinsert.append(img);
440 element.append(toinsert);
458 element.append(toinsert);
441 };
459 };
442
460
443
461
444 OutputArea.prototype.append_latex = function (latex, element) {
462 OutputArea.prototype.append_latex = function (latex, md, element) {
445 // This method cannot do the typesetting because the latex first has to
463 // This method cannot do the typesetting because the latex first has to
446 // be on the page.
464 // be on the page.
447 var toinsert = $("<div/>").addClass("output_subarea output_latex");
465 var toinsert = $("<div/>").addClass("output_subarea output_latex");
General Comments 0
You need to be logged in to leave comments. Login now