-2
appview/pages/pages.go
-2
appview/pages/pages.go
+1
-1
appview/pages/templates/repo/blob.html
+1
-1
appview/pages/templates/repo/blob.html
···
9
9
{{ if ne $idx (sub (len $.BreadCrumbs) 1) }}
10
10
<a href="{{ index . 1}}" class="text-bold text-gray-500 {{ $linkstyle }}">{{ index . 0 }}</a> /
11
11
{{ else }}
12
-
<a href="{{ index . 1}}" class="text-bold text-gray-500 {{ $linkstyle }}">{{ index . 0 }}</a>
12
+
<span class="text-bold text-gray-500">{{ index . 0 }}</span>
13
13
{{ end }}
14
14
{{ end }}
15
15
</div>
+5
-9
appview/pages/templates/repo/index.html
+5
-9
appview/pages/templates/repo/index.html
···
8
8
{{ $containerstyle := "py-1" }}
9
9
{{ $linkstyle := "no-underline hover:underline" }}
10
10
11
-
12
11
<div class="flex justify-end">
13
12
<select
14
-
hx-get="/{{ .RepoInfo.FullName }}/tree/"
15
-
hx-on::config-request = "event.detail.path += this.value"
16
-
hx-trigger="change"
17
-
hx-target="#repo-content"
18
-
hx-select="#repo-content"
19
-
hx-push-url="true"
13
+
onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + this.value"
20
14
class="p-1 border border-gray-500 bg-white"
21
15
>
22
-
<optgroup label="branches" class="font-semibold">
16
+
<optgroup label="branches" class="uppercase bold text-sm">
23
17
{{ range .Branches }}
24
18
<option
25
19
value="{{ .Reference.Name }}"
26
20
class="py-1"
21
+
{{if eq .Reference.Name $.Ref}}selected{{end}}
27
22
>
28
23
{{ .Reference.Name }}
29
24
</option>
30
25
{{ end }}
31
26
</optgroup>
32
-
<optgroup label="tags" class="font-semibold">
27
+
<optgroup label="tags" class="uppercase bold text-sm">
33
28
{{ range .Tags }}
34
29
<option
35
30
value="{{ .Reference.Name }}"
36
31
class="py-1"
32
+
{{if eq .Reference.Name $.Ref}}selected{{end}}
37
33
>
38
34
{{ .Reference.Name }}
39
35
</option>
-42
appview/state/repo.go
-42
appview/state/repo.go
···
52
52
return
53
53
}
54
54
55
-
branchesResp, err := http.Get(fmt.Sprintf("http://%s/%s/%s/branches", f.Knot, f.OwnerDid(), f.RepoName))
56
-
if err != nil {
57
-
log.Println("failed to reach knotserver for branches", err)
58
-
return
59
-
}
60
-
defer branchesResp.Body.Close()
61
-
62
-
tagsResp, err := http.Get(fmt.Sprintf("http://%s/%s/%s/tags", f.Knot, f.OwnerDid(), f.RepoName))
63
-
if err != nil {
64
-
log.Println("failed to reach knotserver for tags", err)
65
-
return
66
-
}
67
-
defer tagsResp.Body.Close()
68
-
69
-
branchesBody, err := io.ReadAll(branchesResp.Body)
70
-
if err != nil {
71
-
log.Println("failed to read branches response", err)
72
-
return
73
-
}
74
-
75
-
tagsBody, err := io.ReadAll(tagsResp.Body)
76
-
if err != nil {
77
-
log.Println("failed to read tags response", err)
78
-
return
79
-
}
80
-
81
-
var branchesResult types.RepoBranchesResponse
82
-
err = json.Unmarshal(branchesBody, &branchesResult)
83
-
if err != nil {
84
-
log.Println("failed to parse branches response", err)
85
-
return
86
-
}
87
-
88
-
var tagsResult types.RepoTagsResponse
89
-
err = json.Unmarshal(tagsBody, &tagsResult)
90
-
if err != nil {
91
-
log.Println("failed to parse tags response", err)
92
-
return
93
-
}
94
-
95
55
log.Println(resp.Status, result)
96
56
97
57
user := s.auth.GetUser(r)
···
104
64
SettingsAllowed: settingsAllowed(s, user, f),
105
65
},
106
66
RepoIndexResponse: result,
107
-
Branches: branchesResult.Branches,
108
-
Tags: tagsResult.Tags,
109
67
})
110
68
111
69
return
+42
knotserver/routes.go
+42
knotserver/routes.go
···
48
48
return
49
49
}
50
50
}
51
+
51
52
commits, err := gr.Commits()
52
53
if err != nil {
53
54
writeError(w, err.Error(), http.StatusInternalServerError)
···
56
57
}
57
58
if len(commits) > 10 {
58
59
commits = commits[:10]
60
+
}
61
+
62
+
branches, err := gr.Branches()
63
+
if err != nil {
64
+
l.Error("getting branches", "error", err.Error())
65
+
writeError(w, err.Error(), http.StatusInternalServerError)
66
+
return
67
+
}
68
+
69
+
bs := []types.Branch{}
70
+
for _, branch := range branches {
71
+
b := types.Branch{}
72
+
b.Hash = branch.Hash().String()
73
+
b.Name = branch.Name().Short()
74
+
bs = append(bs, b)
75
+
}
76
+
77
+
tags, err := gr.Tags()
78
+
if err != nil {
79
+
// Non-fatal, we *should* have at least one branch to show.
80
+
l.Warn("getting tags", "error", err.Error())
81
+
}
82
+
83
+
rtags := []*types.TagReference{}
84
+
for _, tag := range tags {
85
+
tr := types.TagReference{
86
+
Tag: tag.TagObject(),
87
+
}
88
+
89
+
tr.Reference = types.Reference{
90
+
Name: tag.Name(),
91
+
Hash: tag.Hash().String(),
92
+
}
93
+
94
+
if tag.Message() != "" {
95
+
tr.Message = tag.Message()
96
+
}
97
+
98
+
rtags = append(rtags, &tr)
59
99
}
60
100
61
101
var readmeContent template.HTML
···
109
149
Description: getDescription(path),
110
150
Readme: readmeContent,
111
151
Files: files,
152
+
Branches: bs,
153
+
Tags: rtags,
112
154
}
113
155
114
156
writeJSON(w, resp)
+2
types/repo.go
+2
types/repo.go
···
13
13
Commits []*object.Commit `json:"commits,omitempty"`
14
14
Description string `json:"description,omitempty"`
15
15
Files []NiceTree `json:"files,omitempty"`
16
+
Branches []Branch `json:"branches,omitempty"`
17
+
Tags []*TagReference `json:"tags,omitempty"`
16
18
}
17
19
18
20
type RepoLogResponse struct {