Skip to content

Commit 56a477f

Browse files
committed
only refresh follow button
1 parent a86df06 commit 56a477f

File tree

5 files changed

+52
-61
lines changed

5 files changed

+52
-61
lines changed

routers/web/org/home.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,22 @@ func Home(ctx *context.Context) {
4141
if ctx.Written() {
4242
return
4343
}
44-
shared_user.PrepareContextForOrgProfileBigAvatar(ctx)
44+
4545
org := ctx.Org.Organization
4646

4747
ctx.Data["PageIsUserProfile"] = true
4848
ctx.Data["Title"] = org.DisplayName()
49+
if len(org.Description) != 0 {
50+
desc, err := markdown.RenderString(&markup.RenderContext{
51+
Ctx: ctx,
52+
Metas: map[string]string{"mode": "document"},
53+
}, org.Description)
54+
if err != nil {
55+
ctx.ServerError("RenderString", err)
56+
return
57+
}
58+
ctx.Data["RenderedDescription"] = desc
59+
}
4960

5061
var orderBy db.SearchOrderBy
5162
ctx.Data["SortType"] = ctx.FormString("sort")

routers/web/shared/user/header.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,6 @@ 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-
if len(ctx.ContextUser.Description) != 0 {
40-
desc, err := markdown.RenderString(&markup.RenderContext{
41-
Ctx: ctx,
42-
Metas: map[string]string{"mode": "document"},
43-
}, ctx.ContextUser.Description)
44-
if err != nil {
45-
ctx.ServerError("RenderString", err)
46-
return
47-
}
48-
ctx.Data["RenderedDescription"] = desc
49-
}
50-
}
51-
5233
// PrepareContextForProfileBigAvatar set the context for big avatar view on the profile page
5334
func PrepareContextForProfileBigAvatar(ctx *context.Context) {
5435
prepareContextForCommonProfile(ctx)

routers/web/user/profile.go

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

3030
const (
31-
tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
32-
tplOrgProfileBigAvatar base.TplName = "shared/user/org_profile_big_avatar"
31+
tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
32+
tplFollowUnfollow base.TplName = "shared/user/follow_unfollow"
3333
)
3434

3535
// OwnerProfile render profile page for a user or a organization (aka, repo owner)
@@ -324,8 +324,8 @@ func Action(ctx *context.Context) {
324324
ctx.HTML(http.StatusOK, tplProfileBigAvatar)
325325
return
326326
} else if ctx.ContextUser.IsOrganization() {
327-
shared_user.PrepareContextForOrgProfileBigAvatar(ctx)
328-
ctx.HTML(http.StatusOK, tplOrgProfileBigAvatar)
327+
ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
328+
ctx.HTML(http.StatusOK, tplFollowUnfollow)
329329
return
330330
}
331331
log.Error("Failed to apply action %q: unsupport context user type: %s", ctx.FormString("action"), ctx.ContextUser.Type)

templates/org/home.tmpl

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content organization profile">
3-
{{template "shared/user/org_profile_big_avatar" .}}
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+
{{if .IsSigned}}
29+
<button class="ui basic button gt-mr-0" hx-post="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
30+
{{if $.IsFollowing}}
31+
{{ctx.Locale.Tr "user.unfollow"}}
32+
{{else}}
33+
{{ctx.Locale.Tr "user.follow"}}
34+
{{end}}
35+
</button>
36+
{{end}}
37+
</div>
38+
</div>
439

540
{{template "org/menu" .}}
641

templates/shared/user/org_profile_big_avatar.tmpl

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)