mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
don't strip '.ipynb' from notebook names in nblist
The only place the extension is not wanted is editing a name during upload. Everywhere else, it's actually wanted.
This commit is contained in:
parent
7e1a179a7c
commit
e0a7793226
@ -70,11 +70,10 @@ var IPython = (function (IPython) {
|
||||
var reader = new FileReader();
|
||||
reader.readAsText(f);
|
||||
var name_and_ext = utils.splitext(f.name);
|
||||
var nbname = name_and_ext[0];
|
||||
var file_ext = name_and_ext[1];
|
||||
if (file_ext === '.ipynb') {
|
||||
var item = that.new_notebook_item(0);
|
||||
that.add_name_input(nbname, item);
|
||||
that.add_name_input(f.name, item);
|
||||
// Store the notebook item in the reader so we can use it later
|
||||
// to know which item it belongs to.
|
||||
$(reader).data('item', item);
|
||||
@ -171,10 +170,10 @@ var IPython = (function (IPython) {
|
||||
var len = data.length;
|
||||
this.clear_list();
|
||||
if (len === 0) {
|
||||
var item = this.new_notebook_item(0);
|
||||
item = this.new_notebook_item(0);
|
||||
var span12 = item.children().first();
|
||||
span12.empty();
|
||||
span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').text(message))
|
||||
span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').text(message));
|
||||
}
|
||||
var path = this.notebookPath();
|
||||
var offset = 0;
|
||||
@ -190,9 +189,8 @@ var IPython = (function (IPython) {
|
||||
this.add_dir(path, name, item);
|
||||
} else {
|
||||
var name = data[i].name;
|
||||
var nbname = utils.splitext(name)[0];
|
||||
item = this.new_notebook_item(i+offset);
|
||||
this.add_link(path, nbname, item);
|
||||
this.add_link(path, name, item);
|
||||
name = utils.url_path_join(path, name);
|
||||
if(this.sessions[name] === undefined){
|
||||
this.add_delete_button(item);
|
||||
@ -247,7 +245,7 @@ var IPython = (function (IPython) {
|
||||
NotebookList.prototype.add_link = function (path, nbname, item) {
|
||||
item.data('nbname', nbname);
|
||||
item.data('path', path);
|
||||
item.find(".item_name").text(nbname + '.ipynb');
|
||||
item.find(".item_name").text(nbname);
|
||||
item.find(".item_icon").addClass('icon-book');
|
||||
item.find("a.item_link")
|
||||
.attr('href',
|
||||
@ -255,7 +253,7 @@ var IPython = (function (IPython) {
|
||||
this.baseProjectUrl(),
|
||||
"notebooks",
|
||||
path,
|
||||
nbname + ".ipynb"
|
||||
nbname
|
||||
)
|
||||
).attr('target','_blank');
|
||||
};
|
||||
@ -267,7 +265,7 @@ var IPython = (function (IPython) {
|
||||
item.find(".item_name").empty().append(
|
||||
$('<input/>')
|
||||
.addClass("nbname_input")
|
||||
.attr('value', nbname)
|
||||
.attr('value', utils.splitext(nbname)[0])
|
||||
.attr('size', '30')
|
||||
.attr('type', 'text')
|
||||
);
|
||||
@ -336,7 +334,7 @@ var IPython = (function (IPython) {
|
||||
notebooklist.baseProjectUrl(),
|
||||
'api/notebooks',
|
||||
notebooklist.notebookPath(),
|
||||
nbname + '.ipynb'
|
||||
nbname
|
||||
);
|
||||
$.ajax(url, settings);
|
||||
}
|
||||
@ -356,6 +354,9 @@ var IPython = (function (IPython) {
|
||||
.addClass('btn btn-primary btn-mini upload_button')
|
||||
.click(function (e) {
|
||||
var nbname = item.find('.item_name > input').val();
|
||||
if (nbname.slice(nbname.length-6, nbname.length) != ".ipynb") {
|
||||
nbname = nbname + ".ipynb";
|
||||
}
|
||||
var path = that.notebookPath();
|
||||
var nbdata = item.data('nbdata');
|
||||
var content_type = 'application/json';
|
||||
@ -382,7 +383,7 @@ var IPython = (function (IPython) {
|
||||
that.baseProjectUrl(),
|
||||
'api/notebooks',
|
||||
that.notebookPath(),
|
||||
nbname + '.ipynb'
|
||||
nbname
|
||||
);
|
||||
$.ajax(url, settings);
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user