Showing 3 changed files with 141 additions and 65 deletions
+3
lib/Gitprep.pm
... ...
@@ -297,6 +297,9 @@ sub startup {
297 297
             # Settings
298 298
             $r->any('/settings' => template '/settings');
299 299
             
300
+            # Collaboration
301
+            $r->any('/settings/collaboration' => template '/settings/collaboration');
302
+            
300 303
             # Fork
301 304
             $r->any('/fork' => template '/fork');
302 305
 
+75 -65
templates/settings.html.ep
... ...
@@ -171,74 +171,84 @@
171 171
     %= include '/include/message', message => flash('message');
172 172
     %= include '/include/project_header';
173 173
     
174
-    <div style="margin-bottom:20px">
175
-      <div class="border-gray bk-gray-light radius-top" style="padding-left:5px">
176
-        <h4>
177
-          Settings
178
-        </h4>
174
+    <div class="row">
175
+      <div class="span2">
176
+        <ul class="unstyled" style="font-size:13px;">
177
+          <li class="border-gray" style="padding:5px;"><b>Options</b></li>
178
+          <li class="border-gray" style="border-top:none;padding:6px;"><a href="<%= url_for("/$user/$project/settings/collaboration") %>">Collaborators</a></li>
179
+        </ul>
179 180
       </div>
180
-      <div class="border-gray" style="padding:5px 10px;border-top:none">
181
-        <form id="form-rename-project" action="<%= url_for->query(op => 'rename-project') %>" method="post" style="margin-bottom:0px">
182
-          <div >Repository Name</div>
183
-          <div>
184
-            %= text_field 'to-project' => $project, style => 'margin-top:9px';
185
-            <a href="#rename-confirm" role="button" class="btn" data-toggle="modal">
186
-              Rename
187
-            </a>
181
+      <div class="span10">
182
+        <div style="margin-bottom:20px">
183
+          <div class="border-gray bk-gray-light radius-top" style="padding-left:5px">
184
+            <h4>
185
+              Settings
186
+            </h4>
188 187
           </div>
189
-        </form>
190
-      </div>
191
-      <div class="border-gray" style="padding:5px 10px;border-top:none">
192
-        <form action="<%= url_for->query(op => 'change-description') %>" method="post" style="margin-bottom:0px">
193
-          <div >Description</div>
194
-          <div>
195
-            % my $description = $git->description($user, $project);
196
-            % $description = '' unless defined $description;
197
-            %= text_field 'description' => $description, class => 'span8', style => 'margin-top:9px';
198
-            <input type="submit" class="btn" value="Save">
188
+          <div class="border-gray" style="padding:5px 10px;border-top:none">
189
+            <form id="form-rename-project" action="<%= url_for->query(op => 'rename-project') %>" method="post" style="margin-bottom:0px">
190
+              <div >Repository Name</div>
191
+              <div>
192
+                %= text_field 'to-project' => $project, style => 'margin-top:9px';
193
+                <a href="#rename-confirm" role="button" class="btn" data-toggle="modal">
194
+                  Rename
195
+                </a>
196
+              </div>
197
+            </form>
199 198
           </div>
200
-        </form>
201
-      </div>
202
-      <div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none;">
203
-        <form id="form-default-branch" action="<%= url_for->query(op => 'default-branch') %>" method="post" style="margin-bottom:0px">
204
-          Default Branch
205
-          % my $branches = $git->branches($user, $project);
206
-          % my $branch_names = [map { $_->{name} } @$branches];
207
-          % my $default_branch = app->manager->default_branch($user, $project);
208
-          % push @$branch_names, $default_branch unless @$branch_names;
209
-          % param('default-branch', $default_branch);
210
-          %= select_field 'default-branch' => $branch_names, style => 'margin-top:5px';
211
-        </form>
212
-      </div>
213
-      <div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none;">
214
-        <form id="form-default-branch" action="<%= url_for->query(op => 'private') %>" method="post" style="margin-bottom:0px">
215
-          <span>Make this repository private</span>
216
-          % my $private = app->manager->is_private_project($user, $project);
217
-          % if ($private) {
218
-            % param('private', 1);
219
-          % }
220
-          %= check_box 'private' => 1, style => 'margin-top:0px;margin-left:5px;margin-right:10px';
221
-          <input type="submit" class="btn" value="Save">
222
-        </form>
223
-      </div>
224
-    </div>
225
-    
226
-    <div style="margin-bottom:30px">
227
-      <div class="border-gray bk-gray-light radius-top" style="background:red;padding-left:5px">
228
-        <h4 style="color:white">Danger Zone</h4>
229
-      </div>
230
-      <div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none">
231
-        <form id="form-delete-project" action="<%= url_for->query(op => 'delete-project') %>" method="post">
232
-          <div><b>Delete this repository</b></div>
233
-          <span class="muted">
234
-            Once you delete a repository, there is no going back.
235
-          </span>
236
-          <a style="color:red" href="#delete-confirm" role="button" class="btn" data-toggle="modal">
237
-            Delete this repository
238
-          </a>
239
-          %= hidden_field user => $user;
240
-          %= hidden_field project => $project;
241
-        </form>
199
+          <div class="border-gray" style="padding:5px 10px;border-top:none">
200
+            <form action="<%= url_for->query(op => 'change-description') %>" method="post" style="margin-bottom:0px">
201
+              <div >Description</div>
202
+              <div>
203
+                % my $description = $git->description($user, $project);
204
+                % $description = '' unless defined $description;
205
+                %= text_field 'description' => $description, class => 'span8', style => 'margin-top:9px';
206
+                <input type="submit" class="btn" value="Save">
207
+              </div>
208
+            </form>
209
+          </div>
210
+          <div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none;">
211
+            <form id="form-default-branch" action="<%= url_for->query(op => 'default-branch') %>" method="post" style="margin-bottom:0px">
212
+              Default Branch
213
+              % my $branches = $git->branches($user, $project);
214
+              % my $branch_names = [map { $_->{name} } @$branches];
215
+              % my $default_branch = app->manager->default_branch($user, $project);
216
+              % push @$branch_names, $default_branch unless @$branch_names;
217
+              % param('default-branch', $default_branch);
218
+              %= select_field 'default-branch' => $branch_names, style => 'margin-top:5px';
219
+            </form>
220
+          </div>
221
+          <div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none;">
222
+            <form id="form-default-branch" action="<%= url_for->query(op => 'private') %>" method="post" style="margin-bottom:0px">
223
+              <span>Make this repository private</span>
224
+              % my $private = app->manager->is_private_project($user, $project);
225
+              % if ($private) {
226
+                % param('private', 1);
227
+              % }
228
+              %= check_box 'private' => 1, style => 'margin-top:0px;margin-left:5px;margin-right:10px';
229
+              <input type="submit" class="btn" value="Save">
230
+            </form>
231
+          </div>
232
+        </div>
233
+        
234
+        <div style="margin-bottom:30px">
235
+          <div class="border-gray bk-gray-light radius-top" style="background:red;padding-left:5px">
236
+            <h4 style="color:white">Danger Zone</h4>
237
+          </div>
238
+          <div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none">
239
+            <form id="form-delete-project" action="<%= url_for->query(op => 'delete-project') %>" method="post">
240
+              <div><b>Delete this repository</b></div>
241
+              <span class="muted">
242
+                Once you delete a repository, there is no going back.
243
+              </span>
244
+              <a style="color:red" href="#delete-confirm" role="button" class="btn" data-toggle="modal">
245
+                Delete this repository
246
+              </a>
247
+              %= hidden_field user => $user;
248
+              %= hidden_field project => $project;
249
+            </form>
250
+          </div>
251
+        </div>
242 252
       </div>
243 253
     </div>
244 254
   </div>
+63
templates/settings/collaboration.html.ep
... ...
@@ -0,0 +1,63 @@
1
+<%
2
+  # API
3
+  my $api = gitprep_api;
4
+  my $manager = app->manager;
5
+  
6
+  # Parameters
7
+  my $op = param('op') || '';
8
+  my $user = param('user') || '';
9
+  
10
+  # Authentication
11
+  unless ($api->logined($user)) {
12
+    $self->redirect_to('/');
13
+    return;
14
+  }
15
+  
16
+  # Rename project
17
+  my $git = app->git;
18
+  my $errors;
19
+  if ($op eq 'add' && lc $self->req->method eq 'post') {
20
+    my $collaborator = param('collaborator');
21
+    
22
+    eval { $git->description($user, $project) };
23
+    if (my $e = $@) {
24
+      app->log->error(url_with . ": $e");
25
+      $errors = ['Internal Error'];
26
+    }
27
+    else {
28
+      flash(message => 'Collaborator is added.');
29
+      $self->redirect_to('current');
30
+      return;
31
+    }
32
+  }
33
+%>
34
+
35
+% layout 'common', title => 'Collaboration';
36
+  
37
+  %= include '/include/header';
38
+  
39
+  <div class="container">
40
+    %= include '/include/errors', errors => $errors;
41
+    %= include '/include/message', message => flash('message');
42
+    %= include '/include/project_header';
43
+    
44
+    <div class="row">
45
+      <div class="span2">
46
+        <ul class="unstyled" style="font-size:13px;">
47
+          <li class="border-gray" style="padding:6px;"><a href="<%= url_for("/$user/$project/settings") %>">Options</a></li>
48
+          <li class="border-gray" style="border-top:none;padding:5px;"><b>Collaborators</b></li>
49
+        </ul>
50
+      </div>
51
+      <div class="span10">
52
+        <div style="font-size:16px;margin-top:10px;margin-bottom:10px"><b>Manage Collaborators</b></div>
53
+        <form action="<%= url_for->query(op => 'add') %>" method="post">
54
+          <div class="well" style="padding:5px">
55
+            <%= text_field 'collaborator', style => 'margin-bottom:0' %>
56
+            <input type="submit" value="Add"" >
57
+          </div>
58
+        </form>
59
+      </div>
60
+    </div>
61
+  </div>
62
+
63
+  %= include '/include/footer';