added reticulum hash option to add page
This commit is contained in:
parent
a1358c1f3d
commit
b112ee3660
2 changed files with 44 additions and 19 deletions
17
db.py
17
db.py
|
|
@ -131,7 +131,8 @@ def init_db():
|
|||
" title TEXT,"
|
||||
" body TEXT,"
|
||||
" note TEXT DEFAULT '',"
|
||||
" last_modified TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M:%S','now'))"
|
||||
" last_modified TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M:%S','now')),"
|
||||
" reticulum_dest TEXT DEFAULT ''"
|
||||
")"
|
||||
)
|
||||
db.execute(
|
||||
|
|
@ -247,6 +248,11 @@ def init_db():
|
|||
db.execute("ALTER TABLE pages ADD COLUMN summary TEXT DEFAULT ''")
|
||||
db.commit()
|
||||
|
||||
# Migrate pages: add reticulum_dest column if missing
|
||||
if "reticulum_dest" not in page_cols:
|
||||
db.execute("ALTER TABLE pages ADD COLUMN reticulum_dest TEXT DEFAULT ''")
|
||||
db.commit()
|
||||
|
||||
# Chunks table for semantic search embeddings
|
||||
db.execute(
|
||||
"CREATE TABLE IF NOT EXISTS chunks ("
|
||||
|
|
@ -359,19 +365,18 @@ def fetch_page(url):
|
|||
|
||||
|
||||
|
||||
def index_url(url, note=""):
|
||||
def index_url(url, note="", reticulum_dest=""):
|
||||
url = clean_url(url)
|
||||
title, body, links, meta_desc = fetch_page(url)
|
||||
# Use meta description if available and meaningful, otherwise generate from body
|
||||
summary = meta_desc if meta_desc and len(meta_desc) > 20 else ""
|
||||
db = get_db()
|
||||
try:
|
||||
now = __import__("datetime").datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
|
||||
db.execute(
|
||||
"INSERT INTO pages (url, title, body, note, last_modified, summary) VALUES (?, ?, ?, ?, ?, ?) "
|
||||
"INSERT INTO pages (url, title, body, note, last_modified, summary, reticulum_dest) VALUES (?, ?, ?, ?, ?, ?, ?) "
|
||||
"ON CONFLICT(url) DO UPDATE SET title=excluded.title, body=excluded.body, "
|
||||
"note=excluded.note, last_modified=excluded.last_modified, summary=excluded.summary",
|
||||
(url, title, body, note, now, summary),
|
||||
"note=excluded.note, last_modified=excluded.last_modified, summary=excluded.summary, reticulum_dest=excluded.reticulum_dest",
|
||||
(url, title, body, note, now, summary, reticulum_dest),
|
||||
)
|
||||
page_id = db.execute("SELECT id FROM pages WHERE url = ?", (url,)).fetchone()[0]
|
||||
db.execute("DELETE FROM links WHERE page_id = ?", (page_id,))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue