@@ -111,7 +111,22 @@ func home(ctx *context.Context, viewRepositories bool) {
111
111
ctx .Data ["DisableNewPullMirrors" ] = setting .Mirror .DisableNewPull
112
112
ctx .Data ["ShowMemberAndTeamTab" ] = ctx .Org .IsMember || len (members ) > 0
113
113
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 ) {
115
130
ctx .Data ["PageIsViewRepositories" ] = true
116
131
}
117
132
@@ -168,28 +183,26 @@ func home(ctx *context.Context, viewRepositories bool) {
168
183
ctx .HTML (http .StatusOK , tplOrgHome )
169
184
}
170
185
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 )
173
188
defer profileClose ()
174
- ctx .Data ["HasProfileReadme" ] = profileReadme != nil
189
+ ctx .Data [fmt . Sprintf ( "Has%sProfileReadme" , profileType ) ] = profileReadme != nil
175
190
176
191
if profileGitRepo == nil || profileReadme == nil || viewRepositories {
177
192
return false
178
193
}
179
194
180
195
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 )
182
197
} else {
183
198
rctx := renderhelper .NewRenderContextRepoFile (ctx , profileDbRepo , renderhelper.RepoFileOptions {
184
199
CurrentRefPath : path .Join ("branch" , util .PathEscapeSegments (profileDbRepo .DefaultBranch )),
185
200
})
186
201
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 )
188
203
} else {
189
- ctx .Data ["ProfileReadme" ] = profileContent
204
+ ctx .Data [fmt . Sprintf ( "%sProfileReadme" , profileType ) ] = profileContent
190
205
}
191
206
}
192
-
193
- ctx .Data ["PageIsViewOverview" ] = true
194
207
return true
195
208
}
0 commit comments