Skip to content

Commit ebd430e

Browse files
committed
Set disable download source as global variables
1 parent 88210d2 commit ebd430e

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

modules/templates/base.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func BaseVars() Vars {
3939
"ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage,
4040
"ShowFooterBranding": setting.ShowFooterBranding,
4141
"ShowFooterVersion": setting.ShowFooterVersion,
42+
"DisabledDownloadSource": setting.Repository.DisabledDownloadSource,
4243

4344
"EnableSwagger": setting.API.EnableSwagger,
4445
"EnableOpenIDSignIn": setting.Service.EnableOpenIDSignIn,

routers/web/repo/release.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
7878
// Disable the showCreateNewBranch form in the dropdown on this page.
7979
ctx.Data["CanCreateBranch"] = false
8080
ctx.Data["HideBranchesInDropdown"] = true
81-
ctx.Data["DisabledDownloadSource"] = setting.Repository.DisabledDownloadSource
8281

8382
if isTagList {
8483
ctx.Data["Title"] = ctx.Tr("repo.release.tags")

templates/repo/branch/list.tmpl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@
2626
{{svg "octicon-git-branch"}}
2727
</div>
2828
{{end}}
29-
<div class="ui basic jump dropdown icon button tooltip" data-content="{{$.locale.Tr "repo.branch.download" ($.DefaultBranch)}}" data-position="top right">
30-
{{svg "octicon-download"}}
31-
<div class="menu">
32-
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.DefaultBranch}}.zip" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;ZIP</a>
33-
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.DefaultBranch}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;TAR.GZ</a>
29+
{{if not .DisabledDownloadSource}}
30+
<div class="ui basic jump dropdown icon button tooltip" data-content="{{$.locale.Tr "repo.branch.download" ($.DefaultBranch)}}" data-position="top right">
31+
{{svg "octicon-download"}}
32+
<div class="menu">
33+
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.DefaultBranch}}.zip" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;ZIP</a>
34+
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.DefaultBranch}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;TAR.GZ</a>
35+
</div>
3436
</div>
35-
</div>
37+
{{end}}
3638
</td>
3739
</tr>
3840
</tbody>

templates/repo/release/list.tmpl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737
<div class="download df ac">
3838
{{if $.Permission.CanRead $.UnitTypeCode}}
3939
<a class="mr-3 mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
40-
<a class="archive-link mr-3" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}ZIP</a>
41-
<a class="archive-link mr-3" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}TAR.GZ</a>
40+
{{if not $.DisabledDownloadSource}}
41+
<a class="archive-link mr-3" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}ZIP</a>
42+
<a class="archive-link mr-3" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-2"}}TAR.GZ</a>
43+
{{end}}
4244
{{if (and $.CanCreateRelease $release.IsTag)}}
4345
<a class="mr-3" href="{{$.RepoLink}}/releases/new?tag={{.TagName}}">{{svg "octicon-tag" 16 "mr-2"}}{{$.locale.Tr "repo.release.new_release"}}</a>
4446
{{end}}
@@ -104,8 +106,10 @@
104106
<div class="download">
105107
{{if $.Permission.CanRead $.UnitTypeCode}}
106108
<a class="mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
107-
<a class="archive-link" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;ZIP</a>
108-
<a class="archive-link" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;TAR.GZ</a>
109+
{{if not $.DisabledDownloadSource}}
110+
<a class="archive-link" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;ZIP</a>
111+
<a class="archive-link" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}}&nbsp;TAR.GZ</a>
112+
{{end}}
109113
{{end}}
110114
</div>
111115
{{else}}
@@ -146,7 +150,7 @@
146150
{{$.locale.Tr "repo.release.downloads"}}
147151
</summary>
148152
<ul class="list">
149-
{{if and (not .IsDraft) ($.Permission.CanRead $.UnitTypeCode)}}
153+
{{if and (not $.DisabledDownloadSource) (not .IsDraft) ($.Permission.CanRead $.UnitTypeCode)}}
150154
<li>
151155
<a class="archive-link" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow"><strong>{{svg "octicon-file-zip" 16 "mr-2"}}{{$.locale.Tr "repo.release.source_code"}} (ZIP)</strong></a>
152156
</li>

0 commit comments

Comments
 (0)