Signed-off-by: Will did:plc:dadhhalkfcq3gucaq25hjqon
+114
-9
Diff
round #5
+10
appview/db/repos.go
+10
appview/db/repos.go
···
804
804
805
805
return labels, nil
806
806
}
807
+
808
+
func GetForkCount(e Execer, sourceDID string) (int, error) {
809
+
forks := 0
810
+
err := e.QueryRow(
811
+
`select count(source) from repos where source = ?`, sourceDID).Scan(&forks)
812
+
if err != nil {
813
+
return 0, err
814
+
}
815
+
return forks, nil
816
+
}
+14
appview/pages/pages.go
+14
appview/pages/pages.go
···
1557
1557
return p.executeRepo("repo/stars", w, params)
1558
1558
}
1559
1559
1560
+
type RepoForksParams struct {
1561
+
LoggedInUser *oauth.MultiAccountUser
1562
+
RepoInfo repoinfo.RepoInfo
1563
+
Active string
1564
+
Forks []models.Repo
1565
+
Page pagination.Page
1566
+
TotalCount int
1567
+
}
1568
+
1569
+
func (p *Pages) RepoForks(w io.Writer, params RepoForksParams) error {
1570
+
params.Active = "overview"
1571
+
return p.executeRepo("repo/forks", w, params)
1572
+
}
1573
+
1560
1574
type PipelinesParams struct {
1561
1575
LoggedInUser *oauth.MultiAccountUser
1562
1576
RepoInfo repoinfo.RepoInfo
+18
-9
appview/pages/templates/layouts/repobase.html
+18
-9
appview/pages/templates/layouts/repobase.html
···
117
117
"IsStarred" .RepoInfo.IsStarred
118
118
"StarCount" .RepoInfo.Stats.StarCount
119
119
"RepoName" .RepoInfo.Name) }}
120
-
<a
121
-
class="btn text-sm no-underline hover:no-underline flex items-center gap-2 group"
122
-
hx-boost="true"
123
-
href="/{{ .RepoInfo.FullName }}/fork"
124
-
>
125
-
{{ i "git-fork" "w-4 h-4" }}
126
-
fork
127
-
{{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
128
-
</a>
120
+
<div class="flex w-full min-h-[30px] items-stretch overflow-hidden rounded border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm">
121
+
<a
122
+
class="btn text-sm no-underline hover:no-underline flex items-center gap-2 group"
123
+
hx-boost="true"
124
+
href="/{{ .RepoInfo.FullName }}/fork"
125
+
>
126
+
{{ i "git-fork" "w-4 h-4" }}
127
+
fork
128
+
{{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
129
+
</a>
130
+
<a
131
+
href="/{{ .RepoInfo.FullName }}/forks"
132
+
class="flex items-center px-2 text-sm no-underline hover:no-underline border-l border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700"
133
+
title="Starred by"
134
+
>
135
+
{{ .RepoInfo.Stats.ForkCount }}
136
+
</a>
137
+
</div>
129
138
{{ template "repo/fragments/feedDropdown" . }}
130
139
</div>
131
140
{{ end }}
+35
appview/pages/templates/repo/forks.html
+35
appview/pages/templates/repo/forks.html
···
1
+
{{ define "title" }}forks ยท {{ .RepoInfo.FullName }}{{ end }}
2
+
{{ define "repoContent" }}
3
+
<div class="flex flex-col gap-4">
4
+
<h2 class="text-sm uppercase font-bold">Forked by</h2>
5
+
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
6
+
{{ range .Forks }}
7
+
{{ $handle := resolve .Did }}
8
+
{{ $name := .Name}}
9
+
<div class="border border-gray-200 dark:border-gray-700 rounded p-4">
10
+
<div class="flex items-center gap-3">
11
+
{{ template "user/fragments/picLink" (list .Did "size-10") }}
12
+
<div class="flex-1 min-w-0">
13
+
<a href="/{{ $handle }}" class="block truncate">{{ $handle }}</a>
14
+
<a href="/{{ $handle }}/{{ $name }}" class="block truncate">{{ $name }}</a>
15
+
<p class="text-sm text-gray-500 dark:text-gray-400">
16
+
forked {{ .Created | relTimeFmt }}
17
+
</p>
18
+
</div>
19
+
</div>
20
+
</div>
21
+
{{ end }}
22
+
{{ if eq .TotalCount 0 }}
23
+
<p class="text-gray-500 dark:text-gray-400 col-span-3">No forks yet.</p>
24
+
{{ end }}
25
+
</div>
26
+
{{ if gt .TotalCount .Page.Limit }}
27
+
{{ template "fragments/pagination" (dict
28
+
"Page" .Page
29
+
"TotalCount" .TotalCount
30
+
"BasePath" (printf "/%s/forks" .RepoInfo.FullName)
31
+
"QueryParams" (queryParams)
32
+
) }}
33
+
{{ end }}
34
+
</div>
35
+
{{ end }}
+36
appview/repo/repo.go
+36
appview/repo/repo.go
···
1297
1297
})
1298
1298
}
1299
1299
1300
+
func (rp *Repo) Forks(w http.ResponseWriter, r *http.Request) {
1301
+
l := rp.logger.With("handler", "Forks")
1302
+
1303
+
user := rp.oauth.GetMultiAccountUser(r)
1304
+
f, err := rp.repoResolver.Resolve(r)
1305
+
if err != nil {
1306
+
l.Error("failed to resolve source repo", "err", err)
1307
+
return
1308
+
}
1309
+
1310
+
page := pagination.FromContext(r.Context())
1311
+
if page.Limit > 30 || page.Limit <= 0 {
1312
+
page.Limit = 30
1313
+
}
1314
+
1315
+
forks, err := db.GetReposPaginated(rp.db, page, orm.FilterEq("source", f.RepoDid))
1316
+
if err != nil {
1317
+
l.Error("failed to fetch forks", "err", err, "repoAt", f.RepoAt())
1318
+
return
1319
+
}
1320
+
1321
+
totalCount, err := db.GetForkCount(rp.db, f.RepoDid)
1322
+
if err != nil {
1323
+
l.Error("failed to fetch fork count", "err", err, "repoAt", f.RepoAt())
1324
+
return
1325
+
}
1326
+
1327
+
rp.pages.RepoForks(w, pages.RepoForksParams{
1328
+
LoggedInUser: user,
1329
+
RepoInfo: rp.repoResolver.GetRepoInfo(r, user),
1330
+
Forks: forks,
1331
+
Page: page,
1332
+
TotalCount: totalCount,
1333
+
})
1334
+
}
1335
+
1300
1336
// this is used to rollback changes made to the PDS
1301
1337
//
1302
1338
// it is a no-op if the provided ATURI is empty
History
6 rounds
0 comments
willdot.net
submitted
#5
1 commit
expand
collapse
appview/repo: show number of forks on repo and link to page of forks
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>
merge conflicts detected
expand
collapse
expand
collapse
- appview/db/repos.go:301
- appview/models/repo.go:97
expand 0 comments
willdot.net
submitted
#4
1 commit
expand
collapse
appview/repo: show number of forks on repo and link to page of forks
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>
expand 0 comments
willdot.net
submitted
#3
1 commit
expand
collapse
appview/repo: show number of forks on repo and link to page of forks
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>
expand 0 comments
willdot.net
submitted
#2
1 commit
expand
collapse
appview/repo: show number of forks on repo and link to page of forks
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>
expand 0 comments
willdot.net
submitted
#1
1 commit
expand
collapse
appview/repo: show number of forks on repo and link to page of forks
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>
expand 0 comments
willdot.net
submitted
#0
1 commit
expand
collapse
appview/repo: show number of forks on repo and link to page of forks
Signed-off-by: Will <did:plc:dadhhalkfcq3gucaq25hjqon>