user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/6] misc cleanups
@ 2016-07-02  7:56 Eric Wong
  2016-07-02  7:56 ` [PATCH 1/6] TODO: clarify streaming Email::MIME replacement Eric Wong
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Eric Wong @ 2016-07-02  7:56 UTC (permalink / raw)
  To: meta

Should be pretty obvious, and the iffstat looks good :)

Eric Wong (6):
      TODO: clarify streaming Email::MIME replacement
      inbox: base_url method takes PSGI env hashref instead
      extmsg: rework to use Inbox objects
      www: use PSGI env directly
      view: rely on internal query parser for 'o' param
      www: remove Plack::Request dependency entirely

 TODO                          |   1 +
 lib/PublicInbox/ExtMsg.pm     | 102 ++++++++++++++++++------------------------
 lib/PublicInbox/Feed.pm       |  13 +++---
 lib/PublicInbox/Inbox.pm      |  17 +++++--
 lib/PublicInbox/Mbox.pm       |   2 +-
 lib/PublicInbox/SearchView.pm |   2 +-
 lib/PublicInbox/View.pm       |   2 +-
 lib/PublicInbox/WWW.pm        |  24 +++++-----
 lib/PublicInbox/WwwStream.pm  |   9 +---
 script/public-inbox-httpd     |   1 -
 t/httpd-corner.t              |   2 +-
 t/httpd-unix.t                |   2 +-
 t/httpd.t                     |   2 +-
 t/plack.t                     |   2 +-
 t/psgi_attach.t               |   2 +-
 t/psgi_mount.t                |   2 +-
 t/view.t                      |   1 +
 17 files changed, 86 insertions(+), 100 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6] TODO: clarify streaming Email::MIME replacement
  2016-07-02  7:56 [PATCH 0/6] misc cleanups Eric Wong
@ 2016-07-02  7:56 ` Eric Wong
  2016-07-02  7:56 ` [PATCH 2/6] inbox: base_url method takes PSGI env hashref instead Eric Wong
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Wong @ 2016-07-02  7:56 UTC (permalink / raw)
  To: meta

I bet there's a billion other improvements to be made elsewhere.
---
 TODO | 1 +
 1 file changed, 1 insertion(+)

diff --git a/TODO b/TODO
index 30ba38b..644fa03 100644
--- a/TODO
+++ b/TODO
@@ -53,6 +53,7 @@ all need to be considered for everything we introduce)
 * streaming Email::MIME replacement: currently we generate many
   allocations/strings for headers we never look at and slurp
   entire message bodies into memory.
+  (this is pie-in-the-sky territory...)
 
 * Allow in-place Xapian updates without clobbering the whole
   index (versioning each doc data entry?) for big archives
-- 
EW


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/6] inbox: base_url method takes PSGI env hashref instead
  2016-07-02  7:56 [PATCH 0/6] misc cleanups Eric Wong
  2016-07-02  7:56 ` [PATCH 1/6] TODO: clarify streaming Email::MIME replacement Eric Wong
@ 2016-07-02  7:56 ` Eric Wong
  2016-07-02  7:56 ` [PATCH 3/6] extmsg: rework to use Inbox objects Eric Wong
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Wong @ 2016-07-02  7:56 UTC (permalink / raw)
  To: meta

This is lighter and we can work further towards eliminating
our Plack::Request dependency entirely.
---
 lib/PublicInbox/Feed.pm      |  4 +---
 lib/PublicInbox/Inbox.pm     | 12 ++++++++----
 lib/PublicInbox/Mbox.pm      |  2 +-
 lib/PublicInbox/WWW.pm       |  2 +-
 lib/PublicInbox/WwwStream.pm |  9 ++-------
 t/view.t                     |  1 +
 6 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 2f141c4..ffbf5c8 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -297,13 +297,11 @@ sub get_feedopts {
 	my $pi_config = $ctx->{pi_config};
 	my $inbox = $ctx->{inbox};
 	my $obj = $ctx->{-inbox};
-	my $cgi = $ctx->{cgi};
 	my %rv = ( description => $obj->description );
 
 	$rv{address} = $obj->{address};
 	$rv{id_addr} = $obj->{-primary_address};
-	my $url_base;
-	$url_base = $obj->base_url($cgi); # CGI may be undef
+	my $url_base = $obj->base_url($ctx->{env});
 	if (my $mid = $ctx->{mid}) { # per-thread feed:
 		$rv{atomurl} = "$url_base$mid/t.atom";
 	} else {
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index ada713c..96c9265 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -71,10 +71,14 @@ sub cloneurl {
 }
 
 sub base_url {
-	my ($self, $prq) = @_; # Plack::Request
-	if (defined $prq) {
-		my $url = $prq->base->as_string;
-		$url .= '/' if $url !~ m!/\z!; # for mount in Plack::Builder
+	my ($self, $env) = @_;
+	if ($env) { # PSGI env
+		my $scheme = $env->{'psgi.url_scheme'};
+		my $host_port = $env->{HTTP_HOST} ||
+			"$env->{SERVER_NAME}:$env->{SERVER_PORT}";
+		my $url = "$scheme://$host_port". ($env->{SCRIPT_NAME} || '/');
+		# for mount in Plack::Builder
+		$url .= '/' if $url !~ m!/\z!;
 		$url .= $self->{name} . '/';
 	} else {
 		# either called from a non-PSGI environment (e.g. NNTP/POP3)
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index 1c97f95..9dad0f6 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -28,7 +28,7 @@ sub msg_str {
 		$header_obj->header_set($d);
 	}
 	my $ibx = $ctx->{-inbox};
-	my $base = $ibx->base_url($ctx->{cgi});
+	my $base = $ibx->base_url($ctx->{env});
 	my $mid = mid_clean($header_obj->header('Message-ID'));
 	$mid = uri_escape_utf8($mid);
 	my @append = (
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index c4509bd..1e23c43 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -401,7 +401,7 @@ sub r301 {
 		return $r404 if $r404;
 		$obj = $ctx->{-inbox};
 	}
-	my $url = $obj->base_url($cgi);
+	my $url = $obj->base_url($ctx->{env});
 	my $qs = $ctx->{env}->{QUERY_STRING};
 	$url .= (uri_escape_utf8($mid) . '/') if (defined $mid);
 	$url .= $suffix if (defined $suffix);
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index fdab4da..be6ce2e 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -62,13 +62,8 @@ sub _html_end {
 	my $obj = $ctx->{-inbox};
 	my $desc = ascii_html($obj->description);
 
-	# FIXME: cleanup
-	my $env = $ctx->{env};
-	my $scheme = $env->{'psgi.url_scheme'};
-	my $host_port = $env->{HTTP_HOST} ||
-			"$env->{SERVER_NAME}:$env->{SERVER_PORT}";
-	my $http = "$scheme://$host_port".($env->{SCRIPT_NAME} || '/');
-	$http = URI->new($http . $obj->{name})->canonical->as_string;
+	my $http = $obj->base_url($ctx->{env});
+	chop $http;
 	my %seen = ( $http => 1 );
 	my @urls = ($http);
 	foreach my $u (@{$obj->cloneurl}) {
diff --git a/t/view.t b/t/view.t
index 4fdd151..4cee439 100644
--- a/t/view.t
+++ b/t/view.t
@@ -25,6 +25,7 @@ my $ctx = {
 	-inbox => Plack::Util::inline_object(
 		name => 'test',
 		search => sub { undef },
+		base_url => sub { 'http://example.com/' },
 		cloneurl => sub {[]},
 		description => sub { '' }),
 };
-- 
EW


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/6] extmsg: rework to use Inbox objects
  2016-07-02  7:56 [PATCH 0/6] misc cleanups Eric Wong
  2016-07-02  7:56 ` [PATCH 1/6] TODO: clarify streaming Email::MIME replacement Eric Wong
  2016-07-02  7:56 ` [PATCH 2/6] inbox: base_url method takes PSGI env hashref instead Eric Wong
@ 2016-07-02  7:56 ` Eric Wong
  2016-07-02  7:56 ` [PATCH 4/6] www: use PSGI env directly Eric Wong
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Wong @ 2016-07-02  7:56 UTC (permalink / raw)
  To: meta

This is less code and hopefully easier-to-understand.
---
 lib/PublicInbox/ExtMsg.pm | 102 ++++++++++++++++++++--------------------------
 lib/PublicInbox/Inbox.pm  |   5 +++
 2 files changed, 49 insertions(+), 58 deletions(-)

diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index e15abab..4b9e025 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -24,62 +24,53 @@ our @EXT_URL = (
 sub ext_msg {
 	my ($ctx) = @_;
 	my $pi_config = $ctx->{pi_config};
-	my $inbox = $ctx->{inbox};
+	my $cur = $ctx->{-inbox};
 	my $mid = $ctx->{mid};
-	my $cgi = $ctx->{cgi};
-	my $env = $cgi->{env};
+	my $env = $ctx->{env};
 
 	eval { require PublicInbox::Search };
 	my $have_xap = $@ ? 0 : 1;
-	my (@nox, @pfx);
+	my (@nox, @ibx);
 
 	foreach my $k (keys %$pi_config) {
 		$k =~ /\Apublicinbox\.([A-Z0-9a-z-]+)\.url\z/ or next;
 		my $name = $1;
-		next if $name eq $inbox;
-
-		my $git_dir = $pi_config->{"publicinbox.$name.mainrepo"};
-		defined $git_dir or next;
-
-		my $url = $pi_config->{"publicinbox.$name.url"};
-		defined $url or next;
-
-		$url =~ s!/+\z!!;
-		$url = PublicInbox::Hval::prurl($env, $url);
+		next if $name eq $cur->{name};
+		my $other = $pi_config->lookup_name($name) or next;
+		next unless $other->base_url;
+
+		my $s = $other->search;
+		if (!$s) {
+			push @nox, $other;
+			next;
+		}
 
 		# try to find the URL with Xapian to avoid forking
-		if ($have_xap) {
-			my $s;
-			my $doc_id = eval {
-				$s = PublicInbox::Search->new($git_dir);
-				$s->find_unique_doc_id('mid', $mid);
-			};
-			if ($@) {
-				# xapian not configured for this repo
-			} else {
-				# maybe we found it!
-				return r302($url, $mid) if (defined $doc_id);
-
-				# no point in trying the fork fallback if we
-				# know Xapian is up-to-date but missing the
-				# message in the current repo
-				push @pfx, { git_dir => $git_dir, url => $url };
-				next;
-			}
+		my $doc_id = eval { $s->find_unique_doc_id('mid', $mid) };
+		if ($@) {
+			# xapian not configured properly for this repo
+			push @nox, $other;
+			next;
 		}
 
-		# queue up for forking after we've tried Xapian on all of them
-		push @nox, { git_dir => $git_dir, url => $url };
+		# maybe we found it!
+		return r302($other, $mid) if defined $doc_id;
+
+		# no point in trying the fork fallback if we
+		# know Xapian is up-to-date but missing the
+		# message in the current repo
+		push @ibx, $other;
 	}
 
-	# Xapian not installed or configured for some repos
-	my $path = "HEAD:" . mid2path($mid);
+	# Xapian not installed or configured for some repos,
+	# do a full MID check:
+	if (@nox) {
+		my $path = mid2path($mid);
+		foreach my $other (@nox) {
+			my (undef, $type, undef) = $other->path_check($path);
 
-	foreach my $n (@nox) {
-		# TODO: reuse existing PublicInbox::Git objects to save forks
-		my $git = PublicInbox::Git->new($n->{git_dir});
-		my (undef, $type, undef) = $git->check($path);
-		return r302($n->{url}, $mid) if ($type && $type eq 'blob');
+			return r302($other, $mid) if $type && $type eq 'blob';
+		}
 	}
 
 	# fall back to partial MID matching
@@ -88,22 +79,15 @@ sub ext_msg {
 
 	eval { require PublicInbox::Msgmap };
 	my $have_mm = $@ ? 0 : 1;
-	my $base_url = $cgi->base->as_string;
 	if ($have_mm) {
 		my $tmp_mid = $mid;
-		my $url;
 again:
-		$url = $base_url . $inbox;
-		unshift @pfx, { git_dir => $ctx->{git_dir}, url => $url };
-		foreach my $pfx (@pfx) {
-			my $git_dir = delete $pfx->{git_dir} or next;
-			my $mm = eval { PublicInbox::Msgmap->new($git_dir) };
-
-			$mm or next;
+		unshift @ibx, $cur;
+		foreach my $ibx (@ibx) {
+			my $mm = $ibx->mm or next;
 			if (my $res = $mm->mid_prefixes($tmp_mid)) {
 				$n_partial += scalar(@$res);
-				$pfx->{res} = $res;
-				push @partial, $pfx;
+				push @partial, [ $ibx, $res ];
 			}
 		}
 		# fixup common errors:
@@ -124,13 +108,14 @@ again:
 		$code = 300;
 		my $es = $n_partial == 1 ? '' : 'es';
 		$s.= "\n$n_partial partial match$es found:\n\n";
-		foreach my $pfx (@partial) {
-			my $u = $pfx->{url};
-			foreach my $m (@{$pfx->{res}}) {
+		foreach my $pair (@partial) {
+			my ($ibx, $res) = @$pair;
+			my $u = $ibx->base_url or next;
+			foreach my $m (@$res) {
 				my $p = PublicInbox::Hval->new_msgid($m);
 				my $r = $p->as_href;
 				my $t = $p->as_html;
-				$s .= qq{<a\nhref="$u/$r/">$u/$t/</a>\n};
+				$s .= qq{<a\nhref="$u$r/">$u$t/</a>\n};
 			}
 		}
 	}
@@ -152,9 +137,10 @@ again:
 }
 
 # Redirect to another public-inbox which is mapped by $pi_config
+# TODO: prompt for inbox-switching
 sub r302 {
-	my ($url, $mid) = @_;
-	$url .= '/' . uri_escape_utf8($mid) . '/';
+	my ($inbox, $mid) = @_;
+	my $url = $inbox->base_url . uri_escape_utf8($mid) . '/';
 	[ 302,
 	  [ 'Location' => $url, 'Content-Type' => 'text/plain' ],
 	  [ "Redirecting to\n$url\n" ] ]
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 96c9265..728caa0 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -108,6 +108,11 @@ sub msg_by_path ($$;$) {
 	$str;
 }
 
+sub path_check {
+	my ($self, $path) = @_;
+	git($self)->check('HEAD:'.$path);
+}
+
 sub msg_by_mid ($$;$) {
 	my ($self, $mid, $ref) = @_;
 	msg_by_path($self, mid2path($mid), $ref);
-- 
EW


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/6] www: use PSGI env directly
  2016-07-02  7:56 [PATCH 0/6] misc cleanups Eric Wong
                   ` (2 preceding siblings ...)
  2016-07-02  7:56 ` [PATCH 3/6] extmsg: rework to use Inbox objects Eric Wong
@ 2016-07-02  7:56 ` Eric Wong
  2016-07-02  7:56 ` [PATCH 5/6] view: rely on internal query parser for 'o' param Eric Wong
  2016-07-02  7:56 ` [PATCH 6/6] www: remove Plack::Request dependency entirely Eric Wong
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Wong @ 2016-07-02  7:56 UTC (permalink / raw)
  To: meta

More work on on the Plack::Request/CGI.pm removal front,
No need to access the PSGI env through an extra hash lookup.
---
 lib/PublicInbox/SearchView.pm | 2 +-
 lib/PublicInbox/WWW.pm        | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index ce1eff1..15bb823 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -86,7 +86,7 @@ sub mset_summary {
 sub err_txt {
 	my ($ctx, $err) = @_;
 	my $u = '//xapian.org/docs/queryparser.html';
-	$u = PublicInbox::Hval::prurl($ctx->{cgi}->{env}, $u);
+	$u = PublicInbox::Hval::prurl($ctx->{env}, $u);
 	$err =~ s/^\s*Exception:\s*//; # bad word to show users :P
 	$err = ascii_html($err);
 	"\nBad query: <b>$err</b>\n" .
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 1e23c43..940e1c5 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -152,7 +152,7 @@ sub invalid_inbox {
 		$ctx->{git_dir} = $obj->{mainrepo};
 		$ctx->{git} = $obj->git;
 		# for PublicInbox::HTTP::weaken_task:
-		$ctx->{cgi}->{env}->{'pi-httpd.inbox'} = $obj;
+		$ctx->{env}->{'pi-httpd.inbox'} = $obj;
 		$ctx->{-inbox} = $obj;
 		$ctx->{inbox} = $inbox;
 		return;
@@ -162,7 +162,7 @@ sub invalid_inbox {
 	# generation and link things intended for nntp:// to https?://,
 	# so try to infer links and redirect them to the appropriate
 	# list URL.
-	$self->news_www->call($ctx->{cgi}->{env});
+	$self->news_www->call($ctx->{env});
 }
 
 # returns undef if valid, array ref response if invalid
@@ -284,7 +284,7 @@ sub footer {
 	$ctx->{footer} = join("\n",
 		'- ' . $desc,
 		"A <a\nhref=\"" .
-			PublicInbox::Hval::prurl($ctx->{cgi}->{env}, PI_URL) .
+			PublicInbox::Hval::prurl($ctx->{env}, PI_URL) .
 			'">public-inbox</a>, ' .
 			'anybody may post in plain-text (not HTML):',
 		$addr,
@@ -388,13 +388,12 @@ sub legacy_redirects {
 	} elsif ($path_info =~ m!$INBOX_RE/(\S+/\S+)/f\z!o) {
 		r301($ctx, $1, $2);
 	} else {
-		$self->news_www->call($ctx->{cgi}->{env});
+		$self->news_www->call($ctx->{env});
 	}
 }
 
 sub r301 {
 	my ($ctx, $inbox, $mid, $suffix) = @_;
-	my $cgi = $ctx->{cgi};
 	my $obj = $ctx->{-inbox};
 	unless ($obj) {
 		my $r404 = invalid_inbox($ctx->{www}, $ctx, $inbox);
-- 
EW


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/6] view: rely on internal query parser for 'o' param
  2016-07-02  7:56 [PATCH 0/6] misc cleanups Eric Wong
                   ` (3 preceding siblings ...)
  2016-07-02  7:56 ` [PATCH 4/6] www: use PSGI env directly Eric Wong
@ 2016-07-02  7:56 ` Eric Wong
  2016-07-02  7:56 ` [PATCH 6/6] www: remove Plack::Request dependency entirely Eric Wong
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Wong @ 2016-07-02  7:56 UTC (permalink / raw)
  To: meta

Plack::Request will check the request body by merely
calling "param", totally unnecessary and sneaky.
---
 lib/PublicInbox/View.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index fd882aa..1527959 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -908,7 +908,7 @@ sub emit_topics {
 
 sub emit_index_topics {
 	my ($ctx) = @_;
-	my ($off) = (($ctx->{cgi}->param('o') || '0') =~ /(\d+)/);
+	my ($off) = (($ctx->{qp}->{o} || '0') =~ /(\d+)/);
 	$ctx->{order} = [];
 	$ctx->{subjs} = {};
 	$ctx->{latest} = {};
-- 
EW


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6/6] www: remove Plack::Request dependency entirely
  2016-07-02  7:56 [PATCH 0/6] misc cleanups Eric Wong
                   ` (4 preceding siblings ...)
  2016-07-02  7:56 ` [PATCH 5/6] view: rely on internal query parser for 'o' param Eric Wong
@ 2016-07-02  7:56 ` Eric Wong
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Wong @ 2016-07-02  7:56 UTC (permalink / raw)
  To: meta

Lighter and ever-so-slightly faster!

Most importantly, this won't do non-obvious stuff behind our
backs like trying to parse a POST request body for a query
string param.
---
 lib/PublicInbox/Feed.pm   |  9 +++++----
 lib/PublicInbox/WWW.pm    | 13 +++++--------
 script/public-inbox-httpd |  1 -
 t/httpd-corner.t          |  2 +-
 t/httpd-unix.t            |  2 +-
 t/httpd.t                 |  2 +-
 t/plack.t                 |  2 +-
 t/psgi_attach.t           |  2 +-
 t/psgi_mount.t            |  2 +-
 9 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index ffbf5c8..2983514 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -119,17 +119,18 @@ sub end_feed {
 
 sub emit_atom_thread {
 	my ($cb, $ctx) = @_;
-	my $res = $ctx->{srch}->get_thread($ctx->{mid});
+	my $mid = $ctx->{mid};
+	my $res = $ctx->{srch}->get_thread($mid);
 	return _no_thread($cb) unless $res->{total};
 	my $feed_opts = get_feedopts($ctx);
 	my $fh = $cb->([200, ['Content-Type' => 'application/atom+xml']]);
+	my $ibx = $ctx->{-inbox};
+	my $html_url = $ibx->base_url($ctx->{env});
+	$html_url .= PublicInbox::Hval->new_msgid($mid)->as_href;
 
-	my $html_url = $feed_opts->{atomurl} = $ctx->{self_url};
-	$html_url =~ s!/t\.atom\z!/!;
 	$feed_opts->{url} = $html_url;
 	$feed_opts->{emit_header} = 1;
 
-	my $ibx = $ctx->{-inbox};
 	foreach my $msg (@{$res->{msgs}}) {
 		my $s = feed_entry($feed_opts, mid2path($msg->mid), $ibx);
 		$fh->write($s) if defined $s;
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 940e1c5..5425308 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -13,7 +13,6 @@ package PublicInbox::WWW;
 use 5.008;
 use strict;
 use warnings;
-use Plack::Request;
 use PublicInbox::Config;
 use PublicInbox::Hval;
 use URI::Escape qw(uri_escape_utf8 uri_unescape);
@@ -40,9 +39,7 @@ sub run {
 
 sub call {
 	my ($self, $env) = @_;
-	my $cgi = Plack::Request->new($env);
-	my $ctx = { cgi => $cgi, env => $env, www => $self,
-		pi_config => $self->{pi_config} };
+	my $ctx = { env => $env, www => $self, pi_config => $self->{pi_config} };
 
 	# we don't care about multi-value
 	my %qp = map {
@@ -267,10 +264,11 @@ sub footer {
 	my $urls;
 	my @urls = @{$obj->cloneurl};
 	my %seen = map { $_ => 1 } @urls;
-	my $cgi = $ctx->{cgi};
-	my $http = $cgi->base->as_string . $obj->{name};
+	my $env = $ctx->{env};
+	my $http = $obj->base_url($env);
+	chop $http;
 	$seen{$http} or unshift @urls, $http;
-	my $ssoma_url = PublicInbox::Hval::prurl($ctx->{env}, SSOMA_URL);
+	my $ssoma_url = PublicInbox::Hval::prurl($env, SSOMA_URL);
 	if (scalar(@urls) == 1) {
 		$urls = "URL for <a\nhref=\"" . $ssoma_url .
 			qq(">ssoma</a> or <b>git clone --mirror $urls[0]</b>);
@@ -329,7 +327,6 @@ sub get_thread_mbox {
 sub get_thread_atom {
 	my ($ctx) = @_;
 	searcher($ctx) or return need_search($ctx);
-	$ctx->{self_url} = $ctx->{cgi}->uri->as_string;
 	require PublicInbox::Feed;
 	PublicInbox::Feed::generate_thread_atom($ctx);
 }
diff --git a/script/public-inbox-httpd b/script/public-inbox-httpd
index f19582f..8ba42c2 100755
--- a/script/public-inbox-httpd
+++ b/script/public-inbox-httpd
@@ -9,7 +9,6 @@ use Plack::Util;
 use PublicInbox::Daemon;
 use PublicInbox::HTTP;
 use PublicInbox::HTTPD;
-use Plack::Request;
 use Plack::Builder;
 my %httpds;
 my $app;
diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index b9eaa6f..5ecc69b 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -7,7 +7,7 @@ use warnings;
 use Test::More;
 use Time::HiRes qw(gettimeofday tv_interval);
 
-foreach my $mod (qw(Plack::Util Plack::Request Plack::Builder Danga::Socket
+foreach my $mod (qw(Plack::Util Plack::Builder Danga::Socket
 			HTTP::Date HTTP::Status)) {
 	eval "require $mod";
 	plan skip_all => "$mod missing for httpd-corner.t" if $@;
diff --git a/t/httpd-unix.t b/t/httpd-unix.t
index 16f7bdd..ef827fc 100644
--- a/t/httpd-unix.t
+++ b/t/httpd-unix.t
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 use Test::More;
 
-foreach my $mod (qw(Plack::Util Plack::Request Plack::Builder Danga::Socket
+foreach my $mod (qw(Plack::Util Plack::Builder Danga::Socket
 			HTTP::Date HTTP::Status)) {
 	eval "require $mod";
 	plan skip_all => "$mod missing for httpd-unix.t" if $@;
diff --git a/t/httpd.t b/t/httpd.t
index 0e19b56..c2e7360 100644
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 
-foreach my $mod (qw(Plack::Util Plack::Request Plack::Builder Danga::Socket
+foreach my $mod (qw(Plack::Util Plack::Builder Danga::Socket
 			HTTP::Date HTTP::Status)) {
 	eval "require $mod";
 	plan skip_all => "$mod missing for httpd.t" if $@;
diff --git a/t/plack.t b/t/plack.t
index a4f3245..40298e5 100644
--- a/t/plack.t
+++ b/t/plack.t
@@ -11,7 +11,7 @@ my $pi_config = "$tmpdir/config";
 my $maindir = "$tmpdir/main.git";
 my $addr = 'test-public@example.com';
 my $cfgpfx = "publicinbox.test";
-my @mods = qw(HTTP::Request::Common Plack::Request Plack::Test
+my @mods = qw(HTTP::Request::Common Plack::Test
 	Mail::Thread URI::Escape);
 foreach my $mod (@mods) {
 	eval "require $mod";
diff --git a/t/psgi_attach.t b/t/psgi_attach.t
index ef116c6..0d20b7f 100644
--- a/t/psgi_attach.t
+++ b/t/psgi_attach.t
@@ -9,7 +9,7 @@ my $tmpdir = tempdir('psgi-attach-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $maindir = "$tmpdir/main.git";
 my $addr = 'test-public@example.com';
 my $cfgpfx = "publicinbox.test";
-my @mods = qw(HTTP::Request::Common Plack::Request Plack::Test URI::Escape);
+my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape);
 foreach my $mod (@mods) {
 	eval "require $mod";
 	plan skip_all => "$mod missing for plack.t" if $@;
diff --git a/t/psgi_mount.t b/t/psgi_mount.t
index c1c1b0c..dae45ba 100644
--- a/t/psgi_mount.t
+++ b/t/psgi_mount.t
@@ -9,7 +9,7 @@ my $tmpdir = tempdir('psgi-path-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $maindir = "$tmpdir/main.git";
 my $addr = 'test-public@example.com';
 my $cfgpfx = "publicinbox.test";
-my @mods = qw(HTTP::Request::Common Plack::Request Plack::Test URI::Escape);
+my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape);
 foreach my $mod (@mods) {
 	eval "require $mod";
 	plan skip_all => "$mod missing for plack.t" if $@;
-- 
EW


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-02  7:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-02  7:56 [PATCH 0/6] misc cleanups Eric Wong
2016-07-02  7:56 ` [PATCH 1/6] TODO: clarify streaming Email::MIME replacement Eric Wong
2016-07-02  7:56 ` [PATCH 2/6] inbox: base_url method takes PSGI env hashref instead Eric Wong
2016-07-02  7:56 ` [PATCH 3/6] extmsg: rework to use Inbox objects Eric Wong
2016-07-02  7:56 ` [PATCH 4/6] www: use PSGI env directly Eric Wong
2016-07-02  7:56 ` [PATCH 5/6] view: rely on internal query parser for 'o' param Eric Wong
2016-07-02  7:56 ` [PATCH 6/6] www: remove Plack::Request dependency entirely Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).