commit 18876f7969d2b2e3deec5dc20dd71474a8402bac
parent 3f28ebbc6f1db201c5db171f3a3b3e34763a00c0
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Sat, 25 Apr 2026 19:33:53 +0000
Comment URL is stored in a new gruik column
Diffstat:
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/cgi.scm b/src/cgi.scm
@@ -256,9 +256,8 @@ END-OF-CSS
(include "common.scm")
-(unless (= 4 (db-version))
+(unless (= 5 (db-version))
(die "Unexpectad database version"))
-(exec (sql/transient db "UPDATE gruik SET mark=-10 WHERE mark=-1;"))
(define (get-config key)
@@ -366,10 +365,13 @@ END-OF-CSS
(if comm
(exec
(sql db "UPDATE gruik
- SET description=?,notes=trim(notes||char(10)||?,char(10))
+ SET description=?,
+ notes=trim(notes||char(10)||?,char(10)),
+ comment_url=?
WHERE id=? AND COALESCE(description,'')='';")
(conc " + [](" url ")\n(via [" section "](" comm ") sur #gcufeed)")
comm
+ comm
id)
(exec
(sql db "UPDATE gruik SET description=?
diff --git a/src/common.scm b/src/common.scm
@@ -57,6 +57,7 @@
section TEXT NOT NULL,
title TEXT NOT NULL,
url TEXT NOT NULL,
+ comment_url TEXT,
mark INTEGER NOT NULL DEFAULT 0,
ctime INTEGER NOT NULL,
mtime INTEGER NOT NULL,
@@ -64,6 +65,7 @@
entry_id INTEGER REFERENCES entry(id));"
"CREATE UNIQUE INDEX i_gruik ON gruik(position);"
"CREATE INDEX i_gruik_time ON gruik(ptime);"
+ "CREATE INDEX i_gruik_url ON gruik(url);"
"CREATE TABLE gruik_tags
(gruik_id REFERENCES gruik(id) ON UPDATE CASCADE ON DELETE CASCADE,
tag_id REFERENCES tag(id) ON UPDATE CASCADE ON DELETE CASCADE);"
@@ -133,3 +135,17 @@
('Lobsters','https://lobste.rs/rss');"
"ALTER TABLE gruik ADD COLUMN entry_id INTEGER REFERENCES entry(id);"
"PRAGMA user_version = 4;")))
+
+(when (= 4 (db-version))
+ (for-each
+ (lambda (s) (exec (sql/transient db s)))
+ (list "CREATE INDEX i_gruik_url ON gruik(url);"
+ "ALTER TABLE gruik ADD COLUMN comment_url TEXT;"
+ "UPDATE gruik
+ SET comment_url=substr(notes,instr(notes,'https://news.ycombinator.com'))
+ WHERE notes LIKE '%https://news.ycombinator.com%';"
+ "UPDATE gruik
+ SET comment_url=substr(notes,instr(notes,'https://lobste.rs'))
+ WHERE notes LIKE '%https://lobste.rs%';"
+ "UPDATE gruik SET mark=-10 WHERE mark=-1;"
+ "PRAGMA user_version = 5;")))
diff --git a/src/iens.scm b/src/iens.scm
@@ -115,7 +115,7 @@
(include "common.scm")
-(assert (= 4 (db-version)))
+(assert (= 5 (db-version)))
;;;;;;;;;;;;;;;;;;
;; Configuration