[Bps-public-commit] Prophet branch, master, updated. 0.73-16-gf62b176
jesse
jesse at bestpractical.com
Wed Nov 18 11:40:44 EST 2009
The branch, master has been updated
via f62b1762e729320b815abf660b7d942eb8c80b7d (commit)
via 02d61651a0b3dbe6e820db51fff4c926dde05a97 (commit)
from 39d245e87ac27aefc0d53cc52e484828b4243f2b (commit)
Summary of changes:
lib/Prophet/ForeignReplica.pm | 46 ++++++++++++++++++++++++++++++++++++----
lib/Prophet/Server.pm | 15 ++++++++++++-
lib/Prophet/Server/View.pm | 14 ++++++++----
lib/Prophet/Web/Menu.pm | 6 ++++-
4 files changed, 69 insertions(+), 12 deletions(-)
- Log -----------------------------------------------------------------
commit 02d61651a0b3dbe6e820db51fff4c926dde05a97
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Wed Nov 18 10:55:40 2009 -0500
make menu links relative
diff --git a/lib/Prophet/Server.pm b/lib/Prophet/Server.pm
index 0361921..8a416b4 100644
--- a/lib/Prophet/Server.pm
+++ b/lib/Prophet/Server.pm
@@ -159,7 +159,7 @@ sub handle_request {
my ( $self, $cgi ) = validate_pos( @_, { isa => 'Prophet::Server' }, { isa => 'CGI' } );
$self->cgi($cgi);
$self->log_request();
- $self->nav( Prophet::Web::Menu->new( cgi => $self->cgi ) );
+ $self->nav( Prophet::Web::Menu->new( cgi => $self->cgi, server => $self) );
$self->result( Prophet::Web::Result->new() );
if ( $ENV{'PROPHET_DEVEL'} ) {
require Module::Refresh;
@@ -419,4 +419,17 @@ sub _send_redirect {
return '302';
}
+=head2 make_link_relative PATH
+
+This method does its best to convert a URI path from absolute ( starts
+at / ) to relative. (Starts at .).
+
+=cut
+
+sub make_link_relative {
+ my $self = shift;
+ my $link = shift;
+ return URI::file->new($link)->rel("file://".$self->cgi->path_info());
+}
+
1;
diff --git a/lib/Prophet/Server/View.pm b/lib/Prophet/Server/View.pm
index 1320857..252231c 100644
--- a/lib/Prophet/Server/View.pm
+++ b/lib/Prophet/Server/View.pm
@@ -5,7 +5,7 @@ package Prophet::Server::View;
use base 'Template::Declare';
use Template::Declare::Tags;
-
+use URI::file;
# Prophet::Server::ViewHelpers overwrites the form {} function provided by
# Template::Declare::Tags. ViewHelpers uses Exporter::Lite which does not "use
# warnings". When prove -w or make test is run, $^W is set which turns on
@@ -109,10 +109,10 @@ template head => sub {
'http-equiv' => "Content-Type" }};
title { shift @args };
for ( $self->server->css ) {
- link { { rel is 'stylesheet', href is $_, type is "text/css", media is 'screen'} };
+ link { { rel is 'stylesheet', href is link_to($_), type is "text/css", media is 'screen'} };
}
for ( $self->server->js ) {
- script { { src is $_, type is "text/javascript" } };
+ script { { src is link_to($_), type is "text/javascript" } };
}
}
@@ -175,7 +175,7 @@ sub record_table {
if ($i == 0) {
a {
attr {
- href => "$prefix$uuid.html",
+ href => link_to("$prefix$uuid.html"),
};
outs $atom->{value};
}
@@ -205,7 +205,7 @@ template record => page {
p {
a {
attr {
- href => "index.html",
+ href => link_to("index.html"),
};
outs "index";
}
@@ -312,5 +312,9 @@ sub generate_changeset_feed {
return $feed;
}
+sub link_to ($) {
+ my $link = shift;
+ return URI::file->new($link)->rel("file://".$ENV{REQUEST_URI});
+}
1;
diff --git a/lib/Prophet/Web/Menu.pm b/lib/Prophet/Web/Menu.pm
index de0e826..1a0f8bf 100644
--- a/lib/Prophet/Web/Menu.pm
+++ b/lib/Prophet/Web/Menu.pm
@@ -12,6 +12,8 @@ has url => ( isa => 'Str', is => 'bare');
has target => ( isa => 'Str', is => 'rw');
has class => ( isa => 'Str', is => 'rw');
has escape_label => ( isa => 'Bool', is => 'rw');
+has server => (isa => 'Prophet::Server', is => 'ro', weak_ref => 1);
+
=head1 NAME
@@ -98,9 +100,11 @@ sub url {
$self->{url} =~ s!///!/! if $self->{url};
- return $self->{url};
+ return $self->server->make_link_relative($self->{url});
}
+
+
=head2 active [BOOLEAN]
Gets or sets if the menu item is marked as active. Setting this
commit f62b1762e729320b815abf660b7d942eb8c80b7d
Author: franck cuny <franck at lumberjaph.net>
Date: Wed Nov 18 16:40:17 2009 +0100
check and store in config username and secret token
diff --git a/lib/Prophet/ForeignReplica.pm b/lib/Prophet/ForeignReplica.pm
index 810b40f..c9381fb 100644
--- a/lib/Prophet/ForeignReplica.pm
+++ b/lib/Prophet/ForeignReplica.pm
@@ -115,6 +115,16 @@ sub prompt_for_login {
@_,
);
+ #Â check if username is in config
+ my $replica_username = 'replica.' . $self->{url} . '.username';
+ my $replica_secret_token = 'replica.' . $self->{url} . '.secret_token';
+
+ if ( !$args{username} ) {
+ my $check_username
+ = $self->app_handle->config->get( key => $replica_username );
+ $args{username} = $check_username if $check_username;
+ }
+
my $secret;
my $was_in_pager = Prophet::CLI->in_pager();
@@ -129,12 +139,38 @@ sub prompt_for_login {
chomp( $args{username} = ReadLine 0 );
}
- print $args{secret_prompt}($args{uri}, $args{username});
- ReadMode 2;
- chomp( $secret = ReadLine 0 );
- ReadMode 1;
- print "\n";
+ if ( my $check_password
+ = $self->app_handle->config->get( key => $replica_secret_token ) )
+ {
+ $secret = $check_password;
+ }
+ else {
+ print $args{secret_prompt}( $args{uri}, $args{username} );
+ ReadMode 2;
+ chomp( $secret = ReadLine 0 );
+ ReadMode 1;
+ print "\n";
+ }
Prophet::CLI->start_pager() if ($was_in_pager);
+
+ # store username and secret token in config file
+ if ( !$self->app_handle->config->get( key => $replica_username ) ) {
+ print "Setting replica's username in the config file";
+ $self->app_handle->config->set(
+ key => $replica_username,
+ value => $args{username},
+ filename => $self->app_handle->config->origins->{
+ 'core.config-format-version'},
+ );
+ print "Setting replica's secret_token in the config file";
+ $self->app_handle->config->set(
+ key => $replica_secret_token,
+ value => $secret,
+ filename => $self->app_handle->config->origins->{
+ 'core.config-format-version'},
+ );
+ }
+
return ( $args{username}, $secret );
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list