notebook 7.0.0b3__py3-none-any.whl → 7.0.0rc0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of notebook might be problematic. Click here for more details.

Files changed (217) hide show
  1. notebook/_version.py +1 -1
  2. notebook/app.py +84 -17
  3. notebook/custom/custom.css +7 -0
  4. notebook/static/1018.bundle.js +1 -1
  5. notebook/static/1198.bundle.js +1 -1
  6. notebook/static/1337.bundle.js +1 -1
  7. notebook/static/134.bundle.js +1 -0
  8. notebook/static/1408.bundle.js +1 -1
  9. notebook/static/1584.bundle.js +1 -1
  10. notebook/static/162.bundle.js +1 -1
  11. notebook/static/1647.bundle.js +1 -1
  12. notebook/static/1650.bundle.js +1 -1
  13. notebook/static/1682.bundle.js +1 -1
  14. notebook/static/1684.bundle.js +1 -1
  15. notebook/static/1809.bundle.js +1 -1
  16. notebook/static/1827.bundle.js +1 -1
  17. notebook/static/1833.bundle.js +1 -1
  18. notebook/static/1835.bundle.js +1 -1
  19. notebook/static/1950.bundle.js +1 -1
  20. notebook/static/1958.bundle.js +1 -1
  21. notebook/static/2007.bundle.js +1 -1
  22. notebook/static/2067.bundle.js +1 -1
  23. notebook/static/2088.bundle.js +1 -1
  24. notebook/static/2089.bundle.js +1 -1
  25. notebook/static/2122.bundle.js +1 -1
  26. notebook/static/2167.bundle.js +1 -1
  27. notebook/static/2184.bundle.js +1 -1
  28. notebook/static/2251.bundle.js +1 -1
  29. notebook/static/2311.bundle.js +1 -1
  30. notebook/static/2323.bundle.js +1 -1
  31. notebook/static/2330.bundle.js +1 -1
  32. notebook/static/2401.bundle.js +1 -1
  33. notebook/static/2479.bundle.js +1 -0
  34. notebook/static/2512.bundle.js +1 -1
  35. notebook/static/2607.bundle.js +1 -1
  36. notebook/static/2924.bundle.js +1 -1
  37. notebook/static/2955.bundle.js +1 -0
  38. notebook/static/2979.bundle.js +1 -1
  39. notebook/static/3146.bundle.js +1 -1
  40. notebook/static/3213.bundle.js +1 -1
  41. notebook/static/3340.bundle.js +1 -1
  42. notebook/static/3360.bundle.js +1 -1
  43. notebook/static/3466.bundle.js +1 -1
  44. notebook/static/35.bundle.js +1 -1
  45. notebook/static/3676.bundle.js +1 -1
  46. notebook/static/3680.bundle.js +1 -1
  47. notebook/static/3768.bundle.js +1 -0
  48. notebook/static/377.bundle.js +1 -0
  49. notebook/static/3797.bundle.js +1 -1
  50. notebook/static/3863.bundle.js +1 -1
  51. notebook/static/3881.bundle.js +1 -1
  52. notebook/static/4042.bundle.js +1 -0
  53. notebook/static/4131.bundle.js +1 -1
  54. notebook/static/4205.bundle.js +1 -1
  55. notebook/static/4212.bundle.js +1 -1
  56. notebook/static/4234.bundle.js +1 -1
  57. notebook/static/4382.bundle.js +1 -1
  58. notebook/static/4558.bundle.js +1 -1
  59. notebook/static/4645.bundle.js +1 -1
  60. notebook/static/4746.bundle.js +1 -0
  61. notebook/static/4785.bundle.js +1 -1
  62. notebook/static/4810.bundle.js +1 -1
  63. notebook/static/4811.bundle.js +1 -1
  64. notebook/static/4837.bundle.js +1 -0
  65. notebook/static/5016.bundle.js +1 -1
  66. notebook/static/5088.bundle.js +1 -1
  67. notebook/static/5099.bundle.js +1 -1
  68. notebook/static/5125.bundle.js +2 -0
  69. notebook/static/5135.bundle.js +1 -1
  70. notebook/static/5261.bundle.js +1 -0
  71. notebook/static/5313.bundle.js +1 -1
  72. notebook/static/5325.bundle.js +1 -1
  73. notebook/static/5346.bundle.js +1 -1
  74. notebook/static/5426.bundle.js +1 -1
  75. notebook/static/5573.bundle.js +1 -1
  76. notebook/static/5601.bundle.js +1 -1
  77. notebook/static/5649.bundle.js +1 -1
  78. notebook/static/5678.bundle.js +1 -1
  79. notebook/static/5733.bundle.js +1 -1
  80. notebook/static/5765.bundle.js +1 -1
  81. notebook/static/5777.bundle.js +1 -1
  82. notebook/static/5828.bundle.js +1 -1
  83. notebook/static/5912.bundle.js +1 -1
  84. notebook/static/5921.bundle.js +1 -1
  85. notebook/static/6017.bundle.js +1 -1
  86. notebook/static/6027.bundle.js +1 -1
  87. notebook/static/6139.bundle.js +1 -1
  88. notebook/static/62.bundle.js +1 -1
  89. notebook/static/6256.bundle.js +1 -1
  90. notebook/static/6271.bundle.js +1 -1
  91. notebook/static/6345.bundle.js +1 -1
  92. notebook/static/6604.bundle.js +1 -1
  93. notebook/static/6621.bundle.js +1 -1
  94. notebook/static/6627.bundle.js +1 -1
  95. notebook/static/6774.bundle.js +1 -0
  96. notebook/static/6815.bundle.js +1 -1
  97. notebook/static/6853.bundle.js +1 -1
  98. notebook/static/6893.bundle.js +1 -1
  99. notebook/static/690.bundle.js +1 -1
  100. notebook/static/6919.bundle.js +3 -3
  101. notebook/static/6962.bundle.js +1 -1
  102. notebook/static/6999.bundle.js +1 -1
  103. notebook/static/7226.bundle.js +1 -1
  104. notebook/static/7252.bundle.js +1 -0
  105. notebook/static/7302.bundle.js +1 -0
  106. notebook/static/7369.bundle.js +1 -1
  107. notebook/static/7386.bundle.js +1 -1
  108. notebook/static/7391.bundle.js +1 -1
  109. notebook/static/7394.bundle.js +1 -1
  110. notebook/static/7427.bundle.js +1 -0
  111. notebook/static/7439.bundle.js +1 -1
  112. notebook/static/7450.bundle.js +1 -1
  113. notebook/static/7603.bundle.js +1 -1
  114. notebook/static/7639.bundle.js +1 -1
  115. notebook/static/7679.bundle.js +1 -0
  116. notebook/static/7684.bundle.js +1 -1
  117. notebook/static/7819.bundle.js +1 -1
  118. notebook/static/7900.bundle.js +1 -0
  119. notebook/static/7906.bundle.js +1 -1
  120. notebook/static/7957.bundle.js +1 -1
  121. notebook/static/7997.bundle.js +1 -1
  122. notebook/static/8010.bundle.js +1 -1
  123. notebook/static/8136.bundle.js +1 -1
  124. notebook/static/8578.bundle.js +1 -1
  125. notebook/static/8579.bundle.js +1 -1
  126. notebook/static/8633.bundle.js +1 -1
  127. notebook/static/8771.bundle.js +1 -1
  128. notebook/static/880.bundle.js +1 -1
  129. notebook/static/8845.bundle.js +1 -1
  130. notebook/static/8845.bundle.js.LICENSE.txt +2 -2
  131. notebook/static/8875.bundle.js +1 -1
  132. notebook/static/8907.bundle.js +1 -1
  133. notebook/static/8914.bundle.js +1 -1
  134. notebook/static/8928.bundle.js +1 -0
  135. notebook/static/893.bundle.js +1 -1
  136. notebook/static/901.bundle.js +1 -1
  137. notebook/static/9068.bundle.js +1 -1
  138. notebook/static/9086.bundle.js +1 -1
  139. notebook/static/911.bundle.js +1 -1
  140. notebook/static/9151.bundle.js +1 -1
  141. notebook/static/9268.bundle.js +1 -1
  142. notebook/static/9335.bundle.js +1 -1
  143. notebook/static/9341.bundle.js +1 -1
  144. notebook/static/9380.bundle.js +1 -1
  145. notebook/static/9605.bundle.js +1 -1
  146. notebook/static/9609.bundle.js +1 -1
  147. notebook/static/9638.bundle.js +1 -1
  148. notebook/static/9680.bundle.js +1 -0
  149. notebook/static/9685.bundle.js +1 -0
  150. notebook/static/9752.bundle.js +1 -1
  151. notebook/static/9799.bundle.js +1 -1
  152. notebook/static/9852.bundle.js +1 -1
  153. notebook/static/9854.bundle.js +2 -0
  154. notebook/static/bundle.js +1 -1
  155. notebook/static/third-party-licenses.json +1780 -0
  156. notebook/templates/consoles.html +4 -0
  157. notebook/templates/notebooks.html +4 -0
  158. notebook/templates/terminals.html +4 -0
  159. notebook/templates/tree.html +5 -1
  160. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/package.json.orig +14 -13
  161. notebook-7.0.0rc0.data/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/shell.json +34 -0
  162. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/documentsearch-extension/package.json.orig +4 -4
  163. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/help-extension/package.json.orig +6 -6
  164. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/package.json.orig +9 -9
  165. notebook-7.0.0rc0.data/data/share/jupyter/lab/schemas/@jupyter-notebook/tree-extension/file-actions.json +10 -0
  166. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/tree-extension/package.json.orig +15 -15
  167. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/package.json +11 -11
  168. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/schemas/@jupyter-notebook/lab-extension/interface-switcher.json +7 -0
  169. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/schemas/@jupyter-notebook/lab-extension/package.json.orig +10 -10
  170. notebook-7.0.0rc0.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/568.1b31bd587bea2c1816b1.js +1 -0
  171. notebook-7.0.0rc0.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/7.d4d2f899a93808dccf3d.js +1 -0
  172. notebook-7.0.0rc0.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/776.c7baadfaddfd4518c935.js +1 -0
  173. notebook-7.0.0b3.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/928.b111d584f0d884751732.js → notebook-7.0.0rc0.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/928.a832439d17633285a072.js +1 -1
  174. notebook-7.0.0rc0.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/remoteEntry.b00379f3c5b2b5eb657f.js +1 -0
  175. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/third-party-licenses.json +2 -2
  176. {notebook-7.0.0b3.dist-info → notebook-7.0.0rc0.dist-info}/METADATA +2 -2
  177. notebook-7.0.0rc0.dist-info/RECORD +389 -0
  178. {notebook-7.0.0b3.dist-info → notebook-7.0.0rc0.dist-info}/WHEEL +1 -1
  179. notebook/static/1838.bundle.js +0 -1
  180. notebook/static/2274.bundle.js +0 -1
  181. notebook/static/3063.bundle.js +0 -2
  182. notebook/static/3344.bundle.js +0 -1
  183. notebook/static/4710.bundle.js +0 -1
  184. notebook/static/4964.bundle.js +0 -1
  185. notebook/static/51.bundle.js +0 -1
  186. notebook/static/5282.bundle.js +0 -1
  187. notebook/static/5975.bundle.js +0 -1
  188. notebook/static/6541.bundle.js +0 -1
  189. notebook/static/6695.bundle.js +0 -1
  190. notebook/static/6720.bundle.js +0 -1
  191. notebook/static/771.bundle.js +0 -1
  192. notebook/static/7827.bundle.js +0 -2
  193. notebook-7.0.0b3.data/data/share/jupyter/lab/schemas/@jupyter-notebook/documentsearch-extension/notebookShellWidgetListener.json +0 -15
  194. notebook-7.0.0b3.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/568.b5aff22313aa70cecd54.js +0 -1
  195. notebook-7.0.0b3.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/776.5c1c9ffcf8fa98186600.js +0 -1
  196. notebook-7.0.0b3.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/879.2f8e4f4c4819f3fb070d.js +0 -1
  197. notebook-7.0.0b3.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/remoteEntry.0e12542c53b160cf8593.js +0 -1
  198. notebook-7.0.0b3.dist-info/RECORD +0 -380
  199. /notebook/static/{3063.bundle.js.LICENSE.txt → 5125.bundle.js.LICENSE.txt} +0 -0
  200. /notebook/static/{7827.bundle.js.LICENSE.txt → 9854.bundle.js.LICENSE.txt} +0 -0
  201. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/etc/jupyter/jupyter_server_config.d/notebook.json +0 -0
  202. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/applications/jupyter-notebook.desktop +0 -0
  203. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/icons/hicolor/scalable/apps/notebook.svg +0 -0
  204. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/menus.json +0 -0
  205. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/pages.json +0 -0
  206. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/title.json +0 -0
  207. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/top.json +0 -0
  208. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/zen.json +0 -0
  209. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/help-extension/open.json +0 -0
  210. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/checkpoints.json +0 -0
  211. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/kernel-logo.json +0 -0
  212. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/scroll-output.json +0 -0
  213. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/tree-extension/widget.json +0 -0
  214. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/schemas/@jupyter-notebook/lab-extension/launch-tree.json +0 -0
  215. {notebook-7.0.0b3.data → notebook-7.0.0rc0.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/style.js +0 -0
  216. {notebook-7.0.0b3.dist-info → notebook-7.0.0rc0.dist-info}/entry_points.txt +0 -0
  217. {notebook-7.0.0b3.dist-info → notebook-7.0.0rc0.dist-info}/licenses/LICENSE +0 -0
notebook/_version.py CHANGED
@@ -5,7 +5,7 @@ import re
5
5
  from collections import namedtuple
6
6
 
7
7
  # Use "hatch version xx.yy.zz" to handle version changes
8
- __version__ = "7.0.0b3"
8
+ __version__ = "7.0.0rc0"
9
9
 
10
10
  # PEP440 version parser
11
11
  _version_regex = re.compile(
notebook/app.py CHANGED
@@ -1,11 +1,16 @@
1
1
  """Jupyter notebook application."""
2
2
  import os
3
+ import re
3
4
  from os.path import join as pjoin
4
5
 
5
6
  from jupyter_client.utils import ensure_async
6
7
  from jupyter_core.application import base_aliases
8
+ from jupyter_core.paths import jupyter_config_dir
7
9
  from jupyter_server.base.handlers import JupyterHandler
8
- from jupyter_server.extension.handler import ExtensionHandlerJinjaMixin, ExtensionHandlerMixin
10
+ from jupyter_server.extension.handler import (
11
+ ExtensionHandlerJinjaMixin,
12
+ ExtensionHandlerMixin,
13
+ )
9
14
  from jupyter_server.serverapp import flags
10
15
  from jupyter_server.utils import url_escape, url_is_absolute
11
16
  from jupyter_server.utils import url_path_join as ujoin
@@ -19,7 +24,7 @@ from jupyterlab_server.config import LabConfig, get_page_config, recursive_updat
19
24
  from jupyterlab_server.handlers import _camelCase, is_url
20
25
  from notebook_shim.shim import NotebookConfigShimMixin # type:ignore
21
26
  from tornado import web
22
- from traitlets import Bool, default
27
+ from traitlets import Bool, Unicode, default
23
28
 
24
29
  from ._version import __version__
25
30
 
@@ -32,6 +37,10 @@ version = __version__
32
37
  class NotebookBaseHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHandler):
33
38
  """The base notebook API handler."""
34
39
 
40
+ @property
41
+ def custom_css(self):
42
+ return self.settings.get("custom_css", True)
43
+
35
44
  def get_page_config(self):
36
45
  """Get the page config."""
37
46
  config = LabConfig()
@@ -49,19 +58,6 @@ class NotebookBaseHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, Jup
49
58
  "exposeAppInBrowser": app.expose_app_in_browser,
50
59
  }
51
60
 
52
- if "hub_prefix" in app.serverapp.tornado_settings:
53
- tornado_settings = app.serverapp.tornado_settings
54
- hub_prefix = tornado_settings["hub_prefix"]
55
- page_config["hubPrefix"] = hub_prefix
56
- page_config["hubHost"] = tornado_settings["hub_host"]
57
- page_config["hubUser"] = tornado_settings["user"]
58
- page_config["shareUrl"] = ujoin(hub_prefix, "user-redirect")
59
- # Assume the server_name property indicates running JupyterHub 1.0.
60
- if hasattr(app.serverapp, "server_name"):
61
- page_config["hubServerName"] = app.serverapp.server_name
62
- api_token = os.getenv("JUPYTERHUB_API_TOKEN", "")
63
- page_config["token"] = api_token
64
-
65
61
  server_root = self.settings.get("server_root_dir", "")
66
62
  server_root = server_root.replace(os.sep, "/")
67
63
  server_root = os.path.normpath(os.path.expanduser(server_root))
@@ -87,6 +83,7 @@ class NotebookBaseHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, Jup
87
83
 
88
84
  page_config.setdefault("mathjaxConfig", mathjax_config)
89
85
  page_config.setdefault("fullMathjaxUrl", mathjax_url)
86
+ page_config.setdefault("jupyterConfigDir", jupyter_config_dir())
90
87
 
91
88
  # Put all our config in page_config
92
89
  for name in config.trait_names():
@@ -120,7 +117,7 @@ class RedirectHandler(NotebookBaseHandler):
120
117
  @web.authenticated
121
118
  def get(self):
122
119
  """Get the redirect url."""
123
- return self.redirect(self.base_url + "tree")
120
+ return self.redirect(self.base_url.strip("/") + "/" + self.default_url.strip("/"))
124
121
 
125
122
 
126
123
  class TreeHandler(NotebookBaseHandler):
@@ -203,6 +200,27 @@ class NotebookHandler(NotebookBaseHandler):
203
200
  return self.write(tpl)
204
201
 
205
202
 
203
+ class CustomCssHandler(NotebookBaseHandler):
204
+ """A custom CSS handler."""
205
+
206
+ @web.authenticated
207
+ def get(self):
208
+ """Get the custom css file."""
209
+
210
+ self.set_header("Content-Type", 'text/css')
211
+ page_config = self.get_page_config()
212
+ custom_css_file = f"{page_config['jupyterConfigDir']}/custom/custom.css"
213
+
214
+ if not os.path.isfile(custom_css_file):
215
+ static_path_root = re.match('^(.*?)static', page_config['staticDir'])
216
+ if static_path_root is not None:
217
+ custom_dir = static_path_root.groups()[0]
218
+ custom_css_file = f"{custom_dir}custom/custom.css"
219
+
220
+ with open(custom_css_file) as css_f:
221
+ return self.write(css_f.read())
222
+
223
+
206
224
  aliases = dict(base_aliases)
207
225
 
208
226
 
@@ -215,7 +233,7 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
215
233
  version = version
216
234
  app_version = version
217
235
  extension_url = "/"
218
- default_url = "/tree" # type:ignore
236
+ default_url = Unicode("/tree", config=True, help="The default URL to redirect to from `/`")
219
237
  file_url_prefix = "/notebooks"
220
238
  load_other_extensions = True
221
239
  app_dir = app_dir
@@ -227,12 +245,25 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
227
245
  help="Whether to expose the global app instance to browser via window.jupyterapp",
228
246
  )
229
247
 
248
+ custom_css = Bool(
249
+ True,
250
+ config=True,
251
+ help="""Whether custom CSS is loaded on the page.
252
+ Defaults to True and custom CSS is loaded.
253
+ """,
254
+ )
255
+
230
256
  flags = flags
231
257
  flags["expose-app-in-browser"] = (
232
258
  {"JupyterNotebookApp": {"expose_app_in_browser": True}},
233
259
  "Expose the global app instance to browser via window.jupyterapp.",
234
260
  )
235
261
 
262
+ flags["custom-css"] = (
263
+ {"JupyterNotebookApp": {"custom_css": True}},
264
+ "Load custom CSS in template html files. Default is True",
265
+ )
266
+
236
267
  @default("static_dir")
237
268
  def _default_static_dir(self):
238
269
  return os.path.join(HERE, "static")
@@ -261,8 +292,43 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
261
292
  def _default_workspaces_dir(self):
262
293
  return get_workspaces_dir()
263
294
 
295
+ def _prepare_templates(self):
296
+ super(LabServerApp, self)._prepare_templates()
297
+ self.jinja2_env.globals.update(custom_css=self.custom_css) # type:ignore
298
+
299
+ def server_extension_is_enabled(self, extension):
300
+ """Check if server extension is enabled."""
301
+ try:
302
+ extension_enabled = (
303
+ self.serverapp.extension_manager.extensions[extension].enabled is True
304
+ )
305
+ except (AttributeError, KeyError, TypeError):
306
+ extension_enabled = False
307
+ return extension_enabled
308
+
264
309
  def initialize_handlers(self):
265
310
  """Initialize handlers."""
311
+ page_config = self.serverapp.web_app.settings.setdefault("page_config_data", {})
312
+ nbclassic_enabled = self.server_extension_is_enabled("nbclassic")
313
+ page_config["nbclassic_enabled"] = nbclassic_enabled
314
+
315
+ # If running under JupyterHub, add more metadata.
316
+ if "hub_prefix" in self.serverapp.tornado_settings:
317
+ tornado_settings = self.serverapp.tornado_settings
318
+ hub_prefix = tornado_settings["hub_prefix"]
319
+ page_config["hubPrefix"] = hub_prefix
320
+ page_config["hubHost"] = tornado_settings["hub_host"]
321
+ page_config["hubUser"] = tornado_settings["user"]
322
+ page_config["shareUrl"] = ujoin(hub_prefix, "user-redirect")
323
+ # Assume the server_name property indicates running JupyterHub 1.0.
324
+ if hasattr(self.serverapp, "server_name"):
325
+ page_config["hubServerName"] = self.serverapp.server_name
326
+ # avoid setting API token in page config
327
+ # $JUPYTERHUB_API_TOKEN identifies the server, not the client
328
+ # but at least make sure we don't use the token
329
+ # if the serverapp set one
330
+ page_config["token"] = ""
331
+
266
332
  self.handlers.append(
267
333
  (
268
334
  rf"/{self.file_url_prefix}/((?!.*\.ipynb($|\?)).*)",
@@ -276,6 +342,7 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
276
342
  self.handlers.append(("/edit(.*)", FileHandler))
277
343
  self.handlers.append(("/consoles/(.*)", ConsoleHandler))
278
344
  self.handlers.append(("/terminals/(.*)", TerminalHandler))
345
+ self.handlers.append(("/custom/custom.css", CustomCssHandler))
279
346
  super().initialize_handlers()
280
347
 
281
348
  def initialize(self, argv=None):
@@ -0,0 +1,7 @@
1
+ /*
2
+ Placeholder for custom user CSS
3
+
4
+ mainly to be overridden in profile/static/custom/custom.css
5
+
6
+ This will always be an empty file
7
+ */