diff --git a/db.py b/db.py index a0a3580..4943855 100644 --- a/db.py +++ b/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,)) diff --git a/handlers.py b/handlers.py index 5903d0b..a5e66d4 100644 --- a/handlers.py +++ b/handlers.py @@ -341,9 +341,12 @@ def handle_search(query): def handle_add_form(msg=""): return _respond( f"
Add a site via URL or Reticulum destination hash
" f'