package PublicInbox::Repo;
use strict;
use warnings;
+use PublicInbox::Config;
sub new {
my ($class, $opts) = @_;
bless $opts, $class;
}
+sub description {
+ my ($self) = @_;
+ my $desc = $self->{description};
+ return $desc if defined $desc;
+ $desc = PublicInbox::Config::try_cat("$self->{path}/description");
+ local $/ = "\n";
+ chomp $desc;
+ $desc =~ s/\s+/ /smg;
+ $desc = '($GIT_DIR/description missing)' if $desc eq '';
+ $self->{description} = $desc;
+}
+
+sub desc_html {
+ my ($self) = @_;
+ $self->{desc_html} ||=
+ PublicInbox::Hval->utf8($self->description)->as_html;
+}
+
+sub cloneurl {
+ my ($self) = @_;
+ my $url = $self->{cloneurl};
+ return $url if $url;
+ if ($self->{vcs} eq 'git') {
+ $url = PublicInbox::Config::try_cat("$self->{path}/cloneurl");
+ $url = [ split(/\s+/s, $url) ];
+ local $/ = "\n";
+ chomp @$url;
+ }
+ $self->{cloneurl} = $url;
+}
+
1;
# starts an HTML page for Repobrowse in a consistent way
sub html_start {
my ($self, $req, $title_html, $opts) = @_;
- my $desc = $req->{repo_info}->{desc_html};
+ my $desc = $req->{repo_info}->desc_html;
my $meta = '';
if ($opts) {
# Returns something like:
# {
# path => '/home/git/foo.git',
-# description => 'foo repo',
-# cloneurl => "git://example.com/foo.git\nhttp://example.com/foo.git",
# publicinbox => '/home/pub/foo-public.git',
# }
sub lookup {
$rv->{snapshot_re} = qr/\A\Q$snap\E[-_]/;
$rv->{snapshot_pfx} = $snap;
- # gitweb compatibility
- foreach my $key (qw(description cloneurl)) {
- $rv->{$key} = PublicInbox::Config::try_cat("$path/$key");
- }
-
- $rv->{desc_html} =
- PublicInbox::Hval->new_oneline($rv->{description})->as_html;
-
foreach my $key (qw(publicinbox vcs readme group snapshots)) {
$rv->{$key} = $self->{"repo.$repo_path.$key"};
}
$title = utf8_html("$title, branch $req->{q}->{h}");
my $url = repo_root_url($self, $req);
my $hdr = {};
+ my $subtitle = $repo_info->desc_html;
$req->{axml} = qq(<?xml version="1.0"?>\n) .
qq(<feed\nxmlns="http://www.w3.org/2005/Atom">) .
qq(<title>$title</title>) .
- qq(<subtitle>$repo_info->{desc_html}</subtitle>) .
+ qq(<subtitle>$subtitle</subtitle>) .
qq(<link\nrel="alternate"\ntype="text/html"\nhref="$url"\n/>);
my ($plinks, $id, $ai);
my $end = '';
my $l = $p->as_html;
$p = $p->as_path;
$fh->write(qq(<tr><td><tt><a\nhref="$p">$l</a></tt></td>) .
- "<td><tt> $r->{desc_html}</tt></td></tr>");
+ '<td><tt> '.$r->desc_html.'</tt></td></tr>');
}
foreach my $group (keys %$groups) {
$p = $p->as_path;
$fh->write('<tr><td><tt> ' .
qq(<a\nhref="$p">$l</a></tt></td>) .
- "<td><tt> $r->{desc_html}</tt></td></tr>");
+ '<td><tt> '.$r->desc_html.'</tt></td></tr>');
}
}