You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

image_diff.tmpl 2.2 kB

Adds side-by-side diff for images (#6784) * Adds side-by-side diff for images Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Explain blank imports Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Use complete word for width and height labels on image compare Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Update index.css from master Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Moves ImageInfo to git commit file Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Assign ImageInfo function for template and sets correct target for BeforeSourcePath Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adds missing comment Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Return error if ImageInfo failed Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Avoid template panic when ImageInfo failed for some reason Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Show file size on image diff Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Removes unused helper function Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Reverts copyright year change Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Close file reader Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Update commit.go Sets correct data key * Moves reader.Close() up a few lines * Updates index.css * Updates CSS file Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Transfers adjustments for image compare to compare.go file Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adjusts variable name Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Apply lesshint recommendations Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Do not show old image on image compare if it is not in index of base commit Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Change file size text Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
6 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. {{ $imagePathOld := printf "%s/%s" .root.BeforeRawPath (EscapePound .file.OldName) }}
  2. {{ $imagePathNew := printf "%s/%s" .root.RawPath (EscapePound .file.Name) }}
  3. <tr>
  4. <th class="halfwidth center">
  5. {{.root.i18n.Tr "repo.diff.file_before"}}
  6. </th>
  7. <th class="halfwidth center">
  8. {{.root.i18n.Tr "repo.diff.file_after"}}
  9. </th>
  10. </tr>
  11. <tr>
  12. <td class="halfwidth center">
  13. {{ $oldImageExists := (call .root.FileExistsInBaseCommit .file.OldName) }}
  14. {{if $oldImageExists}}
  15. <a href="{{$imagePathOld}}" target="_blank">
  16. <img src="{{$imagePathOld}}" class="border red" />
  17. </a>
  18. {{end}}
  19. </td>
  20. <td class="halfwidth center">
  21. <a href="{{$imagePathNew}}" target="_blank">
  22. <img src="{{$imagePathNew}}" class="border green" />
  23. </a>
  24. </td>
  25. </tr>
  26. {{ $imageInfoBase := (call .root.ImageInfoBase .file.OldName) }}
  27. {{ $imageInfoHead := (call .root.ImageInfo .file.Name) }}
  28. {{if and $imageInfoBase $imageInfoHead }}
  29. <tr>
  30. <td class="halfwidth center">
  31. {{.root.i18n.Tr "repo.diff.file_image_width"}}: <span class="text {{if not (eq $imageInfoBase.Width $imageInfoHead.Width)}}red{{end}}">{{$imageInfoBase.Width}}</span>
  32. &nbsp;|&nbsp;
  33. {{.root.i18n.Tr "repo.diff.file_image_height"}}: <span class="text {{if not (eq $imageInfoBase.Height $imageInfoHead.Height)}}red{{end}}">{{$imageInfoBase.Height}}</span>
  34. &nbsp;|&nbsp;
  35. {{.root.i18n.Tr "repo.diff.file_byte_size"}}: <span class="text {{if not (eq $imageInfoBase.ByteSize $imageInfoHead.ByteSize)}}red{{end}}">{{FileSize $imageInfoBase.ByteSize}}</span>
  36. </td>
  37. <td class="halfwidth center">
  38. {{.root.i18n.Tr "repo.diff.file_image_width"}}: <span class="text {{if not (eq $imageInfoBase.Width $imageInfoHead.Width)}}green{{end}}">{{$imageInfoHead.Width}}</span>
  39. &nbsp;|&nbsp;
  40. {{.root.i18n.Tr "repo.diff.file_image_height"}}: <span class="text {{if not (eq $imageInfoBase.Height $imageInfoHead.Height)}}green{{end}}">{{$imageInfoHead.Height}}</span>
  41. &nbsp;|&nbsp;
  42. {{.root.i18n.Tr "repo.diff.file_byte_size"}}: <span class="text {{if not (eq $imageInfoBase.ByteSize $imageInfoHead.ByteSize)}}green{{end}}">{{FileSize $imageInfoHead.ByteSize}}</span>
  43. </td>
  44. </tr>
  45. {{end}}