aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo/diff.tmpl
blob: 8e5efd146f1ded34f0a76228227b041fe0d57a39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{{template "base/head" .}}
{{template "base/navbar" .}}
{{template "repo/nav" .}}
<div id="body" class="container" data-page="repo">
    <div id="source">
      {{if .IsDiffCompare }}
        <div class="panel panel-info diff-box diff-head-box">
            <div class="panel-heading">
                <a class="pull-right btn btn-primary btn-sm" rel="nofollow" href="{{.SourcePath}}">Browse Source</a>
                <h4><a href="{{$.RepoLink}}/commit/{{.BeforeCommitId}}" class="label label-success">{{ShortSha .BeforeCommitId}}</a> ... <a href="{{$.RepoLink}}/commit/{{.AfterCommitId}}" class="label label-success">{{ShortSha .AfterCommitId}}</a></h4>
            </div>
            <div class="panel-body compare">
              {{template "repo/commits_table" .}}
            </div>
        </div>
      {{else}}
          <div class="panel panel-info diff-box diff-head-box">
            <div class="panel-heading">
                <a class="pull-right btn btn-primary btn-sm" rel="nofollow" href="{{.SourcePath}}">Browse Source</a>
                <h4>{{.Commit.Message}}</h4>
            </div>
            <div class="panel-body">
                <span class="pull-right">
                <ul class="list-unstyled">
                    {{range .Parents}}
                    <li>parent <a href="{{$.RepoLink}}/commit/{{.}}"><span class="label label-default sha">{{ShortSha .}}</span></a></li>
                    {{end}}
                    <li>commit <span class="label label-default sha">{{ShortSha .CommitId}}</span></li>
                </ul>
                </span>
                <p class="author">
                    <img class="avatar" src="{{AvatarLink .Commit.Author.Email}}" alt=""/>
                    <a class="name" href="{{AppSubUrl}}/user/email2user?email={{.Commit.Author.Email}}"><strong>{{.Commit.Author.Name}}</strong></a>
                    <span class="time">{{TimeSince .Commit.Author.When $.Lang}}</span>
                </p>
          </div>
        </div>
      {{end}}
        {{if .DiffNotAvailable}}
        <h4>Diff Data Not Available.</h4>
        {{else}}
        <div class="diff-detail-box diff-box">
            <a class="pull-right btn btn-default" data-toggle="collapse" data-target="#diff-files">Show Diff Stats</a>
            <p class="showing">
                <i class="fa fa-retweet"></i>
                <strong> {{.Diff.NumFiles}} changed files</strong> with <strong>{{.Diff.TotalAddition}} additions</strong> and <strong>{{.Diff.TotalDeletion}} deletions</strong>.
            </p>
            <ol class="detail-files collapse" id="diff-files">
                {{range .Diff.Files}}
                <li>
                    <div class="diff-counter count pull-right">
                        {{if not .IsBin}}
                        <span class="add" data-line="{{.Addition}}">{{.Addition}}</span>
                        <span class="bar">
                            <span class="pull-left add"></span>
                            <span class="pull-left del"></span>
                        </span>
                        <span class="del" data-line="{{.Deletion}}">{{.Deletion}}</span>
                        {{else}}
                        <span>BIN</span>
                        {{end}}
                    </div>
                    <!-- todo finish all file status, now modify, add, delete and rename -->
                    <span class="status {{DiffTypeToStr .Type}}" data-toggle="tooltip" data-placement="right" title="{{DiffTypeToStr .Type}}">&nbsp;</span>
                    <a class="file" href="#diff-{{.Index}}">{{.Name}}</a>
                </li>
                {{end}}
            </ol>
        </div>

        {{range .Diff.Files}}
        <div class="panel panel-default diff-file-box diff-box file-content" id="diff-{{.Index}}">
            <div class="panel-heading">
                <div class="diff-counter count pull-left">
                    {{if not .IsBin}}
                    <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
                    <span class="bar">
                        <span class="pull-left add"></span>
                        <span class="pull-left del"></span>
                    </span>
                    <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
                    {{else}}
                    BIN
                    {{end}}
                </div>
                <a class="btn btn-default btn-sm pull-right" rel="nofollow" href="{{$.SourcePath}}/{{.Name}}">View File</a>
                <span class="file">{{.Name}}</span>
            </div>
            {{$isImage := (call $.IsImageFile .Name)}}
            <div class="panel-body file-body file-code code-view code-diff">
                {{if $isImage}}
                    <div class="text-center">
                        <img src="{{$.RawPath}}/{{.Name}}">
                    </div>
                {{else}}
                <table>
                    <tbody>
                        {{range .Sections}}
                        {{range .Lines}}
                        <tr class="{{DiffLineTypeToStr .Type}}-code nl-1 ol-1">
                            <td class="lines-num lines-num-old">
                                <span rel="L1">{{if .LeftIdx}}{{.LeftIdx}}{{end}}</span>
                            </td>
                            <td class="lines-num lines-num-new">
                                <span rel="L1">{{if .RightIdx}}{{.RightIdx}}{{end}}</span>
                            </td>
                            <td class="lines-code">
                                <pre>{{ToUtf8 .Content}}</pre>
                            </td>
                        </tr>
                        {{end}}
                        {{end}}
                    </tbody>
                </table>
                {{end}}
            </div>
        </div>
        {{end}}
        {{end}}
    </div>
</div>
{{template "base/footer" .}}