Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Keep channels above a paginated release list

77d3fde66af0594afabd4860317dbeb95d78558f · Keenan Nemetz · 15d ago · parent ef3a07d6

Keep channels above a paginated release list

Channels are few and releases can run to hundreds, so the channel list now sits
first and stays on every page while the tag list pages underneath it at the same
25 rows the issue, change, and run lists use. The pager keeps `?page=` on the
releases URL, and the first page keeps the bare URL.

The total is the tag count, so the lightweight note still describes the whole
repository, and the editable column is decided from every tag rather than the
current page so it does not disappear between pages.

The regression test builds 31 tags and one channel, then checks both pages: the
channel section stays above the releases, page one links to page two, and page
two links back to the bare URL.

Refs 01M7QSTRTDSAAH7MW0YC1G1TD3.

server/web/releases.go +29−5

@@ -12,6 +12,7 @@ import (
12 12 "mime"
13 13 "net/http"
14 14 "path"
15 "strconv"
15 16 "strings"
16 17 "time"
17 18
@@ -53,6 +54,7 @@ type releasesView struct {
53 54 AnyEditable bool
54 55 CanManage bool
55 56 ManageChannels bool
57 Pager pager
56 58 }
57 59
58 60 func (w *Web) releasesView(r *http.Request, m *repo.Meta, tags []git.Tag) releasesView {
@@ -65,9 +67,9 @@ func (w *Web) releasesView(r *http.Request, m *repo.Meta, tags []git.Tag) releas
65 67 byName[t.Name] = t
66 68 }
67 69
68 // Channels live on this page: the card keeps their metadata, and a badge on
69 // the target tag row says which release each name follows. One pass over the
70 // list also finds a dangling target, which a per-tag lookup cannot.
70 // Channels live on this page: their section keeps the metadata, and a badge
71 // on the target tag row says which release each name follows. One pass over
72 // the list also finds a dangling target, which a per-tag lookup cannot.
71 73 list := w.channels(m)
72 74 rows := make([]channelRow, 0, len(list))
73 75 byTag := make(map[string][]string, len(list))
@@ -94,8 +96,8 @@ func (w *Web) releasesView(r *http.Request, m *repo.Meta, tags []git.Tag) releas
94 96 // A release a channel names cannot be edited, so the list does not offer the
95 97 // link. Every tag is decided from the channel rows already in hand: the rule
96 98 // that hides the link is the rule the handler enforces. AnyEditable doubles as
97 // "this viewer gets that column at all", so a reader sees the same table as
98 // before the column existed.
99 // "this viewer gets that column at all" and is decided from every tag, not
100 // just the current page, so the column does not vanish between pages.
99 101 editable := make(map[string]bool, len(tags))
100 102 anyEditable := false
101 103 for _, t := range tags {
@@ -103,6 +105,18 @@ func (w *Web) releasesView(r *http.Request, m *repo.Meta, tags []git.Tag) releas
103 105 editable[t.Name] = ok
104 106 anyEditable = anyEditable || ok
105 107 }
108
109 // Channels stay above the list on every page because there are few of them;
110 // the tags are what grows, so only the tag list pages. The total is the tag
111 // count, and the lightweight note stays a count of the whole repository.
112 page, _ := strconv.Atoi(r.URL.Query().Get("page"))
113 pg := newPager(len(tags), listPageSize, page, func(n int) string {
114 return releaseListURL(m.Name, n)
115 })
116 pg.Label = "Release pages"
117 from, to := pg.rows()
118 tags = tags[from:to]
119
106 120 return releasesView{
107 121 Page: w.page(r, m.Name+" · releases"),
108 122 Name: m.Name,
@@ -114,7 +128,17 @@ func (w *Web) releasesView(r *http.Request, m *repo.Meta, tags []git.Tag) releas
114 128 AnyEditable: anyEditable,
115 129 CanManage: canManage,
116 130 ManageChannels: canManage && w.ChannelStore != nil,
131 Pager: pg,
132 }
133 }
134
135 // releaseListURL keeps the page number out of the first page's URL, so the
136 // canonical list address is the one a reader shares.
137 func releaseListURL(name string, page int) string {
138 if page <= 1 {
139 return "/" + name + "/releases"
117 140 }
141 return "/" + name + "/releases?page=" + strconv.Itoa(page)
118 142 }
119 143
120 144 func (w *Web) Releases(rw http.ResponseWriter, r *http.Request) {