]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Search.pm
implement /s/$SUBJECT_PATH.html lookups
[public-inbox.git] / lib / PublicInbox / Search.pm
index 39b06b0afe6045fcd220eee77133a12144f4d476..f4f00b252ced067b4a7df8c5617638fa47b6855d 100644 (file)
@@ -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 {