added form to create reposit...
|
1 |
<% |
add create repository tests
|
2 |
# API |
3 |
my $api = gitprep_api; |
|
4 | ||
improved create repository f...
|
5 |
my $op = param('op') || ''; |
add create repository tests
|
6 | |
7 |
# Authentication |
|
8 |
unless ($api->logined) { |
|
9 |
$self->redirect_to('/'); |
|
10 |
return; |
|
11 |
} |
|
added form to create reposit...
|
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...
|
21 |
project => [ |
added form to create reposit...
|
22 |
['not_blank' => 'Repository name is empty'], |
add create repository tests
|
23 |
['project_name' => 'Invalid repository name'] |
added form to create reposit...
|
24 |
], |
add private checkbox to new ...
|
25 |
description => {require => 0} => [ |
added form to create reposit...
|
26 |
'any' |
added README commited rep fe...
|
27 |
], |
28 |
readme => {require => 0} => [ |
|
29 |
'any' |
|
add private checkbox to new ...
|
30 |
], |
31 |
private => {require => 0} => [ |
|
32 |
'any' |
|
added form to create reposit...
|
33 |
] |
34 |
]; |
|
rename validator to vc to up...
|
35 |
my $vc = app->vc; |
36 |
my $vresult = $vc->validate($params, $rule); |
|
added form to create reposit...
|
37 |
|
improved create repository f...
|
38 |
# Git |
revert encoding support
|
39 |
my $git = app->git; |
added form to create reposit...
|
40 |
if ($vresult->is_ok) { |
improved create repository f...
|
41 |
# Not logined |
42 |
unless ($api->logined) { |
|
43 |
return $self->render_exception; |
|
44 |
} |
|
45 |
|
|
added form to create reposit...
|
46 |
my $data = $vresult->data; |
added reset password feature
|
47 |
my $user = session('user'); |
added create repository feat...
|
48 |
my $project = $data->{project}; |
49 |
my $description = $data->{description}; |
|
add private checkbox to new ...
|
50 |
$description = '' unless defined $description; |
added README commited rep fe...
|
51 |
my $readme = $data->{readme}; |
add private checkbox to new ...
|
52 |
my $private = $data->{private}; |
added README commited rep fe...
|
53 |
|
revert encoding support
|
54 |
my $manager = app->manager; |
added README commited rep fe...
|
55 |
if ($manager->exists_project($user, $project)) { |
add missing 'o'
|
56 |
$errors = ['Repository already exists']; |
improved create repository f...
|
57 |
} |
58 |
else { |
|
59 |
# Create repository |
|
60 |
eval { |
|
added README commited rep fe...
|
61 |
$manager->create_project( |
improved create repository f...
|
62 |
$user, |
63 |
$project, |
|
add private checkbox to new ...
|
64 |
{description => $description, readme => $readme, private => $private} |
improved create repository f...
|
65 |
); |
66 |
}; |
|
67 |
|
|
68 |
if ($@) { |
|
move create project feature ...
|
69 |
app->log->fatal($@); |
70 |
$errors = ['Internal error']; |
|
71 |
} |
|
72 |
else { |
|
73 |
$self->redirect_to("/$user/$project"); |
|
add create repository tests
|
74 |
return; |
improved create repository f...
|
75 |
} |
76 |
} |
|
added form to create reposit...
|
77 |
} |
added create repository feat...
|
78 |
else { $errors = $vresult->messages } |
added form to create reposit...
|
79 |
} |
80 |
%> |
|
81 | ||
add title
|
82 |
% layout 'common', title => 'Create a New Repository'; |
added login page
|
83 | |
84 |
%= include '/include/header'; |
|
added form to create reposit...
|
85 |
|
cleanup create repository pa...
|
86 |
<div class="container"> |
fix bug that create_reposito...
|
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...
|
94 |
% if ($errors) { |
95 |
<div class="alert alert-error"> |
|
96 |
<button type="button" class="close" data-dismiss="alert">×</button> |
|
97 |
% for my $error (@$errors) { |
|
98 |
<p><%= $error %></p> |
|
99 |
% } |
|
100 |
</div> |
|
101 |
% } |
|
cleanup create repository pa...
|
102 |
<form action="<%= url_for->query(op => 'create') %>" method="post"> |
103 |
<div><b>Repository name</b></div> |
|
added create repository feat...
|
104 |
<div><%= input_tag 'project', type => 'text', style => 'width:300px' %></div> |
added login page
|
105 | |
cleanup create repository pa...
|
106 |
<div><b>Description</b> (optional)</div> |
107 |
<div><%= input_tag 'description', type => 'text', style => 'width:600px' %></div> |
|
added README commited rep fe...
|
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 ...
|
114 |
<div class="muted" style="margin-left:20px">This will allow you to git clone the repository immediately.</div> |
added login page
|
115 | |
add private checkbox to new ...
|
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...
|
123 |
</form> |
added login page
|
124 |
</div> |
125 |
%= include '/include/footer'; |