search: match by tag; add: handle ssl errors with manual entry
This commit is contained in:
parent
6c4b26781d
commit
8e68d02413
2 changed files with 18 additions and 1 deletions
|
|
@ -83,7 +83,7 @@ def handle_add_submit(body):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = str(e).lower()
|
error_msg = str(e).lower()
|
||||||
if "block" in error_msg or "cloudflare" in error_msg or "403" in error_msg:
|
if any(x in error_msg for x in ("block", "cloudflare", "403", "ssl", "handshake", "max retries", "timeout", "connection")):
|
||||||
return _respond(
|
return _respond(
|
||||||
f"<h1>add url (manual entry)</h1>"
|
f"<h1>add url (manual entry)</h1>"
|
||||||
f"<p><strong>{esc(url)}</strong> blocks automated access. "
|
f"<p><strong>{esc(url)}</strong> blocks automated access. "
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,23 @@ def handle_search(query):
|
||||||
else:
|
else:
|
||||||
fused_ids = bm25_ids
|
fused_ids = bm25_ids
|
||||||
|
|
||||||
|
# Also match by tag
|
||||||
|
search_terms = [w.lower() for w in q.split() if w]
|
||||||
|
if search_terms:
|
||||||
|
placeholders = ",".join("?" * len(search_terms))
|
||||||
|
tag_rows = db.execute(
|
||||||
|
f"SELECT DISTINCT pt.page_id FROM page_tags pt "
|
||||||
|
f"JOIN tags t ON t.id = pt.tag_id "
|
||||||
|
f"WHERE LOWER(t.name) IN ({placeholders})",
|
||||||
|
search_terms,
|
||||||
|
).fetchall()
|
||||||
|
tag_ids = {r["page_id"] for r in tag_rows}
|
||||||
|
seen = set(fused_ids)
|
||||||
|
for pid in tag_ids:
|
||||||
|
if pid not in seen:
|
||||||
|
fused_ids.append(pid)
|
||||||
|
seen.add(pid)
|
||||||
|
|
||||||
total_results = len(fused_ids)
|
total_results = len(fused_ids)
|
||||||
page_ids = fused_ids[offset:offset + PER_PAGE]
|
page_ids = fused_ids[offset:offset + PER_PAGE]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue