GitPrep 2 need Perl 5.10
|
1 |
use 5.010001; |
renamed gitpub to gitprep
|
2 |
package Gitprep; |
copy gitweblite soruce code
|
3 |
use Mojo::Base 'Mojolicious'; |
cleanup
|
4 | |
5 |
use Carp 'croak'; |
|
added start page
|
6 |
use DBIx::Custom; |
little more secure login
|
7 |
use Gitprep::API; |
cleanup
|
8 |
use Gitprep::Git; |
fixed tags page paging bug a...
|
9 |
use Gitprep::Manager; |
added RepManager rename feat...
|
10 |
use Scalar::Util 'weaken'; |
cleanup
|
11 |
use Validator::Custom; |
add Time::Moment to cpanfil
|
12 |
use Time::Moment; |
fix bug that in CGI reposito...
|
13 | |
Digest::SHA loading to Mojo:...
|
14 |
# Digest::SHA loading to Mojo::Util if not loaded |
15 |
{ |
|
16 |
package Mojo::Util; |
|
17 |
eval {require Digest::SHA; import Digest::SHA qw(sha1 sha1_hex)}; |
|
18 |
} |
|
19 | ||
add Mojolicious::Plugin::DBV...
|
20 |
our $VERSION = 'v2.00_dev'; |
cleanup
|
21 | |
added start page
|
22 |
has 'dbi'; |
revert encoding support
|
23 |
has 'git'; |
added RepManager rename feat...
|
24 |
has 'manager'; |
rename validator to vc to up...
|
25 |
has 'vc'; |
revert encoding support
|
26 | |
27 |
use constant BUFFER_SIZE => 8192; |
|
add /info/refs request
|
28 | |
add repository and work repo...
|
29 |
sub data_dir { |
30 |
my $self = shift; |
|
31 |
|
|
32 |
my $data_dir = $self->config('data_dir'); |
|
33 |
|
|
34 |
return $data_dir; |
|
35 |
} |
|
36 | ||
cleanup
|
37 |
sub rep_home { |
38 |
my $self = shift; |
|
39 |
|
|
40 |
my $rep_home = $self->data_dir . "/rep"; |
|
41 |
|
|
42 |
return $rep_home; |
|
43 |
} |
|
44 | ||
cleanup branch
|
45 |
sub rep_info { |
46 |
my ($self, $user, $project) = @_; |
|
47 |
|
|
48 |
my $info = {}; |
|
add user and project info
|
49 |
$info->{user} = $user; |
cleanup blob
|
50 |
$info->{project} = $project; |
cleanup branch
|
51 |
$info->{git_dir} = $self->rep_home . "/$user/$project.git"; |
52 |
|
|
53 |
return $info; |
|
54 |
} |
|
55 | ||
cleanup
|
56 |
sub work_rep_home { |
57 |
my $self = shift; |
|
58 |
|
|
59 |
my $work_rep_home = $self->data_dir . "/work"; |
|
60 |
|
|
61 |
return $work_rep_home; |
|
62 |
} |
|
63 | ||
cleanup create working direc...
|
64 |
sub work_rep_info { |
65 |
my ($self, $user, $project) = @_; |
|
66 |
|
|
67 |
my $info = {}; |
|
68 |
$info->{user} = $user; |
|
69 |
$info->{project} = $project; |
|
cleanup compare logic
|
70 |
$info->{git_dir} = $self->work_rep_home . "/$user/$project/.git"; |
71 |
$info->{work_tree} = $self->work_rep_home . "/$user/$project"; |
|
cleanup create working direc...
|
72 |
|
73 |
return $info; |
|
74 |
} |
|
75 | ||
copy gitweblite soruce code
|
76 |
sub startup { |
77 |
my $self = shift; |
|
78 |
|
|
cleanup
|
79 |
# Config file |
update Mojolicious and added...
|
80 |
$self->plugin('INIConfig', {ext => 'conf'}); |
81 |
|
|
cleanup
|
82 |
# Config file for developper |
add need_login_always_option
|
83 |
unless ($ENV{GITPREP_NO_MYCONFIG}) { |
84 |
my $my_conf_file = $self->home->rel_file('gitprep.my.conf'); |
|
85 |
$self->plugin('INIConfig', {file => $my_conf_file}) if -f $my_conf_file; |
|
86 |
} |
|
update Mojolicious and added...
|
87 |
|
cleanup
|
88 |
# Listen |
copy gitweblite soruce code
|
89 |
my $conf = $self->config; |
cleanup
|
90 |
my $listen = $conf->{hypnotoad}{listen} ||= ['http://*:10020']; |
91 |
$listen = [split /,/, $listen] unless ref $listen eq 'ARRAY'; |
|
fixed listen bug
|
92 |
$conf->{hypnotoad}{listen} = $listen; |
copy gitweblite soruce code
|
93 |
|
add repository and work repo...
|
94 |
# Data directory |
fix tests
|
95 |
my $data_dir = $ENV{GITPREP_DATA_DIR} ? $ENV{GITPREP_DATA_DIR} : $self->home->rel_file('data'); |
96 |
$self->config(data_dir => $data_dir); |
|
add repository and work repo...
|
97 |
|
revert encoding support
|
98 |
# Git |
renamed gitpub to gitprep
|
99 |
my $git = Gitprep::Git->new; |
cleanup encoding
|
100 |
$git->app($self); |
101 |
weaken $git->{app}; |
|
cleanup
|
102 |
my $git_bin |
103 |
= $conf->{basic}{git_bin} ? $conf->{basic}{git_bin} : $git->search_bin; |
|
fix mini bug
|
104 |
if (!$git_bin || ! -e $git_bin) { |
105 |
$git_bin ||= ''; |
|
cleanup
|
106 |
my $error = "Can't detect or found git command ($git_bin)." |
107 |
. " set git_bin in gitprep.conf"; |
|
fixed git_bin not found bug
|
108 |
$self->log->error($error); |
109 |
croak $error; |
|
110 |
} |
|
improve code structures
|
111 |
$git->bin($git_bin); |
revert encoding support
|
112 |
|
113 |
# Repository Manager |
|
cleanup encoding
|
114 |
my $manager = Gitprep::Manager->new; |
115 |
$manager->app($self); |
|
revert encoding support
|
116 |
weaken $manager->{app}; |
117 |
$self->manager($manager); |
|
118 |
|
|
add key delete feature and u...
|
119 |
# authorized_keys file |
fix authorized_keys_file bug
|
120 |
my $authorized_keys_file = $conf->{basic}{authorized_keys_file}; |
add key delete feature and u...
|
121 |
unless (defined $authorized_keys_file) { |
122 |
if (defined $ENV{HOME}) { |
|
fix update_authorized_keys_f...
|
123 |
$authorized_keys_file = "$ENV{HOME}/.ssh/authorized_keys"; |
add key delete feature and u...
|
124 |
} |
125 |
} |
|
126 |
if (defined $authorized_keys_file) { |
|
127 |
$self->manager->authorized_keys_file($authorized_keys_file); |
|
128 |
} |
|
129 |
else { |
|
130 |
$self->app->log->warn(qq/Config "authorized_keys_file" can't be detected/); |
|
131 |
} |
|
132 |
|
|
fixed git_bin not found bug
|
133 |
# Repository home |
cleanup tests
|
134 |
my $rep_home = "$data_dir/rep"; |
added create repository feat...
|
135 |
unless (-d $rep_home) { |
136 |
mkdir $rep_home |
|
137 |
or croak "Can't create directory $rep_home: $!"; |
|
138 |
} |
|
cleanup
|
139 |
|
add time zone system
|
140 |
# Time Zone |
141 |
if (my $time_zone = $conf->{basic}{time_zone}) { |
|
142 |
|
|
143 |
if ($time_zone =~ /^([\+-])?([0-9]?[0-9]):([0-9][0-9])$/) { |
|
144 |
my $sign = $1 || ''; |
|
145 |
my $hour = $2; |
|
146 |
my $min = $3; |
|
147 |
|
|
148 |
my $time_zone_second = $sign . ($hour * 60 * 60) + ($min * 60); |
|
149 |
$git->time_zone_second($time_zone_second); |
|
150 |
} |
|
151 |
else { |
|
152 |
$self->log->warn("Bad time zone $time_zone. Time zone become GMT"); |
|
153 |
} |
|
154 |
} |
|
155 |
$self->git($git); |
|
cleanup
|
156 |
|
improved create repository f...
|
157 |
# DBI |
cleanup tests
|
158 |
my $db_file = "$data_dir/gitprep.db"; |
improved create repository f...
|
159 |
my $dbi = DBIx::Custom->connect( |
160 |
dsn => "dbi:SQLite:database=$db_file", |
|
161 |
connector => 1, |
|
added original_pid column
|
162 |
option => {sqlite_unicode => 1, sqlite_use_immediate_transaction => 1} |
improved create repository f...
|
163 |
); |
164 |
$self->dbi($dbi); |
|
165 |
|
|
cleanup
|
166 |
# Database file permision |
fixed database file permissi...
|
167 |
if (my $user = $self->config->{hypnotoad}{user}) { |
168 |
my $uid = (getpwnam $user)[2]; |
|
169 |
chown $uid, -1, $db_file; |
|
170 |
} |
|
171 |
if (my $group = $self->config->{hypnotoad}{group}) { |
|
172 |
my $gid = (getgrnam $group)[2]; |
|
173 |
chown -1, $gid, $db_file; |
|
174 |
} |
|
175 |
|
|
improved create repository f...
|
176 |
# Model |
177 |
my $models = [ |
|
178 |
{table => 'user', primary_key => 'id'}, |
|
fix ssh key authentication b...
|
179 |
{table => 'ssh_public_key', primary_key => 'key'}, |
added original_pid column
|
180 |
{table => 'project', primary_key => ['user_id', 'name']}, |
add collaborator register lo...
|
181 |
{table => 'number', primary_key => 'key'}, |
add create pull request logi...
|
182 |
{table => 'collaboration', primary_key => ['user_id', 'project_name', 'collaborator_id']}, |
183 |
{table => 'pull_request'} |
|
improved create repository f...
|
184 |
]; |
185 |
$dbi->create_model($_) for @$models; |
|
186 | ||
187 |
# Validator |
|
rename validator to vc to up...
|
188 |
my $vc = Validator::Custom->new; |
189 |
$self->vc($vc); |
|
190 |
$vc->register_constraint( |
|
added project delete feature
|
191 |
user_name => sub { |
192 |
my $value = shift; |
|
193 |
|
|
allow . as project name
|
194 |
return ($value || '') =~ /^[a-zA-Z0-9_\-]+$/; |
added project delete feature
|
195 |
}, |
196 |
project_name => sub { |
|
197 |
my $value = shift; |
|
allow . as project name
|
198 |
return 0 unless defined $value; |
199 |
return 0 if $value eq '.' || $value eq '..'; |
|
200 | ||
201 |
return ($value || '') =~ /[a-zA-Z0-9_\-\.]+$/; |
|
added project delete feature
|
202 |
} |
203 |
); |
|
improved create repository f...
|
204 |
|
cleanup setting validation
|
205 |
$vc->add_check(project_name => sub { |
206 |
my ($vc, $value) = @_; |
|
207 |
|
|
208 |
return 0 unless defined $value; |
|
209 |
return 0 if $value eq '.' || $value eq '..'; |
|
210 |
|
|
211 |
return ($value || '') =~ /[a-zA-Z0-9_\-\.]+$/; |
|
212 |
}); |
|
cleanup create user validati...
|
213 |
$vc->add_check(user_name => sub { |
214 |
my ($vc, $value) = @_; |
|
215 |
|
|
216 |
return ($value || '') =~ /^[a-zA-Z0-9_\-]+$/; |
|
217 |
}); |
|
cleanup setting validation
|
218 |
|
fixed receive pack bug and a...
|
219 |
# Basic auth plugin |
220 |
$self->plugin('BasicAuth'); |
|
added admin user tests
|
221 | |
added login page
|
222 |
{ |
cleanup
|
223 |
my $r = $self->routes; |
224 | ||
225 |
# DBViewer(only development) |
|
add Mojolicious::Plugin::DBV...
|
226 |
# /dbviewer |
cleanup
|
227 |
if ($self->mode eq 'development') { |
228 |
eval { |
|
229 |
$self->plugin( |
|
230 |
'DBViewer', |
|
231 |
dsn => "dbi:SQLite:database=$db_file" |
|
232 |
); |
|
233 |
}; |
|
added reset password feature
|
234 |
} |
added AutoRoute plugin
|
235 |
|
cleanup
|
236 |
# Auto route |
cleanup many pages
|
237 |
{ |
cleanup
|
238 |
my $r = $r->under(sub { |
239 |
my $self = shift; |
|
240 |
|
|
241 |
my $api = $self->gitprep_api; |
|
242 |
|
|
add need_login_always_option
|
243 |
# Authentication |
cleanup
|
244 |
{ |
245 |
my $path = $self->req->url->path->parts->[0] || ''; |
|
add need_login_always_option
|
246 |
|
247 |
# Admin |
|
cleanup
|
248 |
if ($path eq '_admin' && !$api->logined_admin) { |
249 |
$self->redirect_to('/'); |
|
250 |
return; |
|
251 |
} |
|
252 |
} |
|
253 |
|
|
254 |
return 1; |
|
255 |
}); |
|
add need_login_always_option
|
256 |
|
257 |
# Auto routes |
|
cleanup
|
258 |
$self->plugin('AutoRoute', route => $r); |
fix bug that forst . is not ...
|
259 |
|
add need_login_always_option
|
260 |
# Custom routes |
cleanup
|
261 |
{ |
add ssh key add feature
|
262 |
# Show ssh keys |
remove Mojolicious::Plugin::...
|
263 |
$r->get('/(:user).keys' => sub { shift->render_maybe('/user-keys') }); |
add ssh key add feature
|
264 |
|
add need_login_always_option
|
265 |
# User |
allow . as project name
|
266 |
my $r = $r->route('/:user'); |
add need_login_always_option
|
267 |
{ |
268 |
# Home |
|
remove Mojolicious::Plugin::...
|
269 |
$r->get('/' => [format => 0] => sub { shift->render_maybe('/user') }); |
add need_login_always_option
|
270 |
|
271 |
# Settings |
|
remove Mojolicious::Plugin::...
|
272 |
$r->get('/_settings' => sub { shift->render_maybe('/user-settings') }); |
add ssh keys page design
|
273 |
|
274 |
# SSH keys |
|
remove Mojolicious::Plugin::...
|
275 |
$r->any('/_settings/ssh' => sub { shift->render_maybe('/user-settings/ssh') }); |
add need_login_always_option
|
276 |
} |
add /info/refs request
|
277 | |
278 |
# Smart HTTP |
|
279 |
{ |
|
allow . as project name
|
280 |
my $r = $r->route('/(#project).git'); |
add /info/refs request
|
281 |
|
fixed receive pack bug and a...
|
282 |
{ |
283 |
my $r = $r->under(sub { |
|
284 |
my $self = shift; |
|
285 |
|
|
cleanup
|
286 |
my $api = $self->gitprep_api; |
complete private repository ...
|
287 |
my $user = $self->param('user'); |
288 |
my $project = $self->param('project'); |
|
289 |
my $private = $self->app->manager->is_private_project($user, $project); |
|
cleanup
|
290 |
|
fixed receive pack bug and a...
|
291 |
# Basic auth when push request |
292 |
my $service = $self->param('service') || ''; |
|
complete private repository ...
|
293 |
if ($service eq 'git-receive-pack' || $private) { |
fixed receive pack bug and a...
|
294 |
|
295 |
$self->basic_auth("Git Area", sub { |
|
complete private repository ...
|
296 |
my ($auth_user, $auth_password) = @_; |
add warnings when authentica...
|
297 |
|
298 |
if (!defined $auth_user || !length $auth_user) { |
|
299 |
$self->app->log->warn("Authentication: User name is empty"); |
|
300 |
} |
|
301 |
|
|
fix warnings
|
302 |
$auth_user = '' unless defined $auth_user; |
303 |
$auth_password = '' unless defined $auth_password; |
|
fixed receive pack bug and a...
|
304 |
|
complete collaborator featur...
|
305 |
my $is_valid = |
306 |
($user eq $auth_user || $api->is_collaborator($user, $project, $auth_user)) |
|
307 |
&& $api->check_user_and_password($auth_user, $auth_password); |
|
fixed receive pack bug and a...
|
308 |
|
309 |
return $is_valid; |
|
310 |
}); |
|
311 |
} |
|
312 |
else { |
|
313 |
return 1; |
|
314 |
} |
|
315 |
}); |
|
316 |
|
|
redirect .git access to /use...
|
317 |
# / |
318 |
$r->get('/')->to(cb => sub { |
|
319 |
my $self = shift; |
|
320 |
|
|
321 |
my $user = $self->param('user'); |
|
322 |
my $project = $self->param('project'); |
|
323 |
|
|
324 |
$self->redirect_to("/$user/$project"); |
|
325 |
}); |
|
326 |
|
|
fixed receive pack bug and a...
|
327 |
# /info/refs |
remove Mojolicious::Plugin::...
|
328 |
$r->get('/info/refs' => sub { shift->render_maybe('smart-http/info-refs') }); |
fixed receive pack bug and a...
|
329 |
|
330 |
# /git-upload-pack or /git-receive-pack |
|
331 |
$r->any('/git-(:service)' |
|
332 |
=> [service => qr/(?:upload-pack|receive-pack)/] |
|
remove Mojolicious::Plugin::...
|
333 |
=> sub { shift->render_maybe('smart-http/service') } |
fixed receive pack bug and a...
|
334 |
); |
335 |
|
|
336 |
# Static file |
|
remove Mojolicious::Plugin::...
|
337 |
$r->get('/(*Path)' => sub { shift->render_maybe('smart-http/static') }); |
fixed receive pack bug and a...
|
338 |
} |
add /info/refs request
|
339 |
} |
340 |
|
|
add need_login_always_option
|
341 |
# Project |
342 |
{ |
|
allow . as project name
|
343 |
my $r = $r->route('/#project'); |
add need_login_always_option
|
344 |
|
add private reporitory featu...
|
345 |
{ |
346 |
my $r = $r->under(sub { |
|
347 |
my $self = shift; |
|
348 |
|
|
cleanup
|
349 |
# API |
350 |
my $api = $self->gitprep_api; |
|
improve code structures
|
351 |
|
352 |
# Private |
|
revert encoding support
|
353 |
my $user = $self->param('user'); |
354 |
my $project = $self->param('project'); |
|
add private reporitory featu...
|
355 |
my $private = $self->app->manager->is_private_project($user, $project); |
356 |
if ($private) { |
|
complete collaborator featur...
|
357 |
if ($api->can_access_private_project($user, $project)) { |
add private reporitory featu...
|
358 |
return 1; |
359 |
} |
|
360 |
else { |
|
361 |
$self->render('private'); |
|
362 |
return 0; |
|
363 |
} |
|
364 |
} |
|
365 |
else { |
|
366 |
return 1; |
|
367 |
} |
|
368 |
}); |
|
369 |
|
|
370 |
# Home |
|
remove Mojolicious::Plugin::...
|
371 |
$r->get('/' => sub { shift->render_maybe('/tree') }); |
add pulls page
|
372 | |
373 |
# Tags |
|
374 |
$r->get('/pulls' => sub { shift->render_maybe('/pulls') })->to(tab => 'pulls'); |
|
add private reporitory featu...
|
375 |
|
376 |
# Commit |
|
remove Mojolicious::Plugin::...
|
377 |
$r->get('/commit/*diff' => sub { shift->render_maybe('/commit') }); |
add atom feed part
|
378 | |
add private reporitory featu...
|
379 |
# Commits |
remove Mojolicious::Plugin::...
|
380 |
$r->get('/commits/*rev_file' => sub { shift->render_maybe('/commits') }); |
add private reporitory featu...
|
381 |
|
382 |
# Branches |
|
remove Mojolicious::Plugin::...
|
383 |
$r->any('/branches/:display' => {display => undef} => sub { shift->render_maybe('/branches') }); |
added feature that you see p...
|
384 | |
add private reporitory featu...
|
385 |
# Tags |
remove Mojolicious::Plugin::...
|
386 |
$r->get('/tags' => sub { shift->render_maybe('/tags') }); |
improved network page
|
387 | |
add private reporitory featu...
|
388 |
# Tree |
remove Mojolicious::Plugin::...
|
389 |
$r->get('/tree/*rev_dir' => sub { shift->render_maybe('/tree') }); |
add private reporitory featu...
|
390 |
|
391 |
# Blob |
|
remove Mojolicious::Plugin::...
|
392 |
$r->get('/blob/*rev_file' => sub { shift->render_maybe('/blob') }); |
add private reporitory featu...
|
393 |
|
394 |
# Sub module |
|
remove Mojolicious::Plugin::...
|
395 |
$r->get('/submodule/*rev_file' => sub { shift->render_maybe('/submodule') }); |
add blame method
|
396 | |
add private reporitory featu...
|
397 |
# Raw |
remove Mojolicious::Plugin::...
|
398 |
$r->get('/raw/*rev_file' => sub { shift->render_maybe('/raw') }); |
add blame method
|
399 | |
add private reporitory featu...
|
400 |
# Blame |
remove Mojolicious::Plugin::...
|
401 |
$r->get('/blame/*rev_file' => sub { shift->render_maybe('/blame') }); |
add private reporitory featu...
|
402 |
|
403 |
# Archive |
|
remove Mojolicious::Plugin::...
|
404 |
# Archive |
405 |
$r->get('/archive/(*rev).tar.gz' => sub { shift->render_maybe('/archive') })->to(archive_type => 'tar'); |
|
406 |
$r->get('/archive/(*rev).zip' => sub { shift->render_maybe('/archive') })->to(archive_type => 'zip' ); |
|
add private reporitory featu...
|
407 |
|
408 |
# Compare |
|
add create pull request logi...
|
409 |
$r->any('/compare' => sub { shift->render_maybe('/compare') }); |
410 |
$r->any( |
|
cleanup branch
|
411 |
'/compare/(:rev1)...(:rev2)' |
412 |
=> [rev1 => qr/[^\.]+/, rev2 => qr/[^\.]+/] |
|
413 |
=> sub { shift->render_maybe('/compare') } |
|
414 |
); |
|
add create pull request logi...
|
415 |
$r->any('/compare/(:rev2)' => sub { shift->render_maybe('/compare') }); |
add private reporitory featu...
|
416 |
|
417 |
# Settings |
|
improve tab design
|
418 |
{ |
419 |
my $r = $r->route('/settings')->to(tab => 'settings'); |
|
420 |
|
|
421 |
# Settings |
|
remove Mojolicious::Plugin::...
|
422 |
$r->any('/' => sub { shift->render_maybe('/settings') }); |
improve tab design
|
423 |
|
424 |
# Collaboration |
|
remove Mojolicious::Plugin::...
|
425 |
$r->any('/collaboration' => sub { shift->render_maybe('/settings/collaboration') }); |
improve tab design
|
426 |
} |
add collaboration page
|
427 |
|
add private reporitory featu...
|
428 |
# Fork |
remove Mojolicious::Plugin::...
|
429 |
$r->any('/fork' => sub { shift->render_maybe('/fork') }); |
improve tab design
|
430 |
|
add private reporitory featu...
|
431 |
# Network |
improve tab design
|
432 |
{ |
433 |
my $r = $r->route('/network')->to(tab => 'graph'); |
|
434 |
|
|
435 |
# Network |
|
remove Mojolicious::Plugin::...
|
436 |
$r->get('/' => sub { shift->render_maybe('/network') }); |
cleanup
|
437 | |
improve tab design
|
438 |
# Network Graph |
remove Mojolicious::Plugin::...
|
439 |
$r->get('/graph/(*rev1)...(*rev2_abs)' => sub { shift->render_maybe('/network/graph') }); |
improve tab design
|
440 |
} |
add pull page design
|
441 | |
add private reporitory featu...
|
442 |
# Import branch |
remove Mojolicious::Plugin::...
|
443 |
$r->any('/import-branch/:remote_user/:remote_project' => sub { shift->render_maybe('/import-branch') }); |
add private reporitory featu...
|
444 |
|
445 |
# Get branches and tags |
|
remove Mojolicious::Plugin::...
|
446 |
$r->get('/api/revs' => sub { shift->render_maybe('/api/revs') }); |
add private reporitory featu...
|
447 |
} |
add need_login_always_option
|
448 |
} |
cleanup
|
449 |
} |
added AutoRoute plugin
|
450 |
} |
451 |
} |
|
added admin user tests
|
452 | |
453 |
# Helper |
|
454 |
{ |
|
455 |
# API |
|
456 |
$self->helper(gitprep_api => sub { Gitprep::API->new(shift) }); |
|
457 |
} |
|
added reverse proxy path_dep...
|
458 |
|
X-Forwarded-HTTPS header is ...
|
459 |
# set scheme to https when X-Forwarded-HTTPS header is specified |
460 |
# This is for the backword compatible only. Now X-Forwarded-Proto is used for this purpose |
|
461 |
$self->hook(before_dispatch => sub { |
|
462 |
my $c = shift; |
|
463 |
if ($c->req->headers->header('X-Forwarded-HTTPS')) { |
|
464 |
$c->req->url->base->scheme('https'); |
|
465 |
$c->app->log->warn("X-Forwarded-HTTPS header is DEPRECATED! use X-Forwarded-Proto instead."); |
|
466 |
} |
|
467 |
}); |
|
468 |
|
|
added AutoRoute plugin
|
469 |
# Reverse proxy support |
added reverse proxy path_dep...
|
470 |
my $reverse_proxy_on = $self->config->{reverse_proxy}{on}; |
471 |
my $path_depth = $self->config->{reverse_proxy}{path_depth}; |
|
472 |
if ($reverse_proxy_on) { |
|
473 |
$ENV{MOJO_REVERSE_PROXY} = 1; |
|
474 |
if ($path_depth) { |
|
475 |
$self->hook('before_dispatch' => sub { |
|
476 |
my $self = shift; |
|
477 |
for (1 .. $path_depth) { |
|
478 |
my $prefix = shift @{$self->req->url->path->parts}; |
|
479 |
push @{$self->req->url->base->path->parts}, $prefix; |
|
480 |
} |
|
481 |
}); |
|
added AutoRoute plugin
|
482 |
} |
added reverse proxy path_dep...
|
483 |
} |
cleanup
|
484 |
|
485 |
# Smart HTTP Buffer size |
|
fix bug that lerge repositor...
|
486 |
$ENV{GITPREP_SMART_HTTP_BUFFER_SIZE} ||= 16384; |
copy gitweblite soruce code
|
487 |
} |
488 | ||
489 |
1; |