Separate paging for log and history views.
[catagits/Gitalist.git] / lib / Gitalist.pm
CommitLineData
89de6a33 1package Gitalist;
42fe5d11 2use Moose;
775e96e0 3BEGIN { require 5.008006; }
89de6a33 4use Catalyst::Runtime 5.80;
775e96e0 5use namespace::autoclean;
89de6a33 6
42fe5d11 7extends 'Catalyst';
89de6a33 8
43d4a724 9use Catalyst qw/
89de6a33 10 ConfigLoader
fac828e0 11 Unicode::Encoding
d5cc37a4 12 Static::Simple
fac828e0 13 StackTrace
16bdb8df 14 SubRequest
fac828e0 15/;
61b56ed6 16
9b762ea6 17our $VERSION = '0.002009';
775e96e0 18$VERSION = eval $VERSION;
89de6a33 19
d3feefcf 20__PACKAGE__->config(
61b56ed6 21 name => 'Gitalist',
22 default_view => 'Default',
7bf1a6f5 23 default_model => 'CollectionOfRepos',
e77519b1 24 use_request_uri_for_path => 1,
25 disable_component_resolution_regex_fallback => 1,
d3feefcf 26);
89de6a33 27
89de6a33 28__PACKAGE__->setup();
29
319537bf 30after prepare_path => sub {
31 my ($ctx) = @_;
32 if ($ctx->req->param('a')) {
33 $ctx->request->uri->path('/legacy' . $ctx->request->uri->path);
34 }
35};
36
4df2f62f 37around uri_for => sub {
38 my ($orig, $c) = (shift, shift);
df49ca46 39 my $uri = $c->$orig(@_);
74d26472 40 $$uri =~ tr[&][;] if defined $uri;
4df2f62f 41 return $uri;
42};
61b56ed6 43
906a2dd2 44sub uri_with {
45 my ($self, @args) = @_;
46 my $uri = $self->request->uri_with(@args);
47 # Wow this awful.
48 $uri =~ s[/fragment\b][];
49 return $uri;
50}
51
775e96e0 521;
53
54__END__
55
8004a936 56=encoding UTF-8
57
89de6a33 58=head1 NAME
59
775e96e0 60Gitalist - A modern git web viewer
89de6a33 61
62=head1 SYNOPSIS
63
3a7cd273 64 perl script/gitalist_server.pl --repo_dir /home/me/code/git
89de6a33 65
b6d010e1 66=head1 INSTALL
67
68As Gitalist follows the usual Perl module format the usual approach
8004a936 69for installation should work, e.g.:
b6d010e1 70
3a7cd273 71 perl Makefile.PL
72 make
73 make test
74 make install
b6d010e1 75
63f34424 76or
77
3a7cd273 78 cpan -i Gitalist
63f34424 79
8004a936 80You can also L<check Gitalist out from its git repository|/"GETTING GITALIST">
81and run it, in this case you'll additionally need the author modules,
82but no configuration will be needed as it will default to looking
63f34424 83for repositories the directory above the checkout.
b6d010e1 84
89de6a33 85=head1 DESCRIPTION
86
8004a936 87Gitalist is a web frontend for git repositories based on
88L<gitweb.cgi|https://git.wiki.kernel.org/index.php/Gitweb> and backed by
89L<Catalyst>.
b6d010e1 90
91=head2 History
92
8004a936 93This project started off as an attempt to port I<gitweb.cgi> to a
b6d010e1 94Catalyst app in a piecemeal fashion. As it turns out, thanks largely
8004a936 95to Florian Ragwitz's earlier effort, it was easier to use I<gitweb.cgi>
b6d010e1 96as a template for building a new Catalyst application.
89de6a33 97
69175e49 98=head1 GETTING GITALIST
99
100You can install Gitalist from CPAN in the usual way:
101
102 cpan -i Gitalist
103
104Alternatively, you can get Gitalist using git.
105
106The canonical repository for the master branch is:
107
1d46f550 108 git://git.shadowcat.co.uk/catagits/Gitalist.git
69175e49 109
8004a936 110Gitalist is also mirrored to GitHub at L<https://github.com/broquaint/Gitalist>,
111and a number of people have active forks
69175e49 112with branches and/or new features in the master branch.
113
ccb79ac8 114=head1 BOOTSTRAPPING
115
116As of C<0.002001> Gitalist can now be bootstrapped to run out of its
117own directory by installing its prerequisites locally with the help of
118L<local::lib>. So instead of installing the prerequisites to the
119system path with CPAN they are installed under the Gitalist directory.
120
8004a936 121To do this clone Gitalist from the L<Shadowcat repository mentioned
122above|/"GETTING GITALIST"> or grab a snapshot from broquaint's GitHub repository:
ccb79ac8 123
8004a936 124 https://github.com/broquaint/Gitalist/downloads
ccb79ac8 125
126With the source acquired and unpacked run the following from within the
127Gitalist directory:
128
e2c6e7c1 129 perl script/bootstrap.pl
ccb79ac8 130
131This will install the necessary modules for the build process which in
132turn installs the prerequisites locally.
133
8004a936 134B<NB:> The relevant bootstrap scripts aren't available in the CPAN dist
e2c6e7c1 135as the bootstrap scripts should not be installed.
136
69175e49 137=head1 INITIAL CONFIGURATION
138
139Gitalist is configured using L<Catalyst::Plugin::Configloader>. The supplied sample
140configuration is in L<Config::General> format, however it is possible to configure
141Gitalist using other config file formats (such as YAML) if you prefer.
142
143=head2 WHEN CHECKING GITALIST OUT OF GIT
144
145Gitalist from git includes a minimal C<gitalist_local.conf>, which sets the repository
146directory to one directory higher than the Gitalist repository.
147
148This means that if you check Gitalist out next to your other git checkouts, then starting
149the demo server needs no parameters at all:
150
3a7cd273 151 Gitalist [master]$ perl script/gitalist_server.pl
69175e49 152 You can connect to your server at http://localhost:3000
153
154=head2 FOR CPAN INSTALLS
63f34424 155
156Gitalist can be supplied with a config file by setting the C<< GITALIST_CONFIG >>
157environment variable to point to a configuration file.
158
69175e49 159If you install Gitalist from CPAN, a default configuration is installed along with gitalist,
160which is complete except for a repository directory. You can get a copy of this configuration
161by running:
63f34424 162
163 cp `perl -Ilib -MGitalist -e'print Gitalist->path_to("gitalist.conf")'` gitalist.conf
164
8004a936 165You can then edit this configuration, adding a C<repo_dir> path and customising
166other settings as desired.
69175e49 167
168You can then start the Gitalist demo server by setting C<< GITALIST_CONFIG >>. For example:
169
170 GITALIST_CONFIG=/usr/local/etc/gitalist.conf gitalist_server.pl
63f34424 171
172Alternatively, if you only want to set a repository directory and are otherwise happy with
1d46f550 173the default configuration, then you can set the C<< GITALIST_REPO_DIR >> environment
3d0e045e 174variable, or pass the C<< --repo_dir >> flag to any of the scripts.
63f34424 175
1d46f550 176 GITALIST_REPO_DIR=/home/myuser/code/git gitalist_server.pl
3d0e045e 177 gitalist_server.pl --repo_dir home/myuser/code/git
69175e49 178
1d46f550 179The C<< GITALIST_REPO_DIR >> environment variable will override the repository directory set
3d0e045e 180in configuration, and will itself be overridden by he C<< --repo_dir >> flag.
63f34424 181
69175e49 182=head1 RUNNING
183
184Once you have followed the instructions above to install and configure Gitalist, you may want
185to run it in a more production facing environment than using the single threaded developement
186server.
187
188The recommended deployment method for Gitalist is FastCGI, although Gitalist can also be run
8004a936 189under L<mod_perl|https://perl.apache.org/> or as pure Perl with L<Catalyst::Engine::PreFork>.
69175e49 190
191Assuming that you have installed Gitalist's dependencies into a L<local::lib>, and you
192are running from a git checkout, adding a trivial FCGI script as C<script/gitalist.fcgi>
193(this file is specifically in C<.gitignore> so you can have your own copy):
194
195 #!/bin/sh
69175e49 196 exec /home/t0m/public_html/Gitalist/script/gitalist_fastcgi.pl
197
198This example can be seen live here:
199
f9d6e4f1 200 http://example.gitalist.com
8004a936 201
5111a8ab 202=head1 CONFIGURATION
203
204The Gitalist config is loaded with L<Catalyst::Plugin::ConfigLoader>
205and the available config options are:
206
207=head2 Model::CollectionOfRepos
208
209=over
210
211=item git
212
213Path to the C<git> binary.
214
215=item repo_dir
216
217A directory containing the directories to show.
218
07ee9dc1 219=item repos
220
221A list of directories containing repositories to show.
5111a8ab 222
223=item search_recursively
224
225A boolean indicating whether to always search recursively for
226repositories within C<repo_dir>.
227
228=item whitelist
229
230Path a file containing a list of repositories that can be shown. Each
231line in the file will represent the name of a repo to show e.g
232
233 Gitalist
234 some-bare-repo.git
235
236This is compatible with C<gitweb>'s C<projects.list>.
237
238=item export_ok
239
240If provided every must contain a file of the same name to be
241visible. This is similar to C<gitweb>'s functionality.
242
243=back
244
245=head2 paging
246
247=over
248
249=item log
250
07ee9dc1 251The number of commits to show in the summary, shortlog and longlog views.
5111a8ab 252
253=back
254
321b3fbf 255=head2 FASTCGI
8004a936 256
257Running Gitalist in FastCGI mode requires a webserver with FastCGI
258support (such as apache with L<mod_fcgi|http://www.fastcgi.com/drupal/node/3>
259or L<mod_fcgid|https://httpd.apache.org/mod_fcgid/>). Below is a sample
260configuration using Apache2 with mod_fcgid in a dynamic configuration
261(as opposed to static or standalone mode). More information on these modes and
262their configuration can be found at L<Catalyst::Engine::FastCGI/"Standalone server mode">.
263
264In Apache's F<mime.conf>, add C<AddHandler fcgid-script .fcgi>
265(or C<AddHandler fastcgi-script .fcgi> for mod_fcgi).
266
267And a quick VirtualHost configuration:
268
269 <VirtualHost *:80>
270 ServerName gitalist.yourdomain.com
271 DocumentRoot /path/to/gitalist.fcgi
272 <Directory "/path/to/gitalist.fcgi">
57f9f654 273 AllowOverride all
274 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
275 Order allow,deny
276 Allow from all
8004a936 277 </Directory>
321b3fbf 278
279 # Tell Apache this is a FastCGI application
280 <Files gitalist.fcgi>
57f9f654 281 #change the below to fastcgi-script if using mod_fcgi
321b3fbf 282 SetHandler fcgid-script
283 </Files>
8004a936 284 </VirtualHost>
285
286Now to access your Gitalist instance, you'll go to
287C<gitalist.yourdomain.com/gitalist.fcgi/> (B<do not forget that trailing> C</>).
288If you'd like a different URL, of course, you'll likely want to use
289L<mod_rewrite|https://httpd.apache.org/docs/mod/mod_rewrite.html> or equivalent.
290
291If you find the need to do some troubleshooting, you can call
292C<http://url_to_gitalist.fcgi?dump_info=1> and/or add export C<GITALIST_DEBUG=1>
293to the top of your F<gitalist.fcgi> file (just below the shebang line).
294
295Also, note that Apache will refuse C<%2F> in Gitalist URLs
296unless configured otherwise. Make sure C<AllowEncodedSlashes On>
297is in your F<httpd.conf> file in order for this to run smoothly.
67388737 298
69175e49 299=head1 CONTRIBUTING
300
301Patches are welcome, please feel free to fork on github and send pull requests, send patches
302from git format-patch to the bug tracker, or host your own copy of gitalist somewhere and
303ask us to pull from it.
304
305=head1 SUPPORT
306
307Gitalist has an active irc community in C<#gitalist> on irc.perl.org, please feel free to stop
308by and ask questions, report bugs or installation issues or generally for a chat about where
309we plan to go with the project.
310
89de6a33 311=head1 SEE ALSO
312
b6d010e1 313L<Gitalist::Controller::Root>
314
44a9ed75 315L<Gitalist::Git::Repository>
b6d010e1 316
317L<Catalyst>
89de6a33 318
42fe5d11 319=head1 AUTHORS AND COPYRIGHT
89de6a33 320
42fe5d11 321 Catalyst application:
8004a936 322 © 2009 Venda Ltd and Dan Brook <broq@cpan.org>
323 © 2009, Tom Doran <bobtfish@bobtfish.net>
324 © 2009, Zac Stevens <zts@cryptocracy.com>
42fe5d11 325
326 Original gitweb.cgi from which this was derived:
8004a936 327 © 2005-2006, Kay Sievers <kay.sievers@vrfy.org>
328 © 2005, Christian Gierke
89de6a33 329
b6d010e1 330 Model based on http://github.com/rafl/gitweb
8004a936 331 © 2008, Florian Ragwitz
89de6a33 332
b6d010e1 333=head1 LICENSE
42fe5d11 334
b6d010e1 335Licensed under GNU GPL v2