Show More
@@ -6,6 +6,7 b'' | |||||
6 | import io |
|
6 | import io | |
7 | import os |
|
7 | import os | |
8 | import zipfile |
|
8 | import zipfile | |
|
9 | import collections | |||
9 |
|
10 | |||
10 | from tornado import web |
|
11 | from tornado import web | |
11 |
|
12 | |||
@@ -16,6 +17,7 b' from ..base.handlers import (' | |||||
16 | from IPython.nbformat import from_dict |
|
17 | from IPython.nbformat import from_dict | |
17 |
|
18 | |||
18 | from IPython.utils.py3compat import cast_bytes |
|
19 | from IPython.utils.py3compat import cast_bytes | |
|
20 | from IPython.utils import text | |||
19 |
|
21 | |||
20 | def find_resource_files(output_files_dir): |
|
22 | def find_resource_files(output_files_dir): | |
21 | files = [] |
|
23 | files = [] | |
@@ -87,9 +89,18 b' class NbconvertFileHandler(IPythonHandler):' | |||||
87 | raise web.HTTPError(400, "Not a notebook: %s" % path) |
|
89 | raise web.HTTPError(400, "Not a notebook: %s" % path) | |
88 |
|
90 | |||
89 | self.set_header('Last-Modified', model['last_modified']) |
|
91 | self.set_header('Last-Modified', model['last_modified']) | |
90 |
|
92 | |||
91 | try: |
|
93 | try: | |
92 |
output, resources = exporter.from_notebook_node( |
|
94 | output, resources = exporter.from_notebook_node( | |
|
95 | model['content'], | |||
|
96 | resources={ | |||
|
97 | "metadata": { | |||
|
98 | "name": name[:name.rfind('.')], | |||
|
99 | "modified_date": (model['last_modified'] | |||
|
100 | .strftime(text.date_format)) | |||
|
101 | } | |||
|
102 | } | |||
|
103 | ) | |||
93 | except Exception as e: |
|
104 | except Exception as e: | |
94 | raise web.HTTPError(500, "nbconvert failed: %s" % e) |
|
105 | raise web.HTTPError(500, "nbconvert failed: %s" % e) | |
95 |
|
106 |
@@ -241,7 +241,9 b' class Exporter(LoggingConfigurable):' | |||||
241 | #Make sure the metadata extension exists in resources |
|
241 | #Make sure the metadata extension exists in resources | |
242 | if 'metadata' in resources: |
|
242 | if 'metadata' in resources: | |
243 | if not isinstance(resources['metadata'], ResourcesDict): |
|
243 | if not isinstance(resources['metadata'], ResourcesDict): | |
244 |
|
|
244 | new_metadata = ResourcesDict() | |
|
245 | new_metadata.update(resources['metadata']) | |||
|
246 | resources['metadata'] = new_metadata | |||
245 | else: |
|
247 | else: | |
246 | resources['metadata'] = ResourcesDict() |
|
248 | resources['metadata'] = ResourcesDict() | |
247 | if not resources['metadata']['name']: |
|
249 | if not resources['metadata']['name']: |
General Comments 0
You need to be logged in to leave comments.
Login now