##// END OF EJS Templates
Server side logic for directories.
Brian E. Granger -
Show More
@@ -153,6 +153,38 b' class FileNotebookManager(NotebookManager):'
153 nbpath = self.get_os_path(name, path=path)
153 nbpath = self.get_os_path(name, path=path)
154 return os.path.isfile(nbpath)
154 return os.path.isfile(nbpath)
155
155
156 def list_dirs(self, path):
157 """List the directories for a given API style path."""
158 path = path.strip('/')
159 os_path = self.get_os_path('', path)
160 dir_names = os.listdir(os_path)
161 dirs = []
162 for name in dir_names:
163 os_path = self.get_os_path(name, path)
164 if os.path.isdir(os_path) and not name.startswith('.'):
165 model = self.get_dir_model(name, path)
166 dirs.append(model)
167 dirs = sorted(dirs, key=lambda item: item['name'])
168 return dirs
169
170 def get_dir_model(self, name, path=''):
171 """Get the directory model given a directory name and its API style path"""
172 path = path.strip('/')
173 os_path = self.get_os_path(name, path)
174 if not os.path.isdir(os_path):
175 raise IOError('directory does not exist: %r' % os_path)
176 info = os.stat(os_path)
177 last_modified = tz.utcfromtimestamp(info.st_mtime)
178 created = tz.utcfromtimestamp(info.st_ctime)
179 # Create the notebook model.
180 model ={}
181 model['name'] = name
182 model['path'] = path
183 model['last_modified'] = last_modified
184 model['created'] = created
185 model['type'] = 'directory'
186 return model
187
156 def list_notebooks(self, path):
188 def list_notebooks(self, path):
157 """Returns a list of dictionaries that are the standard model
189 """Returns a list of dictionaries that are the standard model
158 for all notebooks in the relative 'path'.
190 for all notebooks in the relative 'path'.
@@ -175,6 +207,7 b' class FileNotebookManager(NotebookManager):'
175 model = self.get_notebook_model(name, path, content=False)
207 model = self.get_notebook_model(name, path, content=False)
176 notebooks.append(model)
208 notebooks.append(model)
177 notebooks = sorted(notebooks, key=lambda item: item['name'])
209 notebooks = sorted(notebooks, key=lambda item: item['name'])
210 notebooks = self.list_dirs(path) + notebooks
178 return notebooks
211 return notebooks
179
212
180 def get_notebook_model(self, name, path='', content=True):
213 def get_notebook_model(self, name, path='', content=True):
@@ -167,6 +167,7 b' var IPython = (function (IPython) {'
167 if (param !== undefined && param.msg) {
167 if (param !== undefined && param.msg) {
168 message = param.msg;
168 message = param.msg;
169 }
169 }
170 console.log(data);
170 var len = data.length;
171 var len = data.length;
171 this.clear_list();
172 this.clear_list();
172 if (len === 0) {
173 if (len === 0) {
General Comments 0
You need to be logged in to leave comments. Login now