mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
add folder thumbnails (cover.jpg or png)
This commit is contained in:
parent
60ac68d000
commit
081d2cc5d7
|
@ -1525,12 +1525,24 @@ class HttpCli(object):
|
||||||
except:
|
except:
|
||||||
raise Pebkac(404)
|
raise Pebkac(404)
|
||||||
|
|
||||||
if self.readable and not stat.S_ISDIR(st.st_mode):
|
if self.readable:
|
||||||
if rem.startswith(".hist/up2k."):
|
if rem.startswith(".hist/up2k."):
|
||||||
raise Pebkac(403)
|
raise Pebkac(403)
|
||||||
|
|
||||||
|
is_dir = stat.S_ISDIR(st.st_mode)
|
||||||
th_fmt = self.uparam.get("th")
|
th_fmt = self.uparam.get("th")
|
||||||
if th_fmt is not None:
|
if th_fmt is not None:
|
||||||
|
if is_dir:
|
||||||
|
for fn in ["cover.png", "cover.jpg"]:
|
||||||
|
fp = os.path.join(abspath, fn)
|
||||||
|
if os.path.exists(fp):
|
||||||
|
vrem = "{}/{}".format(vrem.rstrip("/"), fn)
|
||||||
|
is_dir = False
|
||||||
|
break
|
||||||
|
|
||||||
|
if is_dir:
|
||||||
|
return self.tx_ico("/")
|
||||||
|
|
||||||
thp = None
|
thp = None
|
||||||
if self.thumbcli:
|
if self.thumbcli:
|
||||||
thp = self.thumbcli.get(
|
thp = self.thumbcli.get(
|
||||||
|
@ -1542,6 +1554,7 @@ class HttpCli(object):
|
||||||
|
|
||||||
return self.tx_ico(rem)
|
return self.tx_ico(rem)
|
||||||
|
|
||||||
|
if not is_dir:
|
||||||
if abspath.endswith(".md") and "raw" not in self.uparam:
|
if abspath.endswith(".md") and "raw" not in self.uparam:
|
||||||
return self.tx_md(abspath)
|
return self.tx_md(abspath)
|
||||||
|
|
||||||
|
|
|
@ -798,6 +798,13 @@ html.light #ghead {
|
||||||
padding: .2em .3em;
|
padding: .2em .3em;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
#ggrid span.dir:before {
|
||||||
|
content: '📂';
|
||||||
|
line-height: 0;
|
||||||
|
font-size: 2em;
|
||||||
|
display: inline-block;
|
||||||
|
margin: -.7em 0 -.5em -.3em;
|
||||||
|
}
|
||||||
#ggrid a:hover {
|
#ggrid a:hover {
|
||||||
background: #444;
|
background: #444;
|
||||||
border-color: #555;
|
border-color: #555;
|
||||||
|
|
|
@ -858,14 +858,15 @@ var thegrid = (function () {
|
||||||
href = esc(ao.getAttribute('href')),
|
href = esc(ao.getAttribute('href')),
|
||||||
ref = ao.getAttribute('id'),
|
ref = ao.getAttribute('id'),
|
||||||
isdir = href.split('?')[0].slice(-1)[0] == '/',
|
isdir = href.split('?')[0].slice(-1)[0] == '/',
|
||||||
|
ac = isdir ? ' class="dir"' : '',
|
||||||
ihref = href;
|
ihref = href;
|
||||||
|
|
||||||
if (isdir) {
|
if (r.thumbs) {
|
||||||
ihref = '/.cpr/ico/folder'
|
|
||||||
}
|
|
||||||
else if (r.thumbs) {
|
|
||||||
ihref += (ihref.indexOf('?') === -1 ? '?' : '&') + 'th=' + (have_webp ? 'w' : 'j');
|
ihref += (ihref.indexOf('?') === -1 ? '?' : '&') + 'th=' + (have_webp ? 'w' : 'j');
|
||||||
}
|
}
|
||||||
|
else if (isdir) {
|
||||||
|
ihref = '/.cpr/ico/folder';
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
var ar = href.split('?')[0].split('.');
|
var ar = href.split('?')[0].split('.');
|
||||||
if (ar.length > 1)
|
if (ar.length > 1)
|
||||||
|
@ -886,7 +887,7 @@ var thegrid = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
html.push('<a href="' + href + '" ref="' + ref + '"><img src="' +
|
html.push('<a href="' + href + '" ref="' + ref + '"><img src="' +
|
||||||
ihref + '" /><span>' + ao.innerHTML + '</span></a>');
|
ihref + '" /><span' + ac + '>' + ao.innerHTML + '</span></a>');
|
||||||
}
|
}
|
||||||
lfiles.style.display = 'none';
|
lfiles.style.display = 'none';
|
||||||
gfiles.style.display = 'block';
|
gfiles.style.display = 'block';
|
||||||
|
|
Loading…
Reference in a new issue