Signed-off-by: Seongmin Lee git@boltless.me
+42
-79
Diff
round #1
+21
-17
appview/db/reference.go
+21
-17
appview/db/reference.go
···
46
46
args := make([]any, 0, len(refLinks)*4)
47
47
for i, ref := range refLinks {
48
48
vals[i] = "(?, ?, ?, ?)"
49
-
args = append(args, ref.Handle, ref.Repo, ref.SubjectId, ref.CommentId)
49
+
args = append(args, ref.Handle, ref.Repo, ref.SubjectId, ref.CommentRkey)
50
50
}
51
51
query := fmt.Sprintf(
52
52
`with input(owner_did, name, issue_id, comment_id) as (
···
106
106
args := make([]any, 0, len(refLinks)*4)
107
107
for i, ref := range refLinks {
108
108
vals[i] = "(?, ?, ?, ?)"
109
-
args = append(args, ref.Handle, ref.Repo, ref.SubjectId, ref.CommentId)
109
+
args = append(args, ref.Handle, ref.Repo, ref.SubjectId, ref.CommentRkey)
110
110
}
111
111
query := fmt.Sprintf(
112
112
`with input(owner_did, name, pull_id, comment_id) as (
···
271
271
return nil, fmt.Errorf("get issue backlinks: %w", err)
272
272
}
273
273
backlinks = append(backlinks, ls...)
274
-
ls, err = getIssueCommentBacklinks(e, target, backlinksMap[tangled.FeedCommentNSID])
275
-
if err != nil {
276
-
return nil, fmt.Errorf("get issue_comment backlinks: %w", err)
277
-
}
278
-
backlinks = append(backlinks, ls...)
279
274
ls, err = getPullBacklinks(e, backlinksMap[tangled.RepoPullNSID])
280
275
if err != nil {
281
276
return nil, fmt.Errorf("get pull backlinks: %w", err)
282
277
}
283
278
backlinks = append(backlinks, ls...)
284
-
ls, err = getPullCommentBacklinks(e, target, backlinksMap[tangled.FeedCommentNSID])
285
-
if err != nil {
286
-
return nil, fmt.Errorf("get pull_comment backlinks: %w", err)
279
+
switch target.Collection() {
280
+
case tangled.RepoIssueNSID:
281
+
ls, err = getIssueCommentBacklinks(e, target, backlinksMap[tangled.FeedCommentNSID])
282
+
if err != nil {
283
+
return nil, fmt.Errorf("get issue_comment backlinks: %w", err)
284
+
}
285
+
backlinks = append(backlinks, ls...)
286
+
case tangled.RepoPullNSID:
287
+
ls, err = getPullCommentBacklinks(e, target, backlinksMap[tangled.FeedCommentNSID])
288
+
if err != nil {
289
+
return nil, fmt.Errorf("get pull_comment backlinks: %w", err)
290
+
}
291
+
backlinks = append(backlinks, ls...)
287
292
}
288
-
backlinks = append(backlinks, ls...)
289
293
290
294
return backlinks, nil
291
295
}
···
340
344
exclude := orm.FilterNotEq("i.at_uri", target)
341
345
rows, err := e.Query(
342
346
fmt.Sprintf(
343
-
`select r.did, r.name, i.issue_id, c.id, i.title, i.open
347
+
`select r.did, r.name, i.issue_id, c.rkey, i.title, i.open
344
348
from comments c
345
349
join issues i
346
350
on i.at_uri = c.subject_uri
···
360
364
for rows.Next() {
361
365
var l models.RichReferenceLink
362
366
l.Kind = models.RefKindIssue
363
-
l.CommentId = new(int)
364
-
if err := rows.Scan(&l.Handle, &l.Repo, &l.SubjectId, l.CommentId, &l.Title, &l.State); err != nil {
367
+
l.CommentRkey = new(syntax.RecordKey)
368
+
if err := rows.Scan(&l.Handle, &l.Repo, &l.SubjectId, l.CommentRkey, &l.Title, &l.State); err != nil {
365
369
return nil, err
366
370
}
367
371
refLinks = append(refLinks, l)
···
422
426
exclude := orm.FilterNotEq("p.at_uri", target)
423
427
rows, err := e.Query(
424
428
fmt.Sprintf(
425
-
`select r.did, r.name, p.pull_id, c.id, p.title, p.state
429
+
`select r.did, r.name, p.pull_id, c.rkey, p.title, p.state
426
430
from repos r
427
431
join pulls p
428
432
on r.at_uri = p.repo_at
···
442
446
for rows.Next() {
443
447
var l models.RichReferenceLink
444
448
l.Kind = models.RefKindPull
445
-
l.CommentId = new(int)
446
-
if err := rows.Scan(&l.Handle, &l.Repo, &l.SubjectId, l.CommentId, &l.Title, &l.State); err != nil {
449
+
l.CommentRkey = new(syntax.RecordKey)
450
+
if err := rows.Scan(&l.Handle, &l.Repo, &l.SubjectId, l.CommentRkey, &l.Title, &l.State); err != nil {
447
451
return nil, err
448
452
}
449
453
refLinks = append(refLinks, l)
+7
-21
appview/models/reference.go
+7
-21
appview/models/reference.go
···
1
1
package models
2
2
3
-
import "fmt"
3
+
import "github.com/bluesky-social/indigo/atproto/syntax"
4
4
5
5
type RefKind int
6
6
···
18
18
}
19
19
20
20
// /@alice.com/cool-proj/issues/123
21
-
// /@alice.com/cool-proj/issues/123#comment-321
21
+
// /@alice.com/cool-proj/issues/123#comment-3mleetx5lhz22
22
22
type ReferenceLink struct {
23
-
Handle string
24
-
Repo string
25
-
Kind RefKind
26
-
SubjectId int
27
-
CommentId *int
28
-
}
29
-
30
-
func (l ReferenceLink) String() string {
31
-
comment := ""
32
-
if l.CommentId != nil {
33
-
comment = fmt.Sprintf("#comment-%d", *l.CommentId)
34
-
}
35
-
return fmt.Sprintf("/%s/%s/%s/%d%s",
36
-
l.Handle,
37
-
l.Repo,
38
-
l.Kind.String(),
39
-
l.SubjectId,
40
-
comment,
41
-
)
23
+
Handle string
24
+
Repo string
25
+
Kind RefKind
26
+
SubjectId int
27
+
CommentRkey *syntax.RecordKey
42
28
}
43
29
44
30
type RichReferenceLink struct {
+9
-9
appview/pages/markup/reference_link.go
+9
-9
appview/pages/markup/reference_link.go
···
8
8
"strconv"
9
9
"strings"
10
10
11
+
"github.com/bluesky-social/indigo/atproto/syntax"
11
12
"github.com/yuin/goldmark/ast"
12
13
"github.com/yuin/goldmark/text"
13
14
"tangled.org/core/appview/models"
···
101
102
if err != nil {
102
103
return nil
103
104
}
104
-
var commentId *int
105
+
var commentRkey *syntax.RecordKey
105
106
if u.Fragment != "" {
106
107
if strings.HasPrefix(u.Fragment, "comment-") {
107
-
commentIdStr := u.Fragment[len("comment-"):]
108
-
if id, err := strconv.Atoi(commentIdStr); err == nil {
109
-
commentId = &id
108
+
if rkey, err := syntax.ParseRecordKey(u.Fragment[len("comment-"):]); err != nil {
109
+
commentRkey = &rkey
110
110
}
111
111
}
112
112
}
113
113
114
114
return &models.ReferenceLink{
115
-
Handle: handle,
116
-
Repo: repo,
117
-
Kind: kind,
118
-
SubjectId: subjectId,
119
-
CommentId: commentId,
115
+
Handle: handle,
116
+
Repo: repo,
117
+
Kind: kind,
118
+
SubjectId: subjectId,
119
+
CommentRkey: commentRkey,
120
120
}
121
121
}
+2
-2
appview/pages/markup/reference_link_test.go
+2
-2
appview/pages/markup/reference_link_test.go
···
20
20
source: `[link](http://127.0.0.1:3000/alice.pds.tngl.boltless.dev/coolproj/issues/1)`,
21
21
wantHandles: make([]string, 0),
22
22
wantRefLinks: []models.ReferenceLink{
23
-
{Handle: "alice.pds.tngl.boltless.dev", Repo: "coolproj", Kind: models.RefKindIssue, SubjectId: 1, CommentId: nil},
23
+
{Handle: "alice.pds.tngl.boltless.dev", Repo: "coolproj", Kind: models.RefKindIssue, SubjectId: 1, CommentRkey: nil},
24
24
},
25
25
},
26
26
{
···
28
28
source: `<http://127.0.0.1:3000/alice.pds.tngl.boltless.dev/coolproj/issues/1>`,
29
29
wantHandles: make([]string, 0),
30
30
wantRefLinks: []models.ReferenceLink{
31
-
{Handle: "alice.pds.tngl.boltless.dev", Repo: "coolproj", Kind: models.RefKindIssue, SubjectId: 1, CommentId: nil},
31
+
{Handle: "alice.pds.tngl.boltless.dev", Repo: "coolproj", Kind: models.RefKindIssue, SubjectId: 1, CommentRkey: nil},
32
32
},
33
33
},
34
34
}
+2
-2
appview/pages/templates/fragments/comment/commentHeader.html
+2
-2
appview/pages/templates/fragments/comment/commentHeader.html
···
26
26
{{ end }}
27
27
28
28
{{ define "timestamp" }}
29
-
<a href="#comment-{{ .Comment.Id }}"
29
+
<a href="#comment-{{ .Comment.Rkey }}"
30
30
class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-400 hover:underline no-underline"
31
-
id="comment-{{ .Comment.Id }}">
31
+
id="comment-{{ .Comment.Rkey }}">
32
32
{{ if .Comment.Deleted }}
33
33
{{ template "repo/fragments/shortTimeAgo" .Comment.Deleted }}
34
34
{{ else if .Comment.Edited }}
+1
-1
appview/pages/templates/repo/fragments/backlinks.html
+1
-1
appview/pages/templates/repo/fragments/backlinks.html
···
33
33
{{ i "git-pull-request-closed" "size-3" }}
34
34
</span>
35
35
{{ end }}
36
-
<a href="{{ . }}" class="line-clamp-1 text-sm"><span class="text-gray-500 dark:text-gray-400">#{{ .SubjectId }}</span> {{ .Title }}</a>
36
+
<a href="/{{ $repoUrl }}/{{ .Kind }}/{{ .SubjectId }}{{ with .CommentRkey }}#comment-{{.}}{{end}}" class="line-clamp-1 text-sm"><span class="text-gray-500 dark:text-gray-400">#{{ .SubjectId }}</span> {{ .Title }}</a>
37
37
</div>
38
38
{{ if not (eq $.RepoInfo.FullName $repoUrl) }}
39
39
<div>
-27
appview/pages/templates/repo/pulls/pull.html
-27
appview/pages/templates/repo/pulls/pull.html
···
649
649
</div>
650
650
{{ end }}
651
651
652
-
{{ define "submissionComment" }}
653
-
{{ $comment := index . 0 }}
654
-
{{ $root := index . 1 }}
655
-
<div id="comment-{{$comment.Id}}" class="flex gap-2 -ml-4 py-4 w-full mx-auto group/comment">
656
-
<!-- left column: profile picture -->
657
-
<div class="flex-shrink-0 h-fit relative">
658
-
{{ template "user/fragments/picLink" (list $comment.Did.String "size-8" (index $root.VouchRelationships (did $comment.OwnerDid))) }}
659
-
</div>
660
-
<!-- right column: name and body in two rows -->
661
-
<div class="flex-1 min-w-0">
662
-
<!-- Row 1: Author and timestamp -->
663
-
<div class="text-sm text-gray-500 dark:text-gray-400 flex items-center gap-1 group-target/comment:bg-yellow-200/30 group-target/comment:dark:bg-yellow-600/30">
664
-
{{ $handle := resolve $comment.Did.String }}
665
-
<a class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-300" href="/{{ $handle }}">{{ $handle }}</a>
666
-
<span class="before:content-['路']"></span>
667
-
<a class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-300" href="#comment-{{$comment.Id}}">
668
-
{{ template "repo/fragments/shortTime" $comment.Created }}
669
-
</a>
670
-
</div>
671
-
<!-- Row 2: Body text -->
672
-
<div class="prose dark:prose-invert mt-1">
673
-
{{ $comment.Body.Text | markdown }}
674
-
</div>
675
-
</div>
676
-
</div>
677
-
{{ end }}
678
-
679
652
{{ define "loginPrompt" }}
680
653
<div class="bg-amber-50 dark:bg-amber-900 border border-amber-500 rounded shadow-sm p-2 relative flex gap-2 items-center">
681
654
<a href="/signup" class="btn-create py-0 hover:no-underline hover:text-white flex items-center gap-2">
History
2 rounds
0 comments
boltless.me
submitted
#1
1 commit
expand
collapse
appview: use
#comment-{rkey} instead of appview-local id
Signed-off-by: Seongmin Lee <git@boltless.me>
merge conflicts detected
expand
collapse
expand
collapse
- appview/migration/migration.go:71
expand 0 comments
boltless.me
submitted
#0
1 commit
expand
collapse
appview: use
#comment-{rkey} instead of appview-local id
Signed-off-by: Seongmin Lee <git@boltless.me>