gitprep / templates / include / commit_body.html.ep /
Newer Older
118 lines | 2.919kb
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
1
<%
2
  # Parameters
cleanup commit_body logic
Yuki Kimoto authored on 2016-08-22
3
  my $user_id = stash('user');
4
  my $project_id = stash('project');
5
  my $rep_info = stash('rep_info') // app->rep_info($user_id, $project_id);
cleanup
Yuki Kimoto authored on 2013-05-31
6
  my $rev = stash('rev');
7
  my $from_rev = stash('from_rev');
add --ignore-space-change fe...
Yuki Kimoto authored on 2014-12-09
8

            
9
  my $param_ignore_space_change = param('w');
remove [basic]show_ignore_sp...
Yuki Kimoto authored on 2016-04-02
10
  my $ignore_space_change;
11
  if ($param_ignore_space_change) {
12
    $ignore_space_change = 1;
13
  }
14
  else {
15
    $ignore_space_change = app->dbi->model('project')->select(
16
      'ignore_space_change',
cleanup commit_body logic
Yuki Kimoto authored on 2016-08-22
17
      where => {user_id => $user_id, name => $project_id}
remove [basic]show_ignore_sp...
Yuki Kimoto authored on 2016-04-02
18
    )->value;
19
  }
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
20
  
21
  # Git
revert encoding support
Yuki Kimoto authored on 2013-11-22
22
  my $git = app->git;
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
23
  
24
  # Diff tree
25
  my $diff_trees = $git->diff_tree(
fix compare page from forke...
Yuki Kimoto authored on 2016-08-20
26
    $rep_info,
cleanup
Yuki Kimoto authored on 2013-05-31
27
    $rev,
28
    $from_rev,
add --ignore-space-change fe...
Yuki Kimoto authored on 2014-12-09
29
    {ignore_space_change => $ignore_space_change}
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
30
  );
improve rename commit
Yuki Kimoto authored on 2013-06-01
31

            
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
32
  my $diff_trees_h = {};
33
  for my $diff_tree (@$diff_trees) {
improve rename commit
Yuki Kimoto authored on 2013-06-01
34
    my $file = $diff_tree->{to_file};
35
    $file = $diff_tree->{from_file} unless defined $file;
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
36
    $diff_trees_h->{$file} = $diff_tree if defined $file;
37
  }
38
  
39
  # Get blob diffs
add --ignore-space-change fe...
Yuki Kimoto authored on 2014-12-09
40
  my $blob_diffs = $git->blob_diffs(
fix compare page from forke...
Yuki Kimoto authored on 2016-08-20
41
    $rep_info,
cleanup rep_info
Yuki Kimoto authored on 2016-04-16
42
    $from_rev,
43
    $rev,
44
    $diff_trees,
45
    {ignore_space_change => $ignore_space_change}
add --ignore-space-change fe...
Yuki Kimoto authored on 2014-12-09
46
  ) || [];
47
  
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
48
  my $blob_diffs_h = {};
add total add and delete lin...
Yuki Kimoto authored on 2013-05-31
49
  my $total_add_line_count = 0;
50
  my $total_delete_line_count = 0;
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
51
  for my $blob_diff (@$blob_diffs) {
52
    my $file = $blob_diff->{file};
53
    $blob_diffs_h->{$file} = $blob_diff;
add total add and delete lin...
Yuki Kimoto authored on 2013-05-31
54
    $total_add_line_count += $blob_diff->{add_line_count};
55
    $total_delete_line_count += $blob_diff->{delete_line_count};
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
56
  }
fix compare and pull page vi...
Yuki Kimoto authored on 2016-08-22
57
  
58
  # diff_tree arguments
59
  my %diff_tree_args = (
60
    rev => $rev,
61
    from_rev => $from_rev,
62
    diff_trees => $diff_trees
63
  );
64
  
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
65
%>
66

            
67
%= javascript begin
68
  $(document).ready(function () {
69
  
70
    // Diff Stats Button
71
    var diff_tree_show = false;
72
    var original_diff_stats_btn_text = $('#diff-stats-btn').text();
73
    
74
    $('#diff-stats-btn').on('click', function () {
75
      if (diff_tree_show) {
76
        $(this).text(original_diff_stats_btn_text);
77
        $('#diff_tree').css('display', 'none');
78
      }
79
      else {
80
        $('#diff_tree').css('display', 'block');
81
      }
82
      diff_tree_show = !diff_tree_show;
83
    });
84
  });
85
% end
86

            
improve commit page design
Yuki Kimoto authored on 2016-02-02
87
<div class="commit-changes">
88
  <div>
89
    Showing <b><a id="diff-stats-btn" href="javascript:void;"><%= @$diff_trees %> changed files</a></b>
improve first commit
Yuki Kimoto authored on 2013-05-31
90
    with
91
    <b><%= $total_add_line_count %> additions</b>
92
    and
93
    <b><%= $total_delete_line_count %> deletions</b>
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
94
  </div>
95
</div>
improve commit page design
Yuki Kimoto authored on 2016-02-02
96

            
97
<div id="diff_tree" style="display:none">
fix compare and pull page vi...
Yuki Kimoto authored on 2016-08-22
98
  %= include '/include/diff_tree', %diff_tree_args;
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
99
</div>
improve commit page design
Yuki Kimoto authored on 2016-02-02
100

            
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
101
% my $num = 0;
102
% for my $file (sort keys %$diff_trees_h) {
fix compare and pull page vi...
Yuki Kimoto authored on 2016-08-22
103
  <%
104
    # blob_diff_body arguments
105
    my $blob_diff = $blob_diffs_h->{$file};
106
    my %blob_diff_body_args = (
107
      user => $user_id,
108
      project => $project_id,
109
      blob_diff => $blob_diff,
110
      diff_tree => $diff_trees_h->{$file}
111
    );
112
  %>
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
113
  <div id="diff-<%= $num %>">
fix compare and pull page vi...
Yuki Kimoto authored on 2016-08-22
114
    %= include '/include/blob_diff_body', %blob_diff_body_args;
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
115
  </div>
116
  % $num++;
117
% }
118
</div>