[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.   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>
This commit is contained in:
parent
6bcaf4f875
commit
1bce2dc5c5
14 changed files with 220 additions and 106 deletions
|
@ -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>
|
||||
|
|
|
@ -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}}
|
||||
|
|
12
templates/swagger/v1_json.tmpl
generated
12
templates/swagger/v1_json.tmpl
generated
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue