gitprep / templates / branches.html.ep /
Newer Older
349 lines | 11.861kb
added Tags link
Yuki Kimoto authored on 2012-11-28
1
<%
added branch status to branc...
Yuki Kimoto authored on 2013-05-06
2

            
added Tags link
Yuki Kimoto authored on 2012-11-28
3
  # API
cleanup
Yuki Kimoto authored on 2013-03-19
4
  my $api = gitprep_api;
added Tags link
Yuki Kimoto authored on 2012-11-28
5

            
cleanup branches page
Yuki Kimoto authored on 2013-01-29
6
  # Parameters
added Tags link
Yuki Kimoto authored on 2012-11-28
7
  my $user = param('user');
cleanup, rename repository t...
Yuki Kimoto authored on 2013-01-29
8
  my $project = param('project');
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
9
  my $op = param('op') || '';
improve some branches page
Yuki Kimoto authored on 2015-12-23
10
  my $display = param('display') || 'overview';
improve tags page design
Yuki Kimoto authored on 2016-02-01
11
  my $page = param('page') || 1;
added Tags link
Yuki Kimoto authored on 2012-11-28
12
  
13
  # Git
revert encoding support
Yuki Kimoto authored on 2013-11-22
14
  my $git = $self->app->git;
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
15

            
16
  # Delete
17
  my $errors;
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
18
  if ($op eq 'delete' && lc $self->req->method eq 'post') {
19
    
20
    # Forbbiden
21
    unless ($api->logined($user)) {
22
      $self->redirect_to('/');
23
      return;    
24
    }
cleanup branch page validati...
Yuki Kimoto authored on 2016-02-11
25
    
26
    # Parameters
27
    my $branch = param('branch');
28
    
29
    # Validator
30
    my $vc = app->vc;
31
    
32
    # Validation result
33
    my $validation = $vc->validation;
34
    
35
    # "branch"
36
    if (!(defined $branch && length $branch)) {
37
      $validation->add_failed(branch => 'Branch name is empty');
38
    }
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
39

            
cleanup branch page validati...
Yuki Kimoto authored on 2016-02-11
40
    if ($validation->is_valid) {
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
41
      # Delete branch
cleanup descriptioN
Yuki Kimoto authored on 2016-04-16
42
      eval { $git->delete_branch(app->rep_info($user, $project), $branch) };
improve error message
Yuki Kimoto authored on 2014-02-13
43
      if (my $e = $@) {
44
        app->log->error(url_with . ": $e");
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
45
        $errors = ['Internal Error'];
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
46
      }
47
      else {
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
48
        $self->flash(message => "Branch $branch is deleted.");
49
        $self->redirect_to;
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
50
        return;
51
      }
52
    }
cleanup branch page validati...
Yuki Kimoto authored on 2016-02-11
53
    else { $errors = $validation->messages }
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
54
  }
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
55
  
56
  # Default branch
improve some branches page
Yuki Kimoto authored on 2015-12-23
57
  my $default_branch_name = app->manager->default_branch($user, $project);
cleanup rep_info
Yuki Kimoto authored on 2016-04-16
58
  my $default_branch = $git->branch($self->app->rep_info($user, $project), $default_branch_name);
improve some branches page
Yuki Kimoto authored on 2015-12-23
59
  
60
  # Branches
improve branches design
Yuki Kimoto authored on 2016-01-30
61
  my $branch_types;
improve some branches page
Yuki Kimoto authored on 2015-12-23
62
  my $branches_h = {
63
    default => [],
64
    active => [],
65
    stale => [],
66
    all => []
67
  };
improve tags page design
Yuki Kimoto authored on 2016-02-01
68

            
69
  # Pagenation
70
  my $page_count = 20;
71
  my $skip = $page_count * ($page - 1);
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
72
  
cleanup rep_info
Yuki Kimoto authored on 2016-04-16
73
  my $branches = $git->branches($self->app->rep_info($user, $project));
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
74
  my $max = 0;
improve tags page design
Yuki Kimoto authored on 2016-02-01
75
  my $active_count = 0;
76
  my $stale_count = 0;
77
  my $all_count = 0;
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
78
  for my $branch (@$branches) {
cleanup branch_status
Yuki Kimoto authored on 2016-04-16
79
    $branch->{status} = $git->branch_status(
cleanup rep_info
Yuki Kimoto authored on 2016-04-16
80
      $self->app->rep_info($user, $project),
81
      $default_branch->{name},
82
      $branch->{name}
cleanup branch_status
Yuki Kimoto authored on 2016-04-16
83
    );
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
84
    $max = $branch->{status}{ahead} if $max < $branch->{status}{ahead};
85
    $max = $branch->{status}{behind} if $max < $branch->{status}{behind};
improve some branches page
Yuki Kimoto authored on 2015-12-23
86
    
fix branches bar
Yuki Kimoto authored on 2016-02-12
87
    if ($branch->{status}{ahead} > 100) {
88
      $branch->{status}{ahead_bar} = 100;
89
    }
90
    else {
91
      $branch->{status}{ahead_bar} = $branch->{status}{ahead};
92
    }
93
    if ($branch->{status}{behind} > 100) {
94
      $branch->{status}{behind_bar} = 100;
95
    }
96
    else {
97
      $branch->{status}{behind_bar} = $branch->{status}{behind};
98
    }
99
    
100
    $max = 100 if $max > 100;
101
    
improve branch design
Yuki Kimoto authored on 2016-01-30
102
    my $branch_type;
103
    if ($branch->{name} eq $default_branch_name) {
104
      $branch_type = 'default';
105
    }
106
    elsif ($branch->{commit}{age} < 60 * 60 * 24 * (365 * 3)) {
107
      $branch_type = 'active';
108
    }
109
    else {
110
      $branch_type = 'stale';
111
    }
separate active, stale
Yuki Kimoto authored on 2015-12-23
112
    
improve some branches page
Yuki Kimoto authored on 2015-12-23
113
    if ($display eq 'overview') {
improve branch design
Yuki Kimoto authored on 2016-01-30
114
      if ($branch_type eq 'default') {
improve some branches page
Yuki Kimoto authored on 2015-12-23
115
        push @{$branches_h->{default}}, $branch;
116
      }
improve branch design
Yuki Kimoto authored on 2016-01-30
117
      elsif ($branch_type eq 'active') {
118
        push @{$branches_h->{active}}, $branch;
119
      }
120
      elsif ($branch_type eq 'stale') {
121
        push @{$branches_h->{stale}}, $branch;
improve some branches page
Yuki Kimoto authored on 2015-12-23
122
      }
123
    }
124
    elsif ($display eq 'active') {
improve branch design
Yuki Kimoto authored on 2016-01-30
125
      if ($branch_type eq 'active') {
improve tags page design
Yuki Kimoto authored on 2016-02-01
126
        if ($active_count >= $skip && $active_count < $skip + $page_count) {
127
          push @{$branches_h->{active}}, $branch;
128
        }
129
        $active_count++;
separate active, stale
Yuki Kimoto authored on 2015-12-23
130
      }
improve some branches page
Yuki Kimoto authored on 2015-12-23
131
    }
132
    elsif ($display eq 'stale') {
improve branch design
Yuki Kimoto authored on 2016-01-30
133
      if ($branch_type eq 'stale') {
improve tags page design
Yuki Kimoto authored on 2016-02-01
134
        if ($stale_count >= $skip && $stale_count < $skip + $page_count) {
135
          push @{$branches_h->{stale}}, $branch;
136
        }
137
        $stale_count++;
separate active, stale
Yuki Kimoto authored on 2015-12-23
138
      }
improve some branches page
Yuki Kimoto authored on 2015-12-23
139
    }
140
    elsif ($display eq 'all') {
improve tags page design
Yuki Kimoto authored on 2016-02-01
141
      if ($all_count >= $skip && $all_count < $skip + $page_count) {
142
        push @{$branches_h->{all}}, $branch;
143
      }
144
      $all_count++;
improve some branches page
Yuki Kimoto authored on 2015-12-23
145
    }
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
146
  }
improve tags page design
Yuki Kimoto authored on 2016-02-01
147
  
added Tags link
Yuki Kimoto authored on 2012-11-28
148
%>
149

            
add title
Yuki Kimoto authored on 2013-06-12
150
% layout 'common', title => "branches  \x{30fb} $user/$project";
added merged branches to bra...
Yuki Kimoto authored on 2013-05-03
151

            
cleanup
Yuki Kimoto authored on 2013-01-28
152
  %= include '/include/header';
cleanup
Yuki Kimoto authored on 2013-03-15
153
  
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
154
  <div class="container" style="padding-bottom:30px">
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
155
    %= include '/include/errors', errors => $errors;
156
    %= include '/include/message', message => flash('message');
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
157
    
improve some branches page
Yuki Kimoto authored on 2015-12-23
158
    <!-- Branches (for tests) -->
design branches page
Yuki Kimoto authored on 2012-12-06
159
    
improve branches design
Yuki Kimoto authored on 2016-01-30
160
    <ul class="branches-select">
161
      <li class="<%= $display eq 'overview' ? 'active' : '' %>">
improve some branches page
Yuki Kimoto authored on 2015-12-23
162
        <a href="<%= url_for("/$user/$project/branches") %>">Overview</a>
163
      </li>
improve branches design
Yuki Kimoto authored on 2016-01-30
164
      <li class="<%= $display eq 'active' ? 'active' : '' %>">
improve some branches page
Yuki Kimoto authored on 2015-12-23
165
        <a href="<%= url_for("/$user/$project/branches/active") %>">Active</a>
166
      </li>
improve branches design
Yuki Kimoto authored on 2016-01-30
167
      <li class="<%= $display eq 'stale' ? 'active' : '' %>">
improve some branches page
Yuki Kimoto authored on 2015-12-23
168
        <a href="<%= url_for("/$user/$project/branches/stale") %>">Stale</a>
169
      </li>
improve branches design
Yuki Kimoto authored on 2016-01-30
170
      <li class="<%= $display eq 'all' ? 'active' : '' %>">
improve some branches page
Yuki Kimoto authored on 2015-12-23
171
        <a href="<%= url_for("/$user/$project/branches/all") %>">All branches</a>
172
      </li>
173
    </ul>
improve branches design
Yuki Kimoto authored on 2016-01-30
174
    <%
175
      if ($display eq 'overview') {
176
        $branch_types = ['default', 'active', 'stale'];
177
      }
178
      elsif ($display eq 'active') {
179
        $branch_types = ['active'];
180
      }
181
      elsif ($display eq 'stale') {
182
        $branch_types = ['stale'];
183
      }
184
      elsif ($display eq 'all') {
185
        $branch_types = ['all'];
186
      }
187
    %>
improve some branches page
Yuki Kimoto authored on 2015-12-23
188
    
189
    % for my $branch_type (@$branch_types) {
190
      % my $branches = $branches_h->{$branch_type};
improve branches design
Yuki Kimoto authored on 2016-01-30
191
      
192
      % if (@$branches || $display ne 'overview') {
improve branch design
Yuki Kimoto authored on 2016-01-27
193
        <ul class="branches">
194
          <li>
195
            % if ($branch_type eq 'default') {
196
              Default branch
197
            % } elsif ($branch_type eq 'active') {
198
              Active branch
199
            % } elsif ($branch_type eq 'stale') {
200
              Stale branch
201
            % } elsif ($branch_type eq 'all') {
202
              All branches
203
            % }
204
          </li>
improve branches design
Yuki Kimoto authored on 2016-01-30
205
          % if (@$branches) {
improve tags page design
Yuki Kimoto authored on 2016-02-01
206
            % my $branches_count;
improve branches design
Yuki Kimoto authored on 2016-01-30
207
            % for (my $i = 0; $i < @$branches; $i++) {
imrpove branches page
Yuki Kimoto authored on 2016-01-30
208
              <%
209
                my $branch = $branches->[$i];
210
                my $bname = $branch->{name};
add user page link from user...
Yuki Kimoto authored on 2016-04-11
211

            
212
                my $commit_author_mail = $branch->{commit}{author_email};
213
                my $commit_author_id = app->dbi->model('user')->select(
214
                  'id',
fix mail bug
Yuki Kimoto authored on 2016-04-21
215
                  where => {email => $commit_author_email}
add user page link from user...
Yuki Kimoto authored on 2016-04-11
216
                )->value;
217
                
imrpove branches page
Yuki Kimoto authored on 2016-01-30
218
              %>
219
              % if ($display eq 'overview' && $i > 4) {
220
                <li class="branches-overview-more">
221
                  <a href="<%= url_for("/$user/$project/branches/$branch_type") %>">
222
                    View more <%= $branch_type %> branches
223
                  </a>
224
                </li>
225
                % last;
226
              % } else {
227

            
228
                <li>
229
                  <ul>
230
                    <li>
231
                      <div class="branches-name">
232
                        <a href="<%= url_for("/$user/$project/tree/$bname") %>">
233
                          <%= $bname %>
234
                        </a>
improve branches design
Yuki Kimoto authored on 2016-01-30
235
                      </div>
imrpove branches page
Yuki Kimoto authored on 2016-01-30
236
                      <div class="branches-age" title="<%= $branch->{commit}{age_string_datetime_local} %>">
237
                        Updated <%= $branch->{commit}{age_string} %> by
238
                      </div>
239
                      <div class="branches-author"  title="<%= $branch->{commit}{author_email} %>">
add user page link from user...
Yuki Kimoto authored on 2016-04-11
240
                        % if (defined $commit_author_id) {
241
                          <a href="<%= url_for("/$commit_author_id") %>"><%= $commit_author_id %></a>
242
                        % } else {
243
                          <%= $branch->{commit}{author_name} %>
244
                        % }
imrpove branches page
Yuki Kimoto authored on 2016-01-30
245
                      </div>
246
                    </li>
247
                    <li class="second-child">
248
                      % if ($bname eq $default_branch_name) {
249
                        <div style="padding-left:80px;padding-top:3px">
250
                          <div class="branches-default">
251
                            Default
252
                          </div>
253
                        </div>
254
                      % } else {
255
                        <table class="ahead-behind">
256
                          <tr>
257
                            <td class="ahead-behind-behind-count">
258
                              <%= $branch->{status}{behind} %>
259
                            </td>
260
                            <td class="ahead-behind-separate">
261
                            </td>
262
                            <td style="padding-left:3px">
263
                              <%= $branch->{status}{ahead} %>
264
                            </td>
265
                          </tr>
266
                          <tr>
267
                            <td style="width:100px">
fix branches bar
Yuki Kimoto authored on 2016-02-12
268
                              <div style="margin-left:auto;margin-right:0;background:#dcdcdc;width:<%= $branch->{status}{behind_bar} %>%;height:4px"></div>
imrpove branches page
Yuki Kimoto authored on 2016-01-30
269
                            </td>
270
                            <td class="ahead-behind-separate">
271
                            </td>
272
                            <td style="width:100px">
fix branches bar
Yuki Kimoto authored on 2016-02-12
273
                              <div style="background:#dcdcdc;width:<%= $branch->{status}{ahead_bar} %>%;height:4px"></div>
imrpove branches page
Yuki Kimoto authored on 2016-01-30
274
                            </td>
275
                          </tr>
276
                        </table>
improve branches design
Yuki Kimoto authored on 2016-01-30
277
                      % }
imrpove branches page
Yuki Kimoto authored on 2016-01-30
278
                    </li>
279
                    <li class="last-child">
280
                      % if ($bname eq $default_branch_name) {
281
                        % if ($api->logined($user)) {
improve default branch link
Yuki Kimoto authored on 2016-04-12
282
                          <a href="<%= url_for("/$user/$project/settings#form-default-branch") %>" type="submit" class="btn btn-small">Change default branch</a>
imrpove branches page
Yuki Kimoto authored on 2016-01-30
283
                        % }
284
                      % } else {
improve compare page
Yuki Kimoto authored on 2016-04-12
285
                        <a class="btn btn-small" href="<%= url_for("/$user/$project/compare/$bname")->query(expand => 1) %>">
fix bug that repository with...
Yuki Kimoto authored on 2016-04-12
286
                          % if ($api->logined) {
287
                            New pull request
288
                          % } else {
289
                            Compare
290
                          % }
imrpove branches page
Yuki Kimoto authored on 2016-01-30
291
                        </a>
292
                        % if ($api->logined($user)) {
293
                          <form action="<%= url_for->query(op => 'delete') %>" method="post" style="display:inline-block">
294
                            <input type="submit" class="btn btn-small delete-branch" style="color:#900;" value="Delete">
295
                            %= hidden_field branch => $bname;
296
                          </form>
297
                        % }
improve branches design
Yuki Kimoto authored on 2016-01-30
298
                      % }
imrpove branches page
Yuki Kimoto authored on 2016-01-30
299
                    </li>
300
                  </ul>
301
                </li>
302
              % }
improve tags page design
Yuki Kimoto authored on 2016-02-01
303
              % $branches_count++;
304
            % }
305

            
306

            
307
            % if ($display ne 'overview') {
308
              <div class="pagenation-container" style="margin-top:20px">
309
                <ul class="pagenation">
310
                  % if ($page == 1) {
311
                    <li><span>Newer</span></li>
312
                  % } else {
313
                    % my $newer_page = $page - 1;
314
                    <li>
315
                      <a href="<%= url_for("/$user/$project/branches/$display?page=$newer_page") %>">Newer</a>
316
                    </li>
317
                  % }
318
                  % if ($branches_count < $page_count) {
319
                    <li><span>Older</span></li>
320
                  % } else {
321
                    % my $older_page = $page + 1;
322
                    <li>
323
                      <a href="<%= url_for("/$user/$project/branches/$display?page=$older_page") %>">Older</a>
324
                    </li>
325
                  % }
326
                </ul>
327
              </div>
improve branches design
Yuki Kimoto authored on 2016-01-30
328
            % }
329
          % } else {
330
            <li style="text-align:center;text-color:#767676">
331
              <%
332
                my $branch_type_name;
333
                if ($branch_type eq 'active' || $branch_type eq 'stale') {
334
                  $branch_type_name = $branch_type;
335
                }
336
                else {
337
                  $branch_type_name = '';
338
                }
339
              %>
340
              
341
              There aren’t any <%= $branch_type_name %> branches.
improve some branches page
Yuki Kimoto authored on 2015-12-23
342
            </li>
343
          % }
344
        </ul>
345
      % }
cleanup branches page
Yuki Kimoto authored on 2013-03-15
346
    % }
added branches link
Yuki Kimoto authored on 2012-11-28
347
  </div>
design branches page
Yuki Kimoto authored on 2012-12-06
348
  
349
  %= include '/include/footer';