Skip to content

Commit 2854ddf

Browse files
committed
fix
1 parent ab45f9e commit 2854ddf

File tree

4 files changed

+57
-37
lines changed

4 files changed

+57
-37
lines changed

routers/web/shared/user/header.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ func prepareContextForCommonProfile(ctx *context.Context) {
3030
ctx.Data["FeedURL"] = ctx.ContextUser.HomeLink()
3131
}
3232

33+
// PrepareContextForProfileBigAvatar set the context for big avatar view on the org profile page
34+
func PrepareContextForOrgProfileBigAvatar(ctx *context.Context) {
35+
prepareContextForCommonProfile(ctx)
36+
37+
ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
38+
}
39+
3340
// PrepareContextForProfileBigAvatar set the context for big avatar view on the profile page
3441
func PrepareContextForProfileBigAvatar(ctx *context.Context) {
3542
prepareContextForCommonProfile(ctx)

routers/web/user/profile.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import (
2828
)
2929

3030
const (
31-
tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
31+
tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
32+
tplOrgProfileBigAvatar base.TplName = "shared/user/org_profile_big_avatar"
3233
)
3334

3435
// OwnerProfile render profile page for a user or a organization (aka, repo owner)
@@ -318,6 +319,15 @@ func Action(ctx *context.Context) {
318319
return
319320
}
320321

321-
shared_user.PrepareContextForProfileBigAvatar(ctx)
322-
ctx.HTML(http.StatusOK, tplProfileBigAvatar)
322+
if ctx.ContextUser.IsIndividual() {
323+
shared_user.PrepareContextForProfileBigAvatar(ctx)
324+
ctx.HTML(http.StatusOK, tplProfileBigAvatar)
325+
return
326+
} else if ctx.ContextUser.IsOrganization() {
327+
shared_user.PrepareContextForOrgProfileBigAvatar(ctx)
328+
ctx.HTML(http.StatusOK, tplOrgProfileBigAvatar)
329+
return
330+
}
331+
log.Error("Failed to apply action %q: unsupport context user type: %s", ctx.FormString("action"), ctx.ContextUser.Type)
332+
ctx.Error(http.StatusBadRequest, fmt.Sprintf("Action %q failed", ctx.FormString("action")))
323333
}

templates/org/home.tmpl

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,6 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content organization profile">
3-
<div class="ui container gt-df">
4-
{{ctx.AvatarUtils.Avatar .Org 140 "org-avatar"}}
5-
<div id="org-info">
6-
<div class="ui header">
7-
{{.Org.DisplayName}}
8-
<span class="org-visibility">
9-
{{if .Org.Visibility.IsLimited}}<span class="ui large basic horizontal label">{{ctx.Locale.Tr "org.settings.visibility.limited_shortname"}}</span>{{end}}
10-
{{if .Org.Visibility.IsPrivate}}<span class="ui large basic horizontal label">{{ctx.Locale.Tr "org.settings.visibility.private_shortname"}}</span>{{end}}
11-
</span>
12-
</div>
13-
{{if $.RenderedDescription}}<div class="render-content markup">{{$.RenderedDescription|Str2html}}</div>{{end}}
14-
<div class="text grey meta">
15-
{{if .Org.Location}}<div class="flex-text-block">{{svg "octicon-location"}} <span>{{.Org.Location}}</span></div>{{end}}
16-
{{if .Org.Website}}<div class="flex-text-block">{{svg "octicon-link"}} <a target="_blank" rel="noopener noreferrer me" href="{{.Org.Website}}">{{.Org.Website}}</a></div>{{end}}
17-
{{if $.IsSigned}}
18-
{{if .Org.Email}}<div class="flex-text-block">{{svg "octicon-mail"}} <a class="muted" href="mailto:{{.Org.Email}}">{{.Org.Email}}</a></div>{{end}}
19-
{{end}}
20-
</div>
21-
</div>
22-
<div class="right menu">
23-
{{if .EnableFeed}}
24-
<a class="ui basic label button gt-mr-0" href="{{$.Org.HomeLink}}.rss" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">
25-
{{svg "octicon-rss" 24}}
26-
</a>
27-
{{end}}
28-
<button class="link-action ui basic button gt-mr-0" data-url="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
29-
{{if $.IsFollowing}}
30-
{{ctx.Locale.Tr "user.unfollow"}}
31-
{{else}}
32-
{{ctx.Locale.Tr "user.follow"}}
33-
{{end}}
34-
</button>
35-
</div>
36-
</div>
3+
{{template "shared/user/org_profile_big_avatar" .}}
374

385
{{template "org/menu" .}}
396

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<div class="ui container gt-df" id="org-profile-avatar-container">
2+
{{ctx.AvatarUtils.Avatar .ContextUser 140 "org-avatar"}}
3+
<div id="org-info">
4+
<div class="ui header">
5+
{{.ContextUser.DisplayName}}
6+
<span class="org-visibility">
7+
{{if .ContextUser.Visibility.IsLimited}}<span class="ui large basic horizontal label">{{ctx.Locale.Tr "org.settings.visibility.limited_shortname"}}</span>{{end}}
8+
{{if .ContextUser.Visibility.IsPrivate}}<span class="ui large basic horizontal label">{{ctx.Locale.Tr "org.settings.visibility.private_shortname"}}</span>{{end}}
9+
</span>
10+
</div>
11+
{{if $.RenderedDescription}}<div class="render-content markup">{{$.RenderedDescription|Str2html}}</div>{{end}}
12+
<div class="text grey meta">
13+
{{if .ContextUser.Location}}<div class="flex-text-block">{{svg "octicon-location"}} <span>{{.ContextUser.Location}}</span></div>{{end}}
14+
{{if .ContextUser.Website}}<div class="flex-text-block">{{svg "octicon-link"}} <a target="_blank" rel="noopener noreferrer me" href="{{.ContextUser.Website}}">{{.ContextUser.Website}}</a></div>{{end}}
15+
{{if $.IsSigned}}
16+
{{if .ContextUser.Email}}<div class="flex-text-block">{{svg "octicon-mail"}} <a class="muted" href="mailto:{{.ContextUser.Email}}">{{.ContextUser.Email}}</a></div>{{end}}
17+
{{end}}
18+
</div>
19+
</div>
20+
<div class="right menu">
21+
{{if .EnableFeed}}
22+
<a class="ui basic label button gt-mr-0" href="{{$.ContextUser.HomeLink}}.rss" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">
23+
{{svg "octicon-rss" 24}}
24+
</a>
25+
{{end}}
26+
{{if .IsSigned}}
27+
<button class="ui basic button gt-mr-0" hx-post="{{.ContextUser.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}" hx-target="#org-profile-avatar-container" hx-indicator="#org-profile-avatar-container">
28+
{{if $.IsFollowing}}
29+
{{ctx.Locale.Tr "user.unfollow"}}
30+
{{else}}
31+
{{ctx.Locale.Tr "user.follow"}}
32+
{{end}}
33+
</button>
34+
{{end}}
35+
</div>
36+
</div>

0 commit comments

Comments
 (0)