gitprep / templates / auto / _new.html.ep /
Newer Older
125 lines | 3.392kb
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;
4

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

            
7
  # Authentication
8
  unless ($api->logined) {
9
    $self->redirect_to('/');
10
    return;
11
  }
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
12
  
13
  my $errors;
14
  if ($op eq 'create') {
15
    # API
16
    my $api = gitprep_api;
17
    
18
    # Validation
19
    my $params = $api->params;
20
    my $rule = [
added create repository feat...
Yuki Kimoto authored on 2013-03-18
21
      project => [
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
22
        ['not_blank' => 'Repository name is empty'],
add create repository tests
Yuki Kimoto authored on 2013-05-19
23
        ['project_name' => 'Invalid repository name']
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
24
      ],
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
25
      description => {require => 0} => [
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
26
        'any'
added README commited rep fe...
Yuki Kimoto authored on 2013-03-28
27
      ],
28
      readme => {require => 0} => [
29
        'any'
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
30
      ],
31
      private => {require => 0} => [
32
        'any'
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
33
      ]
34
    ];
rename validator to vc to up...
Yuki Kimoto authored on 2013-12-02
35
    my $vc = app->vc;
36
    my $vresult = $vc->validate($params, $rule);
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
37
    
improved create repository f...
Yuki Kimoto authored on 2013-03-21
38
    # Git
revert encoding support
Yuki Kimoto authored on 2013-11-22
39
    my $git = app->git;
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
40
    if ($vresult->is_ok) {
improved create repository f...
Yuki Kimoto authored on 2013-03-21
41
      # Not logined
42
      unless ($api->logined) {
43
        return $self->render_exception;
44
      }
45
      
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
46
      my $data = $vresult->data;
added reset password feature
Yuki Kimoto authored on 2013-04-10
47
      my $user = session('user');
added create repository feat...
Yuki Kimoto authored on 2013-03-18
48
      my $project = $data->{project};
49
      my $description = $data->{description};
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
50
      $description = '' unless defined $description;
added README commited rep fe...
Yuki Kimoto authored on 2013-03-28
51
      my $readme = $data->{readme};
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
52
      my $private = $data->{private};
added README commited rep fe...
Yuki Kimoto authored on 2013-03-28
53
      
revert encoding support
Yuki Kimoto authored on 2013-11-22
54
      my $manager = app->manager;
added README commited rep fe...
Yuki Kimoto authored on 2013-03-28
55
      if ($manager->exists_project($user, $project)) {
add missing 'o'
reneeb authored on 2013-10-14
56
        $errors = ['Repository already exists'];
improved create repository f...
Yuki Kimoto authored on 2013-03-21
57
      }
58
      else {
59
        # Create repository
60
        eval {
added README commited rep fe...
Yuki Kimoto authored on 2013-03-28
61
          $manager->create_project(
improved create repository f...
Yuki Kimoto authored on 2013-03-21
62
            $user,
63
            $project,
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
64
            {description => $description, readme => $readme, private => $private}
improved create repository f...
Yuki Kimoto authored on 2013-03-21
65
          );
66
        };
67
        
68
        if ($@) {
move create project feature ...
Yuki Kimoto authored on 2013-03-27
69
          app->log->fatal($@);
70
          $errors = ['Internal error'];
71
        }
72
        else {
73
          $self->redirect_to("/$user/$project");
add create repository tests
Yuki Kimoto authored on 2013-05-19
74
          return;
improved create repository f...
Yuki Kimoto authored on 2013-03-21
75
        }
76
      }
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
77
    }
added create repository feat...
Yuki Kimoto authored on 2013-03-18
78
    else { $errors = $vresult->messages }
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
79
  }
80
%>
81

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

            
84
  %= include '/include/header';
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
85
  
cleanup create repository pa...
Yuki Kimoto authored on 2013-03-18
86
  <div class="container">
fix bug that create_reposito...
Yuki Kimoto authored on 2013-08-28
87
    <ul class="breadcrumb" style="margin-top:10px">
88
      <li><a href="<%= url_for('/') %>"><i class="icon-home"></i></a></li>
89
      /
90
      % my $user = session('user');
91
      <li><a href="<%= url_for("/$user") %>"><%= $user %></a></li>
92
    </ul>
93
  
added form to create reposit...
Yuki Kimoto authored on 2013-03-18
94
    % if ($errors) {
95
      <div class="alert alert-error">
96
        <button type="button" class="close" data-dismiss="alert">&times;</button>
97
        % for my $error (@$errors) {
98
          <p><%= $error %></p>
99
        % }
100
      </div>
101
    % }
cleanup create repository pa...
Yuki Kimoto authored on 2013-03-18
102
    <form action="<%= url_for->query(op => 'create') %>" method="post">
103
      <div><b>Repository name</b></div>
added create repository feat...
Yuki Kimoto authored on 2013-03-18
104
      <div><%= input_tag 'project', type => 'text', style => 'width:300px' %></div>
added login page
Yuki Kimoto authored on 2013-02-09
105

            
cleanup create repository pa...
Yuki Kimoto authored on 2013-03-18
106
      <div><b>Description</b> (optional)</div>
107
      <div><%= input_tag 'description', type => 'text', style => 'width:600px' %></div>
added README commited rep fe...
Yuki Kimoto authored on 2013-03-28
108
      
109
      <div>
110
        <label class="checkbox" style="margin-bottom:0">
111
          <%= check_box readme => 1 %><b>Initialize this repository with a README</b>
112
        </label>
113
      </div>
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
114
      <div class="muted" style="margin-left:20px">This will allow you to git clone the repository immediately.</div>
added login page
Yuki Kimoto authored on 2013-02-09
115

            
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
116
      <div>
117
        <label class="checkbox" style="margin-bottom:0">
118
          <%= check_box private => 1 %><b>Make this repository private </b>
119
        </label>
120
      </div>
121
            
122
      <input style="margin-top:10px" type="submit" class="btn" value="Create repository">
cleanup create repository pa...
Yuki Kimoto authored on 2013-03-18
123
    </form>
added login page
Yuki Kimoto authored on 2013-02-09
124
  </div>
125
  %= include '/include/footer';