From 817a87ce0e39ac2015ff03922a121c87e6536d85 Mon Sep 17 00:00:00 2001 From: M Pacer Date: Wed, 4 Oct 2017 13:22:00 -0700 Subject: [PATCH] match RFC5987 3.2 formatting for Content Disposition, prettify code --- notebook/nbconvert/handlers.py | 3 +- notebook/static/base/js/utils.js | 2 +- notebook/static/notebook/js/menubar.js | 270 +++++++++++++------------ notebook/templates/notebook.html | 1 + 4 files changed, 145 insertions(+), 131 deletions(-) diff --git a/notebook/nbconvert/handlers.py b/notebook/nbconvert/handlers.py index 008119ea56..45672d05d6 100644 --- a/notebook/nbconvert/handlers.py +++ b/notebook/nbconvert/handlers.py @@ -41,8 +41,7 @@ def respond_zip(handler, name, output, resources): # Headers zip_filename = os.path.splitext(name)[0] + '.zip' - handler.set_header('Content-Disposition', - 'attachment; filename="%s"' % escape.url_escape(zip_filename)) + handler.set_attachment_header(zip_filename) handler.set_header('Content-Type', 'application/zip') # create zip file diff --git a/notebook/static/base/js/utils.js b/notebook/static/base/js/utils.js index fa0235fe8b..4df56ea2a0 100644 --- a/notebook/static/base/js/utils.js +++ b/notebook/static/base/js/utils.js @@ -1171,7 +1171,7 @@ define([ js_idx_to_char_idx: js_idx_to_char_idx, char_idx_to_js_idx: char_idx_to_js_idx, _ansispan:_ansispan, - change_favicon: change_favicon + change_favicon: change_favicon, _get_cookie:_get_cookie }; diff --git a/notebook/static/notebook/js/menubar.js b/notebook/static/notebook/js/menubar.js index 63c9a6c0ab..6ab300dd60 100644 --- a/notebook/static/notebook/js/menubar.js +++ b/notebook/static/notebook/js/menubar.js @@ -129,13 +129,14 @@ define('notebook/js/menubar',[ this._new_window(url); }; - - MenuBar.prototype._nbconvert_upload_conf = function (download) { - - var body = $('
'); - var notebook_path = utils.encode_uri_components(this.notebook.notebook_path); - var create_json = function(notebook, config){ + MenuBar.prototype._nbconvert_upload_conf = function(download) { + var body = $("
"); + var notebook_path = utils.encode_uri_components( + this.notebook.notebook_path + ); + + var create_json = function(notebook, config) { var json_to_pass = { notebook: notebook.toJSON(), config: config @@ -143,163 +144,176 @@ define('notebook/js/menubar',[ return json_to_pass; }; - - var form = $('
'); - var fileinput = $('') - .attr('type', 'file') - .attr('tabindex', '1'); + var form = $(""); + var fileinput = $("") + .attr("type", "file") + .attr("tabindex", "1"); + + var fileformat = $("'); - var export_opts = { markdown: { - display_text:'markdown', - exporter_name:'markdown' - }, + display_text: "markdown", + exporter_name: "markdown" + }, html: { - display_text:'html', - exporter_name:'html' - }, + display_text: "html", + exporter_name: "html" + }, rst: { - display_text:'rst', - exporter_name:'rst' - }, + display_text: "rst", + exporter_name: "rst" + }, pdf: { - display_text:'PDF', - exporter_name:'pdf' - }, + display_text: "PDF", + exporter_name: "pdf" + }, latex: { - display_text:'LaTeX', - exporter_name:'latex' - }, + display_text: "LaTeX", + exporter_name: "latex" + }, script: { - display_text:'script', - exporter_name:'script' - } + display_text: "script", + exporter_name: "script" + } }; - for(var x in export_opts){ + for (var x in export_opts) { fileformat.append( - $('