Compare commits

..

5 Commits

Author SHA1 Message Date
ed
c0de3c8053 v1.2.11 2022-05-13 17:24:50 +02:00
ed
a82a3b084a make search results unselectable 2022-05-13 17:18:19 +02:00
ed
67c298e66b don't embed huge docs (defer to ajax), closes #9 2022-05-13 17:08:17 +02:00
ed
c110ccb9ae v1.2.10 2022-05-13 01:44:00 +02:00
ed
0143380306 help the query planner 2022-05-13 01:41:39 +02:00
6 changed files with 37 additions and 17 deletions

View File

@@ -569,6 +569,7 @@ def run_argparse(argv, formatter):
ap2.add_argument("--css-browser", metavar="L", type=u, help="URL to additional CSS to include")
ap2.add_argument("--html-head", metavar="TXT", type=u, default="", help="text to append to the <head> of all HTML pages")
ap2.add_argument("--textfiles", metavar="CSV", type=u, default="txt,nfo,diz,cue,readme", help="file extensions to present as plaintext")
ap2.add_argument("--txt-max", metavar="KiB", type=int, default=64, help="max size of embedded textfiles on ?doc= (anything bigger will be lazy-loaded by JS)")
ap2.add_argument("--doctitle", metavar="TXT", type=u, default="copyparty", help="title / service-name to show in html documents")
ap2 = ap.add_argument_group('debug options')

View File

@@ -1,8 +1,8 @@
# coding: utf-8
VERSION = (1, 2, 9)
VERSION = (1, 2, 11)
CODENAME = "ftp btw"
BUILD_DT = (2022, 5, 12)
BUILD_DT = (2022, 5, 13)
S_VERSION = ".".join(map(str, VERSION))
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)

View File

@@ -2413,7 +2413,7 @@ class HttpCli(object):
continue
w = r[0][:16]
q = "select k, v from mt where w = ? and k != 'x'"
q = "select k, v from mt where w = ? and +k != 'x'"
try:
for k, v in icur.execute(q, (w,)):
taglist[k] = True
@@ -2438,14 +2438,19 @@ class HttpCli(object):
if doc:
doc = unquotep(doc.replace("+", " ").split("?")[0])
j2a["docname"] = doc
doctxt = None
if next((x for x in files if x["name"] == doc), None):
with open(os.path.join(abspath, doc), "rb") as f:
doc = f.read().decode("utf-8", "replace")
docpath = os.path.join(abspath, doc)
sz = bos.path.getsize(docpath)
if sz < 1024 * self.args.txt_max:
with open(docpath, "rb") as f:
doctxt = f.read().decode("utf-8", "replace")
else:
self.log("doc 404: [{}]".format(doc), c=6)
doc = "( textfile not found )"
doctxt = "( textfile not found )"
j2a["doc"] = doc
if doctxt is not None:
j2a["doc"] = doctxt
if not self.conn.hsrv.prism:
j2a["no_prism"] = True

View File

@@ -328,7 +328,7 @@ class U2idx(object):
w = hit["w"]
del hit["w"]
tags = {}
q2 = "select k, v from mt where w = ? and k != 'x'"
q2 = "select k, v from mt where w = ? and +k != 'x'"
for k, v2 in cur.execute(q2, (w,)):
taglist[k] = True
tags[k] = v2

View File

@@ -949,7 +949,7 @@ class Up2k(object):
n_done += 1
for w in to_delete.keys():
q = "delete from mt where w = ? and k = 't:mtp'"
q = "delete from mt where w = ? and +k = 't:mtp'"
cur.execute(q, (w,))
to_delete = {}
@@ -987,7 +987,7 @@ class Up2k(object):
with self.mutex:
done = self._flush_mpool(wcur)
for w in done:
q = "delete from mt where w = ? and k = 't:mtp'"
q = "delete from mt where w = ? and +k = 't:mtp'"
cur.execute(q, (w,))
cur.connection.commit()
@@ -1115,7 +1115,7 @@ class Up2k(object):
for k in tags.keys():
q = "delete from mt where w = ? and ({})".format(
" or ".join(["k = ?"] * len(tags))
" or ".join(["+k = ?"] * len(tags))
)
args = [wark[:16]] + list(tags.keys())
write_cur.execute(q, tuple(args))

View File

@@ -2441,6 +2441,14 @@ var showfile = (function () {
var em = QS('#bdoc>pre');
if (em)
em = [r.sname(window.location.search), window.location.hash, em.textContent];
else {
var m = /[?&]doc=([^&]+)/.exec(window.location.search);
if (m) {
setTimeout(function () {
r.show(uricom_dec(m[1])[0], true);
}, 1);
}
}
r.setstyle = function () {
if (window['no_prism'])
@@ -4166,6 +4174,7 @@ var treectl = (function () {
xhr.open('GET', '/?am_js', true);
xhr.send();
r.ls_cb = showfile.addlinks;
return r.reqls(get_evpath(), false, true);
}
@@ -4807,6 +4816,7 @@ var msel = (function () {
r.all = [];
var links = QSA('#files tbody td:nth-child(2) a:last-child'),
is_srch = !!ebi('unsearch'),
vbase = get_evpath();
for (var a = 0, aa = links.length; a < aa; a++) {
@@ -4821,7 +4831,8 @@ var msel = (function () {
if (item.sel)
r.sel.push(item);
links[a].closest('tr').setAttribute('tabindex', '0');
if (!is_srch)
links[a].closest('tr').setAttribute('tabindex', '0');
}
};
@@ -4890,14 +4901,17 @@ var msel = (function () {
frm.submit();
};
r.render = function () {
var tds = QSA('#files tbody td+td+td');
for (var a = 0, aa = tds.length; a < aa; a++) {
tds[a].onclick = r.seltgl;
}
var tds = QSA('#files tbody td+td+td'),
is_srch = !!ebi('unsearch');
if (!is_srch)
for (var a = 0, aa = tds.length; a < aa; a++)
tds[a].onclick = r.seltgl;
r.selui(true);
arcfmt.render();
fileman.render();
ebi('selzip').style.display = ebi('unsearch') ? 'none' : '';
ebi('selzip').style.display = is_srch ? 'none' : '';
}
return r;
})();