Skip to content

Commit 3f2ce38

Browse files
committed
add server extension hoooks
1 parent 19245ce commit 3f2ce38

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

voila/server_extension.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def _load_jupyter_server_extension(server_app: ServerApp):
8181
voila_configuration = VoilaConfiguration(
8282
parent=server_app, config=load_config_file()
8383
)
84+
page_config_hook = voila_configuration.config.Voila.get("page_config_hook", None)
85+
prelaunch_hook = voila_configuration.config.Voila.get("prelaunch_hook", None)
8486

8587
template_name = voila_configuration.template
8688
template_paths = collect_template_paths(["voila", "nbconvert"], template_name)
@@ -102,8 +104,6 @@ def _load_jupyter_server_extension(server_app: ServerApp):
102104
host_pattern = ".*$"
103105
base_url = url_path_join(web_app.settings["base_url"])
104106

105-
tree_handler_conf = {"voila_configuration": voila_configuration}
106-
107107
themes_dir = pjoin(get_data_dir(), "themes")
108108
web_app.add_handlers(
109109
host_pattern,
@@ -115,17 +115,25 @@ def _load_jupyter_server_extension(server_app: ServerApp):
115115
"config": server_app.config,
116116
"template_paths": template_paths,
117117
"voila_configuration": voila_configuration,
118+
"prelaunch_hook": prelaunch_hook,
119+
"page_config_hook": page_config_hook,
118120
},
119121
),
120122
(
121123
url_path_join(base_url, "/voila"),
122124
TornadoVoilaTreeHandler,
123-
tree_handler_conf,
125+
{
126+
"voila_configuration": voila_configuration,
127+
"page_config_hook": page_config_hook,
128+
},
124129
),
125130
(
126131
url_path_join(base_url, "/voila/tree" + path_regex),
127132
TornadoVoilaTreeHandler,
128-
tree_handler_conf,
133+
{
134+
"voila_configuration": voila_configuration,
135+
"page_config_hook": page_config_hook,
136+
},
129137
),
130138
(
131139
url_path_join(base_url, "/voila/templates/(.*)"),
@@ -162,7 +170,7 @@ def _load_jupyter_server_extension(server_app: ServerApp):
162170
(
163171
url_path_join(base_url, r"/voila/api/contents%s" % path_regex),
164172
VoilaContentsHandler,
165-
tree_handler_conf,
173+
{"voila_configuration": voila_configuration},
166174
),
167175
],
168176
)

0 commit comments

Comments
 (0)