Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Strand Lab
Strand Lab Cellxgene Gateway
Commits
f41db75a
Commit
f41db75a
authored
Dec 21, 2019
by
Alok Saldanha
Browse files
#15 added intermediate index pages
parent
876263c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
cellxgene_gateway/dir_util.py
View file @
f41db75a
...
...
@@ -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
"<li> <a href='
{
url
}
'>
{
entry
[
'name'
]
}
</a></li>"
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>"
cellxgene_gateway/gateway.py
View file @
f41db75a
...
...
@@ -168,6 +168,22 @@ def filecrawl():
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
()
@
app
.
route
(
"/view/<path:path>"
,
methods
=
[
"GET"
,
"PUT"
,
"POST"
])
def
do_view
(
path
):
...
...
cellxgene_gateway/templates/filecrawl.html
View file @
f41db75a
...
...
@@ -21,7 +21,11 @@
</head>
<body>
<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>
<br>
...
...
@@ -29,6 +33,15 @@
<br>
{{ 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>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment