diff --git a/binder/requirements.txt b/binder/requirements.txt new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/binder/requirements.txt @@ -0,0 +1 @@ +. diff --git a/nbgitpuller/handlers.py b/nbgitpuller/handlers.py index d76094e9..a88f3251 100644 --- a/nbgitpuller/handlers.py +++ b/nbgitpuller/handlers.py @@ -13,6 +13,11 @@ from .version import __version__ +jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader( + os.path.join(os.path.dirname(__file__), 'templates') + ), +) + class SyncHandler(IPythonHandler): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -128,19 +133,6 @@ def pull(): class UIHandler(IPythonHandler): - def initialize(self): - super().initialize() - # FIXME: Is this really the best way to use jinja2 here? - # I can't seem to get the jinja2 env in the base handler to - # actually load templates from arbitrary paths ugh. - jinja2_env = self.settings['jinja2_env'] - jinja2_env.loader = jinja2.ChoiceLoader([ - jinja2_env.loader, - jinja2.FileSystemLoader( - os.path.join(os.path.dirname(__file__), 'templates') - ) - ]) - @web.authenticated async def get(self): app_env = os.getenv('NBGITPULLER_APP', default='notebook') @@ -169,10 +161,11 @@ async def get(self): path = 'tree/' + path self.write( - self.render_template( - 'status.html', - repo=repo, branch=branch, path=path, depth=depth, targetpath=targetpath, version=__version__ - )) + jinja_env.get_template('status.html').render( + repo=repo, branch=branch, path=path, depth=depth, targetpath=targetpath, version=__version__, + **self.template_namespace + ) + ) await self.flush() diff --git a/nbgitpuller/templates/page.html b/nbgitpuller/templates/page.html index aae54ad5..e6ef02dc 100644 --- a/nbgitpuller/templates/page.html +++ b/nbgitpuller/templates/page.html @@ -5,9 +5,7 @@ {% block title %}Jupyter Server{% endblock %} {% block favicon %}{% endblock %} - - - + @@ -23,15 +21,15 @@ -