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