Skip to content

Commit 5936a12

Browse files
authored
Merge branch 'release/v1.25' into lunny/release_note_1.25
2 parents f62bdb0 + 88a8571 commit 5936a12

File tree

7 files changed

+17
-7
lines changed

7 files changed

+17
-7
lines changed

modules/web/middleware/data.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func GetContextData(c context.Context) reqctx.ContextData {
2222

2323
func CommonTemplateContextData() reqctx.ContextData {
2424
return reqctx.ContextData{
25+
"PageTitleCommon": setting.AppName,
26+
2527
"IsLandingPageOrganizations": setting.LandingPageURL == setting.LandingPageOrganizations,
2628

2729
"ShowRegistrationButton": setting.Service.ShowRegistrationButton,

routers/web/repo/view_file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func prepareFileView(ctx *context.Context, entry *git.TreeEntry) {
172172

173173
blob := entry.Blob()
174174

175-
ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefFullName.ShortName())
175+
ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+ctx.Repo.TreePath, ctx.Repo.RefFullName.ShortName())
176176
ctx.Data["FileIsSymlink"] = entry.IsLink()
177177
ctx.Data["FileTreePath"] = ctx.Repo.TreePath
178178
ctx.Data["RawFileLink"] = ctx.Repo.RepoLink + "/raw/" + ctx.Repo.RefTypeNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath)

routers/web/repo/view_home.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99
"html/template"
1010
"net/http"
11-
"path"
1211
"strconv"
1312
"strings"
1413
"time"
@@ -139,7 +138,7 @@ func prepareToRenderDirectory(ctx *context.Context) {
139138

140139
if ctx.Repo.TreePath != "" {
141140
ctx.Data["HideRepoInfo"] = true
142-
ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefFullName.ShortName())
141+
ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+ctx.Repo.TreePath, ctx.Repo.RefFullName.ShortName())
143142
}
144143

145144
subfolder, readmeFile, err := findReadmeFileInEntries(ctx, ctx.Repo.TreePath, entries, true)

services/context/repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ func RepoAssignment(ctx *Context) {
537537
}
538538

539539
ctx.Data["Title"] = repo.Owner.Name + "/" + repo.Name
540+
ctx.Data["PageTitleCommon"] = repo.Name + " - " + setting.AppName
540541
ctx.Data["Repository"] = repo
541542
ctx.Data["Owner"] = ctx.Repo.Repository.Owner
542543
ctx.Data["CanWriteCode"] = ctx.Repo.CanWrite(unit_model.TypeCode)

templates/base/head.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="{{ctx.Locale.Lang}}" data-theme="{{UserThemeName .SignedUser}}">
33
<head>
44
<meta name="viewport" content="width=device-width, initial-scale=1">
5-
<title>{{if .Title}}{{.Title}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}}</title>
5+
<title>{{if .Title}}{{.Title}} - {{end}}{{.PageTitleCommon}}</title>
66
{{if .ManifestData}}<link rel="manifest" href="data:{{.ManifestData}}">{{end}}
77
<meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}{{MetaAuthor}}{{end}}">
88
<meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}{{MetaDescription}}{{end}}">

templates/repo/view_content.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{{$isTreePathRoot := not .TreeNames}}
22

3+
<div class="repo-view-content-data tw-hidden" data-document-title="{{ctx.RootData.Title}}" data-document-title-common="{{ctx.RootData.PageTitleCommon}}"></div>
34
{{template "repo/sub_menu" .}}
45
<div class="repo-button-row">
56
<div class="repo-button-row-left">

web_src/js/components/ViewFileTreeStore.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,16 @@ export function createViewFileTreeStore(props: {repoLink: string, treePath: stri
2525
},
2626

2727
async loadViewContent(url: string) {
28-
url = url.includes('?') ? url.replace('?', '?only_content=true') : `${url}?only_content=true`;
29-
const response = await GET(url);
30-
document.querySelector('.repo-view-content').innerHTML = await response.text();
28+
const u = new URL(url, window.origin);
29+
u.searchParams.set('only_content', 'true');
30+
const response = await GET(u.href);
31+
const elViewContent = document.querySelector('.repo-view-content');
32+
elViewContent.innerHTML = await response.text();
33+
const elViewContentData = elViewContent.querySelector('.repo-view-content-data');
34+
if (!elViewContentData) return; // if error occurs, there is no such element
35+
const t1 = elViewContentData.getAttribute('data-document-title');
36+
const t2 = elViewContentData.getAttribute('data-document-title-common');
37+
document.title = `${t1} - ${t2}`; // follow the format in head.tmpl: <head><title>...</title></head>
3138
},
3239

3340
async navigateTreeView(treePath: string) {

0 commit comments

Comments
 (0)