From 6795122e00c91ce015c19e6e0bae2dd39f932430 Mon Sep 17 00:00:00 2001 From: Admin Date: Sun, 11 Jan 2026 04:27:55 +0000 Subject: [PATCH] feat: group release downloads by OS, load primary language for pinned repos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add ToLower to StringUtils template helper - Add slice and Append template functions for grouping - Group release attachments by OS (Windows, macOS, Linux, Other) - Load primary language for org pinned repos to show in cards 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- modules/templates/helper.go | 2 + modules/templates/util_slice.go | 14 +++ modules/templates/util_string.go | 4 + services/org/pinned.go | 8 +- templates/repo/release/list.tmpl | 151 +++++++++++++++++++++++++++---- 5 files changed, 159 insertions(+), 20 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index a7aa321811..4d2d813694 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -48,6 +48,8 @@ func NewFuncMap() template.FuncMap { // utils "StringUtils": NewStringUtils, "SliceUtils": NewSliceUtils, + "slice": func() []any { return []any{} }, + "Append": func(s []any, v any) []any { return append(s, v) }, "JsonUtils": NewJsonUtils, "DateUtils": NewDateUtils, diff --git a/modules/templates/util_slice.go b/modules/templates/util_slice.go index a3318cc11a..33fa5fff8f 100644 --- a/modules/templates/util_slice.go +++ b/modules/templates/util_slice.go @@ -33,3 +33,17 @@ func (su *SliceUtils) Contains(s, v any) bool { } return false } + +// Append appends an element to a slice and returns the new slice +func (su *SliceUtils) Append(s any, v any) any { + if s == nil { + return []any{v} + } + sv := reflect.ValueOf(s) + if sv.Kind() != reflect.Slice { + panic(fmt.Sprintf("invalid type, expected slice, but got: %T", s)) + } + // Create a new slice with the appended element + newSlice := reflect.Append(sv, reflect.ValueOf(v)) + return newSlice.Interface() +} diff --git a/modules/templates/util_string.go b/modules/templates/util_string.go index 683c77a870..bd2ddba278 100644 --- a/modules/templates/util_string.go +++ b/modules/templates/util_string.go @@ -61,6 +61,10 @@ func (su *StringUtils) ToUpper(s string) string { return strings.ToUpper(s) } +func (su *StringUtils) ToLower(s string) string { + return strings.ToLower(s) +} + func (su *StringUtils) TrimPrefix(s, prefix string) string { return strings.TrimPrefix(s, prefix) } diff --git a/services/org/pinned.go b/services/org/pinned.go index e82cfa17f1..ffce57bbae 100644 --- a/services/org/pinned.go +++ b/services/org/pinned.go @@ -37,9 +37,13 @@ func GetOrgPinnedReposWithDetails(ctx context.Context, orgID int64) ([]*organiza return nil, err } - // Attach repos + // Attach repos and load attributes (including primary language) for _, p := range pinnedRepos { - p.Repo = repos[p.RepoID] + repo := repos[p.RepoID] + if repo != nil { + _ = repo.LoadAttributes(ctx) + } + p.Repo = repo } return pinnedRepos, nil diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index 5b7f7bbf47..0131f11f5f 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -92,23 +92,137 @@ {{ctx.Locale.Tr "repo.release.downloads"}} - + + {{end}}