mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Implemented metadata for notebook format.
This commit is contained in:
parent
7e7a6ab50b
commit
ea8b4de42d
@ -147,10 +147,10 @@ class NotebookManager(LoggingConfigurable):
|
||||
|
||||
if name is None:
|
||||
try:
|
||||
name = nb.name
|
||||
name = nb.metadata.name
|
||||
except AttributeError:
|
||||
raise web.HTTPError(400)
|
||||
nb.name = name
|
||||
nb.metadata.name = name
|
||||
|
||||
notebook_id = self.new_notebook_id(name)
|
||||
self.save_notebook_object(notebook_id, nb)
|
||||
@ -167,7 +167,7 @@ class NotebookManager(LoggingConfigurable):
|
||||
raise web.HTTPError(400)
|
||||
|
||||
if name is not None:
|
||||
nb.name = name
|
||||
nb.metadata.name = name
|
||||
self.save_notebook_object(notebook_id, nb)
|
||||
|
||||
def save_notebook_object(self, notebook_id, nb):
|
||||
@ -176,7 +176,7 @@ class NotebookManager(LoggingConfigurable):
|
||||
raise web.HTTPError(404)
|
||||
old_name = self.mapping[notebook_id]
|
||||
try:
|
||||
new_name = nb.name
|
||||
new_name = nb.metadata.name
|
||||
except AttributeError:
|
||||
raise web.HTTPError(400)
|
||||
path = self.get_path_by_name(new_name)
|
||||
|
@ -21,6 +21,7 @@ var IPython = (function (IPython) {
|
||||
this.kernel = null;
|
||||
this.dirty = false;
|
||||
this.msg_cell_map = {};
|
||||
this.metadata = {};
|
||||
this.style();
|
||||
this.create_elements();
|
||||
this.bind_events();
|
||||
@ -711,6 +712,8 @@ var IPython = (function (IPython) {
|
||||
// Always delete cell 0 as they get renumbered as they are deleted.
|
||||
this.delete_cell(0);
|
||||
};
|
||||
// Save the metadata
|
||||
this.metadata = data.metadata;
|
||||
// Only handle 1 worksheet for now.
|
||||
var worksheet = data.worksheets[0];
|
||||
if (worksheet !== undefined) {
|
||||
@ -744,7 +747,8 @@ var IPython = (function (IPython) {
|
||||
};
|
||||
data = {
|
||||
// Only handle 1 worksheet for now.
|
||||
worksheets : [{cells:cell_array}]
|
||||
worksheets : [{cells:cell_array}],
|
||||
metadata : this.metadata
|
||||
}
|
||||
return data
|
||||
};
|
||||
@ -755,7 +759,7 @@ var IPython = (function (IPython) {
|
||||
var nbname = IPython.save_widget.get_notebook_name();
|
||||
// We may want to move the name/id/nbformat logic inside toJSON?
|
||||
var data = this.toJSON();
|
||||
data.name = nbname;
|
||||
data.metadata.name = nbname;
|
||||
data.nbformat = 2;
|
||||
// We do the call with settings so we can set cache to false.
|
||||
var settings = {
|
||||
@ -805,7 +809,7 @@ var IPython = (function (IPython) {
|
||||
this.insert_code_cell_after();
|
||||
};
|
||||
IPython.save_widget.status_save();
|
||||
IPython.save_widget.set_notebook_name(data.name);
|
||||
IPython.save_widget.set_notebook_name(data.metadata.name);
|
||||
this.start_kernel();
|
||||
this.dirty = false;
|
||||
// fromJSON always selects the last cell inserted. We need to wait
|
||||
|
Loading…
Reference in New Issue
Block a user