gitprep / templates / auto / _new.html.ep /
Newer Older
164 lines | 4.481kb
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
1
<%
add create repository tests
Yuki Kimoto authored on 2013-05-19
2
  # API
3
  my $api = gitprep_api;
fix session
Yuki Kimoto authored on 2016-04-21
4
  my $session_user_row_id = session('user_row_id');
5
  my $session_user = app->dbi->model('user')->select(where => {row_id => $session_user_row_id})->one;
add create repository tests
Yuki Kimoto authored on 2013-05-19
6

            
improved create repository f...
Yuki Kimoto authored on 2013-03-21
7
  my $op = param('op') || '';
add create repository tests
Yuki Kimoto authored on 2013-05-19
8

            
9
  # Authentication
10
  unless ($api->logined) {
11
    $self->redirect_to('/');
12
    return;
13
  }
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
14
  
15
  my $errors;
16
  if ($op eq 'create') {
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
17
    # Parameters
fix session
Yuki Kimoto authored on 2016-04-21
18
    my $project_id = param('project');
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
19
    my $description = param('description');
20
    my $readme = param('readme');
21
    my $private = param('private');
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
22
    
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
23
    # Validator
rename validator to vc to up...
Yuki Kimoto authored on 2013-12-02
24
    my $vc = app->vc;
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
25
    
26
    # Validation
27
    my $validation = $vc->validation;
28
    
29
    # "project"
fix session
Yuki Kimoto authored on 2016-04-21
30
    if (!(defined $project_id && length $project_id)) {
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
31
      $validation->add_failed(project => 'Repository name is empty');
32
    }
fix session
Yuki Kimoto authored on 2016-04-21
33
    elsif (!$vc->check($project_id, 'project_name')) {
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
34
      $validation->add_failed(project => 'Invalid repository name');
35
    }
fix session
Yuki Kimoto authored on 2016-04-21
36
    elsif (app->manager->exists_project($session_user->{id}, $project_id)) {
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
37
      $validation->add_failed(project => 'Repository already exists');
38
    }
39
    
40
    # "description"
41
    $description ||= '';
42
    
43
    # "readme"
44
    $readme = $readme ? 1 :0;
45
    
46
    # "private"
47
    $private = $private ? 1 : 0;
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
48
    
improved create repository f...
Yuki Kimoto authored on 2013-03-21
49
    # Git
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
50
    if ($validation->is_valid) {
improved create repository f...
Yuki Kimoto authored on 2013-03-21
51
      # Not logined
52
      unless ($api->logined) {
do success xt tests
Yuki Kimoto authored on 2016-03-25
53
        return $self->reply->exception;
improved create repository f...
Yuki Kimoto authored on 2013-03-21
54
      }
55
      
revert encoding support
Yuki Kimoto authored on 2013-11-22
56
      my $manager = app->manager;
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
57
      # Create repository
58
      eval {
59
        $manager->create_project(
fix session
Yuki Kimoto authored on 2016-04-21
60
          $session_user->{id},
61
          $project_id,
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
62
          {description => $description, readme => $readme, private => $private}
63
        );
64
      };
65
      
66
      if (my $e = $@) {
67
        app->log->error(url_for . ": $e");
68
        $errors = ['Internal error'];
improved create repository f...
Yuki Kimoto authored on 2013-03-21
69
      }
70
      else {
fix session
Yuki Kimoto authored on 2016-04-21
71
        $self->redirect_to("/$session_user->{id}/$project_id");
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
72
        return;
improved create repository f...
Yuki Kimoto authored on 2013-03-21
73
      }
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
74
    }
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
75
    else { $errors = $validation->messages }
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
76
  }
77
%>
78

            
add title
Yuki Kimoto authored on 2013-06-12
79
% layout 'common', title => 'Create a New Repository';
added login page
Yuki Kimoto authored on 2013-02-09
80

            
improve _new page design
Yuki Kimoto authored on 2015-12-19
81
  %= include '/include/header', no_project_header => 1;
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
82
  
improve new page design
Yuki Kimoto authored on 2016-01-21
83
  <div class="new-container">
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
84
    % if ($errors) {
85
      <div class="alert alert-error">
86
        <button type="button" class="close" data-dismiss="alert">&times;</button>
87
        % for my $error (@$errors) {
88
          <p><%= $error %></p>
89
        % }
90
      </div>
91
    % }
improve new page design
Yuki Kimoto authored on 2016-01-21
92
    <div class="new-title-container">
93
      <div class="new-title">
improve _new page design
Yuki Kimoto authored on 2015-12-19
94
        Create a new repository
95
      </div>
improve new page design
Yuki Kimoto authored on 2016-01-21
96
      <div class="new-description">
improve _new page design
Yuki Kimoto authored on 2015-12-19
97
        A repository contains all the files for your project, including the revision history.
98
      </div>
99
    </div>
cleanup create repository pa...
Yuki Kimoto authored on 2013-03-18
100
    <form action="<%= url_for->query(op => 'create') %>" method="post">
improve new page design
Yuki Kimoto authored on 2016-01-21
101
      <div class="new-repository">
102
        <table>
103
          <tr>
104
            <td>
105
              <b>Owner</b>
106
            </td>
107
            <td>
108
            
109
            </td>
110
            <td>
111
              <b>Repository name</b>
112
            </td>
113
          </tr>
114
          <tr>
115
            <td>
fix session
Yuki Kimoto authored on 2016-04-21
116
              <i class="icon-user"></i><%= $session_user->{id} %>
improve new page design
Yuki Kimoto authored on 2016-01-21
117
            </td>
118
            <td style="padding:0 10px">
119
              /
120
            </td>
121
            <td>
122
              <%= text_field 'project'%>
123
            </td>
124
          </tr>
125
        </table>
126
        <div class="2th-child">
127
          <b>Description</b> <span style="color:#767676">(optional)</span>
128
        </div>
129
        <div class="last-child">
130
          <%= text_field 'description' %>
131
        </div>
improve _new page design
Yuki Kimoto authored on 2015-12-19
132
      </div>
improve new page design
Yuki Kimoto authored on 2016-01-21
133
      <ul class="new-private">
134
        <li>
135
          <div>
136
            <%= radio_button private => 0, checked => undef %><span>Public</span>
137
          </div>
138
          <div class="last-child">
139
            Anyone can see this repository. You choose who can commit.
140
          </div>
141
        </li>
142
        <li>
143
          <div>
144
            <%= radio_button private => 1 %><span>Private</span>
145
          </div>
146
          <div class="last-child">
147
            You choose who can see and commit to this repository.
148
          </div>
149
        </li>
150
      </ul>
added README commited rep fe...
Yuki Kimoto authored on 2013-03-28
151
      
improve new page design
Yuki Kimoto authored on 2016-01-21
152
      <div class="new-readme">
153
        <div>
154
          <%= check_box readme => 1 %><span>Initialize this this repository with a README<span>
155
        </div>
156
        <div class="last-child">
157
          This will let you immediately clone the repository to your computer. Skip this step if you’re importing an existing repository.
158
        </div>
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
159
      </div>
improve new page design
Yuki Kimoto authored on 2016-01-21
160
      
161
      <input type="submit" class="btn btn-success" value="Create repository">
cleanup create repository pa...
Yuki Kimoto authored on 2013-03-18
162
    </form>
added login page
Yuki Kimoto authored on 2013-02-09
163
  </div>
164
  %= include '/include/footer';