Skip to content

Commit 70fc47a

Browse files
authoredApr 20, 2023
Fix unclear "Owner" concept (#24233)
Some user/org pages use `Owner` variable. It's an incorrect concept since year 2016: what is a user's owner? Actually, new code is right: use `ContextUser`. This PR cleans all legacy "Owner" variables. ## Screenshots for related pages and test results All pages are as before: ### `web/org/home.go` ![image](https://user-images.githubusercontent.com/2114189/233366687-a3643025-1f78-474d-a901-deea35b72f4d.png) ### `web/user/profile.go` ![image](https://user-images.githubusercontent.com/2114189/233366812-2e5c2fbc-3f78-44e7-88c1-ec2f612c241e.png) ### `web/user/setting/profile.go` ![image](https://user-images.githubusercontent.com/2114189/233366928-7a1e52c9-b400-4379-a4be-af06a853c5fa.png)
1 parent 8ea33ba commit 70fc47a

File tree

8 files changed

+40
-41
lines changed

8 files changed

+40
-41
lines changed
 

‎routers/web/org/home.go

-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ func Home(ctx *context.Context) {
143143
return
144144
}
145145

146-
ctx.Data["Owner"] = org
147146
ctx.Data["Repos"] = repos
148147
ctx.Data["Total"] = count
149148
ctx.Data["MembersTotal"] = membersCount

‎routers/web/user/profile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func Profile(ctx *context.Context) {
6363

6464
ctx.Data["Title"] = ctx.ContextUser.DisplayName()
6565
ctx.Data["PageIsUserProfile"] = true
66-
ctx.Data["Owner"] = ctx.ContextUser
66+
ctx.Data["ContextUser"] = ctx.ContextUser
6767
ctx.Data["OpenIDs"] = openIDs
6868
ctx.Data["IsFollowing"] = isFollowing
6969

‎routers/web/user/setting/profile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ func Repos(ctx *context.Context) {
326326

327327
ctx.Data["Repos"] = repos
328328
}
329-
ctx.Data["Owner"] = ctxUser
329+
ctx.Data["ContextUser"] = ctxUser
330330
pager := context.NewPagination(count, opts.PageSize, opts.Page, 5)
331331
pager.SetDefaultParams(ctx)
332332
ctx.Data["Page"] = pager

‎templates/base/head.tmpl

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
</style>
3131
</noscript>
3232
{{if .PageIsUserProfile}}
33-
<meta property="og:title" content="{{.Owner.DisplayName}}">
33+
<meta property="og:title" content="{{.ContextUser.DisplayName}}">
3434
<meta property="og:type" content="profile">
35-
<meta property="og:image" content="{{.Owner.AvatarLink $.Context}}">
36-
<meta property="og:url" content="{{.Owner.HTMLURL}}">
37-
{{if .Owner.Description}}
38-
<meta property="og:description" content="{{.Owner.Description}}">
35+
<meta property="og:image" content="{{.ContextUser.AvatarLink $.Context}}">
36+
<meta property="og:url" content="{{.ContextUser.HTMLURL}}">
37+
{{if .ContextUser.Description}}
38+
<meta property="og:description" content="{{.ContextUser.Description}}">
3939
{{end}}
4040
{{else if .Repository}}
4141
{{if .Issue}}

‎templates/org/menu.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<div class="ui secondary stackable pointing menu">
33
<a class="{{if .PageIsViewRepositories}}active {{end}}item" href="{{$.Org.HomeLink}}">
44
{{svg "octicon-repo"}} {{.locale.Tr "user.repositories"}}
5-
{{if .Owner.NumRepos}}
6-
<div class="ui small label">{{.Owner.NumRepos}}</div>
5+
{{if .ContextUser.NumRepos}}
6+
<div class="ui small label">{{.ContextUser.NumRepos}}</div>
77
{{end}}
88
</a>
99
{{if and .IsProjectEnabled .CanReadProjects}}

‎templates/user/overview/header.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
{{if not .DisableStars}}
6868
<a class='{{if eq .TabName "stars"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=stars">
6969
{{svg "octicon-star"}} {{.locale.Tr "user.starred"}}
70-
{{if .Owner.NumStars}}
71-
<div class="ui primary label">{{.Owner.NumStars}}</div>
70+
{{if .ContextUser.NumStars}}
71+
<div class="ui primary label">{{.ContextUser.NumStars}}</div>
7272
{{end}}
7373
</a>
7474
{{else}}

‎templates/user/profile.tmpl

+28-28
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@
55
<div class="ui five wide column">
66
<div class="ui card">
77
<div id="profile-avatar" class="content gt-df">
8-
{{if eq .SignedUserName .Owner.Name}}
8+
{{if eq .SignedUserName .ContextUser.Name}}
99
<a class="image" href="{{AppSubUrl}}/user/settings" data-tooltip-content="{{.locale.Tr "user.change_avatar"}}">
10-
{{avatar $.Context .Owner 290}}
10+
{{avatar $.Context .ContextUser 290}}
1111
</a>
1212
{{else}}
1313
<span class="image">
14-
{{avatar $.Context .Owner 290}}
14+
{{avatar $.Context .ContextUser 290}}
1515
</span>
1616
{{end}}
1717
</div>
1818
<div class="content gt-word-break profile-avatar-name">
19-
{{if .Owner.FullName}}<span class="header text center">{{.Owner.FullName}}</span>{{end}}
20-
<span class="username text center">{{.Owner.Name}}</span>
19+
{{if .ContextUser.FullName}}<span class="header text center">{{.ContextUser.FullName}}</span>{{end}}
20+
<span class="username text center">{{.ContextUser.Name}}</span>
2121
{{if .EnableFeed}}
22-
<a href="{{.Owner.HomeLink}}.rss"><i class="ui text grey gt-ml-3" data-tooltip-content="{{.locale.Tr "rss_feed"}}">{{svg "octicon-rss" 18}}</i></a>
22+
<a href="{{.ContextUser.HomeLink}}.rss"><i class="ui text grey gt-ml-3" data-tooltip-content="{{.locale.Tr "rss_feed"}}">{{svg "octicon-rss" 18}}</i></a>
2323
{{end}}
2424
<div class="gt-mt-3">
25-
<a class="muted" href="{{.Owner.HomeLink}}?tab=followers">{{svg "octicon-person" 18 "gt-mr-2"}}{{.Owner.NumFollowers}} {{.locale.Tr "user.followers"}}</a> · <a class="muted" href="{{.Owner.HomeLink}}?tab=following">{{.Owner.NumFollowing}} {{.locale.Tr "user.following"}}</a>
25+
<a class="muted" href="{{.ContextUser.HomeLink}}?tab=followers">{{svg "octicon-person" 18 "gt-mr-2"}}{{.ContextUser.NumFollowers}} {{.locale.Tr "user.followers"}}</a> · <a class="muted" href="{{.ContextUser.HomeLink}}?tab=following">{{.ContextUser.NumFollowing}} {{.locale.Tr "user.following"}}</a>
2626
</div>
2727
</div>
2828
<div class="extra content gt-word-break">
2929
<ul>
30-
{{if .Owner.Location}}
31-
<li>{{svg "octicon-location"}} {{.Owner.Location}}</li>
30+
{{if .ContextUser.Location}}
31+
<li>{{svg "octicon-location"}} {{.ContextUser.Location}}</li>
3232
{{end}}
33-
{{if (eq .SignedUserName .Owner.Name)}}
33+
{{if (eq .SignedUserName .ContextUser.Name)}}
3434
<li>
3535
{{svg "octicon-mail"}}
36-
<a href="mailto:{{.Owner.Email}}" rel="nofollow">{{.Owner.Email}}</a>
36+
<a href="mailto:{{.ContextUser.Email}}" rel="nofollow">{{.ContextUser.Email}}</a>
3737
<a href="{{AppSubUrl}}/user/settings#keep-email-private">
3838
{{if .ShowUserEmail}}
3939
<i class="ui right" data-tooltip-content="{{.locale.Tr "user.email_visibility.limited"}}">
@@ -50,14 +50,14 @@
5050
{{if .ShowUserEmail}}
5151
<li>
5252
{{svg "octicon-mail"}}
53-
<a href="mailto:{{.Owner.Email}}" rel="nofollow">{{.Owner.Email}}</a>
53+
<a href="mailto:{{.ContextUser.Email}}" rel="nofollow">{{.ContextUser.Email}}</a>
5454
</li>
5555
{{end}}
5656
{{end}}
57-
{{if .Owner.Website}}
57+
{{if .ContextUser.Website}}
5858
<li>
5959
{{svg "octicon-link"}}
60-
<a target="_blank" rel="noopener noreferrer me" href="{{.Owner.Website}}">{{.Owner.Website}}</a>
60+
<a target="_blank" rel="noopener noreferrer me" href="{{.ContextUser.Website}}">{{.ContextUser.Website}}</a>
6161
</li>
6262
{{end}}
6363
{{if $.RenderedDescription}}
@@ -73,7 +73,7 @@
7373
</li>
7474
{{end}}
7575
{{end}}
76-
<li>{{svg "octicon-clock"}} {{.locale.Tr "user.join_on"}} {{template "shared/datetime/short" (dict "Datetime" .Owner.CreatedUnix.FormatLong "Fallback" .Owner.CreatedUnix.FormatShort)}}</li>
76+
<li>{{svg "octicon-clock"}} {{.locale.Tr "user.join_on"}} {{template "shared/datetime/short" (dict "Datetime" .ContextUser.CreatedUnix.FormatLong "Fallback" .ContextUser.CreatedUnix.FormatShort)}}</li>
7777
{{if and .Orgs .HasOrgsVisible}}
7878
<li>
7979
<ul class="user-orgs">
@@ -100,7 +100,7 @@
100100
</ul>
101101
</li>
102102
{{end}}
103-
{{if and .IsSigned (ne .SignedUserName .Owner.Name)}}
103+
{{if and .IsSigned (ne .SignedUserName .ContextUser.Name)}}
104104
<li class="follow">
105105
{{if $.IsFollowing}}
106106
<form method="post" action="{{.Link}}?action=unfollow&redirect_to={{$.Link}}">
@@ -121,44 +121,44 @@
121121
</div>
122122
<div class="ui eleven wide column">
123123
<div class="ui secondary stackable pointing tight menu">
124-
<a class='{{if and (ne .TabName "activity") (ne .TabName "following") (ne .TabName "followers") (ne .TabName "stars") (ne .TabName "watching") (ne .TabName "projects") (ne .TabName "code")}}active {{end}}item' href="{{.Owner.HomeLink}}">
124+
<a class='{{if and (ne .TabName "activity") (ne .TabName "following") (ne .TabName "followers") (ne .TabName "stars") (ne .TabName "watching") (ne .TabName "projects") (ne .TabName "code")}}active {{end}}item' href="{{.ContextUser.HomeLink}}">
125125
{{svg "octicon-repo"}} {{.locale.Tr "user.repositories"}}
126-
{{if .Owner.NumRepos}}
127-
<div class="ui small label">{{.Owner.NumRepos}}</div>
126+
{{if .ContextUser.NumRepos}}
127+
<div class="ui small label">{{.ContextUser.NumRepos}}</div>
128128
{{end}}
129129
</a>
130-
<a href="{{.Owner.HomeLink}}/-/projects" class="{{if eq .TabName "projects"}}active {{end}}item">
130+
<a href="{{.ContextUser.HomeLink}}/-/projects" class="{{if eq .TabName "projects"}}active {{end}}item">
131131
{{svg "octicon-project-symlink"}} {{.locale.Tr "user.projects"}}
132132
</a>
133133
{{if .IsPackageEnabled}}
134-
<a class='{{if eq .TabName "packages"}}active {{end}}item' href="{{.Owner.HomeLink}}/-/packages">
134+
<a class='{{if eq .TabName "packages"}}active {{end}}item' href="{{.ContextUser.HomeLink}}/-/packages">
135135
{{svg "octicon-package"}} {{.locale.Tr "packages.title"}}
136136
</a>
137137
{{end}}
138138
{{if .IsRepoIndexerEnabled}}
139-
<a class='{{if eq .TabName "code"}}active {{end}}item' href="{{.Owner.HomeLink}}/-/code">
139+
<a class='{{if eq .TabName "code"}}active {{end}}item' href="{{.ContextUser.HomeLink}}/-/code">
140140
{{svg "octicon-code"}} {{.locale.Tr "user.code"}}
141141
</a>
142142
{{end}}
143-
<a class='{{if eq .TabName "activity"}}active {{end}}item' href="{{.Owner.HomeLink}}?tab=activity">
143+
<a class='{{if eq .TabName "activity"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=activity">
144144
{{svg "octicon-rss"}} {{.locale.Tr "user.activity"}}
145145
</a>
146146
{{if not .DisableStars}}
147-
<a class='{{if eq .TabName "stars"}}active {{end}}item' href="{{.Owner.HomeLink}}?tab=stars">
147+
<a class='{{if eq .TabName "stars"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=stars">
148148
{{svg "octicon-star"}} {{.locale.Tr "user.starred"}}
149-
{{if .Owner.NumStars}}
150-
<div class="ui small label">{{.Owner.NumStars}}</div>
149+
{{if .ContextUser.NumStars}}
150+
<div class="ui small label">{{.ContextUser.NumStars}}</div>
151151
{{end}}
152152
</a>
153153
{{else}}
154-
<a class='{{if eq .TabName "watching"}}active {{end}}item' href="{{.Owner.HomeLink}}?tab=watching">
154+
<a class='{{if eq .TabName "watching"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=watching">
155155
{{svg "octicon-eye"}} {{.locale.Tr "user.watched"}}
156156
</a>
157157
{{end}}
158158
</div>
159159

160160
{{if eq .TabName "activity"}}
161-
{{if .Owner.KeepActivityPrivate}}
161+
{{if .ContextUser.KeepActivityPrivate}}
162162
<div class="ui info message">
163163
<p>{{.locale.Tr "user.disabled_public_activity"}}</p>
164164
</div>

‎templates/user/settings/repos.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{{end}}
3535
{{else}}
3636
<span class="icon">{{svg "octicon-file-directory-fill"}}</span>
37-
<span class="name">{{$.Owner.Name}}/{{$dir}}</span>
37+
<span class="name">{{$.ContextUser.Name}}/{{$dir}}</span>
3838
<div class="right floated content">
3939
{{if $.allowAdopt}}
4040
<button class="ui button submit tiny green adopt show-modal" data-modal="#adopt-unadopted-modal-{{$dirI}}"><span class="icon">{{svg "octicon-plus"}}</span><span class="label">{{$.locale.Tr "repo.adopt_preexisting_label"}}</span></button>

0 commit comments

Comments
 (0)
Please sign in to comment.