Skip to content

Commit 61eaa6f

Browse files
committed
Shorten page title in file view
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.
1 parent bfe597c commit 61eaa6f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

routers/web/repo/view.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ func renderDirectory(ctx *context.Context, treeLink string) {
141141
return
142142
}
143143

144+
if ctx.Repo.TreePath != "" {
145+
ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefName)
146+
}
147+
144148
// 3 for the extensions in exts[] in order
145149
// the last one is for a readme that doesn't
146150
// strictly match an extension
@@ -374,7 +378,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
374378
}
375379
defer dataRc.Close()
376380

377-
ctx.Data["Title"] = ctx.Data["Title"].(string) + " - " + ctx.Tr("repo.file.title", ctx.Repo.TreePath, ctx.Repo.RefName)
381+
ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefName)
378382

379383
fileSize := blob.Size()
380384
ctx.Data["FileIsSymlink"] = entry.IsLink()

0 commit comments

Comments
 (0)