summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorMario Lubenka <mario.lubenka@googlemail.com>2019-10-04 21:58:54 +0200
committertechknowlogick <techknowlogick@gitea.io>2019-10-04 15:58:54 -0400
commitf92a0b68fed81128fa278e82aa0e3d49d74ffdf6 (patch)
tree41a6a7cd2a8a6153046851b5ab3a9c5aacb0cdfd /templates
parentde8a0a3938e811ffaa6800a771d7f09fd6428608 (diff)
downloadgitea-f92a0b68fed81128fa278e82aa0e3d49d74ffdf6.tar.gz
gitea-f92a0b68fed81128fa278e82aa0e3d49d74ffdf6.zip
Bugfix for image compare and minor improvements to image compare (#8289)
* Resolve error when comparing images Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Check blob existence instead of git-ls when checking if file exists Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Show file metadata also when a file was newly added Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Fixes error in commit view Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Excludes assigning path and image infos for compare routers to service package Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Removes nil default and fixes import order Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adds missing comments Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Moves methods for assigning compare data to context into repo router package Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Show image compare for deleted images as well. Simplify check if image should be displayed Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/diff/box.tmpl7
-rw-r--r--templates/repo/diff/image_diff.tmpl57
2 files changed, 51 insertions, 13 deletions
diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl
index edc04f9068..b5fde36a6f 100644
--- a/templates/repo/diff/box.tmpl
+++ b/templates/repo/diff/box.tmpl
@@ -106,7 +106,12 @@
</h4>
<div class="ui attached unstackable table segment">
{{if ne $file.Type 4}}
- {{$isImage := (call $.IsImageFile $file.Name)}}
+ {{$isImage := false}}
+ {{if $file.IsDeleted}}
+ {{$isImage = (call $.IsImageFileInBase $file.Name)}}
+ {{else}}
+ {{$isImage = (call $.IsImageFileInHead $file.Name)}}
+ {{end}}
<div class="file-body file-code code-view code-diff {{if $.IsSplitStyle}}code-diff-split{{else}}code-diff-unified{{end}}">
<table>
<tbody>
diff --git a/templates/repo/diff/image_diff.tmpl b/templates/repo/diff/image_diff.tmpl
index 8fa7f6b872..6afb985e9a 100644
--- a/templates/repo/diff/image_diff.tmpl
+++ b/templates/repo/diff/image_diff.tmpl
@@ -11,36 +11,69 @@
</tr>
<tr>
<td class="halfwidth center">
- {{ $oldImageExists := (call .root.FileExistsInBaseCommit .file.OldName) }}
- {{if $oldImageExists}}
+ {{if or .file.IsDeleted (not .file.IsCreated)}}
<a href="{{$imagePathOld}}" target="_blank">
<img src="{{$imagePathOld}}" class="border red" />
</a>
{{end}}
</td>
<td class="halfwidth center">
- <a href="{{$imagePathNew}}" target="_blank">
- <img src="{{$imagePathNew}}" class="border green" />
- </a>
+ {{if or .file.IsCreated (not .file.IsDeleted)}}
+ <a href="{{$imagePathNew}}" target="_blank">
+ <img src="{{$imagePathNew}}" class="border green" />
+ </a>
+ {{end}}
</td>
</tr>
{{ $imageInfoBase := (call .root.ImageInfoBase .file.OldName) }}
{{ $imageInfoHead := (call .root.ImageInfo .file.Name) }}
-{{if and $imageInfoBase $imageInfoHead }}
+{{if or $imageInfoBase $imageInfoHead }}
<tr>
<td class="halfwidth center">
- {{.root.i18n.Tr "repo.diff.file_image_width"}}: <span class="text {{if not (eq $imageInfoBase.Width $imageInfoHead.Width)}}red{{end}}">{{$imageInfoBase.Width}}</span>
+ {{if $imageInfoBase }}
+ {{ $classWidth := "" }}
+ {{ $classHeight := "" }}
+ {{ $classByteSize := "" }}
+ {{if $imageInfoHead}}
+ {{if not (eq $imageInfoBase.Width $imageInfoHead.Width)}}
+ {{ $classWidth = "red" }}
+ {{end}}
+ {{if not (eq $imageInfoBase.Height $imageInfoHead.Height)}}
+ {{ $classHeight = "red" }}
+ {{end}}
+ {{if not (eq $imageInfoBase.ByteSize $imageInfoHead.ByteSize)}}
+ {{ $classByteSize = "red" }}
+ {{end}}
+ {{end}}
+ {{.root.i18n.Tr "repo.diff.file_image_width"}}: <span class="text {{$classWidth}}">{{$imageInfoBase.Width}}</span>
&nbsp;|&nbsp;
- {{.root.i18n.Tr "repo.diff.file_image_height"}}: <span class="text {{if not (eq $imageInfoBase.Height $imageInfoHead.Height)}}red{{end}}">{{$imageInfoBase.Height}}</span>
+ {{.root.i18n.Tr "repo.diff.file_image_height"}}: <span class="text {{$classHeight}}">{{$imageInfoBase.Height}}</span>
&nbsp;|&nbsp;
- {{.root.i18n.Tr "repo.diff.file_byte_size"}}: <span class="text {{if not (eq $imageInfoBase.ByteSize $imageInfoHead.ByteSize)}}red{{end}}">{{FileSize $imageInfoBase.ByteSize}}</span>
+ {{.root.i18n.Tr "repo.diff.file_byte_size"}}: <span class="text {{$classByteSize}}">{{FileSize $imageInfoBase.ByteSize}}</span>
+ {{end}}
</td>
<td class="halfwidth center">
- {{.root.i18n.Tr "repo.diff.file_image_width"}}: <span class="text {{if not (eq $imageInfoBase.Width $imageInfoHead.Width)}}green{{end}}">{{$imageInfoHead.Width}}</span>
+ {{if $imageInfoHead }}
+ {{ $classWidth := "" }}
+ {{ $classHeight := "" }}
+ {{ $classByteSize := "" }}
+ {{if $imageInfoBase}}
+ {{if not (eq $imageInfoBase.Width $imageInfoHead.Width)}}
+ {{ $classWidth = "green" }}
+ {{end}}
+ {{if not (eq $imageInfoBase.Height $imageInfoHead.Height)}}
+ {{ $classHeight = "green" }}
+ {{end}}
+ {{if not (eq $imageInfoBase.ByteSize $imageInfoHead.ByteSize)}}
+ {{ $classByteSize = "green" }}
+ {{end}}
+ {{end}}
+ {{.root.i18n.Tr "repo.diff.file_image_width"}}: <span class="text {{$classWidth}}">{{$imageInfoHead.Width}}</span>
&nbsp;|&nbsp;
- {{.root.i18n.Tr "repo.diff.file_image_height"}}: <span class="text {{if not (eq $imageInfoBase.Height $imageInfoHead.Height)}}green{{end}}">{{$imageInfoHead.Height}}</span>
+ {{.root.i18n.Tr "repo.diff.file_image_height"}}: <span class="text {{$classHeight}}">{{$imageInfoHead.Height}}</span>
&nbsp;|&nbsp;
- {{.root.i18n.Tr "repo.diff.file_byte_size"}}: <span class="text {{if not (eq $imageInfoBase.ByteSize $imageInfoHead.ByteSize)}}green{{end}}">{{FileSize $imageInfoHead.ByteSize}}</span>
+ {{.root.i18n.Tr "repo.diff.file_byte_size"}}: <span class="text {{$classByteSize}}">{{FileSize $imageInfoHead.ByteSize}}</span>
+ {{end}}
</td>
</tr>
{{end}}