@@ -111,7 +111,22 @@ func home(ctx *context.Context, viewRepositories bool) {
111111 ctx .Data ["DisableNewPullMirrors" ] = setting .Mirror .DisableNewPull
112112 ctx .Data ["ShowMemberAndTeamTab" ] = ctx .Org .IsMember || len (members ) > 0
113113
114- if ! prepareOrgProfileReadme (ctx , viewRepositories ) {
114+ currentURL := ctx .Req .URL
115+ queryParams := currentURL .Query ()
116+ queryParams .Set ("view_as" , "member" )
117+ ctx .Data ["QueryForMember" ] = queryParams .Encode ()
118+ queryParams .Set ("view_as" , "public" )
119+ ctx .Data ["QueryForPublic" ] = queryParams .Encode ()
120+
121+ isViewerMember := ctx .FormString ("view_as" ) == "member"
122+ ctx .Data ["IsViewerMember" ] = isViewerMember
123+
124+ profileType := "Public"
125+ if isViewerMember {
126+ profileType = "Private"
127+ }
128+
129+ if ! prepareOrgProfileReadme (ctx , viewRepositories , profileType ) {
115130 ctx .Data ["PageIsViewRepositories" ] = true
116131 }
117132
@@ -168,28 +183,26 @@ func home(ctx *context.Context, viewRepositories bool) {
168183 ctx .HTML (http .StatusOK , tplOrgHome )
169184}
170185
171- func prepareOrgProfileReadme (ctx * context.Context , viewRepositories bool ) bool {
172- profileDbRepo , profileGitRepo , profileReadme , profileClose := shared_user .FindUserProfileReadme (ctx , ctx .Doer )
186+ func prepareOrgProfileReadme (ctx * context.Context , viewRepositories bool , profileType string ) bool {
187+ profileDbRepo , profileGitRepo , profileReadme , profileClose := shared_user .FindUserProfileReadme (ctx , ctx .Doer , profileType )
173188 defer profileClose ()
174- ctx .Data ["HasProfileReadme" ] = profileReadme != nil
189+ ctx .Data [fmt . Sprintf ( "Has%sProfileReadme" , profileType ) ] = profileReadme != nil
175190
176191 if profileGitRepo == nil || profileReadme == nil || viewRepositories {
177192 return false
178193 }
179194
180195 if bytes , err := profileReadme .GetBlobContent (setting .UI .MaxDisplayFileSize ); err != nil {
181- log .Error ("failed to GetBlobContent: %v" , err )
196+ log .Error ("failed to GetBlobContent for %s profile readme : %v" , profileType , err )
182197 } else {
183198 rctx := renderhelper .NewRenderContextRepoFile (ctx , profileDbRepo , renderhelper.RepoFileOptions {
184199 CurrentRefPath : path .Join ("branch" , util .PathEscapeSegments (profileDbRepo .DefaultBranch )),
185200 })
186201 if profileContent , err := markdown .RenderString (rctx , bytes ); err != nil {
187- log .Error ("failed to RenderString: %v" , err )
202+ log .Error ("failed to RenderString for %s profile readme : %v" , profileType , err )
188203 } else {
189- ctx .Data ["ProfileReadme" ] = profileContent
204+ ctx .Data [fmt . Sprintf ( "%sProfileReadme" , profileType ) ] = profileContent
190205 }
191206 }
192-
193- ctx .Data ["PageIsViewOverview" ] = true
194207 return true
195208}
0 commit comments