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] wwwstream: do not load URI.pm
@ 2019-05-07  8:30  6% Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2019-05-07  8:30 UTC (permalink / raw)
  To: meta

It's unneeded since commit e358bd7a3833f8c5 (2016-07-02)
("inbox: base_url method takes PSGI env hashref instead")

So we only depend on URI::Escape from the "URI" CPAN distribution,
at the moment.
---
 lib/PublicInbox/WwwStream.pm | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index 2893138..f6c5049 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -10,7 +10,6 @@ package PublicInbox::WwwStream;
 use strict;
 use warnings;
 use PublicInbox::Hval qw(ascii_html);
-use URI;
 our $TOR_URL = 'https://www.torproject.org/';
 our $CODE_URL = 'https://public-inbox.org/';
 our $PROJECT = 'public-inbox';
-- 
EW


^ permalink raw reply related	[relevance 6%]

* [PATCH 2/6] inbox: base_url method takes PSGI env hashref instead
  2016-07-02  7:56  6% [PATCH 0/6] misc cleanups Eric Wong
@ 2016-07-02  7:56  7% ` Eric Wong
  0 siblings, 0 replies; 3+ results
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	[relevance 7%]

* [PATCH 0/6] misc cleanups
@ 2016-07-02  7:56  6% Eric Wong
  2016-07-02  7:56  7% ` [PATCH 2/6] inbox: base_url method takes PSGI env hashref instead Eric Wong
  0 siblings, 1 reply; 3+ 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 6%]

Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-07-02  7:56  6% [PATCH 0/6] misc cleanups Eric Wong
2016-07-02  7:56  7% ` [PATCH 2/6] inbox: base_url method takes PSGI env hashref instead Eric Wong
2019-05-07  8:30  6% [PATCH] wwwstream: do not load URI.pm 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).