From e0e6100bbff07602754eb4940aa535cb112c2e95 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Fri, 10 Apr 2026 13:06:49 +0900 Subject: [PATCH] appview: add comment to strings Signed-off-by: Seongmin Lee --- appview/pages/pages.go | 3 ++ appview/pages/templates/strings/string.html | 58 +++++++++++++++++++++ appview/strings/strings.go | 22 +++++++- 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/appview/pages/pages.go b/appview/pages/pages.go index c31b5307..6aa7f3f2 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -1629,6 +1629,9 @@ type SingleStringParams struct { IsStarred bool StarCount int Owner identity.Identity + CommentList []models.CommentListItem + + VouchRelationships map[syntax.DID]*models.VouchRelationship } func (p *Pages) SingleString(w io.Writer, params SingleStringParams) error { diff --git a/appview/pages/templates/strings/string.html b/appview/pages/templates/strings/string.html index f0fd65f1..9115d4b5 100644 --- a/appview/pages/templates/strings/string.html +++ b/appview/pages/templates/strings/string.html @@ -94,4 +94,62 @@ {{ template "fragments/multiline-select" }} +
+ {{ + template "fragments/comment/commentList" + (dict + "LoggedInUser" .LoggedInUser + "VouchRelationships" .VouchRelationships + "CommentList" .CommentList) + }} + {{ template "newComment" . }} +
+{{ end }} + +{{ define "newComment" }} + {{ if .LoggedInUser }} +
+ +
+
+ {{ template "user/fragments/picHandleLink" .LoggedInUser.Did }} +
+ +
+
+
+ +
+
+ {{ else }} +
+ + sign up + + or + login + to add to the discussion +
+ {{ end }} {{ end }} diff --git a/appview/strings/strings.go b/appview/strings/strings.go index 42046afb..12fc400b 100644 --- a/appview/strings/strings.go +++ b/appview/strings/strings.go @@ -157,7 +157,24 @@ func (s *Strings) contents(w http.ResponseWriter, r *http.Request) { isStarred = db.GetStarStatus(s.Db, user.Did, stringUri) } - s.Pages.SingleString(w, pages.SingleStringParams{ + comments, err := db.GetComments(s.Db, orm.FilterEq("subject_uri", string.AtUri())) + if err != nil { + l.Error("failed to get comments", "err", err) + } + + vouchRelationships := make(map[syntax.DID]*models.VouchRelationship) + if user != nil { + var participants []syntax.DID + for _, c := range comments { + participants = append(participants, c.Did) + } + vouchRelationships, err = db.GetVouchRelationshipsBatch(s.Db, syntax.DID(user.Did), participants) + if err != nil { + l.Error("failed to fetch vouch relationships", "err", err) + } + } + + err = s.Pages.SingleString(w, pages.SingleStringParams{ LoggedInUser: user, RenderToggle: renderToggle, ShowRendered: showRendered, @@ -166,6 +183,9 @@ func (s *Strings) contents(w http.ResponseWriter, r *http.Request) { IsStarred: isStarred, StarCount: starCount, Owner: id, + CommentList: models.NewCommentList(comments), + + VouchRelationships: vouchRelationships, }) } -- 2.51.2