@@ -385,7 +385,6 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
385
385
386
386
fileSize := blob .Size ()
387
387
ctx .Data ["FileIsSymlink" ] = entry .IsLink ()
388
- ctx .Data ["FileSize" ] = fileSize
389
388
ctx .Data ["FileName" ] = blob .Name ()
390
389
ctx .Data ["RawFileLink" ] = rawLink + "/" + ctx .Repo .TreePath
391
390
@@ -395,21 +394,8 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
395
394
396
395
isTextFile := base .IsTextFile (buf )
397
396
isLFSFile := false
398
- ctx .Data ["IsTextFile" ] = isTextFile
399
-
400
397
isDisplayingSource := ctx .Query ("display" ) == "source"
401
398
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
413
399
414
400
//Check for LFS meta file
415
401
if isTextFile && setting .LFS .StartServer {
@@ -422,7 +408,6 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
422
408
}
423
409
}
424
410
if meta != nil {
425
- ctx .Data ["IsLFSFile" ] = true
426
411
isLFSFile = true
427
412
428
413
// OK read the lfs object
@@ -445,14 +430,25 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
445
430
buf = buf [:n ]
446
431
447
432
isTextFile = base .IsTextFile (buf )
448
- ctx .Data ["IsTextFile" ] = isTextFile
449
-
450
433
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 )
454
435
}
455
436
}
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
+
456
452
// Check LFS Lock
457
453
lfsLock , err := ctx .Repo .Repository .GetTreePathLock (ctx .Repo .TreePath )
458
454
ctx .Data ["LFSLock" ] = lfsLock
@@ -542,7 +538,6 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
542
538
ctx .Data ["MarkupType" ] = markupType
543
539
ctx .Data ["FileContent" ] = string (markup .Render (blob .Name (), buf , path .Dir (treeLink ), ctx .Repo .Repository .ComposeDocumentMetas ()))
544
540
}
545
-
546
541
}
547
542
548
543
if ctx .Repo .CanEnableEditor () {
0 commit comments