diff --git a/cellxgene_gateway/dir_util.py b/cellxgene_gateway/dir_util.py
index 542de40..05db382 100644
--- a/cellxgene_gateway/dir_util.py
+++ b/cellxgene_gateway/dir_util.py
@@ -68,7 +68,7 @@ def recurse_dir(path):
}
elif os.path.isdir(full_path):
return {
- "path": full_path,
+ "path": full_path.replace(env.cellxgene_data, ""),
"name": el,
"type": "directory",
"children": recurse_dir(full_path),
@@ -88,7 +88,8 @@ def render_entries(entries):
def render_entry(entry):
if entry["type"] == "file":
- url = 'view' + '/' + entry['path'].lstrip("/")
+ url = f"/view/{entry['path'].lstrip('/')}"
return f"
{entry['name']}"
elif entry["type"] == "directory":
- return f"{entry['name']}{render_entries(entry['children'])}"
+ url = f"/filecrawl/{entry['path'].lstrip('/')}"
+ return f"{entry['name']}{render_entries(entry['children'])}"
diff --git a/cellxgene_gateway/gateway.py b/cellxgene_gateway/gateway.py
index 47dafa3..28187e2 100644
--- a/cellxgene_gateway/gateway.py
+++ b/cellxgene_gateway/gateway.py
@@ -168,6 +168,22 @@ def filecrawl():
rendered_html=rendered_html,
)
+@app.route("/filecrawl/")
+def do_filecrawl(path):
+ filecrawl_path = os.path.join(env.cellxgene_data, path)
+ if not os.path.isdir(filecrawl_path):
+ raise CellxgeneException(
+ "Path is not directory: " + filecrawl_path, status.HTTP_400_BAD_REQUEST
+ )
+ entries = recurse_dir(filecrawl_path)
+ rendered_html = render_entries(entries)
+ return render_template(
+ "filecrawl.html",
+ extra_scripts=get_extra_scripts(),
+ rendered_html=rendered_html,
+ path=path,
+ )
+
entry_lock = Lock()
@app.route("/view/", methods=["GET", "PUT", "POST"])
def do_view(path):
diff --git a/cellxgene_gateway/templates/filecrawl.html b/cellxgene_gateway/templates/filecrawl.html
index a52ef25..d752163 100644
--- a/cellxgene_gateway/templates/filecrawl.html
+++ b/cellxgene_gateway/templates/filecrawl.html
@@ -21,7 +21,11 @@
- Cellxgene Gateway - FILE CRAWLER
+ {% if path %}
+ Cellxgene Gateway - {{ path }}
+ {% else %}
+ Cellxgene Gateway - FILE CRAWLER
+ {% endif %}
@@ -29,6 +33,15 @@
{{ rendered_html|safe }}
-
+
+ Navigation:
+
+