gitprep / templates / branches.html.ep /
Newer Older
335 lines | 11.418kb
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
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
42
      eval { $git->delete_branch($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);
58
  my $default_branch = $git->branch($user, $project, $default_branch_name);
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
  
73
  my $branches = $git->branches($user, $project);
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) {
improve some branches page
Yuki Kimoto authored on 2015-12-23
79
    $branch->{status} = $git->branch_status($user, $project, $default_branch->{name}, $branch->{name});
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
80
    $max = $branch->{status}{ahead} if $max < $branch->{status}{ahead};
81
    $max = $branch->{status}{behind} if $max < $branch->{status}{behind};
improve some branches page
Yuki Kimoto authored on 2015-12-23
82
    
fix branches bar
Yuki Kimoto authored on 2016-02-12
83
    if ($branch->{status}{ahead} > 100) {
84
      $branch->{status}{ahead_bar} = 100;
85
    }
86
    else {
87
      $branch->{status}{ahead_bar} = $branch->{status}{ahead};
88
    }
89
    if ($branch->{status}{behind} > 100) {
90
      $branch->{status}{behind_bar} = 100;
91
    }
92
    else {
93
      $branch->{status}{behind_bar} = $branch->{status}{behind};
94
    }
95
    
96
    $max = 100 if $max > 100;
97
    
improve branch design
Yuki Kimoto authored on 2016-01-30
98
    my $branch_type;
99
    if ($branch->{name} eq $default_branch_name) {
100
      $branch_type = 'default';
101
    }
102
    elsif ($branch->{commit}{age} < 60 * 60 * 24 * (365 * 3)) {
103
      $branch_type = 'active';
104
    }
105
    else {
106
      $branch_type = 'stale';
107
    }
separate active, stale
Yuki Kimoto authored on 2015-12-23
108
    
improve some branches page
Yuki Kimoto authored on 2015-12-23
109
    if ($display eq 'overview') {
improve branch design
Yuki Kimoto authored on 2016-01-30
110
      if ($branch_type eq 'default') {
improve some branches page
Yuki Kimoto authored on 2015-12-23
111
        push @{$branches_h->{default}}, $branch;
112
      }
improve branch design
Yuki Kimoto authored on 2016-01-30
113
      elsif ($branch_type eq 'active') {
114
        push @{$branches_h->{active}}, $branch;
115
      }
116
      elsif ($branch_type eq 'stale') {
117
        push @{$branches_h->{stale}}, $branch;
improve some branches page
Yuki Kimoto authored on 2015-12-23
118
      }
119
    }
120
    elsif ($display eq 'active') {
improve branch design
Yuki Kimoto authored on 2016-01-30
121
      if ($branch_type eq 'active') {
improve tags page design
Yuki Kimoto authored on 2016-02-01
122
        if ($active_count >= $skip && $active_count < $skip + $page_count) {
123
          push @{$branches_h->{active}}, $branch;
124
        }
125
        $active_count++;
separate active, stale
Yuki Kimoto authored on 2015-12-23
126
      }
improve some branches page
Yuki Kimoto authored on 2015-12-23
127
    }
128
    elsif ($display eq 'stale') {
improve branch design
Yuki Kimoto authored on 2016-01-30
129
      if ($branch_type eq 'stale') {
improve tags page design
Yuki Kimoto authored on 2016-02-01
130
        if ($stale_count >= $skip && $stale_count < $skip + $page_count) {
131
          push @{$branches_h->{stale}}, $branch;
132
        }
133
        $stale_count++;
separate active, stale
Yuki Kimoto authored on 2015-12-23
134
      }
improve some branches page
Yuki Kimoto authored on 2015-12-23
135
    }
136
    elsif ($display eq 'all') {
improve tags page design
Yuki Kimoto authored on 2016-02-01
137
      if ($all_count >= $skip && $all_count < $skip + $page_count) {
138
        push @{$branches_h->{all}}, $branch;
139
      }
140
      $all_count++;
improve some branches page
Yuki Kimoto authored on 2015-12-23
141
    }
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
142
  }
improve tags page design
Yuki Kimoto authored on 2016-02-01
143
  
added Tags link
Yuki Kimoto authored on 2012-11-28
144
%>
145

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

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

            
217
                <li>
218
                  <ul>
219
                    <li>
220
                      <div class="branches-name">
221
                        <a href="<%= url_for("/$user/$project/tree/$bname") %>">
222
                          <%= $bname %>
223
                        </a>
improve branches design
Yuki Kimoto authored on 2016-01-30
224
                      </div>
imrpove branches page
Yuki Kimoto authored on 2016-01-30
225
                      <div class="branches-age" title="<%= $branch->{commit}{age_string_datetime_local} %>">
226
                        Updated <%= $branch->{commit}{age_string} %> by
227
                      </div>
228
                      <div class="branches-author"  title="<%= $branch->{commit}{author_email} %>">
229
                        <%= $branch->{commit}{author_name} %>
230
                      </div>
231
                    </li>
232
                    <li class="second-child">
233
                      % if ($bname eq $default_branch_name) {
234
                        <div style="padding-left:80px;padding-top:3px">
235
                          <div class="branches-default">
236
                            Default
237
                          </div>
238
                        </div>
239
                      % } else {
240
                        <table class="ahead-behind">
241
                          <tr>
242
                            <td class="ahead-behind-behind-count">
243
                              <%= $branch->{status}{behind} %>
244
                            </td>
245
                            <td class="ahead-behind-separate">
246
                            </td>
247
                            <td style="padding-left:3px">
248
                              <%= $branch->{status}{ahead} %>
249
                            </td>
250
                          </tr>
251
                          <tr>
252
                            <td style="width:100px">
fix branches bar
Yuki Kimoto authored on 2016-02-12
253
                              <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
254
                            </td>
255
                            <td class="ahead-behind-separate">
256
                            </td>
257
                            <td style="width:100px">
fix branches bar
Yuki Kimoto authored on 2016-02-12
258
                              <div style="background:#dcdcdc;width:<%= $branch->{status}{ahead_bar} %>%;height:4px"></div>
imrpove branches page
Yuki Kimoto authored on 2016-01-30
259
                            </td>
260
                          </tr>
261
                        </table>
improve branches design
Yuki Kimoto authored on 2016-01-30
262
                      % }
imrpove branches page
Yuki Kimoto authored on 2016-01-30
263
                    </li>
264
                    <li class="last-child">
265
                      % if ($bname eq $default_branch_name) {
266
                        % if ($api->logined($user)) {
267
                          <a href="<%= url_for("/$user/$project/settings") %>" type="submit" class="btn btn-small">Change default branch</a>
268
                        % }
269
                      % } else {
270
                        <a class="btn btn-small" href="<%= url_for("/$user/$project/compare/$default_branch->{name}...$bname") %>">
271
                          Compare
272
                        </a>
273
                        % if ($api->logined($user)) {
274
                          <form action="<%= url_for->query(op => 'delete') %>" method="post" style="display:inline-block">
275
                            <input type="submit" class="btn btn-small delete-branch" style="color:#900;" value="Delete">
276
                            %= hidden_field branch => $bname;
277
                          </form>
278
                        % }
279
                        % if (app->config->{basic}{show_ignore_space_change_link}) {
280
                          (<a style="font-size:90%;color:#9999FF" href="<%= url_for("/$user/$project/compare/$default_branch->{name}...$bname?w=") %>">
281
                            ignore space
282
                          </a>)
283
                        % }
improve branches design
Yuki Kimoto authored on 2016-01-30
284
                      % }
imrpove branches page
Yuki Kimoto authored on 2016-01-30
285
                    </li>
286
                  </ul>
287
                </li>
288
              % }
improve tags page design
Yuki Kimoto authored on 2016-02-01
289
              % $branches_count++;
290
            % }
291

            
292

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