浏览代码

more cleanup of labapp

Steven Silvester 8 年之前
父节点
当前提交
541c3546dc
共有 1 个文件被更改,包括 17 次插入11 次删除
  1. 17 11
      jupyterlab/labapp.py

+ 17 - 11
jupyterlab/labapp.py

@@ -51,21 +51,26 @@ class LabHandler(IPythonHandler):
 
     @web.authenticated
     def get(self):
-        static_prefix = ujoin(self.base_url, PREFIX)
-        labextensions = self.labextensions
-        data = get_labextension_manifest_data_by_folder(BUILT_FILES)
-        if 'main' not in data:
-            msg = ('JupyterLab build artifacts not detected, please see ' + 
+        manifest = get_labextension_manifest_data_by_folder(BUILT_FILES)
+        if 'main' not in manifest:
+            msg = ('JupyterLab build artifacts not detected, please see ' +
                    'CONTRIBUTING.md for build instructions.')
             self.log.error(msg)
-            self.write(self.render_template('error.html', 
-                       status_code=500, 
+            self.write(self.render_template('error.html',
+                       status_code=500,
                        status_message='JupyterLab Error',
                        page_title='JupyterLab Error',
                        message=msg))
             return
 
-        main = data['main']['entry']
+        config = self._get_lab_config(manifest)
+        self.write(self.render_template('lab.html', **config))
+
+    def _get_lab_config(self, manifest):
+        """Get the config data for the page template."""
+        static_prefix = ujoin(self.base_url, PREFIX)
+        labextensions = self.labextensions
+        main = manifest['main']['entry']
         bundles = [ujoin(static_prefix, name + '.bundle.js') for name in
                    ['loader', 'main']]
         entries = []
@@ -103,19 +108,20 @@ class LabHandler(IPythonHandler):
                 except Exception as e:
                     self.log.error(e)
 
+        mathjax_config = self.settings.get('mathjax_config',
+                                           'TeX-AMS_HTML-full,Safe')
         config = dict(
             static_prefix=static_prefix,
             page_title='JupyterLab Alpha Preview',
             mathjax_url=self.mathjax_url,
+            mathjax_config=mathjax_config,
             jupyterlab_main=main,
             jupyterlab_css=css_files,
             jupyterlab_bundles=bundles,
             plugin_entries=entries,
-            mathjax_config='TeX-AMS_HTML-full,Safe',
-            #mathjax_config=self.mathjax_config # for the next release of the notebook
         )
         config['jupyterlab_config'] = configData
-        self.write(self.render_template('lab.html', **config))
+        return config
 
     def get_template(self, name):
         return FILE_LOADER.load(self.settings['jinja2_env'], name)