Commit | Line | Data |
89de6a33 |
1 | package Gitalist; |
42fe5d11 |
2 | use Moose; |
3 | use namespace::autoclean; |
89de6a33 |
4 | |
5 | use Catalyst::Runtime 5.80; |
6 | |
42fe5d11 |
7 | extends 'Catalyst'; |
89de6a33 |
8 | |
43d4a724 |
9 | use Catalyst qw/ |
89de6a33 |
10 | ConfigLoader |
d5cc37a4 |
11 | Static::Simple |
61b56ed6 |
12 | StackTrace/; |
13 | |
89de6a33 |
14 | our $VERSION = '0.01'; |
15 | |
4666d5c7 |
16 | # Bring in the libified gitweb.cgi. |
17 | use gitweb; |
18 | |
d3feefcf |
19 | __PACKAGE__->config( |
61b56ed6 |
20 | name => 'Gitalist', |
21 | default_view => 'Default', |
1aad4e81 |
22 | default_model => 'GitRepos', |
dd3c4caf |
23 | # Set to 1 to make your fcgi die the request after you push :) |
24 | exit_at_end_of_request_if_updated => 0, |
d3feefcf |
25 | ); |
89de6a33 |
26 | |
dd3c4caf |
27 | { |
28 | my $version; |
29 | my $get_version = sub { |
30 | my $gitdir = shift->path_to('.git'); |
31 | my $version = qx{cat "$gitdir/`cut -d' ' -f2 .git/HEAD`"}; |
32 | chomp $version; |
33 | return $version; |
34 | }; |
35 | |
36 | after setup_finalize => sub { |
37 | my $c = shift; |
38 | $version = $c->$get_version |
39 | if $c->config->{exit_at_end_of_request_if_updated}; |
40 | }; |
41 | after handle_request => sub { |
42 | my $c = shift; |
43 | if ($version) { |
44 | my $new = $c->$get_version; |
45 | exit 0 unless $new eq $version; |
46 | } |
47 | }; |
48 | } |
49 | |
50 | |
89de6a33 |
51 | # Start the application |
52 | __PACKAGE__->setup(); |
53 | |
4df2f62f |
54 | around uri_for => sub { |
55 | my ($orig, $c) = (shift, shift); |
68068ba2 |
56 | my $project_name = $c->stash->{'Project'} && $c->stash->{'Project'}->name; |
c1f608c8 |
57 | my $hash = ref($_[-1]) eq 'HASH' ? pop @_ : {}; |
4df2f62f |
58 | my $params = Catalyst::Utils::merge_hashes( |
68068ba2 |
59 | { p => $hash->{p} || $project_name }, |
c1f608c8 |
60 | $hash, |
4df2f62f |
61 | ); |
68068ba2 |
62 | delete $params->{p} unless defined $params->{p} && length $params->{p}; |
4df2f62f |
63 | (my $uri = $c->$orig(@_, $params)) |
64 | =~ tr[&][;]; |
65 | return $uri; |
66 | }; |
61b56ed6 |
67 | |
89de6a33 |
68 | =head1 NAME |
69 | |
b6d010e1 |
70 | Gitalist - Transitional project to convert gitweb.cgi to a Catalyst app |
89de6a33 |
71 | |
72 | =head1 SYNOPSIS |
73 | |
74 | script/gitalist_server.pl |
75 | |
b6d010e1 |
76 | |
77 | =head1 INSTALL |
78 | |
79 | As Gitalist follows the usual Perl module format the usual approach |
80 | for installation should work e.g |
81 | |
82 | perl Makefile.PL |
83 | make |
84 | make test |
85 | make install |
86 | |
87 | If you're running a git checkout of Gitalist then you'll additionally |
88 | need the author modules. I<NB: As no distribution exists one will |
89 | presently need the author modules>. |
90 | |
89de6a33 |
91 | =head1 DESCRIPTION |
92 | |
b6d010e1 |
93 | Gitalist is a web frontend for git repositories based on gitweb.cgi |
94 | and backed by Catalyst. It doesn't yet have the full functionality of |
95 | gitweb.cgi but it does have a few small additions at this stage. |
96 | |
97 | =head2 History |
98 | |
99 | This project started off as an attempt to port gitweb.cgi to a |
100 | Catalyst app in a piecemeal fashion. As it turns out, thanks largely |
101 | to Florian Ragwitz's earlier effort, it was easier to use gitweb.cgi |
102 | as a template for building a new Catalyst application. |
89de6a33 |
103 | |
104 | =head1 SEE ALSO |
105 | |
b6d010e1 |
106 | L<Gitalist::Controller::Root> |
107 | |
108 | L<Gitalist::Git::Project> |
109 | |
110 | L<Catalyst> |
89de6a33 |
111 | |
42fe5d11 |
112 | =head1 AUTHORS AND COPYRIGHT |
89de6a33 |
113 | |
42fe5d11 |
114 | Catalyst application: |
b6d010e1 |
115 | (C) 2009 Venda Ltd and Dan Brook <broq@cpan.org> |
116 | (C) 2009, Tom Doran <bobtfish@bobtfish.net> |
117 | (C) 2009, Zac Stevens <zts@cryptocracy.com> |
42fe5d11 |
118 | |
119 | Original gitweb.cgi from which this was derived: |
120 | (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org> |
121 | (C) 2005, Christian Gierke |
89de6a33 |
122 | |
b6d010e1 |
123 | Model based on http://github.com/rafl/gitweb |
124 | (C) 2008, Florian Ragwitz |
89de6a33 |
125 | |
b6d010e1 |
126 | =head1 LICENSE |
42fe5d11 |
127 | |
b6d010e1 |
128 | Licensed under GNU GPL v2 |
89de6a33 |
129 | |
130 | =cut |
131 | |
132 | 1; |