Skip to content

Commit

Permalink
Docstring and override base breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
parente committed Jul 5, 2017
1 parent e52283a commit 2fa55a4
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions nbviewer/providers/local/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,27 @@ class LocalFileHandler(RenderingHandler):
def localfile_path(self):
return os.path.abspath(self.settings.get('localfile_path', ''))

def localfile_breadcrumbs(self, path):
def breadcrumbs(self, path):
"""Build a list of breadcrumbs leading up to and including the
given local path.
Parameters
----------
path: str
Relative path up to and including the leaf directory or file to include
in the breadcrumbs list
Returns
-------
list
Breadcrumbs suitable for the link_breadcrumbs() jinja macro
"""
provider_path = '/localfile'
breadcrumbs = [{
'url': url_path_join(self.base_url, self._localfile_path),
'name': 'home'
}]
breadcrumbs.extend(self.breadcrumbs(path, self._localfile_path))
breadcrumbs.extend(super(LocalFileHandler, self).breadcrumbs(path, self._localfile_path))
return breadcrumbs

@gen.coroutine
Expand Down Expand Up @@ -127,7 +141,7 @@ def get(self, path):
public=False,
format=self.format,
request=self.request,
breadcrumbs=self.localfile_breadcrumbs(path),
breadcrumbs=self.breadcrumbs(path),
title=os.path.basename(path))

def show_dir(self, abspath, path):
Expand Down Expand Up @@ -193,6 +207,6 @@ def show_dir(self, abspath, path):

html = self.render_template('dirview.html',
entries=entries,
breadcrumbs=self.localfile_breadcrumbs(path),
breadcrumbs=self.breadcrumbs(path),
title=url_path_join(path, '/'))
return html

0 comments on commit 2fa55a4

Please sign in to comment.