From 0741903e782c07e04811020ae71f3f6e34eac236 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Thu, 1 Feb 2024 07:37:25 +0000 Subject: [PATCH] only refresh follow button --- routers/web/org/home.go | 13 ++++++- routers/web/shared/user/header.go | 19 ---------- routers/web/user/profile.go | 8 ++--- templates/org/home.tmpl | 29 ++++++++++++++- templates/shared/user/follow_unfollow.tmpl | 9 +++++ .../shared/user/org_profile_big_avatar.tmpl | 36 ------------------- 6 files changed, 53 insertions(+), 61 deletions(-) create mode 100644 templates/shared/user/follow_unfollow.tmpl delete mode 100644 templates/shared/user/org_profile_big_avatar.tmpl diff --git a/routers/web/org/home.go b/routers/web/org/home.go index 495c6a95dcf9c..8bf02b2c42a74 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -41,11 +41,22 @@ func Home(ctx *context.Context) { if ctx.Written() { return } - shared_user.PrepareContextForOrgProfileBigAvatar(ctx) + org := ctx.Org.Organization ctx.Data["PageIsUserProfile"] = true ctx.Data["Title"] = org.DisplayName() + if len(org.Description) != 0 { + desc, err := markdown.RenderString(&markup.RenderContext{ + Ctx: ctx, + Metas: map[string]string{"mode": "document"}, + }, org.Description) + if err != nil { + ctx.ServerError("RenderString", err) + return + } + ctx.Data["RenderedDescription"] = desc + } var orderBy db.SearchOrderBy ctx.Data["SortType"] = ctx.FormString("sort") diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go index 1c0d01b3a9aed..a2c0abb47e4a1 100644 --- a/routers/web/shared/user/header.go +++ b/routers/web/shared/user/header.go @@ -30,25 +30,6 @@ func prepareContextForCommonProfile(ctx *context.Context) { ctx.Data["FeedURL"] = ctx.ContextUser.HomeLink() } -// PrepareContextForProfileBigAvatar set the context for big avatar view on the org profile page -func PrepareContextForOrgProfileBigAvatar(ctx *context.Context) { - prepareContextForCommonProfile(ctx) - - ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID) - - if len(ctx.ContextUser.Description) != 0 { - desc, err := markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - Metas: map[string]string{"mode": "document"}, - }, ctx.ContextUser.Description) - if err != nil { - ctx.ServerError("RenderString", err) - return - } - ctx.Data["RenderedDescription"] = desc - } -} - // PrepareContextForProfileBigAvatar set the context for big avatar view on the profile page func PrepareContextForProfileBigAvatar(ctx *context.Context) { prepareContextForCommonProfile(ctx) diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index c26775bc553c3..e7f133e98161e 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -28,8 +28,8 @@ import ( ) const ( - tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar" - tplOrgProfileBigAvatar base.TplName = "shared/user/org_profile_big_avatar" + tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar" + tplFollowUnfollow base.TplName = "shared/user/follow_unfollow" ) // OwnerProfile render profile page for a user or a organization (aka, repo owner) @@ -324,8 +324,8 @@ func Action(ctx *context.Context) { ctx.HTML(http.StatusOK, tplProfileBigAvatar) return } else if ctx.ContextUser.IsOrganization() { - shared_user.PrepareContextForOrgProfileBigAvatar(ctx) - ctx.HTML(http.StatusOK, tplOrgProfileBigAvatar) + ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID) + ctx.HTML(http.StatusOK, tplFollowUnfollow) return } log.Error("Failed to apply action %q: unsupport context user type: %s", ctx.FormString("action"), ctx.ContextUser.Type) diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 63c2801686373..aca7f742aa87b 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -1,6 +1,33 @@ {{template "base/head" .}}