@@ -41,63 +41,39 @@ 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- prepareHomeTreeSideBarSwitch (ctx )
51-
52- branchLink := ctx .Repo .RepoLink + "/src/" + ctx .Repo .RefTypeNameSubURL ()
53- treeLink := branchLink
54- rawLink := ctx .Repo .RepoLink + "/raw/" + ctx .Repo .RefTypeNameSubURL ()
55-
56- if len (ctx .Repo .TreePath ) > 0 {
57- treeLink += "/" + util .PathEscapeSegments (ctx .Repo .TreePath )
58- }
59-
60- var treeNames []string
61- paths := make ([]string , 0 , 5 )
62- if len (ctx .Repo .TreePath ) > 0 {
63- treeNames = strings .Split (ctx .Repo .TreePath , "/" )
64- for i := range treeNames {
65- paths = append (paths , strings .Join (treeNames [:i + 1 ], "/" ))
66- }
67-
68- ctx .Data ["HasParentPath" ] = true
69- if len (paths )- 2 >= 0 {
70- ctx .Data ["ParentPath" ] = "/" + paths [len (paths )- 1 ]
71- }
72- }
73-
74- // Get current entry user currently looking at.
7552 entry , err := ctx .Repo .Commit .GetTreeEntryByPath (ctx .Repo .TreePath )
7653 if err != nil {
7754 HandleGitError (ctx , "Repo.Commit.GetTreeEntryByPath" , err )
7855 return
7956 }
8057
81- 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+ }
8263
8364 ctx .Data ["Paths" ] = paths
84- ctx .Data ["TreeLink" ] = treeLink
8565 ctx .Data ["TreeNames" ] = treeNames
86- ctx .Data ["BranchLink" ] = branchLink
87-
88- ctx .Data ["RawFileLink" ] = rawLink + "/" + util .PathEscapeSegments (ctx .Repo .TreePath )
89- ctx .Data ["PageIsViewCode" ] = true
90-
91- 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 )
9268
69+ blob := entry .Blob ()
9370 fileSize := blob .Size ()
9471 ctx .Data ["FileSize" ] = fileSize
9572 ctx .Data ["FileName" ] = blob .Name ()
9673
97- var tplName templates.TplName
98- if ctx .FormBool ("only_content" ) {
99- tplName = tplRepoViewContent
100- } else {
74+ tplName := tplRepoViewContent
75+ if ! ctx .FormBool ("only_content" ) {
76+ prepareHomeTreeSideBarSwitch (ctx )
10177 tplName = tplRepoView
10278 }
10379
@@ -114,8 +90,7 @@ func RefBlame(ctx *context.Context) {
11490 }
11591
11692 bypassBlameIgnore , _ := strconv .ParseBool (ctx .FormString ("bypass-blame-ignore" ))
117-
118- 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 )
11994 if err != nil {
12095 ctx .NotFound (err )
12196 return
0 commit comments