Merge remote branch 'shadowcat/master'
[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
e704a9cd 17our $VERSION = '0.001003';
775e96e0 18$VERSION = eval $VERSION;
89de6a33 19
d3feefcf 20__PACKAGE__->config(
61b56ed6 21 name => 'Gitalist',
22 default_view => 'Default',
7bf1a6f5 23 default_model => 'CollectionOfRepos',
d3feefcf 24);
89de6a33 25
89de6a33 26__PACKAGE__->setup();
27
319537bf 28after prepare_path => sub {
29 my ($ctx) = @_;
30 if ($ctx->req->param('a')) {
31 $ctx->request->uri->path('/legacy' . $ctx->request->uri->path);
32 }
33};
34
4df2f62f 35around uri_for => sub {
36 my ($orig, $c) = (shift, shift);
df49ca46 37 my $uri = $c->$orig(@_);
74d26472 38 $$uri =~ tr[&][;] if defined $uri;
4df2f62f 39 return $uri;
40};
61b56ed6 41
906a2dd2 42around uri_for_action => sub {
43 my ($orig, $c) = (shift, shift);
44 my $uri = $c->$orig(@_);
45 $$uri =~ s[/fragment\b][] if defined $uri;
46 return $uri;
47};
48
49sub uri_with {
50 my ($self, @args) = @_;
51 my $uri = $self->request->uri_with(@args);
52 # Wow this awful.
53 $uri =~ s[/fragment\b][];
54 return $uri;
55}
56
775e96e0 571;
58
59__END__
60
89de6a33 61=head1 NAME
62
775e96e0 63Gitalist - A modern git web viewer
89de6a33 64
65=head1 SYNOPSIS
66
63f34424 67 script/gitalist_server.pl --repo_dir /home/me/code/git
89de6a33 68
b6d010e1 69=head1 INSTALL
70
71As Gitalist follows the usual Perl module format the usual approach
63f34424 72for installation should work e.g.
b6d010e1 73
74 perl Makefile.PL
75 make
76 make test
77 make install
78
63f34424 79or
80
81 cpan -i Gitalist
82
83You can also check gitalist out from git and run it, in this case you'll additionally
84need the author modules, but no configuration will be needed as it will default to looking
85for repositories the directory above the checkout.
b6d010e1 86
89de6a33 87=head1 DESCRIPTION
88
b6d010e1 89Gitalist is a web frontend for git repositories based on gitweb.cgi
775e96e0 90and backed by Catalyst.
b6d010e1 91
92=head2 History
93
94This project started off as an attempt to port gitweb.cgi to a
95Catalyst app in a piecemeal fashion. As it turns out, thanks largely
96to Florian Ragwitz's earlier effort, it was easier to use gitweb.cgi
97as a template for building a new Catalyst application.
89de6a33 98
69175e49 99=head1 GETTING GITALIST
100
101You can install Gitalist from CPAN in the usual way:
102
103 cpan -i Gitalist
104
105Alternatively, you can get Gitalist using git.
106
107The canonical repository for the master branch is:
108
1d46f550 109 git://git.shadowcat.co.uk/catagits/Gitalist.git
69175e49 110
111Gitalist is also mirrored to github, and a number of people have active forks
112with branches and/or new features in the master branch.
113
114=head1 INITIAL CONFIGURATION
115
116Gitalist is configured using L<Catalyst::Plugin::Configloader>. The supplied sample
117configuration is in L<Config::General> format, however it is possible to configure
118Gitalist using other config file formats (such as YAML) if you prefer.
119
120=head2 WHEN CHECKING GITALIST OUT OF GIT
121
122Gitalist from git includes a minimal C<gitalist_local.conf>, which sets the repository
123directory to one directory higher than the Gitalist repository.
124
125This means that if you check Gitalist out next to your other git checkouts, then starting
126the demo server needs no parameters at all:
127
128 Gitalist [master]$ ./script/gitalist_server.pl
129 You can connect to your server at http://localhost:3000
130
131=head2 FOR CPAN INSTALLS
63f34424 132
133Gitalist can be supplied with a config file by setting the C<< GITALIST_CONFIG >>
134environment variable to point to a configuration file.
135
69175e49 136If you install Gitalist from CPAN, a default configuration is installed along with gitalist,
137which is complete except for a repository directory. You can get a copy of this configuration
138by running:
63f34424 139
140 cp `perl -Ilib -MGitalist -e'print Gitalist->path_to("gitalist.conf")'` gitalist.conf
141
3d0e045e 142You can then edit this confg, adding a repo_dir path and customising other settings as desired.
69175e49 143
144You can then start the Gitalist demo server by setting C<< GITALIST_CONFIG >>. For example:
145
146 GITALIST_CONFIG=/usr/local/etc/gitalist.conf gitalist_server.pl
63f34424 147
148Alternatively, if you only want to set a repository directory and are otherwise happy with
1d46f550 149the default configuration, then you can set the C<< GITALIST_REPO_DIR >> environment
3d0e045e 150variable, or pass the C<< --repo_dir >> flag to any of the scripts.
63f34424 151
1d46f550 152 GITALIST_REPO_DIR=/home/myuser/code/git gitalist_server.pl
3d0e045e 153 gitalist_server.pl --repo_dir home/myuser/code/git
69175e49 154
1d46f550 155The C<< GITALIST_REPO_DIR >> environment variable will override the repository directory set
3d0e045e 156in configuration, and will itself be overridden by he C<< --repo_dir >> flag.
63f34424 157
69175e49 158=head1 RUNNING
159
160Once you have followed the instructions above to install and configure Gitalist, you may want
161to run it in a more production facing environment than using the single threaded developement
162server.
163
164The recommended deployment method for Gitalist is FastCGI, although Gitalist can also be run
165under mod_perl or as pure perl with L<Catalyst::Engine::PreFork>.
166
167Assuming that you have installed Gitalist's dependencies into a L<local::lib>, and you
168are running from a git checkout, adding a trivial FCGI script as C<script/gitalist.fcgi>
169(this file is specifically in C<.gitignore> so you can have your own copy):
170
171 #!/bin/sh
172 export PERL5LIB=/home/t0m/public_html/Gitalist/lib:/home/t0m/perl5/lib/perl5:$PERL5LIB
173 exec /home/t0m/public_html/Gitalist/script/gitalist_fastcgi.pl
174
175This example can be seen live here:
176
177 http://goatse.co.uk/~bobtfish/Gitalist/script/gitalist.fcgi/
178
179=head1 CONTRIBUTING
180
181Patches are welcome, please feel free to fork on github and send pull requests, send patches
182from git format-patch to the bug tracker, or host your own copy of gitalist somewhere and
183ask us to pull from it.
184
185=head1 SUPPORT
186
187Gitalist has an active irc community in C<#gitalist> on irc.perl.org, please feel free to stop
188by and ask questions, report bugs or installation issues or generally for a chat about where
189we plan to go with the project.
190
89de6a33 191=head1 SEE ALSO
192
b6d010e1 193L<Gitalist::Controller::Root>
194
44a9ed75 195L<Gitalist::Git::Repository>
b6d010e1 196
197L<Catalyst>
89de6a33 198
42fe5d11 199=head1 AUTHORS AND COPYRIGHT
89de6a33 200
42fe5d11 201 Catalyst application:
b6d010e1 202 (C) 2009 Venda Ltd and Dan Brook <broq@cpan.org>
203 (C) 2009, Tom Doran <bobtfish@bobtfish.net>
204 (C) 2009, Zac Stevens <zts@cryptocracy.com>
42fe5d11 205
206 Original gitweb.cgi from which this was derived:
207 (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>
208 (C) 2005, Christian Gierke
89de6a33 209
b6d010e1 210 Model based on http://github.com/rafl/gitweb
211 (C) 2008, Florian Ragwitz
89de6a33 212
b6d010e1 213=head1 LICENSE
42fe5d11 214
b6d010e1 215Licensed under GNU GPL v2
89de6a33 216
217=cut