Skip to content

Commit 35d21b2

Browse files
committed
first change
1 parent 1ccdb54 commit 35d21b2

File tree

6 files changed

+267
-138
lines changed

6 files changed

+267
-138
lines changed

modules/context/repo.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,16 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
553553
ctx.ServerError("GetReleaseCountByRepoID", err)
554554
return nil
555555
}
556+
release, err := repo_model.GetLatestReleaseByRepoID(ctx, ctx.Repo.Repository.ID)
557+
if err != nil {
558+
ctx.ServerError("GetLatestReleaseByRepoID", err)
559+
return nil
560+
}
561+
if err = release.LoadAttributes(ctx); err != nil {
562+
ctx.ServerError("release.LoadAttributes", err)
563+
return nil
564+
}
565+
ctx.Data["LatestRelease"] = release
556566

557567
ctx.Data["Title"] = owner.Name + "/" + repo.Name
558568
ctx.Data["Repository"] = repo

options/locale/locale_en-US.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,13 @@ form.reach_limit_of_creation_n = The owner has already reached the limit of %d r
10531053
form.name_reserved = The repository name "%s" is reserved.
10541054
form.name_pattern_not_allowed = The pattern "%s" is not allowed in a repository name.
10551055

1056+
sidebar.readme = Readme
1057+
sidebar.stars = stars
1058+
sidebar.forks = forks
1059+
sidebar.watching = watching
1060+
sidebar.contributors = Contributors
1061+
latest_release = Latest
1062+
10561063
need_auth = Authorization
10571064
migrate_options = Migration Options
10581065
migrate_service = Migration Service

routers/web/repo/view.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ func renderCode(ctx *context.Context) {
10261026
}
10271027

10281028
ctx.Data["Paths"] = paths
1029+
ctx.Data["IsHomePage"] = len(paths) == 0
10291030
ctx.Data["TreeLink"] = treeLink
10301031
ctx.Data["TreeNames"] = treeNames
10311032
ctx.Data["BranchLink"] = branchLink

templates/repo/home.tmpl

Lines changed: 140 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,6 @@
44
<div class="ui container {{if .IsBlame}}fluid padded{{end}}">
55
{{template "base/alert" .}}
66
{{template "repo/code/recently_pushed_new_branches" .}}
7-
{{if and (not .HideRepoInfo) (not .IsBlame)}}
8-
<div class="ui repo-description">
9-
<div id="repo-desc" class="gt-font-16">
10-
{{$description := .Repository.DescriptionHTML $.Context}}
11-
{{if $description}}<span class="description">{{$description | RenderCodeBlock}}</span>{{else if .IsRepositoryAdmin}}<span class="no-description text-italic">{{ctx.Locale.Tr "repo.no_desc"}}</span>{{end}}
12-
<a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a>
13-
</div>
14-
{{if .RepoSearchEnabled}}
15-
<div class="ui repo-search">
16-
<form class="ui form ignore-dirty" action="{{.RepoLink}}/search" method="get">
17-
<div class="field">
18-
<div class="ui small action input{{if .CodeIndexerUnavailable}} disabled left icon{{end}}"{{if .CodeIndexerUnavailable}} data-tooltip-content="{{ctx.Locale.Tr "repo.search.code_search_unavailable"}}"{{end}}>
19-
<input name="q" value="{{.Keyword}}"{{if .CodeIndexerUnavailable}} disabled{{end}} placeholder="{{ctx.Locale.Tr "repo.search.search_repo"}}">
20-
{{if .CodeIndexerUnavailable}}
21-
<i class="icon">{{svg "octicon-alert"}}</i>
22-
{{end}}
23-
<button class="ui small icon button"{{if .CodeIndexerUnavailable}} disabled{{end}} type="submit">
24-
{{svg "octicon-search"}}
25-
</button>
26-
</div>
27-
</div>
28-
</form>
29-
</div>
30-
{{end}}
31-
</div>
32-
<div class="gt-df gt-ac gt-fw gt-gap-2" id="repo-topics">
33-
{{range .Topics}}<a class="ui repo-topic large label topic gt-m-0" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=1">{{.Name}}</a>{{end}}
34-
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}<button id="manage_topic" class="btn interact-fg gt-font-12">{{ctx.Locale.Tr "repo.topic.manage_topics"}}</button>{{end}}
35-
</div>
36-
{{end}}
37-
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}
38-
<div class="ui form gt-hidden gt-df gt-mt-4" id="topic_edit">
39-
<div class="field gt-f1 gt-mr-3">
40-
<div class="ui fluid multiple search selection dropdown" data-text-count-prompt="{{ctx.Locale.Tr "repo.topic.count_prompt"}}" data-text-format-prompt="{{ctx.Locale.Tr "repo.topic.format_prompt"}}">
41-
<input type="hidden" name="topics" value="{{range $i, $v := .Topics}}{{.Name}}{{if Eval $i "+" 1 "<" (len $.Topics)}},{{end}}{{end}}">
42-
{{range .Topics}}
43-
{{/* keey the same layout as Fomantic UI generated labels */}}
44-
<a class="ui label transition visible gt-cursor-default gt-dib" data-value="{{.Name}}">{{.Name}}{{svg "octicon-x" 16 "delete icon"}}</a>
45-
{{end}}
46-
<div class="text"></div>
47-
</div>
48-
</div>
49-
<div>
50-
<button class="ui basic button" id="cancel_topic_edit">{{ctx.Locale.Tr "cancel"}}</button>
51-
<button class="ui primary button" id="save_topic" data-link="{{.RepoLink}}/topics">{{ctx.Locale.Tr "save"}}</button>
52-
</div>
53-
</div>
54-
{{end}}
557
{{if .Repository.IsArchived}}
568
<div class="ui warning message gt-text-center">
579
{{if .Repository.ArchivedUnix.IsZero}}
@@ -61,105 +13,155 @@
6113
{{end}}
6214
</div>
6315
{{end}}
64-
{{template "repo/sub_menu" .}}
65-
<div class="repo-button-row">
66-
<div class="gt-df gt-ac gt-fw gt-gap-y-3">
67-
{{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "gt-mr-2"}}
68-
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
69-
{{$cmpBranch := ""}}
70-
{{if ne .Repository.ID .BaseRepo.ID}}
71-
{{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}}
72-
{{end}}
73-
{{$cmpBranch = print $cmpBranch (.BranchName|PathEscapeSegments)}}
74-
{{$compareLink := printf "%s/compare/%s...%s" .BaseRepo.Link (.BaseRepo.DefaultBranch|PathEscapeSegments) $cmpBranch}}
75-
<a id="new-pull-request" role="button" class="ui compact basic button" href="{{$compareLink}}"
76-
data-tooltip-content="{{if .PullRequestCtx.Allowed}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}">
77-
{{svg "octicon-git-pull-request"}}
78-
</a>
79-
{{end}}
80-
<!-- Show go to file and breadcrumbs if not on home page -->
81-
{{$n := len .TreeNames}}
82-
{{$l := Eval $n "-" 1}}
83-
{{if eq $n 0}}
84-
<a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button">{{ctx.Locale.Tr "repo.find_file.go_to_file"}}</a>
85-
{{end}}
86-
87-
{{if and .CanWriteCode .IsViewBranch (not .Repository.IsMirror) (not .Repository.IsArchived) (not .IsViewFile)}}
88-
<button class="ui dropdown basic compact jump button gt-mr-2"{{if not .Repository.CanEnableEditor}} disabled{{end}}>
89-
{{ctx.Locale.Tr "repo.editor.add_file"}}
90-
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
91-
<div class="menu">
92-
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
93-
{{ctx.Locale.Tr "repo.editor.new_file"}}
94-
</a>
95-
{{if .RepositoryUploadEnabled}}
96-
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
97-
{{ctx.Locale.Tr "repo.editor.upload_file"}}
98-
</a>
16+
<div class="repo-content">
17+
<div class="repo-content-main" data-home={{.IsHomePage}}>
18+
{{template "repo/sub_menu" .}}
19+
<div class="repo-button-row">
20+
<div class="gt-df gt-ac gt-fw gt-gap-y-3">
21+
{{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "gt-mr-2"}}
22+
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
23+
{{$cmpBranch := ""}}
24+
{{if ne .Repository.ID .BaseRepo.ID}}
25+
{{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}}
9926
{{end}}
100-
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
101-
{{ctx.Locale.Tr "repo.editor.patch"}}
27+
{{$cmpBranch = print $cmpBranch (.BranchName|PathEscapeSegments)}}
28+
{{$compareLink := printf "%s/compare/%s...%s" .BaseRepo.Link (.BaseRepo.DefaultBranch|PathEscapeSegments) $cmpBranch}}
29+
<a id="new-pull-request" role="button" class="ui compact basic button" href="{{$compareLink}}"
30+
data-tooltip-content="{{if .PullRequestCtx.Allowed}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}">
31+
{{svg "octicon-git-pull-request"}}
10232
</a>
103-
</div>
104-
</button>
105-
{{end}}
33+
{{end}}
34+
<!-- Show go to file and breadcrumbs if not on home page -->
35+
{{$n := len .TreeNames}}
36+
{{$l := Eval $n "-" 1}}
37+
{{if eq $n 0}}
38+
<a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button">{{ctx.Locale.Tr "repo.find_file.go_to_file"}}</a>
39+
{{end}}
10640

107-
{{if and (eq $n 0) (.Repository.IsTemplate)}}
108-
<a role="button" class="ui primary compact button" href="{{AppSubUrl}}/repo/create?template_id={{.Repository.ID}}">
109-
{{ctx.Locale.Tr "repo.use_template"}}
110-
</a>
111-
{{end}}
112-
{{if ne $n 0}}
113-
<span class="breadcrumb repo-path gt-ml-2">
114-
<a class="section" href="{{.RepoLink}}/src/{{.BranchNameSubURL}}" title="{{.Repository.Name}}">{{StringUtils.EllipsisString .Repository.Name 30}}</a>
115-
{{- range $i, $v := .TreeNames -}}
116-
<span class="breadcrumb-divider">/</span>
117-
{{- if eq $i $l -}}
118-
<span class="active section" title="{{$v}}">{{StringUtils.EllipsisString $v 30}}</span>
119-
{{- else -}}
120-
{{$p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{StringUtils.EllipsisString $v 30}}</a></span>
121-
{{- end -}}
122-
{{- end -}}
123-
</span>
124-
{{end}}
125-
</div>
126-
<div class="gt-df gt-ac">
127-
<!-- Only show clone panel in repository home page -->
128-
{{if eq $n 0}}
129-
<div class="ui action tiny input" id="clone-panel">
130-
{{template "repo/clone_buttons" .}}
131-
<button id="more-btn" class="ui basic small compact jump dropdown icon button" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}">
132-
{{svg "octicon-kebab-horizontal"}}
133-
<div class="menu">
134-
{{if not $.DisableDownloadSourceArchives}}
135-
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.download_zip"}}</a>
136-
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.download_tar"}}</a>
137-
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.bundle" rel="nofollow">{{svg "octicon-package" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.download_bundle"}}</a>
138-
{{if .CitiationExist}}
139-
<a class="item" id="cite-repo-button">{{svg "octicon-cross-reference" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.cite_this_repo"}}</a>
41+
{{if and .CanWriteCode .IsViewBranch (not .Repository.IsMirror) (not .Repository.IsArchived) (not .IsViewFile)}}
42+
<button class="ui dropdown basic compact jump button gt-mr-2"{{if not .Repository.CanEnableEditor}} disabled{{end}}>
43+
{{ctx.Locale.Tr "repo.editor.add_file"}}
44+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
45+
<div class="menu">
46+
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
47+
{{ctx.Locale.Tr "repo.editor.new_file"}}
48+
</a>
49+
{{if .RepositoryUploadEnabled}}
50+
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
51+
{{ctx.Locale.Tr "repo.editor.upload_file"}}
52+
</a>
14053
{{end}}
141-
{{end}}
142-
<a class="item js-clone-url-vsc" href="vscode://vscode.git/clone?url={{.CloneButtonOriginLink.HTTPS}}">{{svg "gitea-vscode" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.clone_in_vsc"}}</a>
54+
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
55+
{{ctx.Locale.Tr "repo.editor.patch"}}
56+
</a>
57+
</div>
58+
</button>
59+
{{end}}
60+
61+
{{if and (eq $n 0) (.Repository.IsTemplate)}}
62+
<a role="button" class="ui primary compact button" href="{{AppSubUrl}}/repo/create?template_id={{.Repository.ID}}">
63+
{{ctx.Locale.Tr "repo.use_template"}}
64+
</a>
65+
{{end}}
66+
{{if ne $n 0}}
67+
<span class="breadcrumb repo-path gt-ml-2">
68+
<a class="section" href="{{.RepoLink}}/src/{{.BranchNameSubURL}}" title="{{.Repository.Name}}">{{StringUtils.EllipsisString .Repository.Name 30}}</a>
69+
{{- range $i, $v := .TreeNames -}}
70+
<span class="breadcrumb-divider">/</span>
71+
{{- if eq $i $l -}}
72+
<span class="active section" title="{{$v}}">{{StringUtils.EllipsisString $v 30}}</span>
73+
{{- else -}}
74+
{{$p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{StringUtils.EllipsisString $v 30}}</a></span>
75+
{{- end -}}
76+
{{- end -}}
77+
</span>
78+
{{end}}
79+
</div>
80+
<div class="gt-df gt-ac">
81+
<!-- Only show clone panel in repository home page -->
82+
{{if eq $n 0}}
83+
<div class="ui action tiny input" id="clone-panel">
84+
{{template "repo/clone_buttons" .}}
85+
<button id="more-btn" class="ui basic small compact jump dropdown icon button" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}">
86+
{{svg "octicon-kebab-horizontal"}}
87+
<div class="menu">
88+
{{if not $.DisableDownloadSourceArchives}}
89+
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.download_zip"}}</a>
90+
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.download_tar"}}</a>
91+
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.bundle" rel="nofollow">{{svg "octicon-package" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.download_bundle"}}</a>
92+
{{if .CitiationExist}}
93+
<a class="item" id="cite-repo-button">{{svg "octicon-cross-reference" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.cite_this_repo"}}</a>
94+
{{end}}
95+
{{end}}
96+
<a class="item js-clone-url-vsc" href="vscode://vscode.git/clone?url={{.CloneButtonOriginLink.HTTPS}}">{{svg "gitea-vscode" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.clone_in_vsc"}}</a>
97+
</div>
98+
</button>
99+
{{template "repo/clone_script" .}}{{/* the script will update `.js-clone-url` and related elements */}}
143100
</div>
144-
</button>
145-
{{template "repo/clone_script" .}}{{/* the script will update `.js-clone-url` and related elements */}}
101+
{{template "repo/cite/cite_modal" .}}
102+
{{end}}
103+
{{if and (ne $n 0) (not .IsViewFile) (not .IsBlame)}}
104+
<a class="ui button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">
105+
{{svg "octicon-history" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.file_history"}}
106+
</a>
107+
{{end}}
146108
</div>
147-
{{template "repo/cite/cite_modal" .}}
148-
{{end}}
149-
{{if and (ne $n 0) (not .IsViewFile) (not .IsBlame)}}
150-
<a class="ui button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">
151-
{{svg "octicon-history" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.file_history"}}
152-
</a>
109+
</div>
110+
{{if .IsViewFile}}
111+
{{template "repo/view_file" .}}
112+
{{else if .IsBlame}}
113+
{{template "repo/blame" .}}
114+
{{else}}
115+
{{template "repo/view_list" .}}
153116
{{end}}
154117
</div>
118+
119+
<div class="repo-content-sidebar" data-home={{.IsHomePage}}>
120+
<div class="flex-list">
121+
{{template "repo/sidebar/repo_info" .}}
122+
123+
<div class="flex-item">
124+
<div class="flex-item-main">
125+
{{if .ReadmeExist}}
126+
<div class="flex-item-body">
127+
<a class="muted" href="{{.TreeLink}}/{{.FileName}}">
128+
{{svg "octicon-book"}}{{ctx.Locale.Tr "repo.sidebar.readme"}}
129+
</a>
130+
</div>
131+
{{end}}
132+
<div class="flex-item-body">
133+
{{svg "octicon-star"}}{{CountFmt .Repository.NumStars}} {{ctx.Locale.Tr "repo.sidebar.stars"}}
134+
</div>
135+
<div class="flex-item-body">
136+
{{svg "octicon-repo-forked"}}{{CountFmt .Repository.NumForks}} {{ctx.Locale.Tr "repo.sidebar.forks"}}
137+
</div>
138+
<div class="flex-item-body">
139+
{{svg "octicon-eye"}}{{CountFmt .Repository.NumWatches}} {{ctx.Locale.Tr "repo.sidebar.watching"}}
140+
</div>
141+
</div>
142+
</div>
143+
144+
{{if .LatestRelease}}
145+
<div class="flex-item">
146+
<div class="flex-item-main">
147+
<div class="flex-item-title">
148+
<a class="muted" href="{{.Link}}/releases">
149+
{{ctx.Locale.Tr "repo.releases"}}
150+
</a>
151+
<span class="ui basic label">{{CountFmt .NumReleases}}</span>
152+
</div>
153+
<div class="flex-item-body">
154+
<a class="muted" href="{{.LatestRelease.Link}}">
155+
{{svg "octicon-tag" 16 "gt-mr-2"}}{{.LatestRelease.TagName}}
156+
</a>
157+
<span class="ui basic green label">{{ctx.Locale.Tr "repo.latest_release"}}</span>
158+
</div>
159+
</div>
160+
</div>
161+
{{end}}
162+
</div>
163+
</div>
155164
</div>
156-
{{if .IsViewFile}}
157-
{{template "repo/view_file" .}}
158-
{{else if .IsBlame}}
159-
{{template "repo/blame" .}}
160-
{{else}}
161-
{{template "repo/view_list" .}}
162-
{{end}}
163165
</div>
164166
</div>
165167
{{template "base/footer" .}}

0 commit comments

Comments
 (0)