iens

Manager of links to read
git clone https://git.instinctive.eu/iens.git
Log | Files | Refs | README | LICENSE

commit 16a9e22f4cfa39ae0ba62b7cd93cdcdb81a56452
parent 20d02aaafa8e82c48dc0eb394b17d0b578fe2489
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Tue,  6 Feb 2024 17:48:31 +0000

Entry tag list is generated by SQL
Diffstat:
Msrc/iens.scm | 33+++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/src/iens.scm b/src/iens.scm @@ -412,7 +412,7 @@ "Append new lines of notes" (apply add-notes* (time-id-strings args))) -(define (print-entry-row id url type descr notes protected ptime ctime mtime) +(define (print-entry-row id url type descr notes protected ptime ctime mtime tags) (write-line (conc vt100-entry-header "#" id (if (zero? protected) "" "*") " - " url vt100-reset)) @@ -426,7 +426,10 @@ (write-string descr)) (unless (null? notes) (write-line (conc "Notes:")) - (write-string notes))) + (write-string notes)) + (if (null? tags) + (write-line "No tags.") + (write-line (string-append "Tags: " tags)))) (define (print-listed-entry-row id url notes protected) (write-line (conc vt100-entry-header @@ -434,22 +437,6 @@ vt100-reset)) (write-string notes)) -(define (print-entry* entry-id) - (query (for-each-row* print-entry-row) - (sql db "SELECT id,url,type,description,notes, - protected,ptime,ctime,mtime - FROM entry WHERE id=?;") - entry-id) - (write-line - (string-intersperse - (cons "Tags:" - (query (map-rows car) - (sql db "SELECT tag.name FROM tagrel - OUTER LEFT JOIN tag ON tagrel.tag_id=tag.id - WHERE url_id=? ORDER BY tag.name;") - entry-id)) - " "))) - (defcmd (list-tagged tag-name . args) "tag-name [limit]" "Display entries with the given tag" (query (for-each-row* print-listed-entry-row) @@ -469,6 +456,16 @@ (sql db "SELECT id,url,notes,protected FROM entry WHERE id NOT IN (SELECT url_id FROM tagrel);"))) +(define (print-entry* entry-id) + (query (for-each-row* print-entry-row) + (sql db "SELECT entry.id,url,type,description,notes, + protected,ptime,ctime,mtime,group_concat(tag.name,' ') + FROM entry + LEFT OUTER JOIN tagrel ON entry.id=tagrel.url_id + LEFT OUTER JOIN tag ON tag.id=tagrel.tag_id + WHERE entry.id=? GROUP BY entry.id;") + entry-id)) + (defcmd (print-entry . args) "[entry-id]" "Display an entry" (if (null? args)