Skip to content

Commit 43fc430

Browse files
jonasfranzlafriks
authored andcommitted
Improve release page UI (#3693)
* Improve release page ui by adding size Signed-off-by: Jonas Franz <[email protected]> * Add documentation to a.MustSize() Signed-off-by: Jonas Franz <[email protected]>
1 parent 47422c2 commit 43fc430

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

models/attachment.go

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"os"
1212
"path"
1313

14+
"code.gitea.io/gitea/modules/log"
1415
"code.gitea.io/gitea/modules/setting"
1516
"code.gitea.io/gitea/modules/util"
1617
api "code.gitea.io/sdk/gitea"
@@ -75,6 +76,16 @@ func (a *Attachment) Size() (int64, error) {
7576
return fi.Size(), nil
7677
}
7778

79+
// MustSize returns the result of a.Size() by ignoring errors
80+
func (a *Attachment) MustSize() int64 {
81+
size, err := a.Size()
82+
if err != nil {
83+
log.Error(4, "size: %v", err)
84+
return 0
85+
}
86+
return size
87+
}
88+
7889
// DownloadURL returns the download url of the attached file
7990
func (a *Attachment) DownloadURL() string {
8091
return fmt.Sprintf("%sattachments/%s", setting.AppURL, a.UUID)

templates/repo/release/list.tmpl

+4-3
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,18 @@
6868
<ul class="list">
6969
{{if $.Repository.UnitEnabled $.UnitTypeCode}}
7070
<li>
71-
<a href="{{$.RepoLink}}/archive/{{.TagName}}.zip" rel="nofollow"><i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (ZIP)</a>
71+
<a href="{{$.RepoLink}}/archive/{{.TagName}}.zip" rel="nofollow"><strong><i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (ZIP)</strong></a>
7272
</li>
7373
<li>
74-
<a href="{{$.RepoLink}}/archive/{{.TagName}}.tar.gz"><i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (TAR.GZ)</a>
74+
<a href="{{$.RepoLink}}/archive/{{.TagName}}.tar.gz"><strong><i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (TAR.GZ)</strong></a>
7575
</li>
7676
{{end}}
7777
{{if .Attachments}}
7878
{{range .Attachments}}
7979
<li>
8080
<a target="_blank" rel="noopener" href="{{AppSubUrl}}/attachments/{{.UUID}}">
81-
<span class="ui image octicon octicon-desktop-download" title='{{.Name}}'></span> {{.Name}}
81+
<strong><span class="ui image octicon octicon-package" title='{{.Name}}'></span> {{.Name}}</strong>
82+
<span class="ui text grey right">{{.MustSize | FileSize}}</span>
8283
</a>
8384
</li>
8485
{{end}}

0 commit comments

Comments
 (0)