diff --git a/db.py b/db.py index 4943855..a0a3580 100644 --- a/db.py +++ b/db.py @@ -131,8 +131,7 @@ def init_db(): " title TEXT," " body TEXT," " note TEXT DEFAULT ''," - " last_modified TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M:%S','now'))," - " reticulum_dest TEXT DEFAULT ''" + " last_modified TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M:%S','now'))" ")" ) db.execute( @@ -248,11 +247,6 @@ 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 (" @@ -365,18 +359,19 @@ def fetch_page(url): -def index_url(url, note="", reticulum_dest=""): +def index_url(url, note=""): 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, reticulum_dest) VALUES (?, ?, ?, ?, ?, ?, ?) " + "INSERT INTO pages (url, title, body, note, last_modified, summary) VALUES (?, ?, ?, ?, ?, ?) " "ON CONFLICT(url) DO UPDATE SET title=excluded.title, body=excluded.body, " - "note=excluded.note, last_modified=excluded.last_modified, summary=excluded.summary, reticulum_dest=excluded.reticulum_dest", - (url, title, body, note, now, summary, reticulum_dest), + "note=excluded.note, last_modified=excluded.last_modified, summary=excluded.summary", + (url, title, body, note, now, summary), ) 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 1665cae..5903d0b 100644 --- a/handlers.py +++ b/handlers.py @@ -338,23 +338,9 @@ def handle_search(query): ) -def handle_add_form(msg="", action_type="index"): - if action_type == "subscribe": - return _respond( - f"
Subscribe to a friend's TinyWeb instance to sync their index
" - f'" - f"" - f"{msg}
" - f'back' - ) +def handle_add_form(msg=""): return _respond( f"Add a site to your index
" f'" f"{msg}
" @@ -548,25 +514,15 @@ def handle_edit_form(page_id, msg=""): def handle_edit_submit(page_id, body): - title = body.get("title", [""])[0].strip() - summary = body.get("summary", [""])[0].strip() note = body.get("note", [""])[0].strip() tags = body.get("tags", [""])[0].strip() - db = get_db() try: - db.execute( - "UPDATE pages SET title = ?, summary = ?, note = ? WHERE id = ?", - (title, summary, note, page_id) - ) - + db.execute("UPDATE pages SET note = ? WHERE id = ?", (note, page_id)) _set_page_tags(page_id, tags, db) - db.commit() - finally: return_db(db) - return _redirect("/pages") @@ -925,7 +881,6 @@ def handle_subscriptions(msg=""): f' ' f'' f'' - f'' f'{msg}
' f'