diff options
author | JakobDev <jakobdev@gmx.de> | 2024-04-24 17:15:55 +0200 |
---|---|---|
committer | Earl Warren <earl-warren@noreply.codeberg.org> | 2024-04-24 17:15:55 +0200 |
commit | 1bce2dc5c576b4818b407efcb04e90019bbe8af6 (patch) | |
tree | aa400298bf85acee51c750d1cdb65ecb1c72043d /templates | |
parent | Merge pull request 'UI: fix rounding of vertical menus on /issues, /pulls' (#... (diff) | |
download | forgejo-1bce2dc5c576b4818b407efcb04e90019bbe8af6.tar.xz forgejo-1bce2dc5c576b4818b407efcb04e90019bbe8af6.zip |
[FEAT]Add Option to hide Release Archive links (#3139)
This adds a new options to releases to hide the links to the automatically generated archives. This is useful, when the automatically generated Archives are broken e.g. because of Submodules.
![grafik](/attachments/5686edf6-f318-4175-8459-89c33973b181)
![grafik](/attachments/74a8bf92-2abb-47a0-876d-d41024770d0b)
Note:
This juts hides the Archives from the UI. Users can still download 5the Archive if they know t correct URL.
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3139
Reviewed-by: Otto <otto@codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: JakobDev <jakobdev@gmx.de>
Co-committed-by: JakobDev <jakobdev@gmx.de>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/repo/release/list.tmpl | 83 | ||||
-rw-r--r-- | templates/repo/release/new.tmpl | 9 | ||||
-rw-r--r-- | templates/swagger/v1_json.tmpl | 12 |
3 files changed, 64 insertions, 40 deletions
diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index 2d38cacfcd..4755da091a 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -61,46 +61,49 @@ <div class="markup desc"> {{$release.RenderedNote}} </div> - <div class="divider"></div> - <details class="download" {{if eq $idx 0}}open{{end}}> - <summary class="tw-my-4"> - {{ctx.Locale.Tr "repo.release.downloads"}} - </summary> - <ul class="list"> - {{$hasReleaseAttachment := gt (len $release.Attachments) 0}} - {{if and (not $.DisableDownloadSourceArchives) (not $release.IsDraft) ($.Permission.CanRead $.UnitTypeCode)}} - <li> - <a class="archive-link tw-flex-1" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.zip" rel="nofollow"><strong>{{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (ZIP)</strong></a> - <div class="tw-mr-1"> - <span class="text grey">{{ctx.Locale.TrN .Release.ArchiveDownloadCount.Zip "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .Release.ArchiveDownloadCount.Zip)}}</span> - </div> - <span data-tooltip-content="{{ctx.Locale.Tr "repo.release.system_generated"}}"> - {{svg "octicon-info"}} - </span> - </li> - <li class="{{if $hasReleaseAttachment}}start-gap{{end}}"> - <a class="archive-link tw-flex-1" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow"><strong>{{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (TAR.GZ)</strong></a> - <div class="tw-mr-1"> - <span class="text grey">{{ctx.Locale.TrN .Release.ArchiveDownloadCount.TarGz "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .Release.ArchiveDownloadCount.TarGz)}}</span> - </div> - <span data-tooltip-content="{{ctx.Locale.Tr "repo.release.system_generated"}}"> - {{svg "octicon-info"}} - </span> - </li> - {{if $hasReleaseAttachment}}<hr>{{end}} - {{end}} - {{range $release.Attachments}} - <li> - <a target="_blank" rel="nofollow" href="{{.DownloadURL}}" download> - <strong>{{svg "octicon-package" 16 "tw-mr-1"}}{{.Name}}</strong> - </a> - <div> - <span class="text grey">{{ctx.Locale.TrN .DownloadCount "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .DownloadCount)}} · {{.Size | ctx.Locale.TrSize}}</span> - </div> - </li> - {{end}} - </ul> - </details> + {{$hasReleaseAttachment := gt (len $release.Attachments) 0}} + {{$hasArchiveLinks := and (not $.DisableDownloadSourceArchives) (not $release.IsDraft) (not $release.HideArchiveLinks) ($.Permission.CanRead $.UnitTypeCode)}} + {{if or $hasArchiveLinks $hasReleaseAttachment}} + <div class="divider"></div> + <details class="download" {{if eq $idx 0}}open{{end}}> + <summary class="tw-my-4"> + {{ctx.Locale.Tr "repo.release.downloads"}} + </summary> + <ul class="list"> + {{if $hasArchiveLinks}} + <li> + <a class="archive-link tw-flex-1" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.zip" rel="nofollow"><strong>{{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (ZIP)</strong></a> + <div class="tw-mr-1"> + <span class="text grey">{{ctx.Locale.TrN .Release.ArchiveDownloadCount.Zip "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .Release.ArchiveDownloadCount.Zip)}}</span> + </div> + <span data-tooltip-content="{{ctx.Locale.Tr "repo.release.system_generated"}}"> + {{svg "octicon-info"}} + </span> + </li> + <li class="{{if $hasReleaseAttachment}}start-gap{{end}}"> + <a class="archive-link tw-flex-1" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow"><strong>{{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (TAR.GZ)</strong></a> + <div class="tw-mr-1"> + <span class="text grey">{{ctx.Locale.TrN .Release.ArchiveDownloadCount.TarGz "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .Release.ArchiveDownloadCount.TarGz)}}</span> + </div> + <span data-tooltip-content="{{ctx.Locale.Tr "repo.release.system_generated"}}"> + {{svg "octicon-info"}} + </span> + </li> + {{if $hasReleaseAttachment}}<hr>{{end}} + {{end}} + {{range $release.Attachments}} + <li> + <a target="_blank" rel="nofollow" href="{{.DownloadURL}}" download> + <strong>{{svg "octicon-package" 16 "tw-mr-1"}}{{.Name}}</strong> + </a> + <div> + <span class="text grey">{{ctx.Locale.TrN .DownloadCount "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .DownloadCount)}} · {{.Size | ctx.Locale.TrSize}}</span> + </div> + </li> + {{end}} + </ul> + </details> + {{end}} <div class="dot"></div> </div> </li> diff --git a/templates/repo/release/new.tmpl b/templates/repo/release/new.tmpl index 81104a70d2..e1881b1d94 100644 --- a/templates/repo/release/new.tmpl +++ b/templates/repo/release/new.tmpl @@ -98,6 +98,15 @@ </div> </div> <span class="help">{{ctx.Locale.Tr "repo.release.prerelease_helper"}}</span> + {{if not .DisableDownloadSourceArchives}} + <div class="field"> + <div class="ui checkbox"> + <input type="checkbox" name="hide_archive_links" {{if .hide_archive_links}}checked{{end}}> + <label><strong>{{ctx.Locale.Tr "repo.release.hide_archive_links"}}</strong></label> + </div> + </div> + <span class="help">{{ctx.Locale.Tr "repo.release.hide_archive_links_helper"}}</span> + {{end}} <div class="divider tw-mt-0"></div> <div class="tw-flex tw-justify-end"> {{if .PageIsEditRelease}} diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index c68a90a4c5..c49c6208ef 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -19890,6 +19890,10 @@ "type": "boolean", "x-go-name": "IsDraft" }, + "hide_archive_links": { + "type": "boolean", + "x-go-name": "HideArchiveLinks" + }, "name": { "type": "string", "x-go-name": "Title" @@ -20795,6 +20799,10 @@ "type": "boolean", "x-go-name": "IsDraft" }, + "hide_archive_links": { + "type": "boolean", + "x-go-name": "HideArchiveLinks" + }, "name": { "type": "string", "x-go-name": "Title" @@ -23562,6 +23570,10 @@ "type": "boolean", "x-go-name": "IsDraft" }, + "hide_archive_links": { + "type": "boolean", + "x-go-name": "HideArchiveLinks" + }, "html_url": { "type": "string", "x-go-name": "HTMLURL" |