diff --git a/.gitignore b/.gitignore index 0ac6ed9dfa..ddca4a0495 100644 --- a/.gitignore +++ b/.gitignore @@ -123,3 +123,6 @@ prime/ # A Makefile for custom make targets Makefile.local + +# Shared .tinqs sibling (Team Tool logs, sessions) +../.tinqs/ diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 285f3968d4..f2c3e60bc2 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -82,6 +82,15 @@ func setCompareContext(ctx *context.Context, before, head *git.Commit, headOwner return st } + ctx.Data["IsHTMLFile"] = func(diffFile *gitdiff.DiffFile) bool { + extension := strings.ToLower(filepath.Ext(diffFile.Name)) + if extension == ".html" || extension == ".htm" { + return true + } + extension = strings.ToLower(filepath.Ext(diffFile.OldName)) + return extension == ".html" || extension == ".htm" + } + setPathsCompareContext(ctx, before, head, headOwner, headName) setImageCompareContext(ctx) setCsvCompareContext(ctx) diff --git a/routers/web/repo/view_file.go b/routers/web/repo/view_file.go index d7a0b3174c..7c37f249fb 100644 --- a/routers/web/repo/view_file.go +++ b/routers/web/repo/view_file.go @@ -154,7 +154,8 @@ func handleFileViewRenderImage(ctx *context.Context, fInfo *fileInfo, prefetchBu } func handleFileViewRenderHTML(ctx *context.Context, fInfo *fileInfo) bool { - if !strings.HasSuffix(strings.ToLower(ctx.Repo.TreePath), ".html") { + lower := strings.ToLower(ctx.Repo.TreePath) + if !strings.HasSuffix(lower, ".html") && !strings.HasSuffix(lower, ".htm") { return false } // Allow toggling to source view diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 390e41ec34..a37d35036f 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -77,8 +77,9 @@ {{$sniffedTypeBase := call $.GetSniffedTypeForBlob $blobBase}} {{$sniffedTypeHead := call $.GetSniffedTypeForBlob $blobHead}} {{$isImage:= or (call $.IsSniffedTypeAnImage $sniffedTypeBase) (call $.IsSniffedTypeAnImage $sniffedTypeHead)}} - {{$isCsv := (call $.IsCsvFile $file)}} - {{$showFileViewToggle := or $isImage (and (not $file.IsIncomplete) $isCsv)}} + {{$isCsv := (call $.IsCsvFile $file)}} + {{$isHTML := (call $.IsHTMLFile $file)}} + {{$showFileViewToggle := or $isImage (and (not $file.IsIncomplete) $isCsv) $isHTML}} {{$isExpandable := or (gt $file.Addition 0) (gt $file.Deletion 0) $file.IsBin}} {{$isReviewFile := and $.IsSigned $.PageIsPullFiles (not $.Repository.IsArchived) $.IsShowingAllCommits}}