From eb5f82b20944d780ac3b2ff9a926c023da9468fd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 16 Aug 2015 08:14:40 +0000 Subject: implement /s/$SUBJECT_PATH.html lookups Quick-and-dirty wiring up of to Subject: paths. This may prove more memorizable and easier-to-share than /t/$MESSAGE_ID.html links, but less strict. This changes our schema version to 1, since we now use lower-case subject paths. --- lib/PublicInbox/Search.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/Search.pm') diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 39b06b0a..f4f00b25 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -12,7 +12,10 @@ use PublicInbox::MID qw/mid_clean mid_compressed/; use constant { TS => 0, - SCHEMA_VERSION => 0, + # SCHEMA_VERSION history + # 0 - initial + # 1 - subject_path is lower-cased + SCHEMA_VERSION => 1, LANG => 'english', QP_FLAGS => FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE|FLAG_WILDCARD, }; @@ -209,6 +212,12 @@ sub query { $self->do_enquire($query, $opts); } +sub get_subject_path { + my ($self, $path, $opts) = @_; + my $query = $self->qp->parse_query("path:$path", 0); + $self->do_enquire($query); +} + # given a message ID, get replies to a message sub get_replies { my ($self, $mid, $opts) = @_; @@ -461,13 +470,13 @@ sub merge_threads { # normalize subjects so they are suitable as pathnames for URLs sub subject_path { - my ($subj) = @_; + my $subj = pop; $subj =~ s/\A\s+//; $subj =~ s/\s+\z//; $subj =~ s/^(?:re|aw):\s*//i; # remove reply prefix (aw: German) $subj =~ s![^a-zA-Z0-9_\.~/\-]+!_!g; - $subj; + lc($subj); } sub do_cat_mail { -- cgit v1.2.3-24-ge0c7