user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 6/6] www: remove Plack::Request dependency entirely
  2016-07-02  7:56  7% [PATCH 0/6] misc cleanups Eric Wong
@ 2016-07-02  7:56  5% ` Eric Wong
  0 siblings, 0 replies; 2+ results
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	[relevance 5%]

* [PATCH 0/6] misc cleanups
@ 2016-07-02  7:56  7% Eric Wong
  2016-07-02  7:56  5% ` [PATCH 6/6] www: remove Plack::Request dependency entirely Eric Wong
  0 siblings, 1 reply; 2+ results
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	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-07-02  7:56  7% [PATCH 0/6] misc cleanups Eric Wong
2016-07-02  7:56  5% ` [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).