gitprep / templates / include / blob_diff_body.html.ep /
Newer Older
157 lines | 5.382kb
cleanup
Yuki Kimoto authored on 2013-05-14
1
<%
cleanup commit_body logic
Yuki Kimoto authored on 2016-08-22
2
  my $user_id = stash('user');
3
  my $project_id = stash('project');
cleanup
Yuki Kimoto authored on 2013-05-31
4
  my $rev = stash('rev');
5
  my $from_rev = stash('from_rev');
impved merge commit logic
Yuki Kimoto authored on 2013-06-01
6
  
revert encoding support
Yuki Kimoto authored on 2013-11-22
7
  my $git = app->git;
binary data not shown
Yuki Kimoto authored on 2013-06-02
8
  
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
9
  my $diff_tree = stash('diff_tree');
improve first commit
Yuki Kimoto authored on 2013-05-31
10
  my $blob_diff = stash('blob_diff');
imprve file mode change
Yuki Kimoto authored on 2013-06-01
11
  my $from_mode_str = $diff_tree->{from_mode_str};
12
  my $to_mode_str = $diff_tree->{to_mode_str};
improve rename commit
Yuki Kimoto authored on 2013-06-01
13
  my $lines = $blob_diff->{lines} || [];
improve first commit
Yuki Kimoto authored on 2013-05-31
14
  my $file = $blob_diff->{file};
improve rename commit
Yuki Kimoto authored on 2013-06-01
15
  $file = '' unless defined $file;
improve first commit
Yuki Kimoto authored on 2013-05-31
16
  my $from_file = $blob_diff->{from_file};
17
  $from_file = $file unless defined $from_file;
imprve file mode change
Yuki Kimoto authored on 2013-06-01
18
  my $status = $diff_tree->{status} || '';
binary data not shown
Yuki Kimoto authored on 2013-06-02
19
  
20
  my $binary_rev_shown;
21
  my $binary_from_rev_shown;
22
  my $binary_not_shown;
23
  
24
  if ($blob_diff->{binary}) {
25
    if ($status eq 'A') {
cleanup commit_body logic
Yuki Kimoto authored on 2016-08-22
26
      if ($git->blob_is_image(app->rep_info($user_id, $project_id), $rev, $file)) {
binary data not shown
Yuki Kimoto authored on 2013-06-02
27
        $binary_rev_shown = 1;
28
      }
29
      else {
30
        $binary_not_shown = 1;
31
      }
32
    } elsif ($status eq 'D') {
cleanup commit_body logic
Yuki Kimoto authored on 2016-08-22
33
      if ($git->blob_is_image(app->rep_info($user_id, $project_id), $from_rev, $file)) {
binary data not shown
Yuki Kimoto authored on 2013-06-02
34
        $binary_from_rev_shown = 1;
35
      }
36
      else {
37
        $binary_not_shown = 1;
38
      }
39
    } else {
cleanup commit_body logic
Yuki Kimoto authored on 2016-08-22
40
      if ($git->blob_is_image(app->rep_info($user_id, $project_id), $from_rev, $file)
41
        && $git->blob_is_image(app->rep_info($user_id, $project_id), $from_rev, $file)) {
binary data not shown
Yuki Kimoto authored on 2013-06-02
42
        $binary_from_rev_shown = 1;
43
        $binary_rev_shown = 1;
44
      }
45
      else {
46
        $binary_not_shown = 1;
47
      }
48
    }
49
  }
cleanup
Yuki Kimoto authored on 2013-05-14
50
%>
51

            
improve commit page design
Yuki Kimoto authored on 2016-02-02
52
  <div class="commit-diff">
53
    <div class="commit-diff-header">
54
      <div>
55
        %= include '/include/diff_status_bar', diff_tree => $diff_tree;
56
        % if ($status eq 'R' || $status eq 'C') {
57
          <%= $from_file %> → <%= $file %>
58
        % } else {
59
          <%= $file %>
60
        % }
61
        % if ($status ne 'A' && $status ne 'D' && $from_mode_str ne $to_mode_str) {
62
          <%= "100$from_mode_str → 100$to_mode_str" %>
63
        % }
64
      </div>
65
      <div class="last-child">
66
        % if ($status eq 'D') {
cleanup commit_body logic
Yuki Kimoto authored on 2016-08-22
67
          <a class="btn" href="<%= url_for("/$user_id/$project_id/blob/$from_rev/$file") %>">
improve commit page design
Yuki Kimoto authored on 2016-02-02
68
            <b>View</b>
69
          </a>
70
        % } else {
cleanup commit_body logic
Yuki Kimoto authored on 2016-08-22
71
          <a class="btn" href="<%= url_for("/$user_id/$project_id/blob/$rev/$file") %>">
improve commit page design
Yuki Kimoto authored on 2016-02-02
72
            <b>View</b>
73
          </a>
74
        % }
improve first commit
Yuki Kimoto authored on 2013-05-31
75
      </div>
76
    </div>
improve commit page design
Yuki Kimoto authored on 2016-02-03
77
    <div class="commit-diff-body">
78
        <%
79
          my $not_shown;
80
          my $from_rev_shown;
81
          my $rev_shown;
82
        %>
83
        
binary data not shown
Yuki Kimoto authored on 2013-06-02
84

            
improve commit page design
Yuki Kimoto authored on 2016-02-03
85
        % if ($blob_diff->{binary}) {
86
          % if ($binary_not_shown) {
87
            <div class="commit-diff-plain">
88
              Binary file not shown.
89
            </div>
90
          % } else {
91
            <div class="commit-diff-image">
92
              % if ($binary_from_rev_shown) {
cleanup commit_body logic
Yuki Kimoto authored on 2016-08-22
93
                <a href="<%= url_for("/$user_id/$project_id/blob/$from_rev/$file") %>">
94
                  <img src="<%= url_for("/$user_id/$project_id/raw/$from_rev/$file") %>" style="border:1px solid red;padding:1px;margin-right:20px">
improve commit page design
Yuki Kimoto authored on 2016-02-03
95
                </a>          
96
              % }
97
              
98
              % if ($binary_rev_shown) {
cleanup commit_body logic
Yuki Kimoto authored on 2016-08-22
99
                <a href="<%= url_for("/$user_id/$project_id/blob/$rev/$file") %>">
100
                  <img src="<%= url_for("/$user_id/$project_id/raw/$rev/$file") %>" style="border:1px solid green;padding:1px;margin-left:20px">
improve commit page design
Yuki Kimoto authored on 2016-02-03
101
                </a>
102
              % }
103
            </div>
104
          % }
105
        % } elsif (@$lines) {
106
          <table>
107

            
108
            % for my $line (@$lines) {
109
              % my $class = $line->{class};
110
              % my $value = $line->{value};
111

            
112
              <%
113
                my $bk_color_line = '';
114
                my $bk_color = '';
115
                my $border_color;
116
                if ($value =~ /^@/) {
117
                  $bk_color_line = '#f3f3ff';
118
                  $border_color = '#e4e4ff';
119
                  $bk_color = '#f8f8ff';
120
                } elsif ($value =~ /^\+/) {
improve commit diff design
Yuki Kimoto authored on 2016-11-30
121
                  $bk_color_line = '#ceffce';
122
                  $border_color = '#b4e2b4';
123
                  $bk_color = '#ddffdd';
improve commit page design
Yuki Kimoto authored on 2016-02-03
124
                } elsif ($value =~ /^-/) {
125
                  $bk_color_line = '#f7c8c8';
126
                  $border_color = '#e9aeae';
127
                  $bk_color = '#fdd';
128
                } else {
129
                  $border_color = '#e5e5e5';
130
                }
131
              %>
132
              <tr >
133
                <td style="font-size:12px;color:#aaa;padding:0 7px;border-right:1px <%= $border_color %> solid;background:<%= $bk_color_line %>;">
134
                  <%= $line->{before_line_num} %>
135
                </td>
136
                <td style="font-size:12px;color:#aaa;padding:0 7px;border-right:1px <%= $border_color %> solid;background:<%= $bk_color_line %>;">
137
                  <%= $line->{after_line_num} %>
138
                </td>
139
                <td style="width:100%;padding-left:7px;background:<%= $bk_color %>;">
140
                  <pre style="border:none;background:none;padding:0;margin:0"><%= $value %></pre>
141
                </td>
142
              </tr>
binary data not shown
Yuki Kimoto authored on 2013-06-02
143
            % }
improve commit page design
Yuki Kimoto authored on 2016-02-03
144
          </table>
145
        % } else {
146
          <div class="commit-diff-plain">
147
            % if ($status eq 'R') {
148
              File renamed without changes.
149
            % } elsif ($status eq 'A' || $status eq 'D') {
150
               No changes.
151
            % } elsif ($from_mode_str ne $to_mode_str) {
152
              File mode changed.
binary data not shown
Yuki Kimoto authored on 2013-06-02
153
            % }
154
          </div>
155
        % }
improve commit page design
Yuki Kimoto authored on 2016-02-03
156
    </div>
improve first commit
Yuki Kimoto authored on 2013-05-31
157
  </div>