hide dotfiles, add logues

This commit is contained in:
ed 2019-07-01 20:00:18 +00:00
parent ff332b07b5
commit 68943ca454
4 changed files with 28 additions and 2 deletions

View file

@ -550,10 +550,10 @@ class HttpCli(object):
dirs = []
files = []
for fn in vfs_ls:
for fn in exclude_dotfiles(vfs_ls):
href = fn
if self.absolute_urls:
href = vpath + "/" + fn
href = "/" + vpath + "/" + fn
fspath = fsroot + "/" + fn
inf = os.stat(fsenc(fspath))
@ -575,6 +575,13 @@ class HttpCli(object):
else:
files.append(item)
logues = [None, None]
for n, fn in enumerate([".prologue.html", ".epilogue.html"]):
fn = os.path.join(abspath, fn)
if os.path.exists(fn):
with open(fn, "rb") as f:
logues[n] = f.read().decode("utf-8")
ts = ""
# ts = "?{}".format(time.time())
@ -585,6 +592,8 @@ class HttpCli(object):
files=dirs,
can_upload=self.writable,
ts=ts,
prologue=logues[0],
epilogue=logues[1],
)
self.reply(html.encode("utf-8", "replace"))
return True

View file

@ -344,6 +344,12 @@ def sanitize_fn(fn):
return fn.replace("\\", "/").split("/")[-1].strip()
def exclude_dotfiles(filepaths):
for fpath in filepaths:
if not fpath.split("/")[-1].startswith("."):
yield fpath
def quotep(txt):
"""url quoter which deals with bytes correctly"""
btxt = fsenc(txt)

View file

@ -123,6 +123,9 @@ a {
#path span {
padding-left: .2em;
}
.logue {
padding: .2em 1.5em;
}
a.play {
color: #e70;
}

View file

@ -24,6 +24,10 @@
<span>{{ vpnodes[-1][1] }}</span>
</h1>
{%- if prologue %}
<div id="pro" class="logue">{{ prologue }}</div>
{%- endif %}
<table id="files">
<thead>
<tr>
@ -41,6 +45,10 @@
</tbody>
</table>
{%- if epilogue %}
<div id="epi" class="logue">{{ epilogue }}</div>
{%- endif %}
<h2><a href="?h">control-panel</a></h2>