File tree Expand file tree Collapse file tree 4 files changed +57
-37
lines changed Expand file tree Collapse file tree 4 files changed +57
-37
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,13 @@ func prepareContextForCommonProfile(ctx *context.Context) {
30
30
ctx .Data ["FeedURL" ] = ctx .ContextUser .HomeLink ()
31
31
}
32
32
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
+
33
40
// PrepareContextForProfileBigAvatar set the context for big avatar view on the profile page
34
41
func PrepareContextForProfileBigAvatar (ctx * context.Context ) {
35
42
prepareContextForCommonProfile (ctx )
Original file line number Diff line number Diff line change @@ -28,7 +28,8 @@ import (
28
28
)
29
29
30
30
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"
32
33
)
33
34
34
35
// OwnerProfile render profile page for a user or a organization (aka, repo owner)
@@ -318,6 +319,15 @@ func Action(ctx *context.Context) {
318
319
return
319
320
}
320
321
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" )))
323
333
}
Original file line number Diff line number Diff line change 1
1
{{template "base/head" .}}
2
2
<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" .}}
37
4
38
5
{{template "org/menu" .}}
39
6
Original file line number Diff line number Diff line change
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>
You can’t perform that action at this time.
0 commit comments