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