From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/9] favor /t/ to /s/, since subjects may change mid-thread
Date: Mon, 17 Aug 2015 03:38:10 +0000 [thread overview]
Message-ID: <1439782697-16412-3-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1439782697-16412-1-git-send-email-e@80x24.org>
/t/ always falls back to subject path searching anyways,
so there's little lost besides perhaps more readable URLs.
Unfortunately people still use non-compliant mail clients which fail
to set In-Reply-To or References headers :<
---
lib/PublicInbox/Feed.pm | 2 +-
lib/PublicInbox/View.pm | 53 +++++++++++++++++++++++++++----------------------
lib/PublicInbox/WWW.pm | 2 ++
3 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 1a89fba..5a41bea 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -76,7 +76,7 @@ sub generate_html_index {
$th->order(*PublicInbox::Thread::sort_ts);
# except we sort top-level messages reverse chronologically
- my $state = [ undef, {}, $first, 0 ];
+ my $state = [ $args->{srch}, {}, $first, 0 ];
for (PublicInbox::Thread::rsort_ts($th->rootset)) {
dump_msg($_, 0, \$html, $state)
}
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 4708243..4960935 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -48,7 +48,7 @@ sub feed_entry {
# state = [ time, seen = {}, first_commit, page_nr = 0 ]
sub index_entry {
my (undef, $mime, $level, $state) = @_;
- my (undef, $seen, $first_commit) = @$state;
+ my ($srch, $seen, $first_commit) = @$state;
my $midx = $state->[3]++;
my ($prev, $next) = ($midx - 1, $midx + 1);
my $rv = '';
@@ -75,10 +75,26 @@ sub index_entry {
my $more = 'permalink';
if ($root_anchor) {
$path = '../';
- $subj = "<u\nid=\"u\">$subj</u>" if $root_anchor eq $id;
} else {
$path = '';
}
+ my $href = $mid->as_href;
+ my $irt = $header_obj->header_raw('In-Reply-To');
+ my ($anchor_idx, $anchor, $t_anchor);
+ if (defined $irt) {
+ $anchor_idx = anchor_for($irt);
+ $anchor = $seen->{$anchor_idx};
+ $t_anchor = T_ANCHOR;
+ } else {
+ $t_anchor = '';
+ }
+
+ if (defined $srch) {
+ $subj = "<a\nhref=\"${path}t/$href.html#u\">$subj</a>";
+ }
+ if ($root_anchor && $root_anchor eq $id) {
+ $subj = "<u\nid=\"u\">$subj</u>";
+ }
my $ts = $mime->header('X-PI-TS');
my $fmt = '%Y-%m-%d %H:%M UTC';
@@ -92,16 +108,6 @@ sub index_entry {
}
$rv .= "\n\n";
- my $irt = $header_obj->header_raw('In-Reply-To');
- my ($anchor_idx, $anchor, $t_anchor);
- if (defined $irt) {
- $anchor_idx = anchor_for($irt);
- $anchor = $seen->{$anchor_idx};
- $t_anchor = T_ANCHOR;
- } else {
- $t_anchor = '';
- }
- my $href = $mid->as_href;
my $mhref = "${path}m/$href.html";
my $fhref = "${path}f/$href.html";
# scan through all parts, looking for displayable text
@@ -126,8 +132,8 @@ sub index_entry {
$rv .= " <a\nhref=\"$anchor\">parent</a>";
}
- if ($first_commit) {
- $rv .= " <a\nhref=\"t/$href.html$t_anchor\">thread</a>";
+ if ($srch) {
+ $rv .= " <a\nhref=\"${path}t/$href.html$t_anchor\">thread</a>";
}
$rv . "\n\n";
@@ -145,7 +151,7 @@ sub thread_html {
my $th = PublicInbox::Thread->new(@$msgs);
$th->thread;
$th->order(*PublicInbox::Thread::sort_ts);
- my $state = [ undef, { root_anchor => anchor_for($mid) }, undef, 0 ];
+ my $state = [ $srch, { root_anchor => anchor_for($mid) }, undef, 0 ];
thread_entry(\$rv, $state, $_, 0) for $th->rootset;
my $final_anchor = $state->[3];
my $next = "<a\nid=\"s$final_anchor\">end of thread</a>\n";
@@ -165,7 +171,7 @@ sub subject_path_html {
my $th = PublicInbox::Thread->new(@$msgs);
$th->thread;
$th->order(*PublicInbox::Thread::sort_ts);
- my $state = [ undef, { root_anchor => 'dummy' }, undef, 0 ];
+ my $state = [ $srch, { root_anchor => 'dummy' }, undef, 0 ];
thread_entry(\$rv, $state, $_, 0) for $th->rootset;
my $final_anchor = $state->[3];
my $next = "<a\nid=\"s$final_anchor\">end of thread</a>\n";
@@ -340,6 +346,10 @@ sub headers_to_html_header {
my $rv = "";
my @title;
+ my $header_obj = $mime->header_obj;
+ my $mid = $header_obj->header_raw('Message-ID');
+ $mid = PublicInbox::Hval->new_msgid($mid);
+ my $mid_href = $mid->as_href;
foreach my $h (qw(From To Cc Subject Date)) {
my $v = $mime->header($h);
defined($v) && length($v) or next;
@@ -351,8 +361,7 @@ sub headers_to_html_header {
} elsif ($h eq 'Subject') {
$title[0] = $v->as_html;
if ($srch) {
- my $path = $srch->subject_path($v->raw);
- $rv .= "$h: <a\nhref=\"../s/$path.html\">";
+ $rv .= "$h: <a\nhref=\"../t/$mid_href.html\">";
$rv .= $v->as_html . "</a>\n";
next;
}
@@ -361,13 +370,9 @@ sub headers_to_html_header {
}
- my $header_obj = $mime->header_obj;
- my $mid = $header_obj->header_raw('Message-ID');
- $mid = PublicInbox::Hval->new_msgid($mid);
$rv .= 'Message-ID: <' . $mid->as_html . '> ';
- my $href = $mid->as_href;
- $href = "../m/$href" unless $full_pfx;
- $rv .= "(<a\nhref=\"$href.txt\">raw</a>)\n";
+ $mid_href = "../m/$mid_href" unless $full_pfx;
+ $rv .= "(<a\nhref=\"$mid_href.txt\">raw</a>)\n";
my $irt = $header_obj->header_raw('In-Reply-To');
if (defined $irt) {
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index bbd438a..5021509 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -126,8 +126,10 @@ sub get_atom {
sub get_index {
my ($ctx, $cgi, $top) = @_;
require PublicInbox::Feed;
+ my $srch = searcher($ctx);
[ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ],
[ PublicInbox::Feed->generate_html_index({
+ srch => $srch,
git_dir => $ctx->{git_dir},
listname => $ctx->{listname},
pi_config => $pi_config,
--
EW
next prev parent reply other threads:[~2015-08-17 3:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-17 3:38 [PATCH 0/9] search pushed and deployed to master Eric Wong
2015-08-17 3:38 ` [PATCH 1/9] feed: remove unnecesary time paramenter in index state Eric Wong
2015-08-17 3:38 ` Eric Wong [this message]
2015-08-17 3:38 ` [PATCH 3/9] WWW: eliminate "top" parameter for feeds Eric Wong
2015-08-17 3:38 ` [PATCH 4/9] www: simplify parameter passing to feed Eric Wong
2015-08-17 3:38 ` [PATCH 5/9] terminology: replies => followups Eric Wong
2015-08-17 3:38 ` [PATCH 6/9] search: use raw headers without MIME decoding Eric Wong
2015-08-17 3:38 ` [PATCH 7/9] feed: disable the generator statement Eric Wong
2015-08-17 3:38 ` [PATCH 8/9] drop bodies and messages ASAP after processing Eric Wong
2015-08-17 3:38 ` [PATCH 9/9] search: apply mid_compression to subject paths, too Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439782697-16412-3-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).