@@ -385,7 +385,6 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
385385
386386 fileSize := blob .Size ()
387387 ctx .Data ["FileIsSymlink" ] = entry .IsLink ()
388- ctx .Data ["FileSize" ] = fileSize
389388 ctx .Data ["FileName" ] = blob .Name ()
390389 ctx .Data ["RawFileLink" ] = rawLink + "/" + ctx .Repo .TreePath
391390
@@ -395,21 +394,8 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
395394
396395 isTextFile := base .IsTextFile (buf )
397396 isLFSFile := false
398- ctx .Data ["IsTextFile" ] = isTextFile
399-
400397 isDisplayingSource := ctx .Query ("display" ) == "source"
401398 isDisplayingRendered := ! isDisplayingSource
402- isRepresentableAsText := base .IsRepresentableAsText (buf )
403- ctx .Data ["IsRepresentableAsText" ] = isRepresentableAsText
404- if ! isRepresentableAsText {
405- // If we can't show plain text, always try to render.
406- isDisplayingSource = false
407- isDisplayingRendered = true
408- }
409- ctx .Data ["IsDisplayingSource" ] = isDisplayingSource
410- ctx .Data ["IsDisplayingRendered" ] = isDisplayingRendered
411-
412- ctx .Data ["IsTextSource" ] = isTextFile || isDisplayingSource
413399
414400 //Check for LFS meta file
415401 if isTextFile && setting .LFS .StartServer {
@@ -422,7 +408,6 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
422408 }
423409 }
424410 if meta != nil {
425- ctx .Data ["IsLFSFile" ] = true
426411 isLFSFile = true
427412
428413 // OK read the lfs object
@@ -445,14 +430,25 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
445430 buf = buf [:n ]
446431
447432 isTextFile = base .IsTextFile (buf )
448- ctx .Data ["IsTextFile" ] = isTextFile
449-
450433 fileSize = meta .Size
451- ctx .Data ["FileSize" ] = meta .Size
452- filenameBase64 := base64 .RawURLEncoding .EncodeToString ([]byte (blob .Name ()))
453- ctx .Data ["RawFileLink" ] = fmt .Sprintf ("%s%s.git/info/lfs/objects/%s/%s" , setting .AppURL , ctx .Repo .Repository .FullName (), meta .Oid , filenameBase64 )
434+ ctx .Data ["RawFileLink" ] = fmt .Sprintf ("%s/media/%s/%s" , ctx .Repo .RepoLink , ctx .Repo .BranchNameSubURL (), ctx .Repo .TreePath )
454435 }
455436 }
437+
438+ isRepresentableAsText := base .IsRepresentableAsText (buf )
439+ if ! isRepresentableAsText {
440+ // If we can't show plain text, always try to render.
441+ isDisplayingSource = false
442+ isDisplayingRendered = true
443+ }
444+ ctx .Data ["IsLFSFile" ] = isLFSFile
445+ ctx .Data ["FileSize" ] = fileSize
446+ ctx .Data ["IsTextFile" ] = isTextFile
447+ ctx .Data ["IsRepresentableAsText" ] = isRepresentableAsText
448+ ctx .Data ["IsDisplayingSource" ] = isDisplayingSource
449+ ctx .Data ["IsDisplayingRendered" ] = isDisplayingRendered
450+ ctx .Data ["IsTextSource" ] = isTextFile || isDisplayingSource
451+
456452 // Check LFS Lock
457453 lfsLock , err := ctx .Repo .Repository .GetTreePathLock (ctx .Repo .TreePath )
458454 ctx .Data ["LFSLock" ] = lfsLock
@@ -542,7 +538,6 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
542538 ctx .Data ["MarkupType" ] = markupType
543539 ctx .Data ["FileContent" ] = string (markup .Render (blob .Name (), buf , path .Dir (treeLink ), ctx .Repo .Repository .ComposeDocumentMetas ()))
544540 }
545-
546541 }
547542
548543 if ctx .Repo .CanEnableEditor () {
0 commit comments