From 83fe8c9f445b915ef6e2d992352157f2cfcf580b Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Tue, 8 Oct 2024 04:34:45 +0000 Subject: [PATCH 01/48] wip --- options/locale/locale_en-US.ini | 2 +- routers/web/repo/view.go | 21 ++ templates/repo/home.tmpl | 350 ++++++++++++++++++++------------ templates/repo/sub_menu.tmpl | 22 -- web_src/css/repo.css | 21 +- 5 files changed, 261 insertions(+), 155 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index f77fd203a2d6b..cabb72c5b8d9f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1032,7 +1032,7 @@ generate_repo = Generate Repository generate_from = Generate From repo_desc = Description repo_desc_helper = Enter short description (optional) -repo_lang = Language +repo_lang = Languages repo_gitignore_helper = Select .gitignore templates. repo_gitignore_helper_desc = Choose which files not to track from a list of templates for common languages. Typical artifacts generated by each language's build tools are included on .gitignore by default. issue_labels = Issue Labels diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 12d202e4a0d45..106ece0880b1b 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -902,6 +902,22 @@ func renderLanguageStats(ctx *context.Context) { ctx.Data["LanguageStats"] = langs } +func renderLatestRelease(ctx *context.Context) { + release, err := repo_model.GetLatestReleaseByRepoID(ctx, ctx.Repo.Repository.ID) + if err != nil && !repo_model.IsErrReleaseNotExist(err) { + ctx.ServerError("GetLatestReleaseByRepoID", err) + return + } + + if release != nil { + if err = release.LoadAttributes(ctx); err != nil { + ctx.ServerError("release.LoadAttributes", err) + return + } + ctx.Data["LatestRelease"] = release + } +} + func renderRepoTopics(ctx *context.Context) { topics, err := db.Find[repo_model.Topic](ctx, &repo_model.FindTopicOptions{ RepoID: ctx.Repo.Repository.ID, @@ -1014,6 +1030,11 @@ func renderHomeCode(ctx *context.Context) { return } + renderLatestRelease(ctx) + if ctx.Written() { + return + } + if entry.IsDir() { renderDirectory(ctx) } else { diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index ff82f2ca80360..489a2f017263b 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -4,154 +4,242 @@
From 3720d0e630234a5f5b6d7999c58132d66c47ebe6 Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Tue, 3 Dec 2024 06:51:43 +0000
Subject: [PATCH 22/48] fix branch-selector-dropdown width
---
web_src/css/repo.css | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/web_src/css/repo.css b/web_src/css/repo.css
index 6f7c18f6fd7ad..8a2e4fead301f 100644
--- a/web_src/css/repo.css
+++ b/web_src/css/repo.css
@@ -2195,7 +2195,7 @@ td .commit-summary {
flex-grow: 0;
}
-@media (max-width: 991px) {
+@media (max-width: 1200px) {
.repository:not(.wiki) .repo-button-row {
flex-direction: column;
align-items: stretch;
@@ -2839,9 +2839,9 @@ tbody.commit-list {
/* FIXME: These media selectors are not ideal (just keep them from old code).
There are many different pages, some need the max-width while some others don't,
they should be tested and improved in the future. */
-@media (min-width: 768px) and (max-width: 991.98px) {
+@media (min-width: 768px) and (max-width: 1235px) {
.branch-selector-dropdown .branch-dropdown-button {
- max-width: 185px;
+ max-width: 301px;
}
}
From ac44d90e040bfd54d9770b69143a98f633dcb546 Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Tue, 3 Dec 2024 07:12:15 +0000
Subject: [PATCH 23/48] fix lint
---
templates/repo/home.tmpl | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index f463228f67237..ce370d21f2a66 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -32,23 +32,23 @@
- {{$branchDropdownCurrentRefType := "branch"}}
- {{$branchDropdownCurrentRefShortName := .BranchName}}
- {{if .IsViewTag}}
- {{$branchDropdownCurrentRefType = "tag"}}
- {{$branchDropdownCurrentRefShortName = .TagName}}
- {{end}}
- {{template "repo/branch_dropdown" dict
- "Repository" .Repository
- "ShowTabBranches" true
- "ShowTabTags" true
- "CurrentRefType" $branchDropdownCurrentRefType
- "CurrentRefShortName" $branchDropdownCurrentRefShortName
- "CurrentTreePath" .TreePath
- "RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}"
- "AllowCreateNewRef" .CanCreateBranch
- "ShowViewAllRefsEntry" true
- }}
+ {{$branchDropdownCurrentRefType := "branch"}}
+ {{$branchDropdownCurrentRefShortName := .BranchName}}
+ {{if .IsViewTag}}
+ {{$branchDropdownCurrentRefType = "tag"}}
+ {{$branchDropdownCurrentRefShortName = .TagName}}
+ {{end}}
+ {{template "repo/branch_dropdown" dict
+ "Repository" .Repository
+ "ShowTabBranches" true
+ "ShowTabTags" true
+ "CurrentRefType" $branchDropdownCurrentRefType
+ "CurrentRefShortName" $branchDropdownCurrentRefShortName
+ "CurrentTreePath" .TreePath
+ "RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}"
+ "AllowCreateNewRef" .CanCreateBranch
+ "ShowViewAllRefsEntry" true
+ }}
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
{{$cmpBranch := ""}}
{{if ne .Repository.ID .BaseRepo.ID}}
From c562e11091616a675177fc91320541eeea673962 Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Tue, 3 Dec 2024 07:16:55 +0000
Subject: [PATCH 24/48] fix topic overflow bug
---
templates/repo/home.tmpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index ce370d21f2a66..2b1f617891849 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -151,7 +151,7 @@
-
{{end}}
- {{if and (.Permission.CanRead ctx.Consts.RepoUnitTypeCode) (not .IsEmptyRepo) .LanguageStats}}
+ {{if and (not .IsEmptyRepo) .LanguageStats}}
+
{{template "repo/home_share_sidebar" .}}
From 5c0e899b4c02b6a2360dea5d96bf780fed0f9f6f Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Tue, 3 Dec 2024 07:24:39 +0000
Subject: [PATCH 25/48] fix label word break
---
templates/repo/home_share_sidebar.tmpl | 2 +-
web_src/css/repo.css | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/templates/repo/home_share_sidebar.tmpl b/templates/repo/home_share_sidebar.tmpl
index c539d4190b409..1bde9bbfee78e 100644
--- a/templates/repo/home_share_sidebar.tmpl
+++ b/templates/repo/home_share_sidebar.tmpl
@@ -11,7 +11,7 @@
{{/* it should match the code in issue-home.js */}}
- {{range .Topics}}{{.Name}}{{end}}
+ {{range .Topics}}{{.Name}}{{end}}
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}
From 4373ad1a623e9756507cd6356edf388017f3b239 Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Thu, 5 Dec 2024 01:29:05 +0000
Subject: [PATCH 30/48] remove jQuery
---
web_src/js/features/citation.ts | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/web_src/js/features/citation.ts b/web_src/js/features/citation.ts
index bdc4dc7024c76..af8cedffbd995 100644
--- a/web_src/js/features/citation.ts
+++ b/web_src/js/features/citation.ts
@@ -30,7 +30,8 @@ export async function initCitationFileCopyContent() {
const citationCopyApa = document.querySelector
-
+
{{if .Repository.IsArchived}}
-{{end}}
\ No newline at end of file
+{{end}}
From b83d4d01b472c9bd2c11e2c55c416589220a511f Mon Sep 17 00:00:00 2001
From: wxiaoguang
{{if .Repository.ArchivedUnix.IsZero}}
From a4b0b0ee8d4166ebdbc620e7975bd2cbd7ae1aaa Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Thu, 5 Dec 2024 06:29:41 +0000
Subject: [PATCH 36/48] improve
---
web_src/js/features/citation.ts | 54 +++++++++++++++++---------------
web_src/js/features/repo-home.ts | 8 +++--
2 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/web_src/js/features/citation.ts b/web_src/js/features/citation.ts
index 705554ce7af42..b703a84f675ec 100644
--- a/web_src/js/features/citation.ts
+++ b/web_src/js/features/citation.ts
@@ -42,34 +42,38 @@ export async function initCitationFileCopyContent() {
citationCopyApa.classList.toggle('primary', !isBibtex);
};
- document.querySelector('#cite-repo-button')?.addEventListener('click', async () => {
- fomanticQuery(elModal).modal('show');
- elModal.classList.add('is-loading');
+ const citeBtnMobile = document.querySelector
-
From 16d77d8b7169052d9cf00cb4fb65be521c7bae15 Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Fri, 6 Dec 2024 06:41:10 +0000
Subject: [PATCH 41/48] fix lint
---
templates/repo/home_sidebar_foot.tmpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/repo/home_sidebar_foot.tmpl b/templates/repo/home_sidebar_foot.tmpl
index af2ce00539754..039764ee35439 100644
--- a/templates/repo/home_sidebar_foot.tmpl
+++ b/templates/repo/home_sidebar_foot.tmpl
@@ -58,4 +58,4 @@
+
\ No newline at end of file
+
+
-
{{if .Repository.IsArchived}}
{{end}}
{{if .Repository.ArchivedUnix.IsZero}}
@@ -20,14 +20,6 @@
{{$l := Eval $n "-" 1}}
{{$isHomepage := (eq $n 0)}}
- {{if $isHomepage}}
-
\ No newline at end of file
diff --git a/web_src/css/modules/flexcontainer.css b/web_src/css/modules/flexcontainer.css
index 02fc702f58211..5d4e12cc129b1 100644
--- a/web_src/css/modules/flexcontainer.css
+++ b/web_src/css/modules/flexcontainer.css
@@ -21,10 +21,6 @@
min-width: 0; /* make the "text truncate" work, otherwise the flex axis is not limited and the text just overflows */
}
-.flex-container-repo {
- width: 25%;
-}
-
@media (max-width: 767.98px) {
.flex-container {
flex-direction: column;
@@ -34,7 +30,4 @@
order: -1;
width: auto;
}
- .flex-container-repo {
- width: auto;
- }
}
diff --git a/web_src/css/repo/home.css b/web_src/css/repo/home.css
index 5cfc8bede37b4..3884718b4eb17 100644
--- a/web_src/css/repo/home.css
+++ b/web_src/css/repo/home.css
@@ -1,3 +1,52 @@
+.repo-home-content {
+ display: grid;
+ grid-template-columns: auto 300px;
+ grid-template-rows: auto auto 1fr;
+}
+
+.repo-home-main {
+ grid-column: 1;
+ grid-row: 1 / 4;
+}
+
+.repo-home-head {
+ grid-column: 2;
+ grid-row: 1;
+ padding-left: 10px;
+}
+
+.repo-home-foot {
+ grid-column: 2;
+ grid-row: 2;
+ padding-left: 10px;
+}
+
+.repo-home-foot > :first-child {
+ border-top: 1px solid var(--color-secondary); /* same to .flex-list > .flex-item + .flex-item { */
+}
+
+@media (max-width: 767.98px) {
+ .repo-home-content {
+ grid-template-columns: 100%;
+ grid-template-rows: auto auto auto;
+ }
+ .repo-home-main {
+ grid-column: 1;
+ grid-row: 2;
+ }
+ .repo-home-head {
+ grid-column: 1;
+ grid-row: 1;
+ }
+ .repo-home-foot {
+ grid-column: 1;
+ grid-row: 3;
+ }
+ .repo-home-foot > :first-child {
+ border-top: 0;
+ }
+}
+
.language-stats {
display: flex;
gap: 2px;
diff --git a/web_src/js/features/citation.ts b/web_src/js/features/citation.ts
index b703a84f675ec..fc5bb38f0aeca 100644
--- a/web_src/js/features/citation.ts
+++ b/web_src/js/features/citation.ts
@@ -30,7 +30,6 @@ export async function initCitationFileCopyContent() {
const citationCopyApa = document.querySelector
- {{template "repo/home_search_code" .}}
-
-
- {{template "repo/home_share_sidebar" .}}
-
- {{end}}
{{template "repo/sub_menu" .}}
@@ -143,80 +135,12 @@
{{template "repo/view_list" .}}
{{end}}
-
{{if $isHomepage}}
-
-
diff --git a/templates/repo/home_search_code.tmpl b/templates/repo/home_search_code.tmpl
deleted file mode 100644
index 63ff6c148d2bd..0000000000000
--- a/templates/repo/home_search_code.tmpl
+++ /dev/null
@@ -1,6 +0,0 @@
-
- {{template "repo/home_search_code" .}}
-
-
-
-
+
- {{template "repo/home_share_sidebar" .}}
-
-
- {{if .LatestRelease}}
-
-
- {{end}}
-
- {{if and (not .IsEmptyRepo) .LanguageStats}}
-
-
-
-
-
-
- {{svg "octicon-tag" 16}}
-
-
-
-
-
-
- {{.LatestRelease.Title}}
- {{ctx.Locale.Tr "latest"}}
-
-
- {{DateUtils.TimeSince .LatestRelease.CreatedUnix}}
-
-
-
- {{end}}
-
-
-
- {{ctx.Locale.Tr "repo.repo_lang"}}
-
-
-
-
-
- {{range .LanguageStats}}
-
- {{end}}
-
-
- {{range .LanguageStats}}
-
-
-
-
- {{if eq .Language "other"}}
- {{ctx.Locale.Tr "repo.language_other"}}
- {{else}}
- {{.Language}}
- {{end}}
-
- {{.Percentage}}%
-
- {{end}}
-
+ {{template "repo/home_sidebar_head" .}}
+
+
+ {{template "repo/home_sidebar_foot" .}}
{{end}}
-
- {{template "shared/search/button"}}
-
-
+
+{{end}}
+
+{{if and (not .IsEmptyRepo) .LanguageStats}}
+
+
+
+
+
+
+ {{svg "octicon-tag" 16}}
+
+
+
+
+
+
+ {{.LatestRelease.Title}}
+ {{ctx.Locale.Tr "latest"}}
+
+
+ {{DateUtils.TimeSince .LatestRelease.CreatedUnix}}
+
+
+
+{{end}}
\ No newline at end of file
diff --git a/templates/repo/home_share_sidebar.tmpl b/templates/repo/home_sidebar_head.tmpl
similarity index 90%
rename from templates/repo/home_share_sidebar.tmpl
rename to templates/repo/home_sidebar_head.tmpl
index 1bde9bbfee78e..4ea6f2dce844c 100644
--- a/templates/repo/home_share_sidebar.tmpl
+++ b/templates/repo/home_sidebar_head.tmpl
@@ -1,3 +1,12 @@
+
+
+
+ {{ctx.Locale.Tr "repo.repo_lang"}}
+
+
+
+
+
+ {{range .LanguageStats}}
+
+ {{end}}
+
+
+ {{range .LanguageStats}}
+
+
+
+
+ {{if eq .Language "other"}}
+ {{ctx.Locale.Tr "repo.language_other"}}
+ {{else}}
+ {{.Language}}
+ {{end}}
+
+ {{.Percentage}}%
+
+ {{end}}
+
+
+
+
+ {{template "shared/search/button"}}
+
+
@@ -53,4 +62,4 @@
{{end}}
-
+
-
-
-
-
-
- {{svg "octicon-tag" 16}}
-
-
-
-
-
-
- {{.LatestRelease.Title}}
- {{ctx.Locale.Tr "latest"}}
-
-
- {{DateUtils.TimeSince .LatestRelease.CreatedUnix}}
-
-
+
{{end}}
{{if and (not .IsEmptyRepo) .LanguageStats}}
-
+
+
+
+
+
+ {{svg "octicon-tag" 16}}
+
+
+
+
+
+
+ {{.LatestRelease.Title}}
+ {{ctx.Locale.Tr "latest"}}
+
+
+ {{DateUtils.TimeSince .LatestRelease.CreatedUnix}}
+
+
-
{{end}}
\ No newline at end of file
diff --git a/templates/repo/home_sidebar_head.tmpl b/templates/repo/home_sidebar_head.tmpl
index 4ea6f2dce844c..c2554335a0fa6 100644
--- a/templates/repo/home_sidebar_head.tmpl
+++ b/templates/repo/home_sidebar_head.tmpl
@@ -62,4 +62,4 @@
-
+
- {{ctx.Locale.Tr "repo.repo_lang"}}
-
+
+
+
+
-
+ {{ctx.Locale.Tr "repo.repo_lang"}}
+
-
-
-
- {{range .LanguageStats}}
-
- {{end}}
-
-
- {{range .LanguageStats}}
-
-
-
-
- {{if eq .Language "other"}}
- {{ctx.Locale.Tr "repo.language_other"}}
- {{else}}
- {{.Language}}
- {{end}}
-
- {{.Percentage}}%
-
- {{end}}
-
+
+
+ {{range .LanguageStats}}
+
+ {{end}}
+
+
+ {{range .LanguageStats}}
+
+
+
+
+ {{if eq .Language "other"}}
+ {{ctx.Locale.Tr "repo.language_other"}}
+ {{else}}
+ {{.Language}}
+ {{end}}
+
+ {{.Percentage}}%
+
+ {{end}}
+
- {{/* it should match the code in issue-home.js */}}
+ {{/* !!!! it SHOULD and MUST match the code in issue-home.js */}}
{{range .Topics}}{{.Name}}{{end}}
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}
{{template "base/alert" .}}
- {{template "repo/code/recently_pushed_new_branches" .}}
-
-
- {{if .Repository.IsArchived}}
-
- {{if .Repository.ArchivedUnix.IsZero}}
- {{ctx.Locale.Tr "repo.archive.title"}}
- {{else}}
- {{ctx.Locale.Tr "repo.archive.title_date" (DateUtils.AbsoluteLong .Repository.ArchivedUnix)}}
- {{end}}
-
+ {{if .Repository.IsArchived}}
+
+ {{if .Repository.ArchivedUnix.IsZero}}
+ {{ctx.Locale.Tr "repo.archive.title"}}
+ {{else}}
+ {{ctx.Locale.Tr "repo.archive.title_date" (DateUtils.AbsoluteLong .Repository.ArchivedUnix)}}
{{end}}
- {{$n := len .TreeNames}}
- {{$l := Eval $n "-" 1}}
- {{$isHomepage := (eq $n 0)}}
+
+ {{end}}
- {{template "repo/sub_menu" .}}
+ {{template "repo/code/recently_pushed_new_branches" .}}
-
+ {{$treeNamesLen := len .TreeNames}}
+ {{$isTreePathRoot := eq $treeNamesLen 0}}
+ {{$showSidebar := $isTreePathRoot}}
+
+
+ {{template "repo/sub_menu" .}}
+
diff --git a/templates/repo/home_sidebar_foot.tmpl b/templates/repo/home_sidebar_bottom.tmpl
similarity index 88%
rename from templates/repo/home_sidebar_foot.tmpl
rename to templates/repo/home_sidebar_bottom.tmpl
index 039764ee35439..fbc277a6c011e 100644
--- a/templates/repo/home_sidebar_foot.tmpl
+++ b/templates/repo/home_sidebar_bottom.tmpl
@@ -1,4 +1,5 @@
-{{if .LatestRelease}}
+
{{$branchDropdownCurrentRefType := "branch"}}
{{$branchDropdownCurrentRefShortName := .BranchName}}
{{if .IsViewTag}}
- {{$branchDropdownCurrentRefType = "tag"}}
- {{$branchDropdownCurrentRefShortName = .TagName}}
+ {{$branchDropdownCurrentRefType = "tag"}}
+ {{$branchDropdownCurrentRefShortName = .TagName}}
{{end}}
{{template "repo/branch_dropdown" dict
- "Repository" .Repository
- "ShowTabBranches" true
- "ShowTabTags" true
- "CurrentRefType" $branchDropdownCurrentRefType
- "CurrentRefShortName" $branchDropdownCurrentRefShortName
- "CurrentTreePath" .TreePath
- "RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}"
- "AllowCreateNewRef" .CanCreateBranch
- "ShowViewAllRefsEntry" true
+ "Repository" .Repository
+ "ShowTabBranches" true
+ "ShowTabTags" true
+ "CurrentRefType" $branchDropdownCurrentRefType
+ "CurrentRefShortName" $branchDropdownCurrentRefShortName
+ "CurrentTreePath" .TreePath
+ "RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}"
+ "AllowCreateNewRef" .CanCreateBranch
+ "ShowViewAllRefsEntry" true
}}
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
{{$cmpBranch := ""}}
@@ -53,8 +53,9 @@
{{svg "octicon-git-pull-request"}}
{{end}}
-
- {{if $isHomepage}}
+
+
+ {{if $isTreePathRoot}}
{{ctx.Locale.Tr "repo.find_file.go_to_file"}}
{{end}}
@@ -78,17 +79,19 @@
{{end}}
- {{if and $isHomepage (.Repository.IsTemplate)}}
+ {{if and $isTreePathRoot .Repository.IsTemplate}}
{{ctx.Locale.Tr "repo.use_template"}}
{{end}}
- {{if not $isHomepage}}
+
+ {{if not $isTreePathRoot}}
+ {{$treeNameIdxLast := Eval $treeNamesLen "-" 1}}
{{StringUtils.EllipsisString .Repository.Name 30}}
{{- range $i, $v := .TreeNames -}}
/
- {{- if eq $i $l -}}
+ {{- if eq $i $treeNameIdxLast -}}
{{$v}}
+
- {{if $isHomepage}}
+ {{if $isTreePathRoot}}
- {{if $isHomepage}}
-
{{template "repo/clone_buttons" .}}
{{template "repo/cite/cite_modal" .}}
{{end}}
- {{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home), TODO: split the templates, avoid using "if" tricks */}}
+ {{if and (not $isTreePathRoot) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home), TODO: split the templates, avoid using "if" tricks */}}
{{svg "octicon-history" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.file_history"}}
@@ -135,13 +139,10 @@
{{template "repo/view_list" .}}
{{end}}
- {{template "repo/home_sidebar_head" .}}
-
-
- {{template "repo/home_sidebar_foot" .}}
-
+
+ {{if $showSidebar}}
+ {{template "repo/home_sidebar_top" .}}
+ {{template "repo/home_sidebar_bottom" .}}
{{end}}
+ {{if .LatestRelease}}
diff --git a/templates/repo/home_sidebar_head.tmpl b/templates/repo/home_sidebar_head.tmpl
deleted file mode 100644
index fa3eec1d8c2fa..0000000000000
--- a/templates/repo/home_sidebar_head.tmpl
+++ /dev/null
@@ -1,65 +0,0 @@
-
@@ -25,9 +26,9 @@
@@ -45,11 +46,7 @@
- {{if eq .Language "other"}}
- {{ctx.Locale.Tr "repo.language_other"}}
- {{else}}
- {{.Language}}
- {{end}}
+ {{Iif (eq .Language "other") (ctx.Locale.Tr "repo.language_other") .Language}}
{{.Percentage}}%
@@ -58,4 +55,5 @@
-
-
-
-
- {{template "shared/search/button"}}
-
-
-
diff --git a/templates/repo/home_sidebar_top.tmpl b/templates/repo/home_sidebar_top.tmpl
new file mode 100644
index 0000000000000..c428f1fbddbe7
--- /dev/null
+++ b/templates/repo/home_sidebar_top.tmpl
@@ -0,0 +1,67 @@
+
-
-
- {{ctx.Locale.Tr "repo.repo_desc"}}
-
- {{if and (not .HideRepoInfo) (not .IsBlame)}}
-
- {{- $description := .Repository.DescriptionHTML ctx -}}
- {{if $description}}{{$description | RenderCodeBlock}}{{else}}{{ctx.Locale.Tr "repo.repo_no_desc"}}{{end}}
- {{if .Repository.Website}}{{svg "octicon-link"}}{{.Repository.Website}}{{end}}
-
-
- {{/* !!!! it SHOULD and MUST match the code in issue-home.js */}}
- {{range .Topics}}{{.Name}}{{end}}
-
- {{if and .Permission.IsAdmin (not .Repository.IsArchived)}}
-
- {{end}}
- {{if .ReadmeExist}}
-
- {{end}}
- {{if .DetectedRepoLicenses}}
-
- {{end}}
- {{if .CitiationExist}}
-
- {{end}}
-
-
- {{range .Topics}}
- {{/* keep the same layout as Fomantic UI generated labels */}}
- {{.Name}}{{svg "octicon-x" 16 "delete icon"}}
- {{end}}
-
-
-
-
-
+
+ {{template "shared/search/button"}}
+
+
+
diff --git a/web_src/css/repo.css b/web_src/css/repo.css
index da55b986c3c71..3eebc0c477dc1 100644
--- a/web_src/css/repo.css
+++ b/web_src/css/repo.css
@@ -422,14 +422,6 @@ td .commit-summary {
border-radius: 0 0 var(--border-radius) var(--border-radius);
}
-.repository.file.list .sidebar {
- padding-left: 0;
-}
-
-.repository.file.list .sidebar .svg {
- width: 16px;
-}
-
.repo-editor-header {
width: 100%;
}
@@ -2162,10 +2154,6 @@ td .commit-summary {
justify-content: flex-end;
}
-.repo-button-row[data-is-homepage="false"] .repo-button-row-right {
- flex-grow: 0;
-}
-
@media (max-width: 1200px) {
.repository:not(.wiki) .repo-button-row {
flex-direction: column;
diff --git a/web_src/css/repo/home.css b/web_src/css/repo/home.css
index 65cb05ca5f43c..f461c605a418d 100644
--- a/web_src/css/repo/home.css
+++ b/web_src/css/repo/home.css
@@ -1,49 +1,48 @@
-.repo-home-content {
+.repo-grid-filelist-sidebar {
display: grid;
- gap: 10px;
grid-template-columns: auto 300px;
grid-template-rows: auto auto 1fr;
}
-.repo-home-main {
+.repo-grid-filelist-sidebar .repo-home-filelist {
grid-column: 1;
grid-row: 1 / 4;
}
-.repo-home-head {
+.repo-grid-filelist-sidebar .repo-home-sidebar-top {
grid-column: 2;
grid-row: 1;
- padding-left: 10px;
+ padding-left: 1em;
}
-
-.repo-home-foot {
+.repo-grid-filelist-sidebar .repo-home-sidebar-bottom {
grid-column: 2;
grid-row: 2;
- padding-left: 10px;
+ padding-left: 1em;
}
-
-.repo-home-foot > :first-child {
+.repo-home-sidebar-bottom > :first-child {
border-top: 1px solid var(--color-secondary); /* same to .flex-list > .flex-item + .flex-item */
}
@media (max-width: 767.98px) {
- .repo-home-content {
+ .repo-grid-filelist-sidebar {
grid-template-columns: 100%;
grid-template-rows: auto auto auto;
}
- .repo-home-main {
+ .repo-grid-filelist-sidebar .repo-home-filelist {
grid-column: 1;
grid-row: 2;
}
- .repo-home-head {
+ .repo-grid-filelist-sidebar .repo-home-sidebar-top {
grid-column: 1;
grid-row: 1;
+ padding-left: 0;
}
- .repo-home-foot {
+ .repo-grid-filelist-sidebar .repo-home-sidebar-bottom {
grid-column: 1;
grid-row: 3;
+ padding-left: 0;
}
- .repo-home-foot > :first-child {
+ .repo-home-sidebar-bottom > :first-child {
border-top: 0;
}
}
@@ -68,7 +67,6 @@
.language-stats-details .item {
height: 30px;
- line-height: var(--line-height-default);
display: flex;
align-items: center;
justify-content: center;
diff --git a/web_src/js/features/repo-home.ts b/web_src/js/features/repo-home.ts
index 048b1c8673a70..df52b87f5ae13 100644
--- a/web_src/js/features/repo-home.ts
+++ b/web_src/js/features/repo-home.ts
@@ -46,12 +46,12 @@ export function initRepoTopicBar() {
topicArray.sort();
for (const topic of topicArray) {
// TODO: sort items in topicDropdown, or items in edit div will have different order to the items in view div
- // !!!! it SHOULD and MUST match the code in "home_sidebar_head.tmpl" !!!!
+ // !!!! it SHOULD and MUST match the code in "home_sidebar_top.tmpl" !!!!
const link = document.createElement('a');
link.classList.add('repo-topic', 'ui', 'large', 'label', 'gt-ellipsis');
link.href = `${appSubUrl}/explore/repos?q=${encodeURIComponent(topic)}&topic=1`;
link.textContent = topic;
- mgrBtn.parentNode.insertBefore(link, mgrBtn); // insert all new topics before manage button
+ viewDiv.append(link);
}
}
hideElem(editDiv);
From ca5bfa68f3062897be25a19302450e34b6b44491 Mon Sep 17 00:00:00 2001
From: wxiaoguang
+
+
+
+
+ {{ctx.Locale.Tr "repo.repo_desc"}}
+
+ {{if and (not .HideRepoInfo) (not .IsBlame)}}
+
+ {{- $description := .Repository.DescriptionHTML ctx -}}
+ {{if $description}}{{$description | RenderCodeBlock}}{{else}}{{ctx.Locale.Tr "repo.repo_no_desc"}}{{end}}
+ {{if .Repository.Website}}{{svg "octicon-link"}}{{.Repository.Website}}{{end}}
+
+
+ {{/* !!!! it SHOULD and MUST match the code in issue-home.js */}}
+ {{range .Topics}}{{.Name}}{{end}}
+
+ {{if and .Permission.IsAdmin (not .Repository.IsArchived)}}
+
+
+ {{end}}
+ {{if .ReadmeExist}}
+
+ {{end}}
+ {{if .DetectedRepoLicenses}}
+
+ {{end}}
+ {{if .CitiationExist}}
+
+ {{end}}
+
+
+ {{range .Topics}}
+ {{/* keep the same layout as Fomantic UI generated labels */}}
+ {{.Name}}{{svg "octicon-x" 16 "delete icon"}}
+ {{end}}
+
+
+
+
+
-
+
{{svg "octicon-law"}}{{if eq (len .DetectedRepoLicenses) 1}}{{index .DetectedRepoLicenses 0}}{{else}}{{ctx.Locale.Tr "repo.multiple_licenses"}}{{end}}
From 6412de600917023fa1d0a443bdfe16de6a2d8d2d Mon Sep 17 00:00:00 2001
From: wxiaoguang |
---|