mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-09 01:38:12 +08:00
#15 added intermediate index pages
This commit is contained in:
@@ -68,7 +68,7 @@ def recurse_dir(path):
|
|||||||
}
|
}
|
||||||
elif os.path.isdir(full_path):
|
elif os.path.isdir(full_path):
|
||||||
return {
|
return {
|
||||||
"path": full_path,
|
"path": full_path.replace(env.cellxgene_data, ""),
|
||||||
"name": el,
|
"name": el,
|
||||||
"type": "directory",
|
"type": "directory",
|
||||||
"children": recurse_dir(full_path),
|
"children": recurse_dir(full_path),
|
||||||
@@ -88,7 +88,8 @@ def render_entries(entries):
|
|||||||
|
|
||||||
def render_entry(entry):
|
def render_entry(entry):
|
||||||
if entry["type"] == "file":
|
if entry["type"] == "file":
|
||||||
url = 'view' + '/' + entry['path'].lstrip("/")
|
url = f"/view/{entry['path'].lstrip('/')}"
|
||||||
return f"<li> <a href='{ url}'>{entry['name']}</a></li>"
|
return f"<li> <a href='{ url}'>{entry['name']}</a></li>"
|
||||||
elif entry["type"] == "directory":
|
elif entry["type"] == "directory":
|
||||||
return f"<li>{entry['name']}{render_entries(entry['children'])}</li>"
|
url = f"/filecrawl/{entry['path'].lstrip('/')}"
|
||||||
|
return f"<li><a href='{url}'>{entry['name']}</a>{render_entries(entry['children'])}</li>"
|
||||||
|
|||||||
@@ -168,6 +168,22 @@ def filecrawl():
|
|||||||
rendered_html=rendered_html,
|
rendered_html=rendered_html,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@app.route("/filecrawl/<path:path>")
|
||||||
|
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()
|
entry_lock = Lock()
|
||||||
@app.route("/view/<path:path>", methods=["GET", "PUT", "POST"])
|
@app.route("/view/<path:path>", methods=["GET", "PUT", "POST"])
|
||||||
def do_view(path):
|
def do_view(path):
|
||||||
|
|||||||
@@ -21,7 +21,11 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header class="navbar navbar-expand navbar-dark flex-column flex-md-row bd-navbar">
|
<header class="navbar navbar-expand navbar-dark flex-column flex-md-row bd-navbar">
|
||||||
<h3>Cellxgene Gateway - FILE CRAWLER</h3>
|
{% if path %}
|
||||||
|
<h3>Cellxgene Gateway - {{ path }}</h3>
|
||||||
|
{% else %}
|
||||||
|
<h3>Cellxgene Gateway - FILE CRAWLER</h3>
|
||||||
|
{% endif %}
|
||||||
</header>
|
</header>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@@ -29,6 +33,15 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
{{ rendered_html|safe }}
|
{{ rendered_html|safe }}
|
||||||
|
<p>
|
||||||
|
Navigation:
|
||||||
|
<ul>
|
||||||
|
{% if path %}
|
||||||
|
<li><a href="/filecrawl.html">top level</a></li>
|
||||||
|
{% else %}
|
||||||
|
{% endif %}
|
||||||
|
<li><a href="/">homepage</a></li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user