use PublicInbox::Reply;
use PublicInbox::ViewDiff qw(flush_diff);
use PublicInbox::Eml;
+use POSIX qw(strftime);
use Time::Local qw(timegm);
use PublicInbox::Smsg qw(subject_normalized);
use PublicInbox::ContentHash qw(content_hash);
}
delete $ctx->{obuf};
eval { $$obuf .= html_footer($ctx, $eml) };
- html_oneshot($ctx, 200, $obuf);
+ html_oneshot($ctx, 200, $$obuf);
}
# public functions: (unstable)
$related = <<EOM;
<form id=related
action=$upfx
-><pre>find likely ancestor, descendant, or conflicting patches:
+><pre>find likely ancestor, descendant, or conflicting patches for <a
+href=#t>this message</a>:
<textarea name=q cols=${\COLS} rows=$rows>$q</textarea>
<input type=submit value=search
/>\t(<a href=${upfx}_/text/help/>help</a>)</pre></form>
}
my @out;
- my $ibx = $ctx->{ibx};
- my $obfs_ibx = $ibx->{obfuscate} ? $ibx : undef;
-
+ my $obfs_ibx = $ctx->{ibx}->{obfuscate} ? $ctx->{ibx} : undef;
+ if (my $note = delete $ctx->{t_note}) {
+ push @out, $note; # "messages from ... to ..."
+ }
# sort by recency, this allows new posts to "bump" old topics...
foreach my $topic (sort { $b->[0] <=> $a->[0] } @$order) {
my ($ds, $n, $seen, $top_subj, @extra) = @$topic;
my $s = "<a\nhref=\"$href/T/$anchor\">$top_subj</a>\n" .
" $ds UTC $n\n";
- for (my $i = 0; $i < scalar(@extra); $i += 2) {
- my $level = $extra[$i];
- my $subj = $extra[$i + 1]; # already normalized
+ while (@extra) {
+ my $level = shift @extra;
+ my $subj = shift @extra; # already normalized
$mid = delete $seen->{$subj};
my @subj = split(/ /, $subj);
my @next_prev = @subj; # full copy
$next = $next ? "$next | " : ' | ';
$prev .= qq[ | <a\nhref="$latest">latest</a>];
}
- ($next || $prev) ? \"<hr><pre>page: $next$prev</pre>" : \'';
+ ($next || $prev) ? "<hr><pre id=nav>page: $next$prev</pre>" : '';
}
sub paginate_recent ($$) {
$t =~ s/\A([0-9]{8,14})-// and $after = str2ts($1);
$t =~ /\A([0-9]{8,14})\z/ and $before = str2ts($1);
- my $ibx = $ctx->{ibx};
- my $msgs = $ibx->recent($opts, $after, $before);
- my $nr = scalar @$msgs;
- if ($nr < $lim && defined($after)) {
+ my $msgs = $ctx->{ibx}->over->recent($opts, $after, $before);
+ if (defined($after) && scalar(@$msgs) < $lim) {
$after = $before = undef;
- $msgs = $ibx->recent($opts);
- $nr = scalar @$msgs;
+ $msgs = $ctx->{ibx}->over->recent($opts);
}
- my $more = $nr == $lim;
+ my $more = scalar(@$msgs) == $lim;
my ($newest, $oldest);
- if ($nr) {
+ if (@$msgs) {
$newest = $msgs->[0]->{ts};
$oldest = $msgs->[-1]->{ts};
# if we only had $after, our SQL query in ->recent ordered
if ($newest < $oldest) {
($oldest, $newest) = ($newest, $oldest);
- $more = 0 if defined($after) && $after < $oldest;
+ $more = undef if defined($after) && $after < $oldest;
+ }
+ if (defined($after // $before)) {
+ my $n = strftime('%Y-%m-%d %H:%M:%S', gmtime($newest));
+ my $o = strftime('%Y-%m-%d %H:%M:%S', gmtime($oldest));
+ $ctx->{t_note} = <<EOM;
+ messages from $o to $n UTC, [<a href="#nav">more...</a>]
+EOM
+ my $s = ts2str($newest);
+ $ctx->{prev_page} = qq[<a\nhref="?t=$s-"\nrel=prev>] .
+ 'prev (newer)</a>';
}
}
if (defined($oldest) && $more) {
$ctx->{next_page} = qq[<a\nhref="?t=$s"\nrel=next>] .
'next (older)</a>';
}
- if (defined($newest) && (defined($before) || defined($after))) {
- my $s = ts2str($newest);
- $ctx->{prev_page} = qq[<a\nhref="?t=$s-"\nrel=prev>] .
- 'prev (newer)</a>';
- }
$msgs;
}