added form to create reposit...
|
1 |
<% |
add create repository tests
|
2 |
# API |
3 |
my $api = gitprep_api; |
|
fix session
|
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
|
6 | |
improved create repository f...
|
7 |
my $op = param('op') || ''; |
add create repository tests
|
8 | |
9 |
# Authentication |
|
10 |
unless ($api->logined) { |
|
11 |
$self->redirect_to('/'); |
|
12 |
return; |
|
13 |
} |
|
added form to create reposit...
|
14 |
|
15 |
my $errors; |
|
16 |
if ($op eq 'create') { |
|
cleanup _new page validation
|
17 |
# Parameters |
fix session
|
18 |
my $project_id = param('project'); |
cleanup _new page validation
|
19 |
my $description = param('description'); |
20 |
my $readme = param('readme'); |
|
21 |
my $private = param('private'); |
|
added form to create reposit...
|
22 |
|
cleanup _new page validation
|
23 |
# Validator |
rename validator to vc to up...
|
24 |
my $vc = app->vc; |
cleanup _new page validation
|
25 |
|
26 |
# Validation |
|
27 |
my $validation = $vc->validation; |
|
28 |
|
|
29 |
# "project" |
|
fix session
|
30 |
if (!(defined $project_id && length $project_id)) { |
cleanup _new page validation
|
31 |
$validation->add_failed(project => 'Repository name is empty'); |
32 |
} |
|
fix session
|
33 |
elsif (!$vc->check($project_id, 'project_name')) { |
cleanup _new page validation
|
34 |
$validation->add_failed(project => 'Invalid repository name'); |
35 |
} |
|
fix session
|
36 |
elsif (app->manager->exists_project($session_user->{id}, $project_id)) { |
cleanup _new page validation
|
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...
|
48 |
|
improved create repository f...
|
49 |
# Git |
cleanup _new page validation
|
50 |
if ($validation->is_valid) { |
improved create repository f...
|
51 |
# Not logined |
52 |
unless ($api->logined) { |
|
do success xt tests
|
53 |
return $self->reply->exception; |
improved create repository f...
|
54 |
} |
55 |
|
|
revert encoding support
|
56 |
my $manager = app->manager; |
cleanup _new page validation
|
57 |
# Create repository |
58 |
eval { |
|
59 |
$manager->create_project( |
|
fix session
|
60 |
$session_user->{id}, |
61 |
$project_id, |
|
cleanup _new page validation
|
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...
|
69 |
} |
70 |
else { |
|
fix session
|
71 |
$self->redirect_to("/$session_user->{id}/$project_id"); |
cleanup _new page validation
|
72 |
return; |
improved create repository f...
|
73 |
} |
added form to create reposit...
|
74 |
} |
cleanup _new page validation
|
75 |
else { $errors = $validation->messages } |
added form to create reposit...
|
76 |
} |
77 |
%> |
|
78 | ||
add title
|
79 |
% layout 'common', title => 'Create a New Repository'; |
added login page
|
80 | |
improve _new page design
|
81 |
%= include '/include/header', no_project_header => 1; |
added form to create reposit...
|
82 |
|
improve new page design
|
83 |
<div class="new-container"> |
added form to create reposit...
|
84 |
% if ($errors) { |
85 |
<div class="alert alert-error"> |
|
86 |
<button type="button" class="close" data-dismiss="alert">×</button> |
|
87 |
% for my $error (@$errors) { |
|
88 |
<p><%= $error %></p> |
|
89 |
% } |
|
90 |
</div> |
|
91 |
% } |
|
improve new page design
|
92 |
<div class="new-title-container"> |
93 |
<div class="new-title"> |
|
improve _new page design
|
94 |
Create a new repository |
95 |
</div> |
|
improve new page design
|
96 |
<div class="new-description"> |
improve _new page design
|
97 |
A repository contains all the files for your project, including the revision history. |
98 |
</div> |
|
99 |
</div> |
|
cleanup create repository pa...
|
100 |
<form action="<%= url_for->query(op => 'create') %>" method="post"> |
improve new page design
|
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
|
116 |
<i class="icon-user"></i><%= $session_user->{id} %> |
improve new page design
|
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
|
132 |
</div> |
improve new page design
|
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...
|
151 |
|
improve new page design
|
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 ...
|
159 |
</div> |
improve new page design
|
160 |
|
161 |
<input type="submit" class="btn btn-success" value="Create repository"> |
|
cleanup create repository pa...
|
162 |
</form> |
added login page
|
163 |
</div> |
164 |
%= include '/include/footer'; |