Showing 3 changed files with 66 additions and 8 deletions
+20
lib/Gitprep/Git.pm
... ...
@@ -6,6 +6,7 @@ use File::Find 'find';
6 6
 use File::Basename qw/basename dirname/;
7 7
 use Fcntl ':mode';
8 8
 use File::Path 'mkpath';
9
+use File::Copy 'move';
9 10
 
10 11
 # Attributes
11 12
 has 'bin';
... ...
@@ -229,6 +230,25 @@ sub create_repository {
229 230
   my @git_init_cmd = $self->_cmd($user, $project, 'init', '--bare');
230 231
   system(@git_init_cmd) == 0
231 232
     or croak "Can't execute git init";
233
+    
234
+  # Add git-daemon-export-ok
235
+  {
236
+    my $file = "$rep/git-daemon-export-ok";
237
+    open my $fh, '>', $file
238
+      or croak "Can't create git-daemon-export-ok: $!"
239
+  }
240
+  
241
+  # HTTP support
242
+  my @git_update_server_info_cmd = $self->_cmd(
243
+    $user,
244
+    $project,
245
+    '--bare',
246
+    'update-server-info'
247
+  );
248
+  system(@git_update_server_info_cmd) == 0
249
+    or croak "Can't execute git --bare update-server-info";
250
+  move("$rep/hooks/post-update.sample", "$rep/hooks/post-update")
251
+    or croak "Can't move post-update";
232 252
   
233 253
   # Description
234 254
   if (my $description = $opts->{description}) {
+44 -6
templates/main/project.html.ep
... ...
@@ -63,9 +63,39 @@
63 63
 %>
64 64
 
65 65
 % layout 'common';
66
+
67
+  %= javascript begin
68
+    $(document).ready(function () {
69
+      var http_rep_url = '<%= url_for("$user/$project.git")->to_abs %>';
70
+      % my $execute_user = getpwuid($>);
71
+      % my $rep = $git->rep($user, $project);
72
+      var ssh_rep_url = '<%= url_for($rep)->to_abs->scheme('ssh')->userinfo($execute_user)->port('') %>';
73
+      
74
+      // Click HTTP button
75
+      $('#btn_http').on('click', function () {
76
+        $('#rep_url').val(http_rep_url);
77
+        $('#access').text('Read-only');
78
+      });
79
+      
80
+      // Click SSH button
81
+      $('#btn_ssh').on('click', function () {
82
+        $('#rep_url').val(ssh_rep_url);
83
+        $('#access').text('Read-write');
84
+      });
85
+
86
+      // Initialize
87
+      var logined = <%= $api->logined ? 'true' : 'false' %>;
88
+      if (logined) {
89
+        $('#btn_ssh').trigger('click');
90
+      }
91
+      else {
92
+        $('#btn_http').trigger('click');
93
+      }
94
+    });
95
+  % end
66 96
   
67 97
   %= include '/include/header';
68
-
98
+  
69 99
   <div class="container">
70 100
     %= include '/include/project_header';
71 101
     
... ...
@@ -73,11 +103,19 @@
73 103
       <h4 style="margin-top:0px">
74 104
         <%= $desc %>
75 105
       </h4>
76
-
77
-      <div class="breadcrumb" style="background-color:white;border:1px solid #ccc;padding:0 5px;">
78
-        <a class="btn" href="<%= url_for("/$user/$project/archive/master.zip") %>"><i class="icon-arrow-down"></i>ZIP</a>
79
-        <a class="btn corner-right-none" href="#" >HTTP</a><a class="btn corner-left-none corner-right-none" href="#">SSH</a><input type="text" style="border-top-left-radius:0;border-bottom-left-radius:0;margin-left:0;margin-top:10px;">
80
-        <span>Read-only access</span>
106
+      
107
+      <div class="border-gray" style="padding:0 5px;margin-bottom:10px">
108
+        <a class="btn" href="<%= url_for("/$user/$project/archive/master.zip") %>">
109
+          <i class="icon-arrow-down"></i>ZIP
110
+        </a>
111
+        <div class="input-append" style="margin-top:10px">
112
+          <div class="btn-group" data-toggle="buttons-radio">
113
+            <button class="btn" id="btn_http" style="border-radius:0">HTTP</button>
114
+            <button class="btn" id="btn_ssh" style="border-radius:0">SSH</button>
115
+          </div>
116
+          <input class="span8" id="rep_url" type="text" style="border-radius:0;">
117
+        </div>
118
+        <b><span id="access"></span></b> access
81 119
       </div>
82 120
       
83 121
       %= include '/include/code_menu', display => 'files';
+2 -2
templates/main/user.html.ep
... ...
@@ -6,7 +6,7 @@
6 6
 %>
7 7
 
8 8
 % layout 'common';
9
-  %= include '/include/header', title => 'Project';
9
+  %= include '/include/header', title => 'Repositories';
10 10
 
11 11
   <div class="container">
12 12
     <div>
... ...
@@ -16,7 +16,7 @@
16 16
         <li><a href="<%= url_for %>"><%= $user %></a></li>
17 17
       </ul>
18 18
 
19
-      <h3>Projects</h3>
19
+      <h3>Repositories</h3>
20 20
       
21 21
       <table class="table">
22 22
         % for my $rep (@$reps) {