gitprep / lib / Gitprep.pm /
Newer Older
488 lines | 13.974kb
GitPrep 2 need Perl 5.10
Yuki Kimoto authored on 2016-03-28
1
use 5.010001;
renamed gitpub to gitprep
Yuki Kimoto authored on 2012-11-26
2
package Gitprep;
copy gitweblite soruce code
root authored on 2012-11-23
3
use Mojo::Base 'Mojolicious';
cleanup
Yuki Kimoto authored on 2013-05-14
4

            
5
use Carp 'croak';
added start page
Yuki Kimoto authored on 2013-02-09
6
use DBIx::Custom;
little more secure login
Yuki Kimoto authored on 2013-03-16
7
use Gitprep::API;
cleanup
Yuki Kimoto authored on 2013-05-14
8
use Gitprep::Git;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
9
use Gitprep::Manager;
added RepManager rename feat...
Yuki Kimoto authored on 2013-03-27
10
use Scalar::Util 'weaken';
cleanup
Yuki Kimoto authored on 2013-05-14
11
use Validator::Custom;
fix bug that in CGI reposito...
Yuki Kimoto authored on 2015-11-05
12

            
Digest::SHA loading to Mojo:...
Yuki Kimoto authored on 2013-08-13
13
# Digest::SHA loading to Mojo::Util if not loaded
14
{
15
  package Mojo::Util;
16
  eval {require Digest::SHA; import Digest::SHA qw(sha1 sha1_hex)};
17
}
18

            
add Mojolicious::Plugin::DBV...
Yuki Kimoto authored on 2016-03-26
19
our $VERSION = 'v2.00_dev';
cleanup
Yuki Kimoto authored on 2013-05-14
20

            
added start page
Yuki Kimoto authored on 2013-02-09
21
has 'dbi';
revert encoding support
Yuki Kimoto authored on 2013-11-22
22
has 'git';
added RepManager rename feat...
Yuki Kimoto authored on 2013-03-27
23
has 'manager';
rename validator to vc to up...
Yuki Kimoto authored on 2013-12-02
24
has 'vc';
revert encoding support
Yuki Kimoto authored on 2013-11-22
25

            
26
use constant BUFFER_SIZE => 8192;
add /info/refs request
Yuki Kimoto authored on 2013-10-01
27

            
add repository and work repo...
Yuki Kimoto authored on 2016-04-14
28
sub data_dir {
29
  my $self = shift;
30
  
31
  my $data_dir = $self->config('data_dir');
32
  
33
  return $data_dir;
34
}
35

            
cleanup
Yuki Kimoto authored on 2016-04-16
36
sub rep_home {
37
  my $self = shift;
38
  
39
  my $rep_home = $self->data_dir . "/rep";
40
  
41
  return $rep_home;
42
}
43

            
cleanup branch
Yuki Kimoto authored on 2016-04-16
44
sub rep_info {
45
  my ($self, $user, $project) = @_;
46
  
47
  my $info = {};
add user and project info
Yuki Kimoto authored on 2016-04-16
48
  $info->{user} = $user;
cleanup blob
Yuki Kimoto authored on 2016-04-16
49
  $info->{project} = $project;
cleanup branch
Yuki Kimoto authored on 2016-04-16
50
  $info->{git_dir} = $self->rep_home . "/$user/$project.git";
51
  
52
  return $info;
53
}
54

            
cleanup
Yuki Kimoto authored on 2016-04-16
55
sub work_rep_home {
56
  my $self = shift;
57
  
58
  my $work_rep_home = $self->data_dir . "/work";
59
  
60
  return $work_rep_home;
61
}
62

            
cleanup create working direc...
Yuki Kimoto authored on 2016-04-16
63
sub work_rep_info {
64
  my ($self, $user, $project) = @_;
65
  
66
  my $info = {};
67
  $info->{user} = $user;
68
  $info->{project} = $project;
cleanup compare logic
Yuki Kimoto authored on 2016-04-18
69
  $info->{git_dir} = $self->work_rep_home . "/$user/$project/.git";
70
  $info->{work_tree} = $self->work_rep_home . "/$user/$project";
cleanup create working direc...
Yuki Kimoto authored on 2016-04-16
71
  
72
  return $info;
73
}
74

            
copy gitweblite soruce code
root authored on 2012-11-23
75
sub startup {
76
  my $self = shift;
77
  
cleanup
Yuki Kimoto authored on 2013-05-14
78
  # Config file
update Mojolicious and added...
Yuki Kimoto authored on 2013-03-20
79
  $self->plugin('INIConfig', {ext => 'conf'});
80
  
cleanup
Yuki Kimoto authored on 2013-05-14
81
  # Config file for developper
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
82
  unless ($ENV{GITPREP_NO_MYCONFIG}) {
83
    my $my_conf_file = $self->home->rel_file('gitprep.my.conf');
84
    $self->plugin('INIConfig', {file => $my_conf_file}) if -f $my_conf_file;
85
  }
update Mojolicious and added...
Yuki Kimoto authored on 2013-03-20
86
  
cleanup
Yuki Kimoto authored on 2013-05-14
87
  # Listen
copy gitweblite soruce code
root authored on 2012-11-23
88
  my $conf = $self->config;
cleanup
Yuki Kimoto authored on 2013-05-14
89
  my $listen = $conf->{hypnotoad}{listen} ||= ['http://*:10020'];
90
  $listen = [split /,/, $listen] unless ref $listen eq 'ARRAY';
fixed listen bug
Yuki Kimoto authored on 2013-03-29
91
  $conf->{hypnotoad}{listen} = $listen;
copy gitweblite soruce code
root authored on 2012-11-23
92
  
add repository and work repo...
Yuki Kimoto authored on 2016-04-14
93
  # Data directory
fix tests
Yuki Kimoto authored on 2016-04-14
94
  my $data_dir = $ENV{GITPREP_DATA_DIR} ? $ENV{GITPREP_DATA_DIR} : $self->home->rel_file('data');
95
  $self->config(data_dir => $data_dir);
add repository and work repo...
Yuki Kimoto authored on 2016-04-14
96
  
revert encoding support
Yuki Kimoto authored on 2013-11-22
97
  # Git
renamed gitpub to gitprep
Yuki Kimoto authored on 2012-11-26
98
  my $git = Gitprep::Git->new;
cleanup encoding
Yuki Kimoto authored on 2016-04-05
99
  $git->app($self);
100
  weaken $git->{app};
cleanup
Yuki Kimoto authored on 2013-05-14
101
  my $git_bin
102
    = $conf->{basic}{git_bin} ? $conf->{basic}{git_bin} : $git->search_bin;
fix mini bug
Yuki Kimoto authored on 2013-03-31
103
  if (!$git_bin || ! -e $git_bin) {
104
    $git_bin ||= '';
cleanup
Yuki Kimoto authored on 2013-05-14
105
    my $error = "Can't detect or found git command ($git_bin)."
106
      . " set git_bin in gitprep.conf";
fixed git_bin not found bug
Yuki Kimoto authored on 2013-03-31
107
    $self->log->error($error);
108
    croak $error;
109
  }
improve code structures
Yuki Kimoto authored on 2013-11-19
110
  $git->bin($git_bin);
revert encoding support
Yuki Kimoto authored on 2013-11-22
111
  
112
  # Repository Manager
cleanup encoding
Yuki Kimoto authored on 2016-04-05
113
  my $manager = Gitprep::Manager->new;
114
  $manager->app($self);
revert encoding support
Yuki Kimoto authored on 2013-11-22
115
  weaken $manager->{app};
116
  $self->manager($manager);
117
  
add key delete feature and u...
gitprep authored on 2014-05-19
118
  # authorized_keys file
fix authorized_keys_file bug
Yuki Kimoto authored on 2015-11-04
119
  my $authorized_keys_file = $conf->{basic}{authorized_keys_file};
add key delete feature and u...
gitprep authored on 2014-05-19
120
  unless (defined $authorized_keys_file) {
121
    if (defined $ENV{HOME}) {
fix update_authorized_keys_f...
gitprep authored on 2014-05-19
122
      $authorized_keys_file = "$ENV{HOME}/.ssh/authorized_keys";
add key delete feature and u...
gitprep authored on 2014-05-19
123
    }
124
  }
125
  if (defined $authorized_keys_file) {
126
    $self->manager->authorized_keys_file($authorized_keys_file);
127
  }
128
  else {
129
    $self->app->log->warn(qq/Config "authorized_keys_file" can't be detected/);
130
  }
131
  
fixed git_bin not found bug
Yuki Kimoto authored on 2013-03-31
132
  # Repository home
cleanup tests
Yuki Kimoto authored on 2016-04-16
133
  my $rep_home = "$data_dir/rep";
added create repository feat...
Yuki Kimoto authored on 2013-03-18
134
  unless (-d $rep_home) {
135
    mkdir $rep_home
136
      or croak "Can't create directory $rep_home: $!";
137
  }
cleanup
Yuki Kimoto authored on 2013-05-14
138
  
add time zone system
Yuki Kimoto authored on 2014-03-08
139
  # Time Zone
140
  if (my $time_zone = $conf->{basic}{time_zone}) {
141
    
142
    if ($time_zone =~ /^([\+-])?([0-9]?[0-9]):([0-9][0-9])$/) {
143
      my $sign = $1 || '';
144
      my $hour = $2;
145
      my $min = $3;
146
      
147
      my $time_zone_second = $sign . ($hour * 60 * 60) + ($min * 60);
148
      $git->time_zone_second($time_zone_second);
149
    }
150
    else {
151
      $self->log->warn("Bad time zone $time_zone. Time zone become GMT");
152
    }
153
  }
154
  $self->git($git);
cleanup
Yuki Kimoto authored on 2013-05-14
155
  
improved create repository f...
Yuki Kimoto authored on 2013-03-21
156
  # DBI
cleanup tests
Yuki Kimoto authored on 2016-04-16
157
  my $db_file = "$data_dir/gitprep.db";
improved create repository f...
Yuki Kimoto authored on 2013-03-21
158
  my $dbi = DBIx::Custom->connect(
159
    dsn => "dbi:SQLite:database=$db_file",
160
    connector => 1,
added original_pid column
Yuki Kimoto authored on 2013-04-18
161
    option => {sqlite_unicode => 1, sqlite_use_immediate_transaction => 1}
improved create repository f...
Yuki Kimoto authored on 2013-03-21
162
  );
163
  $self->dbi($dbi);
164
  
cleanup
Yuki Kimoto authored on 2013-05-14
165
  # Database file permision
fixed database file permissi...
Yuki Kimoto authored on 2013-04-19
166
  if (my $user = $self->config->{hypnotoad}{user}) {
167
    my $uid = (getpwnam $user)[2];
168
    chown $uid, -1, $db_file;
169
  }
170
  if (my $group = $self->config->{hypnotoad}{group}) {
171
    my $gid = (getgrnam $group)[2];
172
    chown -1, $gid, $db_file;
173
  }
174
  
improved create repository f...
Yuki Kimoto authored on 2013-03-21
175
  # Model
176
  my $models = [
177
    {table => 'user', primary_key => 'id'},
fix ssh key authentication b...
gitprep authored on 2014-05-20
178
    {table => 'ssh_public_key', primary_key => 'key'},
added original_pid column
Yuki Kimoto authored on 2013-04-18
179
    {table => 'project', primary_key => ['user_id', 'name']},
add collaborator register lo...
Yuki Kimoto authored on 2013-11-17
180
    {table => 'number', primary_key => 'key'},
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
181
    {table => 'collaboration', primary_key => ['user_id', 'project_name', 'collaborator_id']},
182
    {table => 'pull_request'}
improved create repository f...
Yuki Kimoto authored on 2013-03-21
183
  ];
184
  $dbi->create_model($_) for @$models;
185

            
186
  # Validator
rename validator to vc to up...
Yuki Kimoto authored on 2013-12-02
187
  my $vc = Validator::Custom->new;
188
  $self->vc($vc);
189
  $vc->register_constraint(
added project delete feature
Yuki Kimoto authored on 2013-03-24
190
    user_name => sub {
191
      my $value = shift;
192
      
allow . as project name
Yuki Kimoto authored on 2014-04-21
193
      return ($value || '') =~ /^[a-zA-Z0-9_\-]+$/;
added project delete feature
Yuki Kimoto authored on 2013-03-24
194
    },
195
    project_name => sub {
196
      my $value = shift;
allow . as project name
Yuki Kimoto authored on 2014-04-21
197
      return 0 unless defined $value;
198
      return 0 if $value eq '.' || $value eq '..';
199

            
200
      return ($value || '') =~ /[a-zA-Z0-9_\-\.]+$/;
added project delete feature
Yuki Kimoto authored on 2013-03-24
201
    }
202
  );
improved create repository f...
Yuki Kimoto authored on 2013-03-21
203
  
cleanup setting validation
Yuki Kimoto authored on 2016-02-09
204
  $vc->add_check(project_name => sub {
205
    my ($vc, $value) = @_;
206
    
207
    return 0 unless defined $value;
208
    return 0 if $value eq '.' || $value eq '..';
209
    
210
    return ($value || '') =~ /[a-zA-Z0-9_\-\.]+$/;
211
  });
cleanup create user validati...
Yuki Kimoto authored on 2016-02-09
212
  $vc->add_check(user_name => sub {
213
    my ($vc, $value) = @_;
214
    
215
    return ($value || '') =~ /^[a-zA-Z0-9_\-]+$/;
216
  });
cleanup setting validation
Yuki Kimoto authored on 2016-02-09
217
  
fixed receive pack bug and a...
Yuki Kimoto authored on 2013-10-03
218
  # Basic auth plugin
219
  $self->plugin('BasicAuth');
added admin user tests
Yuki Kimoto authored on 2013-05-17
220

            
added login page
Yuki Kimoto authored on 2013-02-09
221
  {
cleanup
Yuki Kimoto authored on 2013-05-14
222
    my $r = $self->routes;
223

            
224
    # DBViewer(only development)
add Mojolicious::Plugin::DBV...
Yuki Kimoto authored on 2016-03-26
225
    # /dbviewer
cleanup
Yuki Kimoto authored on 2013-05-14
226
    if ($self->mode eq 'development') {
227
      eval {
228
        $self->plugin(
229
          'DBViewer',
230
          dsn => "dbi:SQLite:database=$db_file"
231
        );
232
      };
added reset password feature
Yuki Kimoto authored on 2013-04-10
233
    }
added AutoRoute plugin
Yuki Kimoto authored on 2013-04-09
234
    
cleanup
Yuki Kimoto authored on 2013-05-14
235
    # Auto route
cleanup many pages
Yuki Kimoto authored on 2013-03-31
236
    {
cleanup
Yuki Kimoto authored on 2013-05-14
237
      my $r = $r->under(sub {
238
        my $self = shift;
239
        
240
        my $api = $self->gitprep_api;
241
        
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
242
        # Authentication
cleanup
Yuki Kimoto authored on 2013-05-14
243
        {
244
          my $path = $self->req->url->path->parts->[0] || '';
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
245
          
246
          # Admin
cleanup
Yuki Kimoto authored on 2013-05-14
247
          if ($path eq '_admin' && !$api->logined_admin) {
248
            $self->redirect_to('/');
249
            return;
250
          }
251
        }
252
        
253
        return 1; 
254
      });
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
255
      
256
      # Auto routes
cleanup
Yuki Kimoto authored on 2013-05-14
257
      $self->plugin('AutoRoute', route => $r);
fix bug that forst . is not ...
Yuki Kimoto authored on 2014-04-21
258
      
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
259
      # Custom routes
cleanup
Yuki Kimoto authored on 2013-05-14
260
      {
add ssh key add feature
gitprep authored on 2014-05-17
261
        # Show ssh keys
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
262
        $r->get('/(:user).keys' => sub { shift->render_maybe('/user-keys') });
add ssh key add feature
gitprep authored on 2014-05-17
263
        
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
264
        # User
allow . as project name
Yuki Kimoto authored on 2014-04-21
265
        my $r = $r->route('/:user');
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
266
        {
267
          # Home
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
268
          $r->get('/' => [format => 0] => sub { shift->render_maybe('/user') });
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
269
          
270
          # Settings
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
271
          $r->get('/_settings' => sub { shift->render_maybe('/user-settings') });
add ssh keys page design
gitprep authored on 2014-05-17
272
          
273
          # SSH keys
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
274
          $r->any('/_settings/ssh' => sub { shift->render_maybe('/user-settings/ssh') });
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
275
        }
add /info/refs request
Yuki Kimoto authored on 2013-10-01
276

            
277
        # Smart HTTP
278
        {
allow . as project name
Yuki Kimoto authored on 2014-04-21
279
          my $r = $r->route('/(#project).git');
add /info/refs request
Yuki Kimoto authored on 2013-10-01
280
          
fixed receive pack bug and a...
Yuki Kimoto authored on 2013-10-03
281
          {
282
            my $r = $r->under(sub {
283
              my $self = shift;
284
              
cleanup
Yuki Kimoto authored on 2013-11-16
285
              my $api = $self->gitprep_api;
complete private repository ...
Yuki Kimoto authored on 2013-11-16
286
              my $user = $self->param('user');
287
              my $project = $self->param('project');
288
              my $private = $self->app->manager->is_private_project($user, $project);
cleanup
Yuki Kimoto authored on 2013-11-16
289
              
fixed receive pack bug and a...
Yuki Kimoto authored on 2013-10-03
290
              # Basic auth when push request
291
              my $service = $self->param('service') || '';
complete private repository ...
Yuki Kimoto authored on 2013-11-16
292
              if ($service eq 'git-receive-pack' || $private) {
fixed receive pack bug and a...
Yuki Kimoto authored on 2013-10-03
293
                
294
                $self->basic_auth("Git Area", sub {
complete private repository ...
Yuki Kimoto authored on 2013-11-16
295
                  my ($auth_user, $auth_password) = @_;
add warnings when authentica...
Yuki Kimoto authored on 2014-02-18
296
                  
297
                  if (!defined $auth_user || !length $auth_user) {
298
                    $self->app->log->warn("Authentication: User name is empty");
299
                  }
300
                  
fix warnings
Yuki Kimoto authored on 2013-11-18
301
                  $auth_user = '' unless defined $auth_user;
302
                  $auth_password = '' unless defined $auth_password;
fixed receive pack bug and a...
Yuki Kimoto authored on 2013-10-03
303
                  
complete collaborator featur...
Yuki Kimoto authored on 2013-11-17
304
                  my $is_valid =
305
                    ($user eq $auth_user || $api->is_collaborator($user, $project, $auth_user))
306
                    && $api->check_user_and_password($auth_user, $auth_password);
fixed receive pack bug and a...
Yuki Kimoto authored on 2013-10-03
307
                  
308
                  return $is_valid;
309
                });
310
              }
311
              else {
312
                return 1;
313
              }
314
            });
315
            
redirect .git access to /use...
Yuki Kimoto authored on 2014-02-26
316
            # /
317
            $r->get('/')->to(cb => sub {
318
              my $self = shift;
319
              
320
              my $user = $self->param('user');
321
              my $project = $self->param('project');
322
              
323
              $self->redirect_to("/$user/$project");
324
            });
325
            
fixed receive pack bug and a...
Yuki Kimoto authored on 2013-10-03
326
            # /info/refs
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
327
            $r->get('/info/refs' => sub { shift->render_maybe('smart-http/info-refs') });
fixed receive pack bug and a...
Yuki Kimoto authored on 2013-10-03
328
            
329
            # /git-upload-pack or /git-receive-pack
330
            $r->any('/git-(:service)'
331
              => [service => qr/(?:upload-pack|receive-pack)/]
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
332
              => sub { shift->render_maybe('smart-http/service') }
fixed receive pack bug and a...
Yuki Kimoto authored on 2013-10-03
333
            );
334
            
335
            # Static file
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
336
            $r->get('/(*Path)' => sub { shift->render_maybe('smart-http/static') });
fixed receive pack bug and a...
Yuki Kimoto authored on 2013-10-03
337
          }
add /info/refs request
Yuki Kimoto authored on 2013-10-01
338
        }
339
                
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
340
        # Project
341
        {
allow . as project name
Yuki Kimoto authored on 2014-04-21
342
          my $r = $r->route('/#project');
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
343
          
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
344
          {
345
            my $r = $r->under(sub {
346
              my $self = shift;
347
              
cleanup
Yuki Kimoto authored on 2013-11-16
348
              # API
349
              my $api = $self->gitprep_api;
improve code structures
Yuki Kimoto authored on 2013-11-19
350
              
351
              # Private
revert encoding support
Yuki Kimoto authored on 2013-11-22
352
              my $user = $self->param('user');
353
              my $project = $self->param('project');
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
354
              my $private = $self->app->manager->is_private_project($user, $project);
355
              if ($private) {
complete collaborator featur...
Yuki Kimoto authored on 2013-11-17
356
                if ($api->can_access_private_project($user, $project)) {
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
357
                  return 1;
358
                }
359
                else {
360
                  $self->render('private');
361
                  return 0;
362
                }
363
              }
364
              else {
365
                return 1;
366
              }
367
            });
368
            
369
            # Home
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
370
            $r->get('/' => sub { shift->render_maybe('/tree') });
add pulls page
Yuki Kimoto authored on 2016-04-12
371

            
372
            # Tags
373
            $r->get('/pulls' => sub { shift->render_maybe('/pulls') })->to(tab => 'pulls');
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
374
            
375
            # Commit
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
376
            $r->get('/commit/*diff' => sub { shift->render_maybe('/commit') });
add atom feed part
Yuki Kimoto authored on 2014-10-02
377

            
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
378
            # Commits
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
379
            $r->get('/commits/*rev_file' => sub { shift->render_maybe('/commits') });
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
380
            
381
            # Branches
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
382
            $r->any('/branches/:display' => {display => undef} => sub { shift->render_maybe('/branches') });
added feature that you see p...
Yuki Kimoto authored on 2013-04-11
383

            
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
384
            # Tags
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
385
            $r->get('/tags' => sub { shift->render_maybe('/tags') });
improved network page
Yuki Kimoto authored on 2013-04-16
386

            
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
387
            # Tree
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
388
            $r->get('/tree/*rev_dir' => sub { shift->render_maybe('/tree') });
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
389
            
390
            # Blob
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
391
            $r->get('/blob/*rev_file' => sub { shift->render_maybe('/blob') });
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
392
            
393
            # Sub module
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
394
            $r->get('/submodule/*rev_file' => sub { shift->render_maybe('/submodule') });
add blame method
Yuki Kimoto authored on 2013-08-10
395

            
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
396
            # Raw
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
397
            $r->get('/raw/*rev_file' => sub { shift->render_maybe('/raw') });
add blame method
Yuki Kimoto authored on 2013-08-10
398

            
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
399
            # Blame
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
400
            $r->get('/blame/*rev_file' => sub { shift->render_maybe('/blame') });
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
401
            
402
            # Archive
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
403
            # Archive
404
            $r->get('/archive/(*rev).tar.gz' => sub { shift->render_maybe('/archive') })->to(archive_type => 'tar');
405
            $r->get('/archive/(*rev).zip' => sub { shift->render_maybe('/archive') })->to(archive_type => 'zip' );
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
406
            
407
            # Compare
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
408
            $r->any('/compare' => sub { shift->render_maybe('/compare') });
409
            $r->any(
cleanup branch
Yuki Kimoto authored on 2016-04-12
410
              '/compare/(:rev1)...(:rev2)'
411
              => [rev1 => qr/[^\.]+/, rev2 => qr/[^\.]+/]
412
              => sub { shift->render_maybe('/compare') }
413
            );
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
414
            $r->any('/compare/(:rev2)' => sub { shift->render_maybe('/compare') });
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
415
            
416
            # Settings
improve tab design
Yuki Kimoto authored on 2016-01-26
417
            {
418
              my $r = $r->route('/settings')->to(tab => 'settings');
419
              
420
              # Settings
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
421
              $r->any('/' => sub { shift->render_maybe('/settings') });
improve tab design
Yuki Kimoto authored on 2016-01-26
422
              
423
              # Collaboration
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
424
              $r->any('/collaboration' => sub { shift->render_maybe('/settings/collaboration') });
improve tab design
Yuki Kimoto authored on 2016-01-26
425
            }
add collaboration page
Yuki Kimoto authored on 2013-11-17
426
            
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
427
            # Fork
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
428
            $r->any('/fork' => sub { shift->render_maybe('/fork') });
improve tab design
Yuki Kimoto authored on 2016-01-26
429
            
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
430
            # Network
improve tab design
Yuki Kimoto authored on 2016-01-26
431
            {
432
              my $r = $r->route('/network')->to(tab => 'graph');
433
              
434
              # Network
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
435
              $r->get('/' => sub { shift->render_maybe('/network') });
cleanup
Yuki Kimoto authored on 2013-05-14
436

            
improve tab design
Yuki Kimoto authored on 2016-01-26
437
              # Network Graph
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
438
              $r->get('/graph/(*rev1)...(*rev2_abs)' => sub { shift->render_maybe('/network/graph') });
improve tab design
Yuki Kimoto authored on 2016-01-26
439
            }
add pull page design
Yuki Kimoto authored on 2013-08-13
440

            
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
441
            # Import branch
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
442
            $r->any('/import-branch/:remote_user/:remote_project' => sub { shift->render_maybe('/import-branch') });
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
443
            
444
            # Get branches and tags
remove Mojolicious::Plugin::...
Yuki Kimoto authored on 2016-03-28
445
            $r->get('/api/revs' => sub { shift->render_maybe('/api/revs') });
add private reporitory featu...
Yuki Kimoto authored on 2013-11-16
446
          }
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
447
        }
cleanup
Yuki Kimoto authored on 2013-05-14
448
      }
added AutoRoute plugin
Yuki Kimoto authored on 2013-04-09
449
    }
450
  }
added admin user tests
Yuki Kimoto authored on 2013-05-17
451

            
452
  # Helper
453
  {
454
    # API
455
    $self->helper(gitprep_api => sub { Gitprep::API->new(shift) });
456
  }
added reverse proxy path_dep...
Yuki Kimoto authored on 2013-04-22
457
  
X-Forwarded-HTTPS header is ...
Yuki Kimoto authored on 2016-03-28
458
  # set scheme to https when X-Forwarded-HTTPS header is specified
459
  # This is for the backword compatible only. Now X-Forwarded-Proto is used for this purpose
460
  $self->hook(before_dispatch => sub {
461
    my $c = shift;
462
    if ($c->req->headers->header('X-Forwarded-HTTPS')) {
463
      $c->req->url->base->scheme('https');
464
      $c->app->log->warn("X-Forwarded-HTTPS header is DEPRECATED! use X-Forwarded-Proto instead.");
465
    }
466
  });
467
  
added AutoRoute plugin
Yuki Kimoto authored on 2013-04-09
468
  # Reverse proxy support
added reverse proxy path_dep...
Yuki Kimoto authored on 2013-04-22
469
  my $reverse_proxy_on = $self->config->{reverse_proxy}{on};
470
  my $path_depth = $self->config->{reverse_proxy}{path_depth};
471
  if ($reverse_proxy_on) {
472
    $ENV{MOJO_REVERSE_PROXY} = 1;
473
    if ($path_depth) {
474
      $self->hook('before_dispatch' => sub {
475
        my $self = shift;
476
        for (1 .. $path_depth) {
477
          my $prefix = shift @{$self->req->url->path->parts};
478
          push @{$self->req->url->base->path->parts}, $prefix;
479
        }
480
      });
added AutoRoute plugin
Yuki Kimoto authored on 2013-04-09
481
    }
added reverse proxy path_dep...
Yuki Kimoto authored on 2013-04-22
482
  }
cleanup
Yuki Kimoto authored on 2013-10-11
483
  
484
  # Smart HTTP Buffer size
fix bug that lerge repositor...
Yuki Kimoto authored on 2014-02-17
485
  $ENV{GITPREP_SMART_HTTP_BUFFER_SIZE} ||= 16384;
copy gitweblite soruce code
root authored on 2012-11-23
486
}
487

            
488
1;