99 "html/template"
1010 "net/http"
1111 "path"
12+ "strconv"
1213 "strings"
1314 "time"
1415
@@ -17,6 +18,7 @@ import (
1718 access_model "code.gitea.io/gitea/models/perm/access"
1819 repo_model "code.gitea.io/gitea/models/repo"
1920 unit_model "code.gitea.io/gitea/models/unit"
21+ user_model "code.gitea.io/gitea/models/user"
2022 "code.gitea.io/gitea/modules/git"
2123 "code.gitea.io/gitea/modules/log"
2224 repo_module "code.gitea.io/gitea/modules/repository"
@@ -328,6 +330,21 @@ func handleRepoHomeFeed(ctx *context.Context) bool {
328330 return true
329331}
330332
333+ func prepareHomeTreeSideBarSwitch (ctx * context.Context ) {
334+ showFileViewTreeSidebar := true
335+ if ctx .Doer != nil {
336+ v , err := user_model .GetUserSetting (ctx , ctx .Doer .ID , user_model .SettingsKeyShowFileViewTreeSidebar , "true" )
337+ if err != nil {
338+ log .Error ("GetUserSetting: %v" , err )
339+ } else {
340+ showFileViewTreeSidebar , _ = strconv .ParseBool (v )
341+ }
342+ }
343+ ctx .Data ["RepoPreferences" ] = & preferencesForm {
344+ ShowFileViewTreeSidebar : showFileViewTreeSidebar ,
345+ }
346+ }
347+
331348// Home render repository home page
332349func Home (ctx * context.Context ) {
333350 if handleRepoHomeFeed (ctx ) {
@@ -341,6 +358,8 @@ func Home(ctx *context.Context) {
341358 return
342359 }
343360
361+ prepareHomeTreeSideBarSwitch (ctx )
362+
344363 title := ctx .Repo .Repository .Owner .Name + "/" + ctx .Repo .Repository .Name
345364 if len (ctx .Repo .Repository .Description ) > 0 {
346365 title += ": " + ctx .Repo .Repository .Description
@@ -410,7 +429,13 @@ func Home(ctx *context.Context) {
410429 }
411430 }
412431
413- ctx .HTML (http .StatusOK , tplRepoHome )
432+ if ctx .FormBool ("only_content" ) {
433+ ctx .HTML (http .StatusOK , tplRepoViewContent )
434+ } else if len (treeNames ) != 0 {
435+ ctx .HTML (http .StatusOK , tplRepoView )
436+ } else {
437+ ctx .HTML (http .StatusOK , tplRepoHome )
438+ }
414439}
415440
416441func RedirectRepoTreeToSrc (ctx * context.Context ) {
0 commit comments