... | ... |
@@ -20,3 +20,4 @@ requires 'Module::Load', '== 0.24'; |
20 | 20 |
requires 'Params::Check', '== 0.36'; |
21 | 21 |
requires 'ExtUtils::ParseXS', '== 3.18'; |
22 | 22 |
requires 'Test::MockModule', '== 0.05'; |
23 |
+requires 'Digest::SHA', '== 5.84'; |
... | ... |
@@ -1,19 +1,28 @@ |
1 | 1 |
#!/usr/bin/env perl |
2 |
-use Mojo::Base -strict; |
|
2 |
+ |
|
3 |
+use strict; |
|
4 |
+use warnings; |
|
3 | 5 |
|
4 | 6 |
use File::Basename qw/basename dirname/; |
5 | 7 |
use File::Spec::Functions qw/catdir splitdir/; |
6 | 8 |
|
7 |
-# Source directory has precedence |
|
8 |
-my $script_name = basename __FILE__; |
|
9 |
-my $base_dir_name = $script_name =~ s/\.cgi$//; |
|
10 |
-my @base_dir = (splitdir(dirname __FILE__), $base_dir_name); |
|
11 |
-my $mojolegacy = join('/', @base_dir, 'mojolegacy'); |
|
12 |
-my $lib = join('/', @base_dir, 'lib'); |
|
13 |
-my $extlib = join('/', @base_dir, 'extlib'); |
|
14 |
-push(@INC, $mojolegacy, $extlib, $lib); |
|
9 |
+BEGIN { |
|
10 |
+ # Source directory has precedence |
|
11 |
+ my $script_name = basename __FILE__; |
|
12 |
+ my $base_dir_name = $script_name; |
|
13 |
+ $base_dir_name =~ s/\.cgi$//; |
|
14 |
+ my @base_dir = (splitdir(dirname __FILE__), $base_dir_name); |
|
15 |
+ my $mojolegacy = join('/', @base_dir, 'mojolegacy', 'lib'); |
|
16 |
+ my $lib = join('/', @base_dir, 'lib'); |
|
17 |
+ my $extlib = join('/', @base_dir, 'extlib', 'lib', 'perl5'); |
|
18 |
+ eval 'use lib $mojolegacy, $extlib, $lib'; |
|
19 |
+ croak $@ if $@; |
|
20 |
+ |
|
21 |
+ $DB::single = 1; |
|
22 |
+ 1; |
|
23 |
+} |
|
15 | 24 |
|
16 |
-my $lib = join('/', @base, 'lib'); |
|
25 |
+use Mojolicious::Commands; |
|
17 | 26 |
|
18 | 27 |
# Check if Mojolicious is installed; |
19 | 28 |
die <<EOF unless eval 'use Mojolicious::Commands; 1'; |
... | ... |
@@ -68,7 +68,6 @@ |
68 | 68 |
<link rel="stylesheet" href="css/bootstrap-responsive.css" /> |
69 | 69 |
</head> |
70 | 70 |
<body> |
71 |
- <?php echo $script ?> |
|
72 | 71 |
<div class="container"> |
73 | 72 |
<div class="text-center"><h1>Setup Tool</h1></div> |
74 | 73 |
</div> |
... | ... |
@@ -59,6 +59,14 @@ |
59 | 59 |
$state = 'display'; |
60 | 60 |
} |
61 | 61 |
else { $state = 'init' } |
62 |
+ |
|
63 |
+ my $url = url_for->to_abs; |
|
64 |
+ $url->base(undef); |
|
65 |
+ my $ssh_port = config->{basic}{ssh_port}; |
|
66 |
+ my $rep_home = app->git->rep_home; |
|
67 |
+ my $execute_user = getpwuid($>); |
|
68 |
+ my $ssh_rep_url = "ssh://$execute_user\@" . $url->host |
|
69 |
+ . ($ssh_port ? ":$ssh_port" : '') . "$rep_home/$user/$project.git"; |
|
62 | 70 |
%> |
63 | 71 |
|
64 | 72 |
% layout 'common'; |
... | ... |
@@ -68,14 +76,13 @@ |
68 | 76 |
%= javascript begin |
69 | 77 |
$(document).ready(function () { |
70 | 78 |
var http_rep_url = '<%= url_for("$user/$project.git")->to_abs %>'; |
71 |
- % my $execute_user = getpwuid($>); |
|
72 | 79 |
% my $rep = $git->rep($user, $project); |
73 | 80 |
% my $ssh_port = config->{basic}{ssh_port} || ''; |
74 | 81 |
|
75 | 82 |
var logined = <%= $logined ? 'true' : 'false' %>; |
76 | 83 |
var ssh_rep_url = ''; |
77 | 84 |
if (logined) { |
78 |
- ssh_rep_url = '<%= url_for($rep)->to_abs->scheme('ssh')->userinfo($execute_user)->port($ssh_port) %>'; |
|
85 |
+ ssh_rep_url = '<%= $ssh_rep_url %>'; |
|
79 | 86 |
} |
80 | 87 |
|
81 | 88 |
// Click HTTP button |
... | ... |
@@ -159,18 +166,12 @@ |
159 | 166 |
<b>Create a new repository on the command line</b> |
160 | 167 |
</div> |
161 | 168 |
|
162 |
- % my $url = url_for->to_abs; |
|
163 |
- % my $ssh_port = config->{basic}{ssh_port}; |
|
164 |
- % my $rep_home = app->git->rep_home; |
|
165 |
- % my $ssh_url = 'ssh://kimoto@' . $url->host |
|
166 |
- % . ($ssh_port ? ":$ssh_port" : '') . "$rep_home/$user/$project.git"; |
|
167 |
- |
|
168 | 169 |
<pre style="margin-bottom:30px"> |
169 | 170 |
touch README |
170 | 171 |
git init |
171 | 172 |
git add README |
172 | 173 |
git commit -m "first commit" |
173 |
-git remote add origin <%= $ssh_url %> |
|
174 |
+git remote add origin <%= $ssh_rep_url %> |
|
174 | 175 |
git push -u origin master</pre> |
175 | 176 |
|
176 | 177 |
<div class="text-center" style="margin-bottom:10px"> |
... | ... |
@@ -178,7 +179,7 @@ git push -u origin master</pre> |
178 | 179 |
</div> |
179 | 180 |
|
180 | 181 |
<pre style="margin-bottom:30px"> |
181 |
-git remote add origin <%= $ssh_url %> |
|
182 |
+git remote add origin <%= $ssh_rep_url %> |
|
182 | 183 |
git push -u origin master</pre> |
183 | 184 |
% } else { |
184 | 185 |
<div class="well text-center muted" style="margin-bottom:30px"> |