mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
fix markdown / text-editor jank
* only indicate file-history for markdown files since other files won't load into the editor which makes that entirely pointless; do file extension instead * text-editor: in files containing one single line, ^C followed by ^V ^Z would accidentally a letter and fix unhydrated extensions
This commit is contained in:
parent
3adbb2ff41
commit
407531bcb1
|
@ -152,6 +152,8 @@ RE_HSAFE = re.compile(r"[\x00-\x1f<>\"'&]") # search always much faster
|
||||||
RE_HOST = re.compile(r"[^][0-9a-zA-Z.:_-]") # search faster <=17ch
|
RE_HOST = re.compile(r"[^][0-9a-zA-Z.:_-]") # search faster <=17ch
|
||||||
RE_MHOST = re.compile(r"^[][0-9a-zA-Z.:_-]+$") # match faster >=18ch
|
RE_MHOST = re.compile(r"^[][0-9a-zA-Z.:_-]+$") # match faster >=18ch
|
||||||
RE_K = re.compile(r"[^0-9a-zA-Z_-]") # search faster <=17ch
|
RE_K = re.compile(r"[^0-9a-zA-Z_-]") # search faster <=17ch
|
||||||
|
RE_HR = re.compile(r"[<>\"'&]")
|
||||||
|
RE_MDV = re.compile(r"(.*)\.([0-9]+\.[0-9]{3})(\.[Mm][Dd])$")
|
||||||
|
|
||||||
UPARAM_CC_OK = set("doc move tree".split())
|
UPARAM_CC_OK = set("doc move tree".split())
|
||||||
|
|
||||||
|
@ -5969,7 +5971,7 @@ class HttpCli(object):
|
||||||
# [num-backups, most-recent, hist-path]
|
# [num-backups, most-recent, hist-path]
|
||||||
hist: dict[str, tuple[int, float, str]] = {}
|
hist: dict[str, tuple[int, float, str]] = {}
|
||||||
histdir = os.path.join(fsroot, ".hist")
|
histdir = os.path.join(fsroot, ".hist")
|
||||||
ptn = re.compile(r"(.*)\.([0-9]+\.[0-9]{3})(\.[^\.]+)$")
|
ptn = RE_MDV
|
||||||
try:
|
try:
|
||||||
for hfn in bos.listdir(histdir):
|
for hfn in bos.listdir(histdir):
|
||||||
m = ptn.match(hfn)
|
m = ptn.match(hfn)
|
||||||
|
@ -6002,6 +6004,7 @@ class HttpCli(object):
|
||||||
|
|
||||||
dirs = []
|
dirs = []
|
||||||
files = []
|
files = []
|
||||||
|
ptn_hr = RE_HR
|
||||||
for fn in ls_names:
|
for fn in ls_names:
|
||||||
base = ""
|
base = ""
|
||||||
href = fn
|
href = fn
|
||||||
|
@ -6056,11 +6059,13 @@ class HttpCli(object):
|
||||||
zd.second,
|
zd.second,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
if is_dir:
|
||||||
ext = "---" if is_dir else fn.rsplit(".", 1)[1]
|
ext = "---"
|
||||||
|
elif "." in fn:
|
||||||
|
ext = ptn_hr.sub("@", fn.rsplit(".", 1)[1])
|
||||||
if len(ext) > 16:
|
if len(ext) > 16:
|
||||||
ext = ext[:16]
|
ext = ext[:16]
|
||||||
except:
|
else:
|
||||||
ext = "%"
|
ext = "%"
|
||||||
|
|
||||||
if add_fk and not is_dir:
|
if add_fk and not is_dir:
|
||||||
|
|
|
@ -1078,26 +1078,28 @@ action_stack = (function () {
|
||||||
var p1 = from.length,
|
var p1 = from.length,
|
||||||
p2 = to.length;
|
p2 = to.length;
|
||||||
|
|
||||||
while (p1-- > 0 && p2-- > 0)
|
while (p1 --> 0 && p2 --> 0)
|
||||||
if (from[p1] != to[p2])
|
if (from[p1] != to[p2])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (car > ++p1) {
|
if (car > ++p1)
|
||||||
car = p1;
|
car = p1;
|
||||||
}
|
|
||||||
|
|
||||||
var txt = from.substring(car, p1)
|
var txt = from.substring(car, p1)
|
||||||
return {
|
return {
|
||||||
car: car,
|
car: car,
|
||||||
cdr: ++p2,
|
cdr: p2 + (car && 1),
|
||||||
txt: txt,
|
txt: txt,
|
||||||
cpos: cpos
|
cpos: cpos
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var undiff = function (from, change) {
|
var undiff = function (from, change) {
|
||||||
|
var t1 = from.substring(0, change.car),
|
||||||
|
t2 = from.substring(change.cdr);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
txt: from.substring(0, change.car) + change.txt + from.substring(change.cdr),
|
txt: t1 + change.txt + t2,
|
||||||
cpos: change.cpos
|
cpos: change.cpos
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue