Monorepo for Tangled tangled.org

appview: add comment to strings #1305

open opened by boltless.me targeting master from sl/comment
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3mj4ttwo6ek22
+64
Diff #3
+1
appview/pages/pages.go
··· 1598 1598 IsStarred bool 1599 1599 StarCount int 1600 1600 Owner identity.Identity 1601 + CommentList []models.CommentListItem 1601 1602 } 1602 1603 1603 1604 func (p *Pages) SingleString(w io.Writer, params SingleStringParams) error {
+57
appview/pages/templates/strings/string.html
··· 94 94 </div> 95 95 {{ template "fragments/multiline-select" }} 96 96 </section> 97 + <div class="flex flex-col gap-4 mt-4"> 98 + {{ 99 + template "fragments/comment/commentList" 100 + (dict 101 + "LoggedInUser" .LoggedInUser 102 + "CommentList" .CommentList) 103 + }} 104 + {{ template "newComment" . }} 105 + </div> 106 + {{ end }} 107 + 108 + {{ define "newComment" }} 109 + {{ if .LoggedInUser }} 110 + <form 111 + hx-post="/comment" 112 + hx-trigger="submit, keydown[(ctrlKey || metaKey) && key=='Enter'] from:find textarea" 113 + hx-swap="none" 114 + hx-disabled-elt="find button[type='submit']" 115 + hx-on::after-request="if(event.detail.successful) this.reset()" 116 + class="group/form" 117 + > 118 + <input name="subject-uri" type="hidden" value="{{ .String.AtUri }}"> 119 + <div class="bg-white dark:bg-gray-800 rounded drop-shadow-sm py-4 px-4 relative w-full"> 120 + <div class="text-sm pb-2 text-gray-500 dark:text-gray-400"> 121 + {{ template "user/fragments/picHandleLink" .LoggedInUser.Did }} 122 + </div> 123 + <textarea 124 + name="body" 125 + class="w-full p-2 rounded" 126 + placeholder="Add to the discussion. Markdown is supported." 127 + rows="5" 128 + required 129 + ></textarea> 130 + <div id="comment-error" class="error"></div> 131 + </div> 132 + <div class="flex gap-2 mt-2"> 133 + <button 134 + id="comment-button" 135 + type="submit" 136 + class="btn-create p-2 flex items-center gap-2 no-underline hover:no-underline" 137 + > 138 + {{ i "message-square-plus" "w-4 h-4 inline group-[.htmx-request]/form:hidden" }} 139 + {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]/form:inline" }} 140 + comment 141 + </button> 142 + </div> 143 + </form> 144 + {{ else }} 145 + <div class="bg-amber-50 dark:bg-amber-900 border border-amber-500 rounded drop-shadow-sm p-6 relative flex gap-2 items-center"> 146 + <a href="/signup" class="btn-create py-0 hover:no-underline hover:text-white flex items-center gap-2"> 147 + sign up 148 + </a> 149 + <span class="text-gray-500 dark:text-gray-400">or</span> 150 + <a href="/login" class="underline">login</a> 151 + to add to the discussion 152 + </div> 153 + {{ end }} 97 154 {{ end }}
+6
appview/strings/strings.go
··· 156 156 isStarred = db.GetStarStatus(s.Db, user.Did, string.AtUri()) 157 157 } 158 158 159 + comments, err := db.GetComments(s.Db, orm.FilterEq("subject_uri", string.AtUri())) 160 + if err != nil { 161 + l.Error("failed to get comments", "err", err) 162 + } 163 + 159 164 s.Pages.SingleString(w, pages.SingleStringParams{ 160 165 LoggedInUser: user, 161 166 RenderToggle: renderToggle, ··· 165 170 IsStarred: isStarred, 166 171 StarCount: starCount, 167 172 Owner: id, 173 + CommentList: models.NewCommentList(comments), 168 174 }) 169 175 } 170 176

History

4 rounds 1 comment
sign up or login to add to the discussion
1 commit
expand
appview: add comment to strings
3/3 failed
expand
no conflicts, ready to merge
expand 0 comments
1 commit
expand
appview: add comment to strings
3/3 failed
expand
expand 0 comments
1 commit
expand
appview: add comment to strings
3/3 failed
expand
expand 1 comment
1 commit
expand
appview: add comment to strings
3/3 failed
expand
expand 0 comments