Skip to content

Commit 073d3b6

Browse files
committed
fix(dataset): serve nested TinyMCE assets so the description editor loads
The description editor (TinyMCE, base_url /dataset/dist) loads its runtime from nested folders — models/dom/, themes/silver/, skins/, icons/. splent's BaseBlueprint asset route only matches a single path segment, so every nested file 404'd and TinyMCE never initialised (no textarea, no editor visible). Add a dataset-owned route /dataset/dist/<path:filename> (send_from_directory, binary-safe, longer prefix wins) that serves the whole compiled tree, pinning .js/.css MIME types. Same fix pattern as the generator Pyodide assets. Verified: the nested assets now return 200 and Selenium confirms the editor renders (.tox-tinymce present). Regression tests added.
1 parent d03f68d commit 073d3b6

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

app/features/dataset/routes.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
render_template,
2222
request,
2323
send_file,
24+
send_from_directory,
2425
url_for,
2526
)
2627
from flask_login import current_user, login_required
@@ -345,6 +346,32 @@ def new_dataset_version(dataset_id):
345346
)
346347

347348

349+
_DATASET_ASSETS_DIR = os.path.join(os.path.dirname(__file__), "assets")
350+
351+
_ASSET_MIMETYPES = {
352+
".js": "text/javascript",
353+
".mjs": "text/javascript",
354+
".css": "text/css",
355+
}
356+
357+
358+
@dataset_bp.route("/dataset/dist/<path:filename>", methods=["GET"])
359+
def dist_asset(filename):
360+
"""Serve the dataset's compiled front-end assets.
361+
362+
splent's BaseBlueprint asset route only matches a single path segment and
363+
reads files in text mode, so it cannot serve the nested TinyMCE runtime
364+
(models/, themes/, skins/, icons/, plugins/) the description editor loads
365+
from base_url '/dataset/dist'. This route serves that tree with a path
366+
converter and binary-safe streaming, taking precedence via its longer prefix.
367+
"""
368+
response = send_from_directory(os.path.join(_DATASET_ASSETS_DIR, "dist"), filename)
369+
mimetype = _ASSET_MIMETYPES.get(os.path.splitext(filename)[1])
370+
if mimetype:
371+
response.headers["Content-Type"] = mimetype
372+
return response
373+
374+
348375
@dataset_bp.route("/datasets/list", methods=["GET"])
349376
@login_required
350377
def list_dataset():

app/features/dataset/tests/test_integration.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,20 @@ def test_new_version_validation_error_returns_400(test_client):
414414
response = test_client.post("/dataset/1/new-version", data={}, content_type="multipart/form-data")
415415
assert response.status_code == 400
416416
test_client.get("/logout", follow_redirects=True)
417+
418+
419+
# --- Compiled asset serving (nested TinyMCE files) -----------------------
420+
421+
422+
def test_dist_asset_serves_nested_tinymce_model(test_client):
423+
# splent's BaseBlueprint asset route 404s on nested paths; dist_asset must
424+
# serve them so the TinyMCE description editor can load (base_url /dataset/dist).
425+
response = test_client.get("/dataset/dist/models/dom/model.js")
426+
assert response.status_code == 200
427+
assert "javascript" in response.headers["Content-Type"]
428+
429+
430+
def test_dist_asset_serves_nested_skin_css(test_client):
431+
response = test_client.get("/dataset/dist/skins/ui/oxide/skin.min.css")
432+
assert response.status_code == 200
433+
assert "text/css" in response.headers["Content-Type"]

0 commit comments

Comments
 (0)