[Jifty-commit] r1647 - in jifty/branches/moose: . bin
doc/examples/CounterDemo/bin doc/talks/npw.2006/Blog/t
lib/Jifty lib/Jifty/Script t t/Continuations/bin
t/Continuations/t t/Mapper/t t/TestApp/bin t/TestApp/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Jul 22 01:15:54 EDT 2006
Author: audreyt
Date: Sat Jul 22 01:15:50 2006
New Revision: 1647
Added:
jifty/branches/moose/t/09-url.t (contents, props changed)
Modified:
jifty/branches/moose/ (props changed)
jifty/branches/moose/bin/jifty
jifty/branches/moose/bin/service
jifty/branches/moose/doc/examples/CounterDemo/bin/jifty
jifty/branches/moose/doc/talks/npw.2006/Blog/t/00-model-Entry.t
jifty/branches/moose/lib/Jifty/LetMe.pm
jifty/branches/moose/lib/Jifty/Request.pm
jifty/branches/moose/lib/Jifty/Script/Action.pm
jifty/branches/moose/lib/Jifty/Script/Model.pm
jifty/branches/moose/lib/Jifty/Web.pm
jifty/branches/moose/t/00-load.t
jifty/branches/moose/t/01-dependencies.t
jifty/branches/moose/t/01-version_checks.t
jifty/branches/moose/t/02-connect.t
jifty/branches/moose/t/05-dispatcher.t
jifty/branches/moose/t/07-limit-actions.t
jifty/branches/moose/t/Continuations/bin/jifty
jifty/branches/moose/t/Continuations/t/00-prototype.t
jifty/branches/moose/t/Continuations/t/01-raw-api.t
jifty/branches/moose/t/Continuations/t/02-api.t
jifty/branches/moose/t/Continuations/t/03-gc.t
jifty/branches/moose/t/Continuations/t/04-before-blocks.t
jifty/branches/moose/t/Mapper/bin/jifty
jifty/branches/moose/t/Mapper/t/00-prototype.t
jifty/branches/moose/t/Mapper/t/01-raw-api.t
jifty/branches/moose/t/Mapper/t/02-api.t
jifty/branches/moose/t/TestApp/bin/jifty
jifty/branches/moose/t/TestApp/t/00-model-User.t
jifty/branches/moose/t/TestApp/t/00-prototype.t
jifty/branches/moose/t/TestApp/t/01-config.t
jifty/branches/moose/t/TestApp/t/02-dispatch.t
jifty/branches/moose/t/TestApp/t/03-static.t
jifty/branches/moose/t/TestApp/t/04-sessions.t
jifty/branches/moose/t/TestApp/t/05-actions-before-redirect.pm
jifty/branches/moose/t/TestApp/t/05-editactions-Cachable.t
jifty/branches/moose/t/TestApp/t/05-editactions-Record.t
jifty/branches/moose/t/TestApp/t/06-validation.t
jifty/branches/moose/t/TestApp/t/07-sandboxing.t
jifty/branches/moose/t/TestApp/t/08-notifications.t
Log:
r16488 at T (orig r1643): zev | 2006-07-21 15:46:50 -0400
r11795 at truegrounds: zev | 2006-07-21 15:46:38 -0400
* added a path option to Jifty::Web->url
* added url tests
r16489 at T (orig r1644): zev | 2006-07-21 16:43:46 -0400
r11822 at truegrounds: zev | 2006-07-21 16:43:41 -0400
* added url test
r16490 at T (orig r1645): zev | 2006-07-21 18:02:35 -0400
r11824 at truegrounds: zev | 2006-07-21 18:02:28 -0400
* changed all instances of '/usr/bin/perl' to '/usr/bin/env perl'
Modified: jifty/branches/moose/bin/jifty
==============================================================================
--- jifty/branches/moose/bin/jifty (original)
+++ jifty/branches/moose/bin/jifty Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
use File::Basename qw(dirname);
Modified: jifty/branches/moose/bin/service
==============================================================================
--- jifty/branches/moose/bin/service (original)
+++ jifty/branches/moose/bin/service Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use strict;
use warnings;
Modified: jifty/branches/moose/doc/examples/CounterDemo/bin/jifty
==============================================================================
--- jifty/branches/moose/doc/examples/CounterDemo/bin/jifty (original)
+++ jifty/branches/moose/doc/examples/CounterDemo/bin/jifty Sat Jul 22 01:15:50 2006
@@ -1,6 +1,6 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
-eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
+eval 'exec /usr/bin/env perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
use warnings;
use strict;
Modified: jifty/branches/moose/doc/talks/npw.2006/Blog/t/00-model-Entry.t
==============================================================================
--- jifty/branches/moose/doc/talks/npw.2006/Blog/t/00-model-Entry.t (original)
+++ jifty/branches/moose/doc/talks/npw.2006/Blog/t/00-model-Entry.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/lib/Jifty/LetMe.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/LetMe.pm (original)
+++ jifty/branches/moose/lib/Jifty/LetMe.pm Sat Jul 22 01:15:50 2006
@@ -238,7 +238,7 @@
sub as_url {
my $self = shift;
- return Jifty->web->url . $self->base_path. $self->as_encoded_token;
+ return Jifty->web->url(path => $self->base_path . $self->as_encoded_token);
}
Modified: jifty/branches/moose/lib/Jifty/Request.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/Request.pm (original)
+++ jifty/branches/moose/lib/Jifty/Request.pm Sat Jul 22 01:15:50 2006
@@ -515,7 +515,7 @@
);
# Set us up with the new continuation
- Jifty->web->_redirect( Jifty::Web->url . $path
+ Jifty->web->_redirect( Jifty->web->url(path => $path)
. ( $path =~ /\?/ ? "&" : "?" ) . "J:C="
. $c->id );
}
Modified: jifty/branches/moose/lib/Jifty/Script/Action.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/Script/Action.pm (original)
+++ jifty/branches/moose/lib/Jifty/Script/Action.pm Sat Jul 22 01:15:50 2006
@@ -115,7 +115,7 @@
my $testFile = <<"EOT";
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/lib/Jifty/Script/Model.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/Script/Model.pm (original)
+++ jifty/branches/moose/lib/Jifty/Script/Model.pm Sat Jul 22 01:15:50 2006
@@ -84,7 +84,7 @@
my $testFile = <<"EOT";
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/lib/Jifty/Web.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/Web.pm (original)
+++ jifty/branches/moose/lib/Jifty/Web.pm Sat Jul 22 01:15:50 2006
@@ -110,29 +110,43 @@
=head3 url
Returns the root url of this Jifty application. This is pulled from
-the configuration file. Takes an optional named parameter C<scheme>
-to specify the scheme.
+the configuration file. Takes an optional named path which will
+form the path part of the resulting URL.
=cut
sub url {
my $self = shift;
my %args = (scheme => undef,
+ path => undef,
@_);
- my $url = Jifty->config->framework("Web")->{BaseURL};
- my $port = Jifty->config->framework("Web")->{Port};
-
if ($args{'scheme'}) {
$self->log->error("Jifty->web->url no longer accepts a 'scheme' argument");
}
- my $uri = URI->new($url);
- $uri->port($port);
-
+
+ my $uri;
if ($ENV{'HTTP_HOST'}) {
- return $uri->scheme ."://".$ENV{'HTTP_HOST'};
+ my $host = $ENV{HTTP_HOST};
+ if ($host !~ m{^http://}) {
+ $host = 'http://' . $host;
+ }
+ $uri = URI->new($host);
+ } else {
+ my $url = Jifty->config->framework("Web")->{BaseURL};
+ my $port = Jifty->config->framework("Web")->{Port};
+
+ $uri = URI->new($url);
+ $uri->port($port);
}
+ if (defined $args{path}) {
+ my $path = $args{path};
+ # strip off leading '/' because ->canonical provides one
+ $path =~ s{^/}{};
+ $uri->path($path);
+ }
+
return $uri->canonical;
}
Modified: jifty/branches/moose/t/00-load.t
==============================================================================
--- jifty/branches/moose/t/00-load.t (original)
+++ jifty/branches/moose/t/00-load.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl -w
use strict;
use Test::More tests => 2;
Modified: jifty/branches/moose/t/01-dependencies.t
==============================================================================
--- jifty/branches/moose/t/01-dependencies.t (original)
+++ jifty/branches/moose/t/01-dependencies.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/01-version_checks.t
==============================================================================
--- jifty/branches/moose/t/01-version_checks.t (original)
+++ jifty/branches/moose/t/01-version_checks.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl -w
use strict;
use Test::More qw(no_plan);
Modified: jifty/branches/moose/t/02-connect.t
==============================================================================
--- jifty/branches/moose/t/02-connect.t (original)
+++ jifty/branches/moose/t/02-connect.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl -w
use strict;
use Jifty::Test tests => 6;
Modified: jifty/branches/moose/t/05-dispatcher.t
==============================================================================
--- jifty/branches/moose/t/05-dispatcher.t (original)
+++ jifty/branches/moose/t/05-dispatcher.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/07-limit-actions.t
==============================================================================
--- jifty/branches/moose/t/07-limit-actions.t (original)
+++ jifty/branches/moose/t/07-limit-actions.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Added: jifty/branches/moose/t/09-url.t
==============================================================================
--- (empty file)
+++ jifty/branches/moose/t/09-url.t Sat Jul 22 01:15:50 2006
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+Tests that URLs constructed with Jifty->web->url are correct
+
+=cut
+
+use Jifty::Test tests => 5;
+
+like(Jifty->web->url, qr{^http://localhost:\d+/$}, 'basic call works');
+like(Jifty->web->url(path => 'foo/bar'), qr{^http://localhost:\d+/foo/bar$}, 'path works');
+like(Jifty->web->url(path => '/foo/bar'), qr{^http://localhost:\d+/foo/bar$}, 'path with leading slash works');
+
+$ENV{HTTP_HOST} = 'example.com';
+
+is(Jifty->web->url, 'http://example.com/', 'setting hostname via env works');
+is(Jifty->web->url(path => 'foo/bar'), 'http://example.com/foo/bar', 'hostname via env and path works');
Modified: jifty/branches/moose/t/Continuations/bin/jifty
==============================================================================
--- jifty/branches/moose/t/Continuations/bin/jifty (original)
+++ jifty/branches/moose/t/Continuations/bin/jifty Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
use File::Basename qw(dirname);
Modified: jifty/branches/moose/t/Continuations/t/00-prototype.t
==============================================================================
--- jifty/branches/moose/t/Continuations/t/00-prototype.t (original)
+++ jifty/branches/moose/t/Continuations/t/00-prototype.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/Continuations/t/01-raw-api.t
==============================================================================
--- jifty/branches/moose/t/Continuations/t/01-raw-api.t (original)
+++ jifty/branches/moose/t/Continuations/t/01-raw-api.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/Continuations/t/02-api.t
==============================================================================
--- jifty/branches/moose/t/Continuations/t/02-api.t (original)
+++ jifty/branches/moose/t/Continuations/t/02-api.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/Continuations/t/03-gc.t
==============================================================================
--- jifty/branches/moose/t/Continuations/t/03-gc.t (original)
+++ jifty/branches/moose/t/Continuations/t/03-gc.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/Continuations/t/04-before-blocks.t
==============================================================================
--- jifty/branches/moose/t/Continuations/t/04-before-blocks.t (original)
+++ jifty/branches/moose/t/Continuations/t/04-before-blocks.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/Mapper/bin/jifty
==============================================================================
--- jifty/branches/moose/t/Mapper/bin/jifty (original)
+++ jifty/branches/moose/t/Mapper/bin/jifty Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
use File::Basename qw(dirname);
Modified: jifty/branches/moose/t/Mapper/t/00-prototype.t
==============================================================================
--- jifty/branches/moose/t/Mapper/t/00-prototype.t (original)
+++ jifty/branches/moose/t/Mapper/t/00-prototype.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/Mapper/t/01-raw-api.t
==============================================================================
--- jifty/branches/moose/t/Mapper/t/01-raw-api.t (original)
+++ jifty/branches/moose/t/Mapper/t/01-raw-api.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/Mapper/t/02-api.t
==============================================================================
--- jifty/branches/moose/t/Mapper/t/02-api.t (original)
+++ jifty/branches/moose/t/Mapper/t/02-api.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/bin/jifty
==============================================================================
--- jifty/branches/moose/t/TestApp/bin/jifty (original)
+++ jifty/branches/moose/t/TestApp/bin/jifty Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
use File::Basename qw(dirname);
Modified: jifty/branches/moose/t/TestApp/t/00-model-User.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/00-model-User.t (original)
+++ jifty/branches/moose/t/TestApp/t/00-model-User.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/t/00-prototype.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/00-prototype.t (original)
+++ jifty/branches/moose/t/TestApp/t/00-prototype.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/t/01-config.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/01-config.t (original)
+++ jifty/branches/moose/t/TestApp/t/01-config.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use strict;
use warnings;
Modified: jifty/branches/moose/t/TestApp/t/02-dispatch.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/02-dispatch.t (original)
+++ jifty/branches/moose/t/TestApp/t/02-dispatch.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/t/03-static.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/03-static.t (original)
+++ jifty/branches/moose/t/TestApp/t/03-static.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/t/04-sessions.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/04-sessions.t (original)
+++ jifty/branches/moose/t/TestApp/t/04-sessions.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/t/05-actions-before-redirect.pm
==============================================================================
--- jifty/branches/moose/t/TestApp/t/05-actions-before-redirect.pm (original)
+++ jifty/branches/moose/t/TestApp/t/05-actions-before-redirect.pm Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/t/05-editactions-Cachable.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/05-editactions-Cachable.t (original)
+++ jifty/branches/moose/t/TestApp/t/05-editactions-Cachable.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/t/05-editactions-Record.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/05-editactions-Record.t (original)
+++ jifty/branches/moose/t/TestApp/t/05-editactions-Record.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/t/06-validation.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/06-validation.t (original)
+++ jifty/branches/moose/t/TestApp/t/06-validation.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/t/07-sandboxing.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/07-sandboxing.t (original)
+++ jifty/branches/moose/t/TestApp/t/07-sandboxing.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
Modified: jifty/branches/moose/t/TestApp/t/08-notifications.t
==============================================================================
--- jifty/branches/moose/t/TestApp/t/08-notifications.t (original)
+++ jifty/branches/moose/t/TestApp/t/08-notifications.t Sat Jul 22 01:15:50 2006
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
More information about the Jifty-commit
mailing list