@@ -41,60 +41,45 @@ type blameRow struct {
4141
4242// RefBlame render blame page
4343func RefBlame (ctx * context.Context ) {
44- fileName := ctx .Repo .TreePath
45- if len (fileName ) == 0 {
44+ ctx .Data ["PageIsViewCode" ] = true
45+ ctx .Data ["IsBlame" ] = true
46+
47+ // Get current entry user currently looking at.
48+ if ctx .Repo .TreePath == "" {
4649 ctx .NotFound (nil )
4750 return
4851 }
49-
50- branchLink := ctx .Repo .RepoLink + "/src/" + ctx .Repo .RefTypeNameSubURL ()
51- treeLink := branchLink
52- rawLink := ctx .Repo .RepoLink + "/raw/" + ctx .Repo .RefTypeNameSubURL ()
53-
54- if len (ctx .Repo .TreePath ) > 0 {
55- treeLink += "/" + util .PathEscapeSegments (ctx .Repo .TreePath )
56- }
57-
58- var treeNames []string
59- paths := make ([]string , 0 , 5 )
60- if len (ctx .Repo .TreePath ) > 0 {
61- treeNames = strings .Split (ctx .Repo .TreePath , "/" )
62- for i := range treeNames {
63- paths = append (paths , strings .Join (treeNames [:i + 1 ], "/" ))
64- }
65-
66- ctx .Data ["HasParentPath" ] = true
67- if len (paths )- 2 >= 0 {
68- ctx .Data ["ParentPath" ] = "/" + paths [len (paths )- 1 ]
69- }
70- }
71-
72- // Get current entry user currently looking at.
7352 entry , err := ctx .Repo .Commit .GetTreeEntryByPath (ctx .Repo .TreePath )
7453 if err != nil {
7554 HandleGitError (ctx , "Repo.Commit.GetTreeEntryByPath" , err )
7655 return
7756 }
7857
79- blob := entry .Blob ()
58+ treeNames := strings .Split (ctx .Repo .TreePath , "/" )
59+ var paths []string
60+ for i := range treeNames {
61+ paths = append (paths , strings .Join (treeNames [:i + 1 ], "/" ))
62+ }
8063
8164 ctx .Data ["Paths" ] = paths
82- ctx .Data ["TreeLink" ] = treeLink
8365 ctx .Data ["TreeNames" ] = treeNames
84- ctx .Data ["BranchLink" ] = branchLink
85-
86- ctx .Data ["RawFileLink" ] = rawLink + "/" + util .PathEscapeSegments (ctx .Repo .TreePath )
87- ctx .Data ["PageIsViewCode" ] = true
88-
89- ctx .Data ["IsBlame" ] = true
66+ ctx .Data ["BranchLink" ] = ctx .Repo .RepoLink + "/src/" + ctx .Repo .RefTypeNameSubURL ()
67+ ctx .Data ["RawFileLink" ] = ctx .Repo .RepoLink + "/raw/" + ctx .Repo .RefTypeNameSubURL () + "/" + util .PathEscapeSegments (ctx .Repo .TreePath )
9068
69+ blob := entry .Blob ()
9170 fileSize := blob .Size ()
9271 ctx .Data ["FileSize" ] = fileSize
9372 ctx .Data ["FileName" ] = blob .Name ()
9473
74+ tplName := tplRepoViewContent
75+ if ! ctx .FormBool ("only_content" ) {
76+ prepareHomeTreeSideBarSwitch (ctx )
77+ tplName = tplRepoView
78+ }
79+
9580 if fileSize >= setting .UI .MaxDisplayFileSize {
9681 ctx .Data ["IsFileTooLarge" ] = true
97- ctx .HTML (http .StatusOK , tplRepoHome )
82+ ctx .HTML (http .StatusOK , tplName )
9883 return
9984 }
10085
@@ -105,8 +90,7 @@ func RefBlame(ctx *context.Context) {
10590 }
10691
10792 bypassBlameIgnore , _ := strconv .ParseBool (ctx .FormString ("bypass-blame-ignore" ))
108-
109- result , err := performBlame (ctx , ctx .Repo .Repository , ctx .Repo .Commit , fileName , bypassBlameIgnore )
93+ result , err := performBlame (ctx , ctx .Repo .Repository , ctx .Repo .Commit , ctx .Repo .TreePath , bypassBlameIgnore )
11094 if err != nil {
11195 ctx .NotFound (err )
11296 return
@@ -122,7 +106,7 @@ func RefBlame(ctx *context.Context) {
122106
123107 renderBlame (ctx , result .Parts , commitNames )
124108
125- ctx .HTML (http .StatusOK , tplRepoHome )
109+ ctx .HTML (http .StatusOK , tplName )
126110}
127111
128112type blameResult struct {
0 commit comments