diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py
index 52bc1e4e..692fbc69 100644
--- a/copyparty/httpcli.py
+++ b/copyparty/httpcli.py
@@ -5282,11 +5282,10 @@ class HttpCli(object):
# chrome cannot handle more than ~2000 unique SVGs
# so url-param "raster" returns a png/webp instead
# (useragent-sniffing kinshi due to caching proxies)
- # mime, ico = self.conn.hsrv.ico.get(txt, not small, "raster" in self.uparam, self.uparam.get('a'))
+ mime, ico = self.conn.hsrv.ico.get(txt, not small, "raster" in self.uparam, self.uparam.get('a'))
lm = formatdate(self.E.t0)
- # self.reply(ico, mime=mime, headers={"Last-Modified": lm})
- self.reply('', headers={"Last-Modified": lm})
+ self.reply(ico, mime=mime, headers={"Last-Modified": lm})
return True
def tx_qr(self):
@@ -6852,7 +6851,7 @@ class HttpCli(object):
pass
if is_dir:
- return self.tx_svg("folder")
+ return '' # self.tx_svg("folder")
thp = None
if self.thumbcli and not nothumb:
@@ -6872,7 +6871,7 @@ class HttpCli(object):
elif th_fmt in ACODE2_FMT:
raise Pebkac(415)
- return self.tx_ico(rem)
+ return '' # self.tx_ico(rem)
elif self.can_write and th_fmt is not None:
return self.tx_svg("upload\nonly")
diff --git a/copyparty/ico.py b/copyparty/ico.py
index 663942c1..f49e8071 100644
--- a/copyparty/ico.py
+++ b/copyparty/ico.py
@@ -20,15 +20,7 @@ class Ico(object):
bext = ext.encode("ascii", "replace")
ext = bext.decode("utf-8")
- zb = hashlib.sha1(bext).digest()[2:4]
- if PY2:
- zb = [ord(x) for x in zb] # type: ignore
-
- c1 = colorsys.hsv_to_rgb(zb[0] / 256.0, 1, 1)
- c2 = colorsys.hsv_to_rgb(zb[0] / 256.0, 0.5 if HAVE_PILF else 1, 0.9)
- ci = [int(x * 255) for x in list(c1) + list(c2)]
- c = "".join(["%02x" % (x,) for x in ci])
-
+
w = 100
h = 30
if as_thumb:
@@ -48,11 +40,11 @@ class Ico(object):
h = int(128.0 * h / w)
w = 128
- img = Image.new("RGBA", (w, h), "#" + c[:6] + 'aa')
+ img = Image.new("RGBA", (w, h), "#00000000")
pb = ImageDraw.Draw(img)
_, _, tw, th = pb.textbbox((0, 0), ext2, font_size=16)
xy = (int((w - tw) / 2), int((h - th) / 2))
- pb.text(xy, ext2, fill="#" + c[6:], font_size=16)
+ pb.text(xy, ext2, fill=accent, font_size=16)
img = img.resize((w * 2, h * 2), Image.NEAREST)
@@ -69,7 +61,7 @@ class Ico(object):
h = int(64.0 * h / w)
w = 64
- img = Image.new("RGBA", (w, h), "#" + c[:6] + 'aa')
+ img = Image.new("RGBA", (w, h), "#00000000")
pb = ImageDraw.Draw(img)
try:
_, _, tw, th = pb.textbbox((0, 0), ext)
@@ -79,7 +71,7 @@ class Ico(object):
tw += len(ext)
cw = tw // len(ext)
x = ((w - tw) // 2) - (cw * 2) // 3
- fill = "#" + c[6:]
+ fill = accent
for ch in ext:
pb.text((x, (h - th) // 2), " %s " % (ch,), fill=fill)
x += cw
@@ -90,14 +82,14 @@ class Ico(object):
img.save(buf, format="PNG", compress_level=1)
return "image/png", buf.getvalue()
-# svg = """\
-#
-#
-# """
+ svg = """\
+
+
+"""
txt = html_escape(ext, True)
if "\n" in txt:
@@ -107,52 +99,8 @@ class Ico(object):
zs = '%s'
txt = "".join([zs % (x,) for x in lines])
else:
- y = "55%"
+ y = "50%"
- #svg = svg.format(h, c[:6], y, c[6:], txt)
-
- if(len(ext) > 3):
- fontsz = 12 / len(ext) * 3
- else:
- fontsz = 12
-
- svg = """\
-
-
-"""
- svg = svg.format(c[:6], accent, accent, fontsz, accent, y, txt)
-
- if(txt == 'folder'):
- svg = """\
-
-
-"""
- svg = svg.format(accent)
+ svg = svg.format(h, y, accent, txt)
return "image/svg+xml", svg.encode("utf-8")