optimize --name-url (#884)

This commit is contained in:
ed 2025-10-04 10:45:17 +00:00
parent 38cc809822
commit 9b7f933b78
5 changed files with 12 additions and 6 deletions

View file

@ -1156,6 +1156,7 @@ def add_general(ap, nc, srvname):
ap2.add_argument("--wintitle", metavar="TXT", type=u, default="cpp @ $pub", help="server terminal title, for example [\033[32m$ip-10.1.2.\033[0m] or [\033[32m$ip-]")
ap2.add_argument("--name", metavar="TXT", type=u, default=srvname, help="server name (displayed topleft in browser and in mDNS)")
ap2.add_argument("--name-url", metavar="TXT", type=u, help="URL for server name hyperlink (displayed topleft in browser)")
ap2.add_argument("--name-html", type=u, help=argparse.SUPPRESS)
ap2.add_argument("--mime", metavar="EXT=MIME", type=u, action="append", help="\033[34mREPEATABLE:\033[0m map file \033[33mEXT\033[0mension to \033[33mMIME\033[0mtype, for example [\033[32mjpg=image/jpeg\033[0m]")
ap2.add_argument("--mimes", action="store_true", help="list default mimetype mapping and exit")
ap2.add_argument("--rmagic", action="store_true", help="do expensive analysis to improve accuracy of returned mimetypes; will make file-downloads, rss, and webdav slower (volflag=rmagic)")

View file

@ -6493,11 +6493,7 @@ class HttpCli(object):
try:
if not self.args.nih:
if self.args.name_url:
url = html_escape(self.args.name_url, True, True)
srv_info.append(f"<a href='{url}'>{self.args.name}</a>")
else:
srv_info.append(self.args.name)
srv_info.append(self.args.name_html)
except:
self.log("#wow #whoa")

View file

@ -67,6 +67,7 @@ from .util import (
build_netmap,
expat_ver,
gzip,
html_escape,
load_ipr,
load_ipu,
lock_file,
@ -1171,6 +1172,13 @@ class SvcHub(object):
if len(al.tcolor) == 3: # fc5 => ffcc55
al.tcolor = "".join([x * 2 for x in al.tcolor])
if self.args.name_url:
zs = html_escape(self.args.name_url, True, True)
zs = '<a href="%s">%s</a>' % (zs, self.args.name)
else:
zs = self.args.name
self.args.name_html = zs
zs = al.u2sz
zsl = [x.strip() for x in zs.split(",")]
if len(zsl) not in (1, 3):

View file

@ -134,7 +134,6 @@
CGV = {{ cgv|tojson }},
TS = "{{ ts }}",
dtheme = "{{ dtheme }}",
srvinf = "{{ srv_info }}",
lang = "{{ lang }}",
dfavico = "{{ favico }}",
have_tags_idx = {{ have_tags_idx }},

View file

@ -13093,6 +13093,7 @@ var ACtx = !IPHONE && (window.AudioContext || window.webkitAudioContext),
abrt_key = "",
can_shr = false,
rtt = null,
srvinf = "",
ldks = [],
dks = {},
dk, mp;
@ -19336,6 +19337,7 @@ var treectl = (function () {
r.hydrate = function () {
qsr('#bbsw');
srvinf = ebi('srv_info').innerHTML.slice(6, -7);
if (ls0 === null) {
var xhr = new XHR();
xhr.open('GET', SR + '/?setck=js=y', true);