[Jifty-commit] r584 -
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Feb 14 17:45:27 EST 2006
Author: jesse
Date: Tue Feb 14 17:45:26 2006
New Revision: 584
Modified:
/ (props changed)
jifty/trunk/lib/Jifty/Config.pm
jifty/trunk/lib/Jifty/Web.pm
Log:
r23730 at truegrounds: jesse | 2006-02-14 17:43:26 -0500
* Let the actual URL the user came in on override our default configuration. Makes remote testing SO MUCH EASIER.
Modified: jifty/trunk/lib/Jifty/Config.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Config.pm (original)
+++ jifty/trunk/lib/Jifty/Config.pm Tue Feb 14 17:45:26 2006
@@ -229,6 +229,8 @@
Web => {
DefaultStaticRoot => Jifty::Util->share_root . '/web/static',
DefaultTemplateRoot => Jifty::Util->share_root . '/web/templates',
+ Port => '8888',
+ BaseURL => 'http://localhost',
SessionDir => "var/session",
DataDir => "var/mason",
StaticRoot => "web/static",
Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm (original)
+++ jifty/trunk/lib/Jifty/Web.pm Tue Feb 14 17:45:26 2006
@@ -63,29 +63,35 @@
}
-=head3 url [SCHEME]
+=head3 url
+
+Returns the root url of this Jifty application. This is pulled from the
+configuration file.
-Returns the root url of the server. This is pulled from the
-configuration file. Optionally overrides the default (http or https)
-scheme with the given C<SCHEME>.
=cut
sub url {
my $self = shift;
- my $url = Jifty->config->framework("Web")->{BaseURL}
- || "http://localhost";
- my $port = Jifty->config->framework("Web")->{Port} || 8888;
+ my $url = Jifty->config->framework("Web")->{BaseURL};
+ my $port = Jifty->config->framework("Web")->{Port};
+
+ my $scheme = 'http';
+ if ($url =~ /^(\w+)/) {
+ $scheme = $1;
+ }
- $url =~ s/^\w+/shift/e if @_;
+ if ($ENV{'HTTP_HOST'}) {
+ return $scheme ."://".$ENV{'HTTP_HOST'};
+ }
- if ( ( $url =~ /^http\b/ and $port == 80 )
- or ( $url =~ /^https\b/ and $port == 443 ) )
- {
- return $url;
- } else {
- return $url . ":" . $port;
+ my $append_port = 0;
+ if ( ( $scheme eq 'http' and $port != 80 )
+ or ( $scheme eq'https' and $port != 443 ) ) {
+ $append_port = 1;
}
+ return( $url . ($append_port ? ":$port" : ""));
+
}
=head3 serial
More information about the Jifty-commit
mailing list