# public functions: (unstable)
sub msg_html {
- my ($ctx, $mime, $footer) = @_;
+ my ($ctx, $mime) = @_;
my $hdr = $mime->header_obj;
my $tip = _msg_html_prepare($hdr, $ctx);
PublicInbox::WwwStream->response($ctx, 200, sub {
my ($nr, undef) = @_;
if ($nr == 1) {
- $tip . multipart_text_as_html($mime, '') .
- '</pre><hr />'
+ $tip . multipart_text_as_html($mime, '') . '</pre><hr>'
} elsif ($nr == 2) {
# fake an EOF if generating the footer fails;
# we want to at least show the message if something
# add the footer
$rv .= "\n<a\nhref=#$id_m\nid=e$id>^</a> ".
"<a\nhref=\"$mhref\">permalink</a>" .
- " / <a\nhref=\"${mhref}raw\">raw</a>" .
- " / <a\nhref=\"${mhref}#R\">reply</a>";
+ " <a\nhref=\"${mhref}raw\">raw</a>" .
+ " <a\nhref=\"${mhref}#R\">reply</a>";
if (my $pct = $ctx->{pct}) { # used by SearchView.pm
- $rv .= " [relevance $pct->{$mid_raw}%]";
+ $rv .= "\t[relevance $pct->{$mid_raw}%]";
} elsif ($mapping) {
my $threaded = 'threaded';
my $flat = 'flat';
} else {
$threaded = "<b>$threaded</b>";
}
- $rv .= " / [<a\nhref=\"${mhref}T/#u\">$flat</a>";
+ $rv .= "\t[<a\nhref=\"${mhref}T/#u\">$flat</a>";
$rv .= "|<a\nhref=\"${mhref}t/#u\">$threaded</a>]";
- $rv .= " / <a\nhref=#r$id>$ctx->{s_nr}</a>";
+ $rv .= " <a\nhref=#r$id>$ctx->{s_nr}</a>";
}
$rv .= $more ? "\n\n" : "\n";
my $this = $map->[1];
$this =~ s!\n\z!</b>\n!s;
$this =~ s!<a\nhref.*</a> !!s; # no point in duplicating subject
+ $this =~ s!<a\nhref=[^>]+>([^<]+)</a>!$1!s; # no point linking to self
$rv .= "<b>@ $this";
my $node = $map->[2];
if (my $child = $node->child) {
my $msgs = load_results($sres);
my $nr = $sres->{total};
return missing_thread($ctx) if $nr == 0;
- my $skel = '<hr /><pre>';
+ my $skel = '<hr><pre>';
$skel .= $nr == 1 ? 'only message in thread' : 'end of thread';
$skel .= ", back to <a\nhref=\"../../\">index</a>";
$skel .= "\n<a\nid=t>$nr+ messages in thread:</a> (download: ";
my $irt = in_reply_to($hdr);
if (defined $irt) {
- my $v = PublicInbox::Hval->new_msgid($irt, 1);
+ my $v = PublicInbox::Hval->new_msgid($irt);
my $html = $v->as_html;
my $href = $v->as_href;
$rv .= "In-Reply-To: <";
}
sub linkify_ref_nosrch {
- my $v = PublicInbox::Hval->new_msgid($_[0], 1);
+ my $v = PublicInbox::Hval->new_msgid($_[0]);
my $html = $v->as_html;
my $href = $v->as_href;
"<<a\nhref=\"../$href/\">$html</a>>";
}
}
-sub emit_topics {
+sub topics {
my ($ctx) = @_;
my $order = $ctx->{order};
my $subjs = $ctx->{subjs};
my $latest = $ctx->{latest};
- my $fh = $ctx->{fh};
- return $fh->write("\n[No topics in range]</pre>") unless scalar @$order;
+ if (!@$order) {
+ $ctx->{-html_tip} = '<pre>[No topics in range]</pre>';
+ return 404;
+ }
my $pfx;
my $prev = 0;
my $prev_attr = '';
my ($level, $subj) = @$info;
my $n = delete $subjs->{$subj};
my ($mid, $ts) = @{delete $latest->{$subj}};
- $mid = PublicInbox::Hval->new_msgid($mid)->as_href;
+ my $href = PublicInbox::Hval->new_msgid($mid)->as_href;
$pfx = indent_for($level);
my $nl = $level == $prev ? "\n" : '';
if ($nl && $cur) {
}
$subj = PublicInbox::Hval->new($subj)->as_html;
- $cur->[1] .= "<a\nhref=\"$mid/T/#u\"><b>$subj</b></a>\n";
+ $cur->[1] .= "<a\nhref=\"$href/T/#u\"><b>$subj</b></a>\n";
$ts = fmt_ts($ts);
my $attr = " $ts UTC";
$n = $n == 1 ? '' : " ($n+ messages)";
if ($level == 0 || $attr ne $prev_attr) {
- my $mbox = qq(<a\nhref="$mid/t.mbox.gz">mbox.gz</a>);
- my $atom = qq(<a\nhref="$mid/t.atom">Atom</a>);
+ my $mbox = qq(<a\nhref="$href/t.mbox.gz">mbox.gz</a>);
+ my $atom = qq(<a\nhref="$href/t.atom">Atom</a>);
$pfx .= INDENT if $level > 0;
$cur->[1] .= $pfx . $attr . $n . " - $mbox / $atom\n";
$prev_attr = $attr;
}
push @recent, $cur if $cur;
@recent = map { $_->[1] } sort { $b->[0] <=> $a->[0] } @recent;
- $fh->write(join('', @recent) . '</pre>');
+ $ctx->{-html_tip} = join('', '<pre>', @recent, '</pre>');
+ 200;
}
-sub emit_index_topics {
+sub index_nav { # callback for WwwStream
+ my (undef, $ctx) = @_;
+ delete $ctx->{qp} or return;
+ my ($next, $prev);
+ $next = $prev = ' ';
+ my $latest = '';
+
+ my $next_o = $ctx->{-next_o};
+ if ($next_o) {
+ $next = qq!<a\nhref="?o=$next_o"\nrel=next>next</a>!;
+ }
+ if (my $cur_o = $ctx->{-cur_o}) {
+ $latest = qq! <a\nhref=.>latest</a>!;
+
+ my $o = $cur_o - ($next_o - $cur_o);
+ if ($o > 0) {
+ $prev = qq!<a\nhref="?o=$o"\nrel=prev>prev</a>!;
+ } elsif ($o == 0) {
+ $prev = qq!<a\nhref=.\nrel=prev>prev</a>!;
+ }
+ }
+ "<hr><pre>page: $next $prev$latest</pre>";
+}
+
+sub index_topics {
my ($ctx) = @_;
- my ($off) = (($ctx->{cgi}->param('o') || '0') =~ /(\d+)/);
- $ctx->{order} = [];
+ my ($off) = (($ctx->{qp}->{o} || '0') =~ /(\d+)/);
+ my $order = $ctx->{order} = [];
$ctx->{subjs} = {};
$ctx->{latest} = {};
my $max = 25;
walk_thread(thread_results($sres), $ctx, *add_topic);
$opts{offset} += $nr;
}
-
- emit_topics($ctx);
- $opts{offset};
+ $ctx->{-next_o} = $opts{offset};
+ $ctx->{-cur_o} = $off;
+ PublicInbox::WwwStream->response($ctx, topics($ctx), *index_nav);
}
sub thread_adj_level {