Skip to content

Commit 89cfe90

Browse files
Merge branch 'main' into lunny/upgrade_crypto
2 parents 1e34ea7 + 874b848 commit 89cfe90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+714
-826
lines changed

routers/api/packages/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ func CommonRoutes() *web.Router {
358358
r.Get("/PACKAGES", cran.EnumerateSourcePackages)
359359
r.Get("/PACKAGES{format}", cran.EnumerateSourcePackages)
360360
r.Get("/{filename}", cran.DownloadSourcePackageFile)
361+
r.Get("/Archive/{packagename}/{filename}", cran.DownloadSourcePackageFile)
361362
})
362363
r.Put("", reqPackageAccess(perm.AccessModeWrite), cran.UploadSourcePackageFile)
363364
})

routers/web/repo/view_home.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ func prepareOpenWithEditorApps(ctx *context.Context) {
7474
schema, _, _ := strings.Cut(app.OpenURL, ":")
7575
var iconHTML template.HTML
7676
if schema == "vscode" || schema == "vscodium" || schema == "jetbrains" {
77-
iconHTML = svg.RenderHTML(fmt.Sprintf("gitea-%s", schema), 16, "tw-mr-2")
77+
iconHTML = svg.RenderHTML(fmt.Sprintf("gitea-%s", schema), 16)
7878
} else {
79-
iconHTML = svg.RenderHTML("gitea-git", 16, "tw-mr-2") // TODO: it could support user's customized icon in the future
79+
iconHTML = svg.RenderHTML("gitea-git", 16) // TODO: it could support user's customized icon in the future
8080
}
8181
tmplApps = append(tmplApps, map[string]any{
8282
"DisplayName": app.DisplayName,

templates/repo/clone_buttons.tmpl

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
<!-- there is always at least one button (by context/repo.go) -->
2-
{{if $.CloneButtonShowHTTPS}}
3-
<button class="ui small button" id="repo-clone-https" data-link="{{$.CloneButtonOriginLink.HTTPS}}">
4-
HTTPS
1+
<!-- there is always at least one button (guaranteed by context/repo.go) -->
2+
<div class="ui action small input clone-buttons-combo">
3+
{{if $.CloneButtonShowHTTPS}}
4+
<button class="ui small button repo-clone-https" data-link="{{$.CloneButtonOriginLink.HTTPS}}">HTTPS</button>
5+
{{end}}
6+
{{if $.CloneButtonShowSSH}}
7+
<button class="ui small button repo-clone-ssh" data-link="{{$.CloneButtonOriginLink.SSH}}">SSH</button>
8+
{{end}}
9+
<input size="10" class="repo-clone-url js-clone-url" value="{{$.CloneButtonOriginLink.HTTPS}}" readonly>
10+
<button class="ui small icon button" data-clipboard-target=".repo-clone-url" data-tooltip-content="{{ctx.Locale.Tr "copy_url"}}">
11+
{{svg "octicon-copy" 14}}
512
</button>
6-
{{end}}
7-
{{if $.CloneButtonShowSSH}}
8-
<button class="ui small button" id="repo-clone-ssh" data-link="{{$.CloneButtonOriginLink.SSH}}">
9-
SSH
10-
</button>
11-
{{end}}
12-
<input id="repo-clone-url" size="10" class="js-clone-url" value="{{$.CloneButtonOriginLink.HTTPS}}" readonly>
13-
<button class="ui small icon button" id="clipboard-btn" data-tooltip-content="{{ctx.Locale.Tr "copy_url"}}" data-clipboard-target="#repo-clone-url" aria-label="{{ctx.Locale.Tr "copy_url"}}">
14-
{{svg "octicon-copy" 14}}
15-
</button>
13+
</div>

templates/repo/clone_panel.tmpl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<button class="ui green button js-btn-clone-panel">
2+
<span>{{svg "octicon-code" 16}} Code</span>
3+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
4+
</button>
5+
<div class="clone-panel-popup tippy-target">
6+
<div class="flex-text-block clone-panel-field">{{svg "octicon-terminal"}} Clone</div>
7+
8+
<div class="clone-panel-tab">
9+
<!-- there is always at least one button (guaranteed by context/repo.go) -->
10+
{{if $.CloneButtonShowHTTPS}}
11+
<button class="item repo-clone-https" data-link="{{$.CloneButtonOriginLink.HTTPS}}">HTTPS</button>
12+
{{end}}
13+
{{if $.CloneButtonShowSSH}}
14+
<button class="item repo-clone-ssh" data-link="{{$.CloneButtonOriginLink.SSH}}">SSH</button>
15+
{{end}}
16+
</div>
17+
<div class="divider"></div>
18+
19+
<div class="clone-panel-field">
20+
<div class="ui input tiny action">
21+
<input size="30" class="repo-clone-url js-clone-url" value="{{$.CloneButtonOriginLink.HTTPS}}" readonly>
22+
<div class="ui small compact icon button" data-clipboard-target=".js-clone-url" data-tooltip-content="{{ctx.Locale.Tr "copy_url"}}">
23+
{{svg "octicon-copy" 14}}
24+
</div>
25+
</div>
26+
</div>
27+
28+
{{if not .PageIsWiki}}
29+
<div class="flex-items-block clone-panel-list">
30+
{{range .OpenWithEditorApps}}
31+
<a class="item muted js-clone-url-editor" data-href-template="{{.OpenURL}}">{{.IconHTML}}{{ctx.Locale.Tr "repo.open_with_editor" .DisplayName}}</a>
32+
{{end}}
33+
</div>
34+
35+
{{if and (not $.DisableDownloadSourceArchives) $.RefName}}
36+
<div class="divider"></div>
37+
<div class="flex-items-block clone-panel-list">
38+
<a class="item muted archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.zip" rel="nofollow">{{svg "octicon-file-zip"}} {{ctx.Locale.Tr "repo.download_zip"}}</a>
39+
<a class="item muted archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}} {{ctx.Locale.Tr "repo.download_tar"}}</a>
40+
<a class="item muted archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.bundle" rel="nofollow">{{svg "octicon-package"}} {{ctx.Locale.Tr "repo.download_bundle"}}</a>
41+
</div>
42+
{{end}}
43+
{{end}}
44+
</div>

templates/repo/clone_script.tmpl

Lines changed: 0 additions & 50 deletions
This file was deleted.

templates/repo/empty.tmpl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737
</a>
3838
{{end}}
3939
{{end}}
40-
<div class="clone-panel ui action small input tw-flex-1">
41-
{{template "repo/clone_buttons" .}}
42-
</div>
40+
{{template "repo/clone_buttons" .}}
4341
</div>
4442
</div>
4543

@@ -73,7 +71,6 @@ git push -u origin {{.Repository.DefaultBranch}}</code></pre>
7371
{{ctx.Locale.Tr "repo.empty_message"}}
7472
</div>
7573
{{end}}
76-
{{template "repo/clone_script" .}}
7774
</div>
7875
</div>
7976
</div>

templates/repo/home.tmpl

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,10 @@
102102
{{end}}
103103
</div>
104104

105-
{{/* by default, the row-right flex grows, but on non-root tree path, it should not because the row-left might contain a long path */}}
106-
<div class="repo-button-row-right {{if not $isTreePathRoot}}tw-flex-grow-0{{end}}">
105+
<div class="repo-button-row-right">
107106
<!-- Only show clone panel in repository home page -->
108107
{{if $isTreePathRoot}}
109-
<div class="clone-panel ui action tiny input">
110-
{{template "repo/clone_buttons" .}}
111-
<button class="ui small jump dropdown icon button" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}">
112-
{{svg "octicon-kebab-horizontal"}}
113-
<div class="menu">
114-
{{if not $.DisableDownloadSourceArchives}}
115-
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_zip"}}</a>
116-
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_tar"}}</a>
117-
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.bundle" rel="nofollow">{{svg "octicon-package" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_bundle"}}</a>
118-
{{end}}
119-
{{range .OpenWithEditorApps}}
120-
<a class="item js-clone-url-editor" data-href-template="{{.OpenURL}}">{{.IconHTML}}{{ctx.Locale.Tr "repo.open_with_editor" .DisplayName}}</a>
121-
{{end}}
122-
</div>
123-
</button>
124-
{{template "repo/clone_script" .}}{{/* the script will update `.js-clone-url` and related elements */}}
125-
</div>
108+
{{template "repo/clone_panel" .}}
126109
{{end}}
127110
{{if and (not $isTreePathRoot) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home), TODO: split the templates, avoid using "if" tricks */}}
128111
<a class="ui button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">
@@ -140,6 +123,9 @@
140123
{{template "repo/code/upstream_diverging_info" .}}
141124
{{end}}
142125
{{template "repo/view_list" .}}
126+
{{if and .ReadmeExist (or .IsMarkup .IsPlainText)}}
127+
{{template "repo/view_file" .}}
128+
{{end}}
143129
{{end}}
144130
</div>
145131

templates/repo/latest_commit.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{if not .LatestCommit}}
2-
<div class="ui active tiny slow centered inline">…</div>
2+
33
{{else}}
44
{{if .LatestCommitUser}}
55
{{ctx.AvatarUtils.Avatar .LatestCommitUser 24 "tw-mr-1"}}

templates/repo/view_list.tmpl

Lines changed: 52 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,57 @@
1-
<table id="repo-files-table" class="ui single line fixed table tw-mt-0" {{if .HasFilesWithoutLatestCommit}}hx-indicator="tr.notready td.message span" hx-trigger="load" hx-swap="morph" hx-post="{{.LastCommitLoaderURL}}"{{end}}>
2-
<thead>
3-
<tr class="commit-list">
4-
<th class="tw-overflow-hidden" colspan="2">
5-
<div class="tw-flex">
6-
<div class="latest-commit">
7-
{{template "repo/latest_commit" .}}
8-
</div>
9-
</div>
10-
</th>
11-
<th class="text grey right age">{{if .LatestCommit}}{{if .LatestCommit.Committer}}{{DateUtils.TimeSince .LatestCommit.Committer.When}}{{end}}{{end}}</th>
12-
</tr>
13-
</thead>
14-
<tbody>
15-
{{if .HasParentPath}}
16-
<tr class="has-parent">
17-
<td colspan="3">{{svg "octicon-reply"}}<a class="muted" href="{{.BranchLink}}{{if .ParentPath}}{{PathEscapeSegments .ParentPath}}{{end}}">..</a></td>
18-
</tr>
19-
{{end}}
20-
{{range $item := .Files}}
1+
{{/* use grid layout, still use the old ID because there are many other CSS styles depending on this ID */}}
2+
<div id="repo-files-table" {{if .HasFilesWithoutLatestCommit}}hx-indicator="#repo-files-table .repo-file-cell.message" hx-trigger="load" hx-swap="morph" hx-post="{{.LastCommitLoaderURL}}"{{end}}>
3+
<div class="repo-file-line">
4+
<div class="latest-commit">{{template "repo/latest_commit" .}}</div>
5+
<div>{{if and .LatestCommit .LatestCommit.Committer}}{{DateUtils.TimeSince .LatestCommit.Committer.When}}{{end}}</div>
6+
</div>
7+
{{if .HasParentPath}}
8+
<div class="repo-file-line">
9+
{{svg "octicon-reply"}} <a class="muted" href="{{.BranchLink}}{{if .ParentPath}}{{PathEscapeSegments .ParentPath}}{{end}}">..</a>
10+
</div>
11+
{{end}}
12+
{{range $item := .Files}}
13+
<div class="repo-file-item">
2114
{{$entry := $item.Entry}}
2215
{{$commit := $item.Commit}}
2316
{{$subModuleFile := $item.SubModuleFile}}
24-
<tr data-entryname="{{$entry.Name}}" data-ready="{{if $commit}}true{{else}}false{{end}}" class="{{if not $commit}}not{{end}}ready entry">
25-
<td class="name four wide">
26-
<span class="truncate">
27-
{{if $entry.IsSubModule}}
28-
{{svg "octicon-file-submodule"}}
29-
{{$refURL := $subModuleFile.RefURL AppUrl $.Repository.FullName $.SSHDomain}} {{/* FIXME: the usage of AppUrl seems incorrect, it would be fixed in the future, use AppSubUrl instead */}}
30-
{{if $refURL}}
31-
<a class="muted" href="{{$refURL}}">{{$entry.Name}}</a><span class="at">@</span><a href="{{$refURL}}/commit/{{PathEscape $subModuleFile.RefID}}">{{ShortSha $subModuleFile.RefID}}</a>
17+
<div class="repo-file-cell name {{if not $commit}}notready{{end}}">
18+
{{if $entry.IsSubModule}}
19+
{{svg "octicon-file-submodule"}}
20+
{{$refURL := $subModuleFile.RefURL AppUrl $.Repository.FullName $.SSHDomain}} {{/* FIXME: the usage of AppUrl seems incorrect, it would be fixed in the future, use AppSubUrl instead */}}
21+
{{if $refURL}}
22+
<a class="muted" href="{{$refURL}}">{{$entry.Name}}</a><span class="at">@</span><a href="{{$refURL}}/commit/{{PathEscape $subModuleFile.RefID}}">{{ShortSha $subModuleFile.RefID}}</a>
23+
{{else}}
24+
{{$entry.Name}}<span class="at">@</span>{{ShortSha $subModuleFile.RefID}}
25+
{{end}}
26+
{{else}}
27+
{{if $entry.IsDir}}
28+
{{$subJumpablePathName := $entry.GetSubJumpablePathName}}
29+
{{svg "octicon-file-directory-fill"}}
30+
<a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $subJumpablePathName}}" title="{{$subJumpablePathName}}">
31+
{{$subJumpablePathFields := StringUtils.Split $subJumpablePathName "/"}}
32+
{{$subJumpablePathFieldLast := (Eval (len $subJumpablePathFields) "-" 1)}}
33+
{{if eq $subJumpablePathFieldLast 0}}
34+
{{$subJumpablePathName}}
3235
{{else}}
33-
{{$entry.Name}}<span class="at">@</span>{{ShortSha $subModuleFile.RefID}}
36+
{{$subJumpablePathPrefixes := slice $subJumpablePathFields 0 $subJumpablePathFieldLast}}
37+
<span class="text light-2">{{StringUtils.Join $subJumpablePathPrefixes "/"}}</span>/{{index $subJumpablePathFields $subJumpablePathFieldLast}}
3438
{{end}}
35-
{{else}}
36-
{{if $entry.IsDir}}
37-
{{$subJumpablePathName := $entry.GetSubJumpablePathName}}
38-
{{svg "octicon-file-directory-fill"}}
39-
<a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $subJumpablePathName}}" title="{{$subJumpablePathName}}">
40-
{{$subJumpablePathFields := StringUtils.Split $subJumpablePathName "/"}}
41-
{{$subJumpablePathFieldLast := (Eval (len $subJumpablePathFields) "-" 1)}}
42-
{{if eq $subJumpablePathFieldLast 0}}
43-
{{$subJumpablePathName}}
44-
{{else}}
45-
{{$subJumpablePathPrefixes := slice $subJumpablePathFields 0 $subJumpablePathFieldLast}}
46-
<span class="text light-2">{{StringUtils.Join $subJumpablePathPrefixes "/"}}</span>/{{index $subJumpablePathFields $subJumpablePathFieldLast}}
47-
{{end}}
48-
</a>
49-
{{else}}
50-
{{svg (printf "octicon-%s" (EntryIcon $entry))}}
51-
<a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $entry.Name}}" title="{{$entry.Name}}">{{$entry.Name}}</a>
52-
{{end}}
53-
{{end}}
54-
</span>
55-
</td>
56-
<td class="message nine wide">
57-
<span class="truncate">
58-
{{if $commit}}
59-
{{$commitLink := printf "%s/commit/%s" $.RepoLink (PathEscape $commit.ID.String)}}
60-
{{ctx.RenderUtils.RenderCommitMessageLinkSubject $commit.Message $commitLink ($.Repository.ComposeMetas ctx)}}
61-
{{else}}
62-
<div class="ui active tiny slow centered inline"></div>
63-
{{end}}
64-
</span>
65-
</td>
66-
<td class="text right age three wide">{{if $commit}}{{DateUtils.TimeSince $commit.Committer.When}}{{end}}</td>
67-
</tr>
68-
{{end}}
69-
</tbody>
70-
</table>
71-
{{if and .ReadmeExist (or .IsMarkup .IsPlainText)}}
72-
{{template "repo/view_file" .}}
73-
{{end}}
39+
</a>
40+
{{else}}
41+
{{svg (printf "octicon-%s" (EntryIcon $entry))}}
42+
<a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $entry.Name}}" title="{{$entry.Name}}">{{$entry.Name}}</a>
43+
{{end}}
44+
{{end}}
45+
</div>
46+
<div class="repo-file-cell message loading-icon-2px">
47+
{{if $commit}}
48+
{{$commitLink := printf "%s/commit/%s" $.RepoLink (PathEscape $commit.ID.String)}}
49+
{{ctx.RenderUtils.RenderCommitMessageLinkSubject $commit.Message $commitLink ($.Repository.ComposeMetas ctx)}}
50+
{{else}}
51+
… {{/* will be loaded again by LastCommitLoaderURL */}}
52+
{{end}}
53+
</div>
54+
<div class="repo-file-cell age">{{if $commit}}{{DateUtils.TimeSince $commit.Committer.When}}{{end}}</div>
55+
</div>
56+
{{end}}
57+
</div>

templates/repo/wiki/revision.tmpl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
</div>
1616
</div>
1717
<div class="ui eight wide column text right">
18-
<div class="clone-panel ui action small input">
19-
{{template "repo/clone_buttons" .}}
20-
{{template "repo/clone_script" .}}
21-
</div>
18+
{{template "repo/clone_panel" .}}
2219
</div>
2320
</div>
2421
<h2 class="ui top header">{{ctx.Locale.Tr "repo.wiki.wiki_page_revisions"}}</h2>

0 commit comments

Comments
 (0)