gitprep / templates / auto / _new.html.ep /
Newer Older
163 lines | 4.32kb
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;
improve _new page design
Yuki Kimoto authored on 2015-12-19
4
  my $session_user = session('user');
add create repository tests
Yuki Kimoto authored on 2013-05-19
5

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

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

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

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