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 | ||
version up to 2.5
|
20 |
our $VERSION = 'v2.5'; |
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 { |
change is_collaborator argum...
|
46 |
my ($self, $user_id, $project_id) = @_; |
cleanup branch
|
47 |
|
48 |
my $info = {}; |
|
change is_collaborator argum...
|
49 |
$info->{user} = $user_id; |
50 |
$info->{project} = $project_id; |
|
51 |
$info->{git_dir} = $self->rep_home . "/$user_id/$project_id.git"; |
|
cleanup branch
|
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 { |
change is_collaborator argum...
|
65 |
my ($self, $user_id, $project_id) = @_; |
cleanup create working direc...
|
66 |
|
67 |
my $info = {}; |
|
change is_collaborator argum...
|
68 |
$info->{user} = $user_id; |
69 |
$info->{project} = $project_id; |
|
70 |
$info->{git_dir} = $self->work_rep_home . "/$user_id/$project_id/.git"; |
|
71 |
$info->{work_tree} = $self->work_rep_home . "/$user_id/$project_id"; |
|
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 |
change is_collaborator argum...
|
167 |
if (my $user_id = $self->config->{hypnotoad}{user}) { |
168 |
my $uid = (getpwnam $user_id)[2]; |
|
fixed database file permissi...
|
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 = [ |
|
fix project page
|
178 |
{ |
179 |
table => 'user', |
|
180 |
primary_key => 'row_id' |
|
181 |
}, |
|
182 |
{ |
|
183 |
table => 'ssh_public_key', |
|
184 |
primary_key => 'row_id', |
|
185 |
join => [ |
|
issue belong to project
|
186 |
'left join user on ssh_public_key.user = user.row_id' |
fix project page
|
187 |
] |
188 |
}, |
|
189 |
{ |
|
190 |
table => 'project', |
|
191 |
primary_key => 'row_id', |
|
192 |
join => [ |
|
issue belong to project
|
193 |
'left join user on project.user = user.row_id' |
fix project page
|
194 |
] |
195 |
}, |
|
196 |
{ |
|
197 |
table => 'collaboration', |
|
198 |
primary_key => 'row_id', |
|
199 |
join => [ |
|
issue belong to project
|
200 |
'left join user on collaboration.user = user.row_id', |
201 |
'left join project on collaboration.project = project.row_id', |
|
fix project page
|
202 |
] |
203 |
}, |
|
fix pulls page
|
204 |
{ |
205 |
table => 'issue', |
|
206 |
join => [ |
|
issue belong to project
|
207 |
'left join project on issue.project = project.row_id', |
can add new issue message an...
|
208 |
'left join user as project__user on project.user = project__user.row_id', |
issue belong to project
|
209 |
'left join pull_request on issue.pull_request = pull_request.row_id', |
remove table __ prefix
|
210 |
'left join user as open_user on issue.open_user = open_user.row_id', |
211 |
'left join project as pull_request__base_project on pull_request.base_project = pull_request__base_project.row_id', |
|
212 |
'left join user as pull_request__base_project__user' |
|
213 |
. ' on pull_request__base_project.user = pull_request__base_project__user.row_id', |
|
214 |
'left join project as pull_request__target_project on pull_request.target_project = pull_request__target_project.row_id', |
|
215 |
'left join user as pull_request__target_project__user' |
|
216 |
. ' on pull_request__target_project.user = pull_request__target_project__user.row_id' |
|
fix pulls page
|
217 | |
218 |
] |
|
219 |
}, |
|
220 |
{ |
|
221 |
table => 'issue_message', |
|
222 |
primary_key => 'row_id', |
|
223 |
join => [ |
|
issue belong to project
|
224 |
'left join user on issue_message.user = user.row_id', |
225 |
'left join issue on issue_message.issue = issue.row_id' |
|
fix pulls page
|
226 |
] |
227 |
}, |
|
add pulls description
|
228 |
{ |
229 |
table => 'pull_request', |
|
fix project page
|
230 |
primary_key => 'row_id', |
231 |
join => [ |
|
remove table __ prefix
|
232 |
'left join user as open_user on pull_request.open_user = open_user.row_id', |
233 |
'left join project as base_project on pull_request.base_project = base_project.row_id', |
|
234 |
'left join user as base_project__user' |
|
235 |
. ' on base_project.user = base_project__user.row_id', |
|
236 |
'left join project as target_project on pull_request.target_project = target_project.row_id', |
|
fix pull_request table bug
|
237 |
'left join user as pull_request__target_project__user' |
remove table __ prefix
|
238 |
. ' on target_project.user = target_project__user.row_id' |
fix project page
|
239 |
] |
add pull request message log...
|
240 |
}, |
add label initialize logic
|
241 |
{ |
242 |
table => 'label', |
|
243 |
primary_key => 'row_id', |
|
244 |
join => [ |
|
show labels
|
245 |
'left join project on label.project = project.row_id', |
246 |
'left join user as project__user on project.user = project__user.row_id' |
|
add label initialize logic
|
247 |
] |
add label apply
|
248 |
}, |
249 |
{ |
|
250 |
table => 'issue_label', |
|
show added labels
|
251 |
primary_key => 'row_id', |
252 |
join => [ |
|
253 |
'left join label on issue_label.label = label.row_id' |
|
254 |
] |
|
add label initialize logic
|
255 |
} |
improved create repository f...
|
256 |
]; |
257 |
$dbi->create_model($_) for @$models; |
|
add pulls description
|
258 |
$dbi->setup_model; |
improved create repository f...
|
259 | |
260 |
# Validator |
|
rename validator to vc to up...
|
261 |
my $vc = Validator::Custom->new; |
262 |
$self->vc($vc); |
|
263 |
$vc->register_constraint( |
|
added project delete feature
|
264 |
user_name => sub { |
265 |
my $value = shift; |
|
266 |
|
|
allow . as project name
|
267 |
return ($value || '') =~ /^[a-zA-Z0-9_\-]+$/; |
added project delete feature
|
268 |
}, |
269 |
project_name => sub { |
|
270 |
my $value = shift; |
|
allow . as project name
|
271 |
return 0 unless defined $value; |
272 |
return 0 if $value eq '.' || $value eq '..'; |
|
273 | ||
274 |
return ($value || '') =~ /[a-zA-Z0-9_\-\.]+$/; |
|
added project delete feature
|
275 |
} |
276 |
); |
|
improved create repository f...
|
277 |
|
cleanup setting validation
|
278 |
$vc->add_check(project_name => sub { |
279 |
my ($vc, $value) = @_; |
|
280 |
|
|
281 |
return 0 unless defined $value; |
|
282 |
return 0 if $value eq '.' || $value eq '..'; |
|
283 |
|
|
284 |
return ($value || '') =~ /[a-zA-Z0-9_\-\.]+$/; |
|
285 |
}); |
|
cleanup create user validati...
|
286 |
$vc->add_check(user_name => sub { |
287 |
my ($vc, $value) = @_; |
|
288 |
|
|
289 |
return ($value || '') =~ /^[a-zA-Z0-9_\-]+$/; |
|
290 |
}); |
|
cleanup setting validation
|
291 |
|
fixed receive pack bug and a...
|
292 |
# Basic auth plugin |
293 |
$self->plugin('BasicAuth'); |
|
added admin user tests
|
294 | |
added login page
|
295 |
{ |
cleanup
|
296 |
my $r = $self->routes; |
297 | ||
298 |
# DBViewer(only development) |
|
add Mojolicious::Plugin::DBV...
|
299 |
# /dbviewer |
cleanup
|
300 |
if ($self->mode eq 'development') { |
301 |
eval { |
|
302 |
$self->plugin( |
|
303 |
'DBViewer', |
|
304 |
dsn => "dbi:SQLite:database=$db_file" |
|
305 |
); |
|
306 |
}; |
|
added reset password feature
|
307 |
} |
added AutoRoute plugin
|
308 |
|
cleanup
|
309 |
# Auto route |
cleanup many pages
|
310 |
{ |
cleanup
|
311 |
my $r = $r->under(sub { |
312 |
my $self = shift; |
|
313 |
|
|
314 |
my $api = $self->gitprep_api; |
|
315 |
|
|
add need_login_always_option
|
316 |
# Authentication |
cleanup
|
317 |
{ |
318 |
my $path = $self->req->url->path->parts->[0] || ''; |
|
add need_login_always_option
|
319 |
|
320 |
# Admin |
|
cleanup
|
321 |
if ($path eq '_admin' && !$api->logined_admin) { |
322 |
$self->redirect_to('/'); |
|
323 |
return; |
|
324 |
} |
|
325 |
} |
|
326 |
|
|
327 |
return 1; |
|
328 |
}); |
|
add need_login_always_option
|
329 |
|
330 |
# Auto routes |
|
cleanup
|
331 |
$self->plugin('AutoRoute', route => $r); |
fix bug that forst . is not ...
|
332 |
|
add need_login_always_option
|
333 |
# Custom routes |
cleanup
|
334 |
{ |
add ssh key add feature
|
335 |
# Show ssh keys |
remove Mojolicious::Plugin::...
|
336 |
$r->get('/(:user).keys' => sub { shift->render_maybe('/user-keys') }); |
add ssh key add feature
|
337 |
|
add need_login_always_option
|
338 |
# User |
allow . as project name
|
339 |
my $r = $r->route('/:user'); |
add need_login_always_option
|
340 |
{ |
341 |
# Home |
|
remove Mojolicious::Plugin::...
|
342 |
$r->get('/' => [format => 0] => sub { shift->render_maybe('/user') }); |
add need_login_always_option
|
343 |
|
344 |
# Settings |
|
remove Mojolicious::Plugin::...
|
345 |
$r->get('/_settings' => sub { shift->render_maybe('/user-settings') }); |
add ssh keys page design
|
346 |
|
347 |
# SSH keys |
|
remove Mojolicious::Plugin::...
|
348 |
$r->any('/_settings/ssh' => sub { shift->render_maybe('/user-settings/ssh') }); |
add need_login_always_option
|
349 |
} |
add /info/refs request
|
350 | |
351 |
# Smart HTTP |
|
352 |
{ |
|
allow . as project name
|
353 |
my $r = $r->route('/(#project).git'); |
add /info/refs request
|
354 |
|
fixed receive pack bug and a...
|
355 |
{ |
356 |
my $r = $r->under(sub { |
|
357 |
my $self = shift; |
|
358 |
|
|
cleanup
|
359 |
my $api = $self->gitprep_api; |
change is_collaborator argum...
|
360 |
my $user_id = $self->param('user'); |
361 |
my $project_id = $self->param('project'); |
|
362 |
my $private = $self->app->manager->is_private_project($user_id, $project_id); |
|
cleanup
|
363 |
|
fixed receive pack bug and a...
|
364 |
# Basic auth when push request |
365 |
my $service = $self->param('service') || ''; |
|
complete private repository ...
|
366 |
if ($service eq 'git-receive-pack' || $private) { |
fixed receive pack bug and a...
|
367 |
|
368 |
$self->basic_auth("Git Area", sub { |
|
change is_collaborator argum...
|
369 |
my ($auth_user_id, $auth_password) = @_; |
add warnings when authentica...
|
370 |
|
change is_collaborator argum...
|
371 |
if (!defined $auth_user_id || !length $auth_user_id) { |
add warnings when authentica...
|
372 |
$self->app->log->warn("Authentication: User name is empty"); |
373 |
} |
|
374 |
|
|
change is_collaborator argum...
|
375 |
$auth_user_id = '' unless defined $auth_user_id; |
fix warnings
|
376 |
$auth_password = '' unless defined $auth_password; |
fixed receive pack bug and a...
|
377 |
|
complete collaborator featur...
|
378 |
my $is_valid = |
change is_collaborator argum...
|
379 |
($user_id eq $auth_user_id || $api->is_collaborator($auth_user_id, $user_id, $project_id)) |
380 |
&& $api->check_user_and_password($auth_user_id, $auth_password); |
|
fixed receive pack bug and a...
|
381 |
|
382 |
return $is_valid; |
|
383 |
}); |
|
384 |
} |
|
385 |
else { |
|
386 |
return 1; |
|
387 |
} |
|
388 |
}); |
|
389 |
|
|
redirect .git access to /use...
|
390 |
# / |
391 |
$r->get('/')->to(cb => sub { |
|
392 |
my $self = shift; |
|
393 |
|
|
change is_collaborator argum...
|
394 |
my $user_id = $self->param('user'); |
395 |
my $project_id = $self->param('project'); |
|
redirect .git access to /use...
|
396 |
|
change is_collaborator argum...
|
397 |
$self->redirect_to("/$user_id/$project_id"); |
redirect .git access to /use...
|
398 |
}); |
399 |
|
|
fixed receive pack bug and a...
|
400 |
# /info/refs |
remove Mojolicious::Plugin::...
|
401 |
$r->get('/info/refs' => sub { shift->render_maybe('smart-http/info-refs') }); |
fixed receive pack bug and a...
|
402 |
|
403 |
# /git-upload-pack or /git-receive-pack |
|
404 |
$r->any('/git-(:service)' |
|
405 |
=> [service => qr/(?:upload-pack|receive-pack)/] |
|
remove Mojolicious::Plugin::...
|
406 |
=> sub { shift->render_maybe('smart-http/service') } |
fixed receive pack bug and a...
|
407 |
); |
408 |
|
|
409 |
# Static file |
|
remove Mojolicious::Plugin::...
|
410 |
$r->get('/(*Path)' => sub { shift->render_maybe('smart-http/static') }); |
fixed receive pack bug and a...
|
411 |
} |
add /info/refs request
|
412 |
} |
413 |
|
|
add need_login_always_option
|
414 |
# Project |
415 |
{ |
|
allow . as project name
|
416 |
my $r = $r->route('/#project'); |
add need_login_always_option
|
417 |
|
add private reporitory featu...
|
418 |
{ |
419 |
my $r = $r->under(sub { |
|
420 |
my $self = shift; |
|
421 |
|
|
cleanup
|
422 |
# API |
423 |
my $api = $self->gitprep_api; |
|
improve code structures
|
424 |
|
425 |
# Private |
|
change is_collaborator argum...
|
426 |
my $user_id = $self->param('user'); |
427 |
my $project_id = $self->param('project'); |
|
428 |
my $private = $self->app->manager->is_private_project($user_id, $project_id); |
|
add private reporitory featu...
|
429 |
if ($private) { |
change is_collaborator argum...
|
430 |
if ($api->can_access_private_project($user_id, $project_id)) { |
add private reporitory featu...
|
431 |
return 1; |
432 |
} |
|
433 |
else { |
|
434 |
$self->render('private'); |
|
435 |
return 0; |
|
436 |
} |
|
437 |
} |
|
438 |
else { |
|
439 |
return 1; |
|
440 |
} |
|
441 |
}); |
|
442 |
|
|
443 |
# Home |
|
remove Mojolicious::Plugin::...
|
444 |
$r->get('/' => sub { shift->render_maybe('/tree') }); |
add issue page
|
445 |
|
446 |
# Issue |
|
447 |
$r->get('/issues' => sub { shift->render_maybe('/issues') })->to(tab => 'issues'); |
|
support markdown table
|
448 | |
449 |
# New issue |
|
add new issue feature
|
450 |
$r->any('/issues/new' => sub { shift->render_maybe('/issues/new') })->to(tab => 'issues'); |
can add new issue message an...
|
451 |
$r->any('/issues/:number' => sub { shift->render_maybe('/issue') })->to(tab => 'issues'); |
add labels page
|
452 | |
453 |
# Labels |
|
add create label
|
454 |
$r->any('/labels' => sub { shift->render_maybe('/labels') })->to(tab => 'issues'); |
add issue page
|
455 |
|
improve pull page design
|
456 |
# Pull requests |
add pulls page
|
457 |
$r->get('/pulls' => sub { shift->render_maybe('/pulls') })->to(tab => 'pulls'); |
add private reporitory featu...
|
458 |
|
improve pull page design
|
459 |
# Pull request |
fix issue number bug
|
460 |
$r->get('/pull/(:number).patch' => sub { shift->render_maybe('/pull') })->to(tab => 'pulls', patch => 1); |
461 |
$r->any('/pull/:number' => sub { shift->render_maybe('/pull') })->to(tab => 'pulls'); |
|
improve pull page design
|
462 |
|
add private reporitory featu...
|
463 |
# Commit |
remove Mojolicious::Plugin::...
|
464 |
$r->get('/commit/*diff' => sub { shift->render_maybe('/commit') }); |
add atom feed part
|
465 | |
add private reporitory featu...
|
466 |
# Commits |
remove Mojolicious::Plugin::...
|
467 |
$r->get('/commits/*rev_file' => sub { shift->render_maybe('/commits') }); |
add private reporitory featu...
|
468 |
|
469 |
# Branches |
|
fix branch paging
|
470 |
$r->any('/branches' => sub { shift->render_maybe('/branches') }); |
added feature that you see p...
|
471 | |
add private reporitory featu...
|
472 |
# Tags |
remove Mojolicious::Plugin::...
|
473 |
$r->get('/tags' => sub { shift->render_maybe('/tags') }); |
improved network page
|
474 | |
add private reporitory featu...
|
475 |
# Tree |
remove Mojolicious::Plugin::...
|
476 |
$r->get('/tree/*rev_dir' => sub { shift->render_maybe('/tree') }); |
add private reporitory featu...
|
477 |
|
478 |
# Blob |
|
remove Mojolicious::Plugin::...
|
479 |
$r->get('/blob/*rev_file' => sub { shift->render_maybe('/blob') }); |
add private reporitory featu...
|
480 |
|
481 |
# Sub module |
|
remove Mojolicious::Plugin::...
|
482 |
$r->get('/submodule/*rev_file' => sub { shift->render_maybe('/submodule') }); |
add blame method
|
483 | |
add private reporitory featu...
|
484 |
# Raw |
remove Mojolicious::Plugin::...
|
485 |
$r->get('/raw/*rev_file' => sub { shift->render_maybe('/raw') }); |
add blame method
|
486 | |
add private reporitory featu...
|
487 |
# Blame |
remove Mojolicious::Plugin::...
|
488 |
$r->get('/blame/*rev_file' => sub { shift->render_maybe('/blame') }); |
add private reporitory featu...
|
489 |
|
490 |
# Archive |
|
remove Mojolicious::Plugin::...
|
491 |
# Archive |
492 |
$r->get('/archive/(*rev).tar.gz' => sub { shift->render_maybe('/archive') })->to(archive_type => 'tar'); |
|
493 |
$r->get('/archive/(*rev).zip' => sub { shift->render_maybe('/archive') })->to(archive_type => 'zip' ); |
|
add private reporitory featu...
|
494 |
|
495 |
# Compare |
|
add create pull request logi...
|
496 |
$r->any('/compare' => sub { shift->render_maybe('/compare') }); |
497 |
$r->any( |
|
cleanup branch
|
498 |
'/compare/(:rev1)...(:rev2)' |
499 |
=> [rev1 => qr/[^\.]+/, rev2 => qr/[^\.]+/] |
|
500 |
=> sub { shift->render_maybe('/compare') } |
|
501 |
); |
|
add create pull request logi...
|
502 |
$r->any('/compare/(:rev2)' => sub { shift->render_maybe('/compare') }); |
add private reporitory featu...
|
503 |
|
504 |
# Settings |
|
improve tab design
|
505 |
{ |
506 |
my $r = $r->route('/settings')->to(tab => 'settings'); |
|
507 |
|
|
508 |
# Settings |
|
remove Mojolicious::Plugin::...
|
509 |
$r->any('/' => sub { shift->render_maybe('/settings') }); |
improve tab design
|
510 |
|
511 |
# Collaboration |
|
remove Mojolicious::Plugin::...
|
512 |
$r->any('/collaboration' => sub { shift->render_maybe('/settings/collaboration') }); |
improve tab design
|
513 |
} |
add collaboration page
|
514 |
|
add private reporitory featu...
|
515 |
# Fork |
remove Mojolicious::Plugin::...
|
516 |
$r->any('/fork' => sub { shift->render_maybe('/fork') }); |
improve tab design
|
517 |
|
add private reporitory featu...
|
518 |
# Network |
improve tab design
|
519 |
{ |
520 |
my $r = $r->route('/network')->to(tab => 'graph'); |
|
521 |
|
|
522 |
# Network |
|
remove Mojolicious::Plugin::...
|
523 |
$r->get('/' => sub { shift->render_maybe('/network') }); |
cleanup
|
524 | |
improve tab design
|
525 |
# Network Graph |
remove Mojolicious::Plugin::...
|
526 |
$r->get('/graph/(*rev1)...(*rev2_abs)' => sub { shift->render_maybe('/network/graph') }); |
improve tab design
|
527 |
} |
add pull page design
|
528 | |
add private reporitory featu...
|
529 |
# Import branch |
remove Mojolicious::Plugin::...
|
530 |
$r->any('/import-branch/:remote_user/:remote_project' => sub { shift->render_maybe('/import-branch') }); |
add private reporitory featu...
|
531 |
|
532 |
# Get branches and tags |
|
remove Mojolicious::Plugin::...
|
533 |
$r->get('/api/revs' => sub { shift->render_maybe('/api/revs') }); |
add private reporitory featu...
|
534 |
} |
add need_login_always_option
|
535 |
} |
cleanup
|
536 |
} |
added AutoRoute plugin
|
537 |
} |
538 |
} |
|
added admin user tests
|
539 | |
540 |
# Helper |
|
541 |
{ |
|
542 |
# API |
|
543 |
$self->helper(gitprep_api => sub { Gitprep::API->new(shift) }); |
|
544 |
} |
|
added reverse proxy path_dep...
|
545 |
|
X-Forwarded-HTTPS header is ...
|
546 |
# set scheme to https when X-Forwarded-HTTPS header is specified |
547 |
# This is for the backword compatible only. Now X-Forwarded-Proto is used for this purpose |
|
548 |
$self->hook(before_dispatch => sub { |
|
549 |
my $c = shift; |
|
550 |
if ($c->req->headers->header('X-Forwarded-HTTPS')) { |
|
551 |
$c->req->url->base->scheme('https'); |
|
552 |
$c->app->log->warn("X-Forwarded-HTTPS header is DEPRECATED! use X-Forwarded-Proto instead."); |
|
553 |
} |
|
554 |
}); |
|
fix smart http decompress bu...
|
555 | |
change is_collaborator argum...
|
556 |
# Set auto_decompress for Smart HTTP |
557 |
# HTTP request body of /smart-http/service is compressed. |
|
558 |
# If auto_decompress is not set, Smart HTTP fail. |
|
fix smart http decompress bu...
|
559 |
$self->hook('after_build_tx' => sub { |
560 |
my ($tx, $app) = @_; |
|
561 |
|
|
562 |
$tx->req->content->auto_decompress(1); |
|
563 |
}); |
|
564 | ||
added AutoRoute plugin
|
565 |
# Reverse proxy support |
added reverse proxy path_dep...
|
566 |
my $reverse_proxy_on = $self->config->{reverse_proxy}{on}; |
567 |
my $path_depth = $self->config->{reverse_proxy}{path_depth}; |
|
568 |
if ($reverse_proxy_on) { |
|
569 |
$ENV{MOJO_REVERSE_PROXY} = 1; |
|
570 |
if ($path_depth) { |
|
571 |
$self->hook('before_dispatch' => sub { |
|
572 |
my $self = shift; |
|
573 |
for (1 .. $path_depth) { |
|
574 |
my $prefix = shift @{$self->req->url->path->parts}; |
|
575 |
push @{$self->req->url->base->path->parts}, $prefix; |
|
576 |
} |
|
577 |
}); |
|
added AutoRoute plugin
|
578 |
} |
added reverse proxy path_dep...
|
579 |
} |
cleanup
|
580 |
|
581 |
# Smart HTTP Buffer size |
|
fix bug that lerge repositor...
|
582 |
$ENV{GITPREP_SMART_HTTP_BUFFER_SIZE} ||= 16384; |
copy gitweblite soruce code
|
583 |
} |
584 | ||
585 |
1; |