From eb92e0e64900fbfe77eed9f646127207181ea650 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Tue, 3 Jun 2025 09:27:09 +0200 Subject: [PATCH] Make description visible in empty repo --- routers/web/repo/view.go | 5 +++-- templates/repo/description.tmpl | 36 +++++++++++++++++++++++++++++++++ templates/repo/empty.tmpl | 3 +++ templates/repo/home.tmpl | 31 +--------------------------- 4 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 templates/repo/description.tmpl diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index de508509dc..58d2b09ee7 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -973,6 +973,9 @@ func renderHomeCode(ctx *context.Context) { ctx.Data["RepositoryUploadEnabled"] = setting.Repository.Upload.Enabled prepareOpenWithEditorApps(ctx) + // Get Topics of this repo. Earlier, beacuse we show them even when the repo is empty. + renderRepoTopics(ctx) + if ctx.Repo.Commit == nil || ctx.Repo.Repository.IsEmpty || ctx.Repo.Repository.IsBroken() { showEmpty := true var err error @@ -1021,8 +1024,6 @@ func renderHomeCode(ctx *context.Context) { } ctx.Data["Title"] = title - // Get Topics of this repo - renderRepoTopics(ctx) if ctx.Written() { return } diff --git a/templates/repo/description.tmpl b/templates/repo/description.tmpl new file mode 100644 index 0000000000..b6f6e74fbc --- /dev/null +++ b/templates/repo/description.tmpl @@ -0,0 +1,36 @@ +
{{/* Magic number warning */}} +
+
+ {{$description := .Repository.DescriptionHTML $.Context}} + {{if $description}}{{$description | RenderCodeBlock}}{{else}}{{ctx.Locale.Tr "repo.no_desc"}}{{end}} + {{if .Repository.Website}} + {{svg "octicon-globe"}} {{.Repository.Website}} + {{end}} +
+
+ +
+ {{/* it should match the code in issue-home.js */}} + {{range .Topics}} + {{.Name}} + {{end}} + {{if and .Permission.IsAdmin (not .Repository.IsArchived)}}{{end}} +
+ + {{if and .Permission.IsAdmin (not .Repository.IsArchived)}} +
+ +
+ + +
+
+ {{end}} +
\ No newline at end of file diff --git a/templates/repo/empty.tmpl b/templates/repo/empty.tmpl index 3a8995bfea..5397b33000 100644 --- a/templates/repo/empty.tmpl +++ b/templates/repo/empty.tmpl @@ -14,6 +14,9 @@ {{end}} {{end}} + {{if not .HideRepoInfo}} + {{template "repo/description" .}} + {{end}} {{if .Repository.IsBroken}}
{{ctx.Locale.Tr "repo.broken_message"}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index f480c1f17f..c1db85d2d2 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -4,36 +4,7 @@
{{template "base/alert" .}} {{if and (not .HideRepoInfo) (not .IsBlame)}} -
-
- {{$description := .Repository.DescriptionHTML $.Context}} - {{if $description}}{{$description | RenderCodeBlock}}{{else}}{{ctx.Locale.Tr "repo.no_desc"}}{{end}} - {{if .Repository.Website}} - {{svg "octicon-globe"}} {{.Repository.Website}} - {{end}} -
-
-
- {{/* it should match the code in issue-home.js */}} - {{range .Topics}}{{.Name}}{{end}} - {{if and .Permission.IsAdmin (not .Repository.IsArchived)}}{{end}} -
- {{end}} - {{if and .Permission.IsAdmin (not .Repository.IsArchived)}} -
- -
- - -
-
+ {{template "repo/description" .}} {{end}} {{if RepoFlagsEnabled}}