##// END OF EJS Templates
redirect /edit/ to /files/ if not (utf8) text
Min RK -
Show More
@@ -370,7 +370,8 b' def json_errors(method):'
370 370 message = e.log_message
371 371 self.log.warn(message)
372 372 self.set_status(e.status_code)
373 self.finish(json.dumps(dict(message=message)))
373 reply = dict(message=message, reason=e.reason)
374 self.finish(json.dumps(reply))
374 375 except Exception:
375 376 self.log.error("Unhandled error in API request", exc_info=True)
376 377 status = 500
@@ -378,7 +379,7 b' def json_errors(method):'
378 379 t, value, tb = sys.exc_info()
379 380 self.set_status(status)
380 381 tb_text = ''.join(traceback.format_exception(t, value, tb))
381 reply = dict(message=message, traceback=tb_text)
382 reply = dict(message=message, reason=None, traceback=tb_text)
382 383 self.finish(json.dumps(reply))
383 384 else:
384 385 return result
@@ -282,7 +282,7 b' class FileContentsManager(ContentsManager):'
282 282 model['content'] = bcontent.decode('utf8')
283 283 except UnicodeError as e:
284 284 if format == 'text':
285 raise web.HTTPError(400, "%s is not UTF-8 encoded" % path)
285 raise web.HTTPError(400, "%s is not UTF-8 encoded" % path, reason='bad format')
286 286 else:
287 287 model['format'] = 'text'
288 288
@@ -345,14 +345,14 b' class FileContentsManager(ContentsManager):'
345 345 if os.path.isdir(os_path):
346 346 if type_ not in (None, 'directory'):
347 347 raise web.HTTPError(400,
348 u'%s is a directory, not a %s' % (path, type_))
348 u'%s is a directory, not a %s' % (path, type_), reason='bad type')
349 349 model = self._dir_model(path, content=content)
350 350 elif type_ == 'notebook' or (type_ is None and path.endswith('.ipynb')):
351 351 model = self._notebook_model(path, content=content)
352 352 else:
353 353 if type_ == 'directory':
354 354 raise web.HTTPError(400,
355 u'%s is not a directory')
355 u'%s is not a directory', reason='bad type')
356 356 model = self._file_model(path, content=content, format=format)
357 357 return model
358 358
@@ -79,6 +79,14 b' function($,'
79 79 that.events.trigger("file_loaded.Editor", model);
80 80 },
81 81 function(error) {
82 that.events.trigger("file_load_failed.Editor", error);
83 if (error.xhr.responseJSON.reason === 'bad format') {
84 window.location = utils.url_path_join(
85 that.base_url,
86 'files',
87 that.file_path
88 );
89 }
82 90 cm.setValue("Error! " + error.message +
83 91 "\nSaving disabled.");
84 92 that.save_enabled = false;
@@ -73,7 +73,7 b' require(['
73 73 page.show();
74 74
75 75 window.onbeforeunload = function () {
76 if (!editor.codemirror.isClean(editor.generation)) {
76 if (editor.save_enabled && !editor.codemirror.isClean(editor.generation)) {
77 77 return "Unsaved changes will be lost. Close anyway?";
78 78 }
79 79 };
General Comments 0
You need to be logged in to leave comments. Login now