|
8 | 8 | #############################################################################
|
9 | 9 |
|
10 | 10 | import asyncio
|
| 11 | +import io |
11 | 12 | import json
|
12 | 13 | import os
|
13 | 14 | import sys
|
| 15 | +import tempfile |
14 | 16 | import threading
|
15 | 17 | import warnings
|
16 | 18 | from copy import deepcopy
|
17 | 19 | from functools import partial
|
18 | 20 | from pathlib import Path
|
19 | 21 | from typing import Awaitable, Dict, List
|
| 22 | +import zipfile |
20 | 23 |
|
| 24 | +import requests |
21 | 25 | import websockets
|
22 | 26 | from jupyter_core.paths import jupyter_path
|
23 | 27 | from jupyter_server.config_manager import recursive_update
|
@@ -97,24 +101,47 @@ def get_page_config(base_url, settings, log, voila_configuration: VoilaConfigura
|
97 | 101 | "baseUrl": base_url,
|
98 | 102 | "terminalsAvailable": False,
|
99 | 103 | "fullStaticUrl": url_path_join(base_url, "voila/static"),
|
100 |
| - "fullLabextensionsUrl": url_path_join(base_url, "voila/labextensions"), |
101 | 104 | "extensionConfig": voila_configuration.extension_config,
|
| 105 | + "fullLabextensionsUrl": url_path_join( |
| 106 | + voila_configuration.labextensions_url, "labextensions" |
| 107 | + ) |
| 108 | + or url_path_join(base_url, "voila/labextensions"), |
102 | 109 | }
|
| 110 | + |
103 | 111 | mathjax_config = settings.get("mathjax_config", "TeX-AMS_CHTML-full,Safe")
|
104 | 112 | mathjax_url = settings.get(
|
105 | 113 | "mathjax_url", "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js"
|
106 | 114 | )
|
107 | 115 | page_config.setdefault("mathjaxConfig", mathjax_config)
|
108 | 116 | page_config.setdefault("fullMathjaxUrl", mathjax_url)
|
109 |
| - labextensions_path = jupyter_path("labextensions") |
110 |
| - |
111 |
| - recursive_update( |
112 |
| - page_config, |
113 |
| - gpc( |
114 |
| - labextensions_path, |
115 |
| - logger=log, |
116 |
| - ), |
| 117 | + print("########### page_config", page_config) |
| 118 | + |
| 119 | + # If I want to do use the existing url and the custom, the the server here should |
| 120 | + # have the 'download_all_extensions' endpoint... |
| 121 | + |
| 122 | + download_extensions_url = url_path_join( |
| 123 | + page_config.get("fullLabextensionsUrl"), "download_all_extensions" |
117 | 124 | )
|
| 125 | + |
| 126 | + response = requests.get(download_extensions_url) |
| 127 | + response.raise_for_status() |
| 128 | + |
| 129 | + with tempfile.TemporaryDirectory() as labextensions_temp_path: |
| 130 | + |
| 131 | + # Extract the ZIP file into the temporary directory |
| 132 | + with zipfile.ZipFile(io.BytesIO(response.content)) as zip_ref: |
| 133 | + zip_ref.extractall(labextensions_temp_path) |
| 134 | + |
| 135 | + # I need to replace labextensions_temp_path with the actual result of |
| 136 | + recursive_update( |
| 137 | + page_config, |
| 138 | + gpc( |
| 139 | + [labextensions_temp_path], |
| 140 | + logger=log, |
| 141 | + ), |
| 142 | + ) |
| 143 | + |
| 144 | + print("################Updatedsss page_config", page_config) |
118 | 145 | disabled_extensions = [
|
119 | 146 | "@voila-dashboards/jupyterlab-preview",
|
120 | 147 | "@jupyter/collaboration-extension",
|
|
0 commit comments