mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-03-04 16:24:46 +01:00

Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
* add MIME types `application/zip` and `application/gzip` to anchors of automatically generated archives. * add testing for that, and also for https://codeberg.org/forgejo/forgejo/pulls/2899 ## Why Many instances are struggling with crawlers that are fetching these links, causing archives to be generated. The content is actually never downloaded. [MDN describes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#type) this attribute as a "hint". So this hint can help a client to decide against fetching the href contents. I don't believe this change will actually improve the situation, however, I think this attribute is nice to have. ## MIME types It was a bit difficult to determine which are the right ones for this use case. [IANA lists](https://www.iana.org/assignments/media-types/media-types.xhtml) both `application/zip` and `application/gzip`. `application/zip` refers to [RFC6713](https://datatracker.ietf.org/doc/html/rfc6713) and `application/gzip` doesn't refer to an RFC directly. It also has [detailed information](https://www.iana.org/assignments/media-types/application/zip) about zip. [gzip is less detailed](https://www.iana.org/assignments/media-types/application/gzip). * [`application/zip`](https://www.iana.org/assignments/media-types/application/zip): > ZIP files are binary data and thus should be encoded for MIME mail transmission. This was written in 1993, but probably applies to the more modern web as well. * [`application/gzip`](https://datatracker.ietf.org/doc/rfc6713): > The 'application/gzip' media type describes a block of data that is compressed using gzip [RFC1952] compression. The data is a stream of bytes as described in RFC 1952. [RFC1952](https://datatracker.ietf.org/doc/rfc1952/) is a "GZIP file format specification", but there's a warning: "This RFC is not endorsed by the IETF and has no formal standing in the IETF standards process.". Anyway, I consider it as the right way to mark .tar.gz files too. Additional stuff that I read while researching: * https://stackoverflow.com/questions/2110269/add-mime-type-to-html-link Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6959 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Otto <otto@codeberg.org> Co-authored-by: 0ko <0ko@noreply.codeberg.org> Co-committed-by: 0ko <0ko@noreply.codeberg.org>
142 lines
6.9 KiB
Go HTML Template
142 lines
6.9 KiB
Go HTML Template
{{template "base/head" .}}
|
|
<div role="main" aria-label="{{.Title}}" class="page-content repository releases">
|
|
{{template "repo/header" .}}
|
|
<div class="ui container">
|
|
{{template "base/alert" .}}
|
|
{{template "repo/release_tag_header" .}}
|
|
<ul id="release-list">
|
|
{{range $idx, $info := .Releases}}
|
|
{{$release := $info.Release}}
|
|
<li class="ui grid">
|
|
<div class="ui four wide column meta">
|
|
<a class="muted" href="{{if not (and $release.Sha1 ($.Permission.CanRead $.UnitTypeCode))}}#{{else}}{{$.RepoLink}}/src/tag/{{$release.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "tw-mr-1"}}{{$release.TagName}}</a>
|
|
{{if and $release.Sha1 ($.Permission.CanRead $.UnitTypeCode)}}
|
|
<a class="muted tw-font-mono" href="{{$.RepoLink}}/src/commit/{{$release.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha $release.Sha1}}</a>
|
|
{{template "repo/branch_dropdown" dict "root" $ "release" $release}}
|
|
{{end}}
|
|
</div>
|
|
<div class="ui twelve wide column detail">
|
|
<div class="tw-flex tw-items-center tw-justify-between tw-flex-wrap tw-mb-2">
|
|
<h4 class="release-list-title tw-break-anywhere">
|
|
<a href="{{$.RepoLink}}/releases/tag/{{$release.TagName | PathEscapeSegments}}">{{$release.Title}}</a>
|
|
{{template "repo/commit_statuses" dict "Status" $info.CommitStatus "Statuses" $info.CommitStatuses "AdditionalClasses" "tw-flex"}}
|
|
{{if $release.IsDraft}}
|
|
<span class="ui yellow label">{{ctx.Locale.Tr "repo.release.draft"}}</span>
|
|
{{else if $release.IsPrerelease}}
|
|
<span class="ui orange label">{{ctx.Locale.Tr "repo.release.prerelease"}}</span>
|
|
{{else if (not $release.IsTag)}}
|
|
<span class="ui green label">{{ctx.Locale.Tr "repo.release.stable"}}</span>
|
|
{{end}}
|
|
</h4>
|
|
<div>
|
|
{{if $.CanCreateRelease}}
|
|
<a class="muted" data-tooltip-content="{{ctx.Locale.Tr "repo.release.edit"}}" href="{{$.RepoLink}}/releases/edit/{{$release.TagName | PathEscapeSegments}}" rel="nofollow">
|
|
{{svg "octicon-pencil"}}
|
|
</a>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
<p class="text grey">
|
|
<span class="author">
|
|
{{if $release.OriginalAuthor}}
|
|
{{svg (MigrationIcon $release.Repo.GetOriginalURLHostname) 20 "tw-mr-1"}}{{$release.OriginalAuthor}}
|
|
{{else if $release.Publisher}}
|
|
{{ctx.AvatarUtils.Avatar $release.Publisher 20 "tw-mr-1"}}
|
|
<a href="{{$release.Publisher.HomeLink}}">{{$release.Publisher.GetDisplayName}}</a>
|
|
{{else}}
|
|
Ghost
|
|
{{end}}
|
|
</span>
|
|
<span class="released">
|
|
{{ctx.Locale.Tr "repo.released_this"}}
|
|
</span>
|
|
{{if $release.CreatedUnix}}
|
|
<span class="time">{{DateUtils.TimeSince $release.CreatedUnix}}</span>
|
|
{{end}}
|
|
{{if and (not $release.IsDraft) ($.Permission.CanRead $.UnitTypeCode)}}
|
|
| <span class="ahead"><a href="{{$.RepoLink}}/compare/{{$release.TagName | PathEscapeSegments}}...{{$release.TargetBehind | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.release.ahead.commits" $release.NumCommitsBehind}}</a> {{ctx.Locale.Tr "repo.release.ahead.target" $release.TargetBehind}}</span>
|
|
{{end}}
|
|
</p>
|
|
{{template "repo/tag/verification_line" (dict "ctxData" $ "release" $release)}}
|
|
<div class="markup desc">
|
|
{{$release.RenderedNote}}
|
|
</div>
|
|
{{$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 flex-text-inline tw-font-bold" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.zip" rel="nofollow" type="application/zip">
|
|
{{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (ZIP)
|
|
</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 flex-text-inline tw-font-bold" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow" type="application/gzip">
|
|
{{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (TAR.GZ)
|
|
</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}}
|
|
{{if .ExternalURL}}
|
|
<li>
|
|
<a class="tw-flex-1 flex-text-inline tw-font-bold" target="_blank" rel="nofollow" href="{{.DownloadURL}}" download>
|
|
{{svg "octicon-link-external" 16 "tw-mr-1"}}{{.Name}}
|
|
</a>
|
|
</li>
|
|
{{else}}
|
|
<li>
|
|
<a class="tw-flex-1 flex-text-inline tw-font-bold" target="_blank" rel="nofollow" href="{{.DownloadURL}}" download>
|
|
{{svg "octicon-package" 16 "tw-mr-1"}}{{.Name}}
|
|
</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}}
|
|
{{end}}
|
|
</ul>
|
|
</details>
|
|
{{end}}
|
|
<div class="dot"></div>
|
|
</div>
|
|
</li>
|
|
{{end}}
|
|
</ul>
|
|
|
|
{{template "base/paginate" .}}
|
|
</div>
|
|
</div>
|
|
|
|
{{if (and ($.Permission.CanWrite $.UnitTypeCode) .PageIsTagList)}}
|
|
<div class="ui g-modal-confirm delete modal">
|
|
<div class="header">
|
|
{{svg "octicon-trash"}}
|
|
{{ctx.Locale.Tr "repo.release.delete_tag"}}
|
|
</div>
|
|
<div class="content">
|
|
<p>{{ctx.Locale.Tr "repo.release.deletion_tag_desc"}}</p>
|
|
</div>
|
|
{{template "base/modal_actions_confirm" .}}
|
|
</div>
|
|
{{end}}
|
|
|
|
{{template "base/footer" .}}
|