]> source.dussan.org Git - gitea.git/commitdiff
add multifile support to diff view highlighting
authorAlexey Makhov <makhov.alex@gmail.com>
Wed, 4 Feb 2015 18:54:45 +0000 (21:54 +0300)
committerAlexey Makhov <makhov.alex@gmail.com>
Wed, 4 Feb 2015 18:54:45 +0000 (21:54 +0300)
templates/repo/diff.tmpl

index 8becb006597ecdf32e8b84be30d57a11abfdf177..13b78a38b95d6a55464949766fb121349c6cd93c 100644 (file)
             </ol>
         </div>
 
-        {{range .Diff.Files}}
+        {{range $i, $file := .Diff.Files}}
         <div class="panel panel-radius diff-file-box diff-box file-content" id="diff-{{.Index}}">
             <div class="panel-header">
                 <div class="diff-counter count pull-left">
-                    {{if not .IsBin}}
+                    {{if not $file.IsBin}}
                     <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
                     <span class="bar">
                         <span class="pull-left add"></span>
@@ -90,9 +90,9 @@
                     {{end}}
                 </div>
                 <a class="btn btn-gray btn-header btn-radius text-black pull-right" rel="nofollow" href="{{$.SourcePath}}/{{.Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
-                <span class="file">{{.Name}}</span>
+                <span class="file">{{$file.Name}}</span>
             </div>
-            {{$isImage := (call $.IsImageFile .Name)}}
+            {{$isImage := (call $.IsImageFile $file.Name)}}
             <div class="panel-body file-body file-code code-view code-diff">
                 {{if $isImage}}
                     <div class="text-center">
                 {{else}}
                 <table>
                     <tbody>
-                        {{range .Sections}}
-                        {{range $i, $line := .Lines}}
+                        {{range $j, $section := $file.Sections}}
+                        {{range $k, $line := $section.Lines}}                        
                         <tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$i}} ol-{{$i}}">
                             <td class="lines-num lines-num-old">
-                                <span rel="L{{$i}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
+                                <span rel="L{{Add $i 1}}{{Add $j 1}}{{$k}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
                             </td>
                             <td class="lines-num lines-num-new">
-                                <span rel="L{{$i}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
+                                <span rel="L{{Add $i 1}}{{Add $j 1}}{{$k}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
                             </td>
                             
                             <td class="lines-code">