Updated README text in Gitalist.pm for README generation...
[catagits/Gitalist.git] / lib / Gitalist.pm
1 package Gitalist;
2 use Moose;
3 BEGIN { require 5.008006; }
4 use Catalyst::Runtime 5.80;
5 use namespace::autoclean;
6
7 extends 'Catalyst';
8
9 use Catalyst qw/
10                 ConfigLoader
11                 Unicode::Encoding
12                 Static::Simple
13                 StackTrace
14                 SubRequest
15 /;
16
17 our $VERSION = '0.002005';
18 $VERSION = eval $VERSION;
19
20 __PACKAGE__->config(
21     name => 'Gitalist',
22     default_view => 'Default',
23     default_model => 'CollectionOfRepos',
24     use_request_uri_for_path => 1,
25     disable_component_resolution_regex_fallback => 1,
26 );
27
28 __PACKAGE__->setup();
29
30 after 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
37 around uri_for => sub {
38   my ($orig, $c) = (shift, shift);
39   my $uri = $c->$orig(@_);
40   $$uri =~ tr[&][;] if defined $uri;
41   return $uri;
42 };
43
44 around 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
51 sub 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
59 1;
60
61 __END__
62
63 =head1 NAME
64
65 Gitalist - A modern git web viewer
66
67 =head1 SYNOPSIS
68
69     script/gitalist_server.pl --repo_dir /home/me/code/git
70
71 =head1 INSTALL
72
73 As Gitalist follows the usual Perl module format the usual approach
74 for installation should work e.g.
75
76   perl Makefile.PL
77   make
78   make test
79   make install
80
81 or
82
83   cpan -i Gitalist
84
85 You can also check gitalist out from git and run it, in this case you'll additionally
86 need the author modules, but no configuration will be needed as it will default to looking
87 for repositories the directory above the checkout.
88
89 =head1 DESCRIPTION
90
91 Gitalist is a web frontend for git repositories based on gitweb.cgi
92 and backed by Catalyst.
93
94 =head2 History
95
96 This project started off as an attempt to port gitweb.cgi to a
97 Catalyst app in a piecemeal fashion. As it turns out, thanks largely
98 to Florian Ragwitz's earlier effort, it was easier to use gitweb.cgi
99 as a template for building a new Catalyst application.
100
101 =head1 GETTING GITALIST
102
103 You can install Gitalist from CPAN in the usual way:
104
105     cpan -i Gitalist
106
107 Alternatively, you can get Gitalist using git.
108
109 The canonical repository for the master branch is:
110
111     git://git.shadowcat.co.uk/catagits/Gitalist.git
112
113 Gitalist is also mirrored to github, and a number of people have active forks
114 with branches and/or new features in the master branch.
115
116 =head1 BOOTSTRAPPING
117
118 As of C<0.002001> Gitalist can now be bootstrapped to run out of its
119 own directory by installing its prerequisites locally with the help of
120 L<local::lib>. So instead of installing the prerequisites to the
121 system path with CPAN they are installed under the Gitalist directory.
122
123 To do this clone Gitalist from the Shadowcat repository mentioned
124 above or grab a snapshot from broquaint's github repository:
125
126     http://github.com/broquaint/Gitalist/downloads
127
128 With the source acquired and unpacked run the following from within the
129 Gitalist directory:
130
131     perl script/bootstrap.pl
132
133 This will install the necessary modules for the build process which in
134 turn installs the prerequisites locally.
135
136 I<NB> The relevant bootstrap scripts aren't available in the CPAN dist
137 as the bootstrap scripts should not be installed.
138
139 =head1 INITIAL CONFIGURATION
140
141 Gitalist is configured using L<Catalyst::Plugin::Configloader>. The supplied sample
142 configuration is in L<Config::General> format, however it is possible to configure
143 Gitalist using other config file formats (such as YAML) if you prefer.
144
145 =head2 WHEN CHECKING GITALIST OUT OF GIT
146
147 Gitalist from git includes a minimal C<gitalist_local.conf>, which sets the repository
148 directory to one directory higher than the Gitalist repository.
149
150 This means that if you check Gitalist out next to your other git checkouts, then starting
151 the demo server needs no parameters at all:
152
153     Gitalist [master]$ ./script/gitalist_server.pl
154     You can connect to your server at http://localhost:3000
155
156 =head2 FOR CPAN INSTALLS
157
158 Gitalist can be supplied with a config file by setting the C<< GITALIST_CONFIG >>
159 environment variable to point to a configuration file.
160
161 If you install Gitalist from CPAN, a default configuration is installed along with gitalist,
162 which is complete except for a repository directory. You can get a copy of this configuration
163 by running:
164
165   cp `perl -Ilib -MGitalist -e'print Gitalist->path_to("gitalist.conf")'` gitalist.conf
166
167 You can then edit this confg, adding a repo_dir path and customising other settings as desired.
168
169 You can then start the Gitalist demo server by setting C<< GITALIST_CONFIG >>. For example:
170
171     GITALIST_CONFIG=/usr/local/etc/gitalist.conf gitalist_server.pl
172
173 Alternatively, if you only want to set a repository directory and are otherwise happy with
174 the default configuration, then you can set the C<< GITALIST_REPO_DIR >> environment
175 variable, or pass the C<< --repo_dir >> flag to any of the scripts.
176
177     GITALIST_REPO_DIR=/home/myuser/code/git gitalist_server.pl
178     gitalist_server.pl --repo_dir home/myuser/code/git
179
180 The C<< GITALIST_REPO_DIR >> environment variable will override the repository directory set
181 in configuration, and will itself be overridden by he C<< --repo_dir >> flag.
182
183 =head1 RUNNING
184
185 Once you have followed the instructions above to install and configure Gitalist, you may want
186 to run it in a more production facing environment than using the single threaded developement
187 server.
188
189 The recommended deployment method for Gitalist is FastCGI, although Gitalist can also be run
190 under mod_perl or as pure perl with L<Catalyst::Engine::PreFork>.
191
192 Assuming that you have installed Gitalist's dependencies into a L<local::lib>, and you
193 are running from a git checkout, adding a trivial FCGI script as C<script/gitalist.fcgi>
194 (this file is specifically in C<.gitignore> so you can have your own copy):
195
196     #!/bin/sh
197     exec /home/t0m/public_html/Gitalist/script/gitalist_fastcgi.pl
198
199 This example can be seen live here:
200
201     http://example.gitalist.com
202     
203 =head2 FASTCGI
204                         Running Gitalist in FastCGI mode requires a webserver with FastCGI 
205                         support (such as apache with mod_fcgi or fcgid). Below is a sample configuration using Apache2 with fcgid in a
206                         dynamic configuration (as opposed to static or standalone mode). More information on these modes and 
207                         their configuration can be found at 
208                         http://search.cpan.org/~bobtfish/Catalyst-Runtime-5.80025/lib/Catalyst/Engine/FastCGI.pm#Standalone_server_mode
209                         
210                         In Apache's mime.conf, add AddHandler fcgid-script .fcgi (or AddHandler fastcgi-script .fcgi for mod_fcgi)
211                         
212                         And a quick VirtualHost configuration:
213                         
214                         <VirtualHost *:80>
215         ServerName gitalist.yourdomain.com
216         DocumentRoot /path/to/gitalist.fcgi
217         <Directory "/path/to/gitalist.fcgi">
218                 AllowOverride all
219                 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
220                 Order allow,deny
221                 Allow from all
222         </Directory>
223
224         # Tell Apache this is a FastCGI application
225         <Files gitalist.fcgi>
226                         #change the below to fastcgi-script if using mod_fcgi
227             SetHandler fcgid-script
228         </Files>
229                         </VirtualHost>
230                         
231                         Now to access your gitalist instance, you'll go to gitalist.yourdomain.com/gitalist.fcgi/ 
232                         (DO NOT FORGET THAT TRAILING /). If you'd like a different URL, of course, you'll likely want to use 
233                         mod_rewrite or equivalent
234                         
235                         If you find the need to do some troubleshooting, you can call http://url_to_gitalist.fcgi?dump_info=1
236                         and/or add export GITALIST_DEBUG=1 to the top of you gitalist.fcgi file (just below the shebang line).
237                 
238
239 =head1 CONTRIBUTING
240
241 Patches are welcome, please feel free to fork on github and send pull requests, send patches
242 from git format-patch to the bug tracker, or host your own copy of gitalist somewhere and
243 ask us to pull from it.
244
245 =head1 SUPPORT
246
247 Gitalist has an active irc community in C<#gitalist> on irc.perl.org, please feel free to stop
248 by and ask questions, report bugs or installation issues or generally for a chat about where
249 we plan to go with the project.
250
251 =head1 SEE ALSO
252
253 L<Gitalist::Controller::Root>
254
255 L<Gitalist::Git::Repository>
256
257 L<Catalyst>
258
259 =head1 AUTHORS AND COPYRIGHT
260
261   Catalyst application:
262     (C) 2009 Venda Ltd and Dan Brook <broq@cpan.org>
263     (C) 2009, Tom Doran <bobtfish@bobtfish.net>
264     (C) 2009, Zac Stevens <zts@cryptocracy.com>
265
266   Original gitweb.cgi from which this was derived:
267     (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>
268     (C) 2005, Christian Gierke
269
270   Model based on http://github.com/rafl/gitweb
271     (C) 2008, Florian Ragwitz
272
273 =head1 LICENSE
274
275 Licensed under GNU GPL v2
276
277 =cut