gitprep / templates / auto / _new.html.ep /
Newer Older
172 lines | 4.894kb
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;
add validation to _new
Yuki Kimoto authored on 2016-05-04
16
  if (lc $self->req->method eq 'post') {
17
    if ($op eq 'create') {
18
      # Parameters
19
      my $project_id = param('project');
20
      my $description = param('description');
21
      my $readme = param('readme');
22
      my $private = param('private');
improved create repository f...
Yuki Kimoto authored on 2013-03-21
23
      
add validation to _new
Yuki Kimoto authored on 2016-05-04
24
      # Validator
25
      my $vc = app->vc;
cleanup _new page validation
Yuki Kimoto authored on 2016-02-11
26
      
add validation to _new
Yuki Kimoto authored on 2016-05-04
27
      # Validation
28
      my $validation = $vc->validation;
29
      
30
      # "project"
31
      if (!(defined $project_id && length $project_id)) {
32
        $validation->add_failed(project => 'Repository name is empty');
33
      }
34
      elsif (length $project_id > 300) {
35
        $validation->add_failed(project => 'Repository name is too long');
36
      }
37
      elsif (!$vc->check($project_id, 'project_name')) {
38
        $validation->add_failed(project => 'Invalid repository name');
improved create repository f...
Yuki Kimoto authored on 2013-03-21
39
      }
add validation to _new
Yuki Kimoto authored on 2016-05-04
40
      elsif (app->manager->exists_project($session_user->{id}, $project_id)) {
41
        $validation->add_failed(project => 'Repository already exists');
42
      }
43
      
44
      # "description"
45
      $description ||= '';
46
      if (length $description > 300) {
47
        $validation->add_failed(description => 'description is too long');
48
      }
49
      
50
      # "readme"
51
      $readme = $readme ? 1 :0;
52
      
53
      # "private"
54
      $private = $private ? 1 : 0;
55
      
56
      # Git
57
      if ($validation->is_valid) {
58
        # Not logined
59
        unless ($api->logined) {
60
          return $self->reply->exception;
61
        }
62
        
63
        my $manager = app->manager;
64
        # Create repository
65
        eval {
66
          $manager->create_project(
67
            $session_user->{id},
68
            $project_id,
69
            {description => $description, readme => $readme, private => $private}
70
          );
71
        };
72
        
73
        if (my $e = $@) {
74
          app->log->error(url_for . ": $e");
75
          $errors = ['Internal error'];
76
        }
77
        else {
78
          $self->redirect_to("/$session_user->{id}/$project_id");
79
          return;
80
        }
improved create repository f...
Yuki Kimoto authored on 2013-03-21
81
      }
add validation to _new
Yuki Kimoto authored on 2016-05-04
82
      else { $errors = $validation->messages }
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
83
    }
84
  }
85
%>
86

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

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