commit 6f0e4ec8b84f95fd863689551af3f37d34a1ade2
parent 18876f7969d2b2e3deec5dc20dd71474a8402bac
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Sun, 26 Apr 2026 17:20:19 +0000
Gruik section links to comment URL
Diffstat:
| M | src/cgi.scm | | | 47 | +++++++++++++++++++++++++---------------------- |
1 file changed, 25 insertions(+), 22 deletions(-)
diff --git a/src/cgi.scm b/src/cgi.scm
@@ -46,6 +46,7 @@ textarea { display: block; max-width: 100%; }
.tag-list label { display: block; }
span.ptime { font-size: 80%; }
span.section { font-size: 80%; }
+a.section { font-size: 80%; }
span.title { font-weight: bold; display: block; }
@media (min-width: 60rem) {
form {
@@ -396,20 +397,22 @@ END-OF-CSS
,(spinner-bar 90 10 120 "0.25s")
,(spinner-bar 120 10 120 "0.5s")))
-(define (post-p-fragment id ptime section title url)
+(define (post-p-fragment id ptime section title url comm-url)
`(p
(span (@ (class "ptime") (title ,id)) ,ptime)
- (span (@ (class "section")) ,section)
+ ,(if (null? comm-url)
+ `(span (@ (class "section")) ,section)
+ `(a (@ (href ,comm-url) (class "section")) ,section))
(span (@ (class "title")) ,title)
(a (@ (href ,url)) ,url)))
-(define (edit-post-fragment id ptime section title url mark notes description)
+(define (edit-post-fragment id ptime section title url comm-url mark notes description)
`(form (@ (method "POST") (action "do-edit")
(id ,(conc "post-" id)) (class "edit-post")
(hx-swap "outerHTML") (hx-post "xdo-edit"))
(input (@ (type "submit") (name "submit") (class lsub) (value "Edit")))
(div (@ (class "form-body"))
- ,(post-p-fragment id ptime section title url)
+ ,(post-p-fragment id ptime section title url comm-url)
(p ,(conc "Mark: " mark)
(label (input (@ (type radio) (name mark) (value 0))) "Unmark")
(label (input (@ (type radio) (name mark) (value 1) (checked))) "Keep")
@@ -437,7 +440,7 @@ END-OF-CSS
(define (edit-post-fragment* id)
(query
(map-rows* edit-post-fragment)
- (sql db "SELECT id,ptime,section,title,url,mark,notes,description FROM gruik WHERE mark=1 AND id=?;")
+ (sql db "SELECT id,ptime,section,title,url,comment_url,mark,notes,description FROM gruik WHERE mark=1 AND id=?;")
id))
(define (db-edit)
@@ -477,58 +480,58 @@ END-OF-CSS
(loop (- tid 1))))))
id))
-(define (bad-post-fragment id ptime section title url)
+(define (bad-post-fragment id ptime section title url comm-url)
`(form (@ (method "POST") (action "do-undelete")
(id ,(conc "post-" id)) (class "bad-post")
(hx-swap "outerHTML") (hx-post "xdo-undelete"))
(input (@ (type "submit") (name "submit") (class lsub) (value "Restore")))
(div (@ (class "form-body"))
- ,(post-p-fragment id ptime section title url))
+ ,(post-p-fragment id ptime section title url comm-url))
(input (@ (type "hidden") (name "id") (value ,id)))))
-(define (locked-post-fragment id ptime section title url mark)
+(define (locked-post-fragment id ptime section title url comm-url mark)
`(form (@ (method "POST") (action "do-locked")
(id ,(conc "post-" id))
(class ,(if (> mark 2) "protected-post" "locked-post"))
(hx-swap "outerHTML") (hx-post "xdo-locked"))
(input (@ (type "submit") (name "submit") (class lsub) (value "Push")))
(div (@ (class "form-body"))
- ,(post-p-fragment id ptime section title url))
+ ,(post-p-fragment id ptime section title url comm-url))
(input (@ (type "hidden") (name "id") (value ,id)))
(input (@ (type "submit") (name "submit") (class rsub) (value "Unlock")))))
-(define (marked-post-fragment id ptime section title url)
+(define (marked-post-fragment id ptime section title url comm-url)
`(form (@ (method "POST") (action "do-marked")
(id ,(conc "post-" id)) (class "marked-post")
(hx-swap "outerHTML") (hx-post "xdo-marked"))
(input (@ (type "submit") (name "submit") (class lsub) (value "Edit")))
(div (@ (class "form-body"))
- ,(post-p-fragment id ptime section title url))
+ ,(post-p-fragment id ptime section title url comm-url))
(input (@ (type "hidden") (name "id") (value ,id)))
(input (@ (type "submit") (name "submit") (class rsub) (value "Unmark")))))
-(define (unmarked-post-fragment id ptime section title url)
+(define (unmarked-post-fragment id ptime section title url comm-url)
`(form (@ (method "POST") (action "do-unmarked")
(id ,(conc "post-" id)) (class "unmarked-post")
(hx-swap "outerHTML") (hx-post "xdo-unmarked"))
(input (@ (type "submit") (name "submit") (class lsub) (value "Mark")))
(div (@ (class "form-body"))
- ,(post-p-fragment id ptime section title url))
+ ,(post-p-fragment id ptime section title url comm-url))
(input (@ (type "hidden") (name "id") (value ,id)))
(input (@ (type "submit") (name "submit") (class rsub) (value "Delete")))))
-(define (post-fragment id mark ptime section title url)
+(define (post-fragment id mark ptime section title url comm-url)
(case mark
- ((0) (unmarked-post-fragment id ptime section title url))
- ((1) (marked-post-fragment id ptime section title url))
- ((2 3) (locked-post-fragment id ptime section title url mark))
- (else (bad-post-fragment id ptime section title url))))
+ ((0) (unmarked-post-fragment id ptime section title url comm-url))
+ ((1) (marked-post-fragment id ptime section title url comm-url))
+ ((2 3) (locked-post-fragment id ptime section title url comm-url mark))
+ (else (bad-post-fragment id ptime section title url comm-url))))
(define (post-htmx id)
(htmx-output
(query
(map-rows* post-fragment)
- (sql db "SELECT id,mark,ptime,section,title,url FROM gruik WHERE id=?;")
+ (sql db "SELECT id,mark,ptime,section,title,url,comment_url FROM gruik WHERE id=?;")
id)))
(define (gruik-list-view title q)
@@ -559,7 +562,7 @@ END-OF-CSS
(let* ((last-id (string->number (required-input-var "last-id")))
(frags (query
(map-rows* post-fragment)
- (sql db "SELECT id,mark,ptime,section,title,url FROM gruik WHERE id > ? AND mark >= -5;")
+ (sql db "SELECT id,mark,ptime,section,title,url,comment_url FROM gruik WHERE id > ? AND mark >= -5;")
last-id))
(btn (if (null? frags) "Recheck" "More")))
(htmx-output
@@ -579,7 +582,7 @@ END-OF-CSS
(catch-up)
(gruik-list-view
"Deleted gruiks"
- "SELECT id,mark,ptime,section,title,url FROM gruik WHERE mark < 0 ORDER BY mtime;"))
+ "SELECT id,mark,ptime,section,title,url,comment_url FROM gruik WHERE mark < 0 ORDER BY mtime;"))
(define (edit-view id)
(let ((title (conc "Gruik #" id)))
@@ -600,7 +603,7 @@ END-OF-CSS
(catch-up)
(gruik-list-view
"Latest gruiks"
- "SELECT id,mark,ptime,section,title,url FROM gruik WHERE mark >= -5;"))
+ "SELECT id,mark,ptime,section,title,url,comment_url FROM gruik WHERE mark >= -5;"))
(define (db-push-gruik str-id)
(let ((id (string->number str-id)))