aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2021-12-14 23:50:11 -0800
committerGitHub <noreply@github.com>2021-12-15 15:50:11 +0800
commitf58e687a83b18d58298097d485f4febf98062dd7 (patch)
treec30c5ce611a90ca29fbdc8fd828b3c3f0fb85610 /routers
parent4da1d9781025aa4a85899b1ddeb25aabbaa82703 (diff)
downloadgitea-f58e687a83b18d58298097d485f4febf98062dd7.tar.gz
gitea-f58e687a83b18d58298097d485f4febf98062dd7.zip
Shorten page title in file view (#17987)
Move the more relevant sections of the page title earlier which make it possible to distinguish multiple tabs from each other when tab width is limited. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/view.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index e19fb9bf91..45d5a650ba 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -141,6 +141,10 @@ func renderDirectory(ctx *context.Context, treeLink string) {
return
}
+ if ctx.Repo.TreePath != "" {
+ ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefName)
+ }
+
// 3 for the extensions in exts[] in order
// the last one is for a readme that doesn't
// strictly match an extension
@@ -374,7 +378,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
}
defer dataRc.Close()
- ctx.Data["Title"] = ctx.Data["Title"].(string) + " - " + ctx.Tr("repo.file.title", ctx.Repo.TreePath, ctx.Repo.RefName)
+ ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefName)
fileSize := blob.Size()
ctx.Data["FileIsSymlink"] = entry.IsLink()