@@ -41,60 +41,45 @@ type blameRow struct {
41
41
42
42
// RefBlame render blame page
43
43
func 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 == "" {
46
49
ctx .NotFound (nil )
47
50
return
48
51
}
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.
73
52
entry , err := ctx .Repo .Commit .GetTreeEntryByPath (ctx .Repo .TreePath )
74
53
if err != nil {
75
54
HandleGitError (ctx , "Repo.Commit.GetTreeEntryByPath" , err )
76
55
return
77
56
}
78
57
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
+ }
80
63
81
64
ctx .Data ["Paths" ] = paths
82
- ctx .Data ["TreeLink" ] = treeLink
83
65
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 )
90
68
69
+ blob := entry .Blob ()
91
70
fileSize := blob .Size ()
92
71
ctx .Data ["FileSize" ] = fileSize
93
72
ctx .Data ["FileName" ] = blob .Name ()
94
73
74
+ tplName := tplRepoViewContent
75
+ if ! ctx .FormBool ("only_content" ) {
76
+ prepareHomeTreeSideBarSwitch (ctx )
77
+ tplName = tplRepoView
78
+ }
79
+
95
80
if fileSize >= setting .UI .MaxDisplayFileSize {
96
81
ctx .Data ["IsFileTooLarge" ] = true
97
- ctx .HTML (http .StatusOK , tplRepoHome )
82
+ ctx .HTML (http .StatusOK , tplName )
98
83
return
99
84
}
100
85
@@ -105,8 +90,7 @@ func RefBlame(ctx *context.Context) {
105
90
}
106
91
107
92
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 )
110
94
if err != nil {
111
95
ctx .NotFound (err )
112
96
return
@@ -122,7 +106,7 @@ func RefBlame(ctx *context.Context) {
122
106
123
107
renderBlame (ctx , result .Parts , commitNames )
124
108
125
- ctx .HTML (http .StatusOK , tplRepoHome )
109
+ ctx .HTML (http .StatusOK , tplName )
126
110
}
127
111
128
112
type blameResult struct {
0 commit comments