[Bps-public-commit] Prophet branch, master, updated. 0.743-25-g76dab84
Christine Spang
spang at bestpractical.com
Sun Oct 24 01:19:07 EDT 2010
The branch, master has been updated
via 76dab8428c551a9ce1ed71e92d1a1b9678b3bfac (commit)
via 677218e32ea16ca763b09db20356139e64afe782 (commit)
via cc1a08dded0c0bdb3ea002ecabd4e0c0de2adbee (commit)
from 5d5ec19d98e09e49ad368d7b0cf3eaa9d9016579 (commit)
Summary of changes:
lib/Prophet/Server.pm | 60 +++++++++++++++++++++++++++++++++++++++---------
1 files changed, 48 insertions(+), 12 deletions(-)
- Log -----------------------------------------------------------------
commit cc1a08dded0c0bdb3ea002ecabd4e0c0de2adbee
Author: Christine Spang <spang at bestpractical.com>
Date: Mon Oct 18 23:04:57 2010 -0400
give the option of using system yui/jquery
Mostly relevant for Debian/Ubuntu for now, but generally
applicable in theory.
diff --git a/lib/Prophet/Server.pm b/lib/Prophet/Server.pm
index d0bc43a..98a6b89 100644
--- a/lib/Prophet/Server.pm
+++ b/lib/Prophet/Server.pm
@@ -143,6 +143,22 @@ sub app_static_root {
return $APP_STATIC_ROOT;
}
+# Use system-installed CSS and Javascript libraries if they exist, so distros
+# have the option to not ship our embedded copies.
+#
+# I'm not sure if RPM-based systems have a standard location for system
+# Javascript libraries, but this ought to work on Debian/Ubuntu. Patches
+# welcome.
+sub system_js_and_css {
+ my $mapping = {
+ 'yui/css/reset.css'
+ => '/usr/share/javascript/yui/reset/reset.css',
+ 'jquery/js/jquery-1.2.6.min.js',
+ => '/usr/share/javascript/jquery/jquery.min.js',
+ };
+ return $mapping;
+}
+
sub css {
return
'/static/prophet/yui/css/reset.css',
@@ -375,16 +391,27 @@ sub send_static_file {
} elsif ( $filename =~ /.png$/ ) {
$type = 'image/png';
}
- for my $root ( $self->app_static_root, $self->prophet_static_root) {
- next unless -f Prophet::Util->catfile( $root => $filename );
- my $qualified_file = Cwd::fast_abs_path( Prophet::Util->catfile( $root => $filename ) );
- next if substr( $qualified_file, 0, length($root) ) ne $root;
- my $content = Prophet::Util->slurp($qualified_file);
- return $self->send_content( static => 1, content => $content, content_type => $type );
- }
- return $self->_send_404;
+ my $system_library_mapping = $self->system_js_and_css();
+ my $content;
+ if ( $system_library_mapping->{ $filename } ) {
+ $content = Prophet::Util->slurp( $system_library_mapping->{ $filename } );
+ }
+ else {
+ for my $root ( $self->app_static_root, $self->prophet_static_root) {
+ next unless -f Prophet::Util->catfile( $root => $filename );
+ my $qualified_file = Cwd::fast_abs_path( File::Spec->catfile( $root => $filename ) );
+ next if substr( $qualified_file, 0, length($root) ) ne $root;
+ $content = Prophet::Util->slurp($qualified_file);
+ }
+ }
+ if ( defined $content ) {
+ return $self->send_content( static => 1, content => $content, content_type => $type );
+ }
+ else {
+ return $self->_send_404;
+ }
}
sub send_content {
commit 677218e32ea16ca763b09db20356139e64afe782
Author: Christine Spang <christine at debian.org>
Date: Sat Oct 23 23:17:02 2010 -0400
actually bail out from server if File::ShareDir or Template::Declare are missing
diff --git a/lib/Prophet/Server.pm b/lib/Prophet/Server.pm
index 98a6b89..2c8484f 100644
--- a/lib/Prophet/Server.pm
+++ b/lib/Prophet/Server.pm
@@ -43,8 +43,8 @@ sub run {
Net::Rendezvous::Publish->new;
};
- eval { require Template::Declare } || return "Without Template::Declare installed, Prophet's Web UI won't work";
- eval { require File::ShareDir } || return "Without File::ShareDir installed, Prophet's Web UI won't work";
+ eval { require Template::Declare } || die "Without Template::Declare installed, Prophet's Web UI won't work";
+ eval { require File::ShareDir } || die "Without File::ShareDir installed, Prophet's Web UI won't work";
if ($publisher) {
$publisher->publish(
commit 76dab8428c551a9ce1ed71e92d1a1b9678b3bfac
Author: Christine Spang <christine at debian.org>
Date: Sat Oct 23 23:37:56 2010 -0400
bail out with a helpful message when server port in use
diff --git a/lib/Prophet/Server.pm b/lib/Prophet/Server.pm
index 2c8484f..bd60eec 100644
--- a/lib/Prophet/Server.pm
+++ b/lib/Prophet/Server.pm
@@ -59,8 +59,17 @@ sub run {
}
$self->setup_template_roots();
print ref($self) . ": Starting up local server. You can stop the server with Ctrl-c.\n";
- $self->SUPER::run(@_);
-}
+ eval {
+ $self->SUPER::run(@_);
+ };
+ if ($@) {
+ if ( $@ =~ m/^bind to \*:(\d+): Address already in use/ ) {
+ die "\nPort $1 is already in use! Start the server on a different port using --port.\n";
+ } else {
+ die "\nError while starting server:\n\n$@\n";
+ }
+ }
+ }
=head2 database_bonjour_name
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list