use Catalyst qw/-Debug
ConfigLoader
- Static::Simple/;
+ Static::Simple
+ StackTrace/;
our $VERSION = '0.01';
# Bring in the libified gitweb.cgi.
};
$capture->stop();
- gitweb::git_header_html();
- gitweb::git_footer_html();
my $output = join '', $capture->read;
$c->stash->{content} = $output
unless $c->stash->{content};
}
sub index :Path :Args(0) {
- my ( $self, $c ) = @_;
-
- my $order = $c->req->param('order');
- if($order && $order !~ m/none|project|descr|owner|age/) {
- die "Unknown order parameter";
- }
+ my ( $self, $c ) = @_;
- my @list = $c->model('Git')->list_projects;
- if (!@list) {
+ my $list = $c->model('Git')->list_projects;
+ unless(@$list) {
die "No projects found";
}
- if (-f $c->config->{home_text}) {
- $c->stash->{home_text_contents} = slurp($c->config->{home_text});
- }
-
- $c->config->{ENV} = \%ENV;
- $c->stash->{searchtext} = $c->req->param('searchtext');
- $c->stash->{projects} = \@list;
- $c->stash->{action} = 'index';
+ $c->stash(
+ searchtext => $c->req->param('searchtext') || '',
+ projects => $list,
+ action => 'index',
+ );
}
sub auto : Private {
my @feeds;
my $project = $c->req->param('project') || $c->req->param('p');
if(defined $project) {
- # ... this could be simpler ... # Chop off .git
- my $descr = $c->model('Git')->project_info(substr($project, 0, -5))->{description};
+ (my $pstr = $project) =~ s[/?\.git$][];
+ my $descr = $c->model('Git')->project_info($project)->{description};
$c->stash->{project_description} = defined $descr
? encode_entities($descr)
: '';
sub is_git_repo {
my ($self, $dir) = @_;
- #FIXME: Only handles bare repos. Is that enough?
- return -f $dir->file('HEAD') or -f $dir->file('.git/HEAD');
+ return -f $dir->file('HEAD') || -f $dir->file('.git/HEAD');
}
sub project_info {
delete $props{description};
}
- #Carp::cluck "dir is: $dir";
$props{owner} = (getpwuid $dir->stat->uid)[6];
my $output = $self->run_cmd_in($dir, qw{
my $obj = $base->subdir($file);
next unless -d $obj;
next unless $self->is_git_repo($obj);
+ # XXX Leaky abstraction alert!
+ $obj = $obj->subdir('.git')
+ if -d $obj->subdir('.git');
push @ret, {
- name => ($obj->dir_list)[-1],
+ name => (File::Spec->splitdir($base->subdir($file)))[-1],
$self->get_project_properties($obj),
};
}
sub git_dir_from_project_name {
my ($self, $project) = @_;
- warn 'er, dir - '.dir(Gitalist->config->{repo_dir});
- warn 'er, subdir - '.dir(Gitalist->config->{repo_dir})->subdir($project);
return dir(Gitalist->config->{repo_dir})->subdir($project);
}
--- /dev/null
+[% IF home_text_contents %]
+<div class="index_include">
+ [% home_text_contents %]
+</div>
+[% END %]
+
+<form method="get" action="/" enctype="application/x-www-form-urlencoded">
+<p class="projsearch">Search:
+<input type="text" name="s" value="[% search_text %]" />
+</p>
+</form>
+
+<table class="project_list">
+<thead>
+ <tr>
+ <th>Project</th>
+ <th><a class="header" href="/projects?o=descr">Description</a></th>
+ <th><a class="header" href="/projects?o=owner">Owner</a></th>
+ <th><a class="header" href="/projects?o=age">Last Change</a></th>
+ <th></th>
+ </tr>
+</thead>
+
+<tbody>
+ [%
+ USE Cycle('dark', 'light');
+ FOR p IN projects %]
+ <tr class="[% Cycle.next %]">
+ <td><a class="list" href="/?p=[% p.name %];a=summary">[% p.name %]</a></td>
+ <td><a class="list" title="[% p.description %]" href="/?p=[% p.name %];a=summary">[% p.description.substr(0, 20) %]</a></td>
+ <td>[% p.owner %]</td>
+ <td class="age2">[% p.last_change %]</td>
+ <td class="link"><a href="/?p=[% p.name %];a=summary">summary</a>
+ | <a href="/?p=[% p.name %];a=shortlog">shortlog</a>
+ | <a href="/?p=[% p.name %];a=log">log</a>
+ | <a href="/?p=[% p.name %];a=tree">tree</a></td>
+ </tr>
+ [% END %]
+</tbody>
+
+</table>