- $feed->add_entry(
- author => { name => $name, email => $email },
- title => $subject,
- updated => $date,
- content => { type => 'xhtml', content => $content },
- link => $midurl . $href,
- id => 'urn:uuid:' . join('-', @uuid5),
- );
- 1;
-}
-
-sub dump_html_line {
- my ($self, $level, $args) = @_; # args => [ $html, $midurl ]
- if ($self->message) {
- $args->[0] .= (' ' x $level);
- my $mime = $self->message;
- my $subj = $mime->header('Subject');
- my $mid = $mime->header_obj->header_raw('Message-ID');
- $mid = PublicInbox::Hval->new_msgid($mid);
- my $url = $args->[1] . $mid->as_href;
- my $from = mime_header($mime, 'From');
-
- my @from = Email::Address->parse($from);
- $from = $from[0]->name;
- (defined($from) && length($from)) or $from = $from[0]->address;
-
- $from = PublicInbox::Hval->new_oneline($from)->as_html;
- $subj = PublicInbox::Hval->new_oneline($subj)->as_html;
- $args->[0] .= "<a href=\"$url.html\">$subj</a> $from\n";
- }
- dump_html_line($self->child, $level+1, $args) if $self->child;
- dump_html_line($self->next, $level, $args) if $self->next;
-}
-
-sub try_git_pm {
- my ($dir) = @_;
- eval { Git->repository(Directory => $dir) };
-};
-
-sub do_cat_mail {
- my ($git, $path) = @_;
- my $str;
- if ($git) {
- open my $fh, '>', \$str or
- die "failed to setup string handle: $!\n";
- binmode $fh;
- my $err = '';
- my $bytes;
- {
- local $SIG{__WARN__} = sub { $err .= $_[0] };
- $bytes = $git->cat_blob("HEAD:$path", $fh);
- }
- close $fh or die "failed to close string handle: $!\n";
-
- if ($bytes < 0 && $err &&
- $err !~ /doesn't exist in the repository/) {
- warn $err;
- }
- return if $bytes <= 0;
- } else {
- $str = `git cat-file blob HEAD:$path`;
- return if $? != 0 || length($str) == 0;
- }
- Email::MIME->new($str);