[Bps-public-commit] SD branch, master, updated. 5462a024150517ae0c239d26e648e87a334057fe
jesse
jesse at bestpractical.com
Mon Mar 16 13:48:12 EDT 2009
The branch, master has been updated
via 5462a024150517ae0c239d26e648e87a334057fe (commit)
via e5f4c8706a669412acc389be7db1ba89c37df1d9 (commit)
from e1a372151b30cd43e3dea800201ab77b2a9dceb5 (commit)
Summary of changes:
lib/App/SD/CLI/Command/Browser.pm | 39 +++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
create mode 100644 lib/App/SD/CLI/Command/Browser.pm
- Log -----------------------------------------------------------------
commit e5f4c8706a669412acc389be7db1ba89c37df1d9
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Mar 16 13:46:05 2009 -0400
Added an "auto open in the browser" command
diff --git a/lib/App/SD/CLI/Command/Browser.pm b/lib/App/SD/CLI/Command/Browser.pm
new file mode 100644
index 0000000..a460819
--- /dev/null
+++ b/lib/App/SD/CLI/Command/Browser.pm
@@ -0,0 +1,38 @@
+package App::SD::CLI::Command::Server;
+use Any::Moose;
+
+extends 'Prophet::CLI::Command::Server';
+
+sub setup_server {
+ my $self = shift;
+ my $server = $self->SUPER::setup_server();
+ $self->open_browser(url => 'http://localhost:'. $server->port);
+ return $server;
+}
+
+
+sub open_browser {
+ my $self = shift;
+ my %args = (@_);
+ my $opener = $self->open_url_cmd;
+ if ($args{url}) {
+ fork || do { sleep 2; `$opener $args{url}`; exit};
+ }
+}
+
+sub open_url_cmd {
+ my $self = shift;
+ if ( $^O eq 'darwin' ) {
+ return 'open';
+ } elsif ( $^O eq 'MSWin32' ) {
+ return 'start';
+ }
+ for my $cmd (qw|www-browser htmlview firefox iceweasel w3m lynx|) {
+ my $cmd_path = `which $cmd`;
+ chomp($cmd_path);
+ next unless $cmd_path;
+ if ( -f $cmd_path && -x _ ) {
+ return $cmd_path;
+ }
+ }
+}
commit 5462a024150517ae0c239d26e648e87a334057fe
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Mar 16 13:47:39 2009 -0400
more browser choice
diff --git a/lib/App/SD/CLI/Command/Browser.pm b/lib/App/SD/CLI/Command/Browser.pm
index a460819..8d99538 100644
--- a/lib/App/SD/CLI/Command/Browser.pm
+++ b/lib/App/SD/CLI/Command/Browser.pm
@@ -27,7 +27,8 @@ sub open_url_cmd {
} elsif ( $^O eq 'MSWin32' ) {
return 'start';
}
- for my $cmd (qw|www-browser htmlview firefox iceweasel w3m lynx|) {
+ for my $cmd (qw|www-browser htmlview gnome-open gnome-moz-remote
+ firefox iceweasel opera w3m lynx|) {
my $cmd_path = `which $cmd`;
chomp($cmd_path);
next unless $cmd_path;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list