]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Inbox.pm
Merge remote-tracking branch 'origin/wwwlisting'
[public-inbox.git] / lib / PublicInbox / Inbox.pm
index 6fe896f49efeb64a6a9fe364763aca2cbaa54c54..286555f65cb3b4c8f4a7820b0489e4f6f6005e72 100644 (file)
@@ -95,6 +95,15 @@ sub new {
        if (defined $dir && -f "$dir/inbox.lock") {
                $opts->{version} = 2;
        }
+
+       # allow any combination of multi-line or comma-delimited hide entries
+       my $hide = {};
+       if (defined(my $h = $opts->{hide})) {
+               foreach my $v (@$h) {
+                       $hide->{$_} = 1 foreach (split(/\s*,\s*/, $v));
+               }
+               $opts->{-hide} = $hide;
+       }
        bless $opts, $class;
 }
 
@@ -202,8 +211,8 @@ sub cloneurl {
 
 sub base_url {
        my ($self, $env) = @_;
-       if ($env) { # PSGI env
-               my $scheme = $env->{'psgi.url_scheme'};
+       my $scheme;
+       if ($env && ($scheme = $env->{'psgi.url_scheme'})) { # PSGI env
                my $host_port = $env->{HTTP_HOST} ||
                        "$env->{SERVER_NAME}:$env->{SERVER_PORT}";
                my $url = "$scheme://$host_port". ($env->{SCRIPT_NAME} || '/');
@@ -333,4 +342,16 @@ sub recent {
        search($self)->{over_ro}->recent($opts, $after, $before);
 }
 
+sub modified {
+       my ($self) = @_;
+       if (my $srch = search($self)) {
+               my $msgs = $srch->{over_ro}->recent({limit => 1});
+               if (my $smsg = $msgs->[0]) {
+                       return $smsg->{ts};
+               }
+               return time;
+       }
+       git($self)->modified; # v1
+}
+
 1;