about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Cgit.pm16
-rw-r--r--lib/PublicInbox/ExtMsg.pm4
-rw-r--r--lib/PublicInbox/View.pm3
-rw-r--r--lib/PublicInbox/ViewDiff.pm2
-rw-r--r--lib/PublicInbox/WwwHighlight.pm11
-rw-r--r--lib/PublicInbox/WwwStream.pm5
6 files changed, 28 insertions, 13 deletions
diff --git a/lib/PublicInbox/Cgit.pm b/lib/PublicInbox/Cgit.pm
index 8922ec56..353f4162 100644
--- a/lib/PublicInbox/Cgit.pm
+++ b/lib/PublicInbox/Cgit.pm
@@ -35,7 +35,15 @@ sub locate_cgit ($) {
                 }
         }
         unless (defined $cgit_data) {
-                foreach my $d (qw(/var/www/htdocs/cgit /usr/share/cgit)) {
+                my @dirs = qw(/var/www/htdocs/cgit /usr/share/cgit);
+
+                # local installs of cgit from source have
+                # CGIT_SCRIPT_PATH==CGIT_DATA_PATH by default,
+                # so we can usually infer the cgit_data path from cgit_bin
+                if (defined($cgit_bin) && $cgit_bin =~ m!\A(.+?)/[^/]+\z!) {
+                        unshift @dirs, $1 if -d $1;
+                }
+                foreach my $d (@dirs) {
                         my $f = "$d/cgit.css";
                         next unless -f $f;
                         $cgit_data = $d;
@@ -90,6 +98,7 @@ my @PASS_ENV = qw(
 sub call {
         my ($self, $env) = @_;
         my $path_info = $env->{PATH_INFO};
+        my $cgit_data;
 
         # handle requests without spawning cgit iff possible:
         if ($path_info =~ m!\A/(.+?)/($PublicInbox::GitHTTPBackend::ANY)\z!ox) {
@@ -97,10 +106,11 @@ sub call {
                 if (my $git = $self->{"\0$nick"}) {
                         return serve($env, $git, $path);
                 }
-        } elsif ($path_info =~ m!$self->{static}!) {
+        } elsif ($path_info =~ m!$self->{static}! &&
+                 defined($cgit_data = $self->{cgit_data})) {
                 my $f = $1;
                 my $type = Plack::MIME->mime_type($f);
-                return static_result($env, [], "$self->{cgit_data}$f", $type);
+                return static_result($env, [], $cgit_data.$f, $type);
         }
 
         my $cgi_env = { PATH_INFO => $path_info };
diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index 14d49cc5..d07d5a79 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -8,13 +8,13 @@
 package PublicInbox::ExtMsg;
 use strict;
 use warnings;
-use PublicInbox::Hval;
+use PublicInbox::Hval qw/ascii_html/;
 use PublicInbox::MID qw/mid2path/;
 use PublicInbox::WwwStream;
 our $MIN_PARTIAL_LEN = 16;
 
 # TODO: user-configurable
-our @EXT_URL = (
+our @EXT_URL = map { ascii_html($_) } (
         # leading "//" denotes protocol-relative (http:// or https://)
         '//marc.info/?i=%s',
         '//www.mail-archive.com/search?l=mid&q=%s',
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 62bdf0a1..47a2046e 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -458,7 +458,8 @@ sub thread_html {
         $ctx->{prev_level} = 0;
         $ctx->{root_anchor} = anchor_for($mid);
         $ctx->{mapping} = {};
-        $ctx->{s_nr} = "$nr+ messages in thread";
+        $ctx->{s_nr} = ($nr > 1 ? "$nr+ messages" : 'only message')
+                       .' in thread';
 
         my $rootset = thread_results($ctx, $msgs);
 
diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm
index 0cce952d..6b8d9437 100644
--- a/lib/PublicInbox/ViewDiff.pm
+++ b/lib/PublicInbox/ViewDiff.pm
@@ -146,7 +146,7 @@ sub flush_diff ($$$) {
                 if ($s =~ /^---$/) {
                         to_state($dst, $state, DSTATE_STAT);
                         $$dst .= $s;
-                } elsif ($s =~ /^ /) {
+                } elsif ($s =~ /^ / || ($s =~ /^$/ && $state >= DSTATE_CTX)) {
                         # works for common cases, but not weird/long filenames
                         if ($state == DSTATE_STAT &&
                                         $s =~ /^ (.+)( +\| .*\z)/s) {
diff --git a/lib/PublicInbox/WwwHighlight.pm b/lib/PublicInbox/WwwHighlight.pm
index 01916401..bc349f8a 100644
--- a/lib/PublicInbox/WwwHighlight.pm
+++ b/lib/PublicInbox/WwwHighlight.pm
@@ -24,6 +24,8 @@ use warnings;
 use bytes (); # only for bytes::length
 use HTTP::Status qw(status_message);
 use parent qw(PublicInbox::HlMod);
+use PublicInbox::Linkify qw();
+use PublicInbox::Hval qw(ascii_html);
 
 # TODO: support highlight(1) for distros which don't package the
 # SWIG extension.  Also, there may be admins who don't want to
@@ -64,7 +66,14 @@ sub call {
         return r(405) if $req_method ne 'PUT';
 
         my $bref = read_in_full($env) or return r(500);
-        $bref = $self->do_hl($bref, $env->{PATH_INFO});
+        my $l = PublicInbox::Linkify->new;
+        $l->linkify_1($$bref);
+        if (my $res = $self->do_hl($bref, $env->{PATH_INFO})) {
+                $bref = $res;
+        } else {
+                $$bref = ascii_html($$bref);
+        }
+        $l->linkify_2($$bref);
 
         my $h = [ 'Content-Type', 'text/html; charset=UTF-8' ];
         push @$h, 'Content-Length', bytes::length($$bref);
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index c708c21f..2893138d 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -12,7 +12,6 @@ use warnings;
 use PublicInbox::Hval qw(ascii_html);
 use URI;
 our $TOR_URL = 'https://www.torproject.org/';
-our $TOR2WEB_URL = 'https://www.tor2web.org/';
 our $CODE_URL = 'https://public-inbox.org/';
 our $PROJECT = 'public-inbox';
 
@@ -140,10 +139,6 @@ EOF
         if ($urls =~ m!\b[^:]+://\w+\.onion/!) {
                 $urls .= "\n note: .onion URLs require Tor: ";
                 $urls .= qq[<a\nhref="$TOR_URL">$TOR_URL</a>];
-                if ($TOR2WEB_URL) {
-                        $urls .= "\n       or Tor2web: ";
-                        $urls .= qq[<a\nhref="$TOR2WEB_URL">$TOR2WEB_URL</a>];
-                }
         }
         '<hr><pre>'.join("\n\n",
                 $desc,