[Jifty-commit] r3530 - in jifty/branches/trimclient: . doc/talks lib/Jifty lib/Jifty/Manual lib/Jifty/Plugin lib/Jifty/Plugin/Authentication/Password lib/Jifty/Plugin/Feedback lib/Jifty/Plugin/OpenID lib/Jifty/Plugin/OpenID/Action lib/Jifty/Plugin/SinglePage lib/Jifty/Plugin/SiteNews lib/Jifty/Plugin/SiteNews/View lib/Jifty/View/Declare lib/Jifty/Web lib/Jifty/Web/Form t/TestApp/lib/TestApp t/TestApp/share/web/templates/dispatch t/TestApp/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Jun 19 01:51:08 EDT 2007


Author: gugod
Date: Tue Jun 19 01:51:06 2007
New Revision: 3530

Added:
   jifty/branches/trimclient/t/TestApp/share/web/templates/dispatch/protocol
   jifty/branches/trimclient/t/TestApp/t/02-dispatch-http.t
   jifty/branches/trimclient/t/TestApp/t/02-dispatch-https.t
Removed:
   jifty/branches/trimclient/doc/talks/
Modified:
   jifty/branches/trimclient/   (props changed)
   jifty/branches/trimclient/lib/Jifty/Config.pm
   jifty/branches/trimclient/lib/Jifty/Dispatcher.pm
   jifty/branches/trimclient/lib/Jifty/Manual/Continuations.pod
   jifty/branches/trimclient/lib/Jifty/Plugin/Authentication/Password/View.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/CompressedCSSandJS.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/Feedback/View.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/OpenID.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Action/CreateOpenIDUser.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Dispatcher.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Mixin/Model/User.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/View.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/SinglePage.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/SinglePage/Dispatcher.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews/Dispatcher.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews/View/News.pm
   jifty/branches/trimclient/lib/Jifty/View/Declare/Page.pm
   jifty/branches/trimclient/lib/Jifty/Web.pm
   jifty/branches/trimclient/lib/Jifty/Web/Form/Link.pm
   jifty/branches/trimclient/lib/Jifty/Web/Session.pm
   jifty/branches/trimclient/t/TestApp/lib/TestApp/Dispatcher.pm

Log:
 r6808 at GOP (orig r3507):  jesse | 2007-06-16 00:07:40 +0800
 * Extracting talks from the jifty dist
 r6812 at GOP (orig r3514):  trs | 2007-06-18 04:53:50 +0800
  r24679 at zot:  tom | 2007-06-16 15:20:42 -0400
  HTTPS and HTTP adjectives for dispatcher rules
 
 r6813 at GOP (orig r3515):  trs | 2007-06-18 04:53:55 +0800
  r24680 at zot:  tom | 2007-06-16 16:41:16 -0400
  Allow scheme to be specified for Jifty->web->url.  This functionality was taken out during the move from "heuristics" to URI.pm, but for a non-apparent reason.
 
 r6814 at GOP (orig r3516):  trs | 2007-06-18 04:54:01 +0800
  r24683 at zot:  tom | 2007-06-17 16:49:49 -0400
  Now with more POD!  (and passing POD tests)
 
 r6815 at GOP (orig r3517):  trs | 2007-06-18 04:54:09 +0800
  r24684 at zot:  tom | 2007-06-17 16:53:22 -0400
  Fix typos
 
 r6825 at GOP (orig r3527):  bartb | 2007-06-18 17:25:24 +0800
 typo fix
 r6826 at GOP (orig r3528):  audreyt | 2007-06-18 23:03:37 +0800
 * Web::Form::Link - When escape_label was set, the tooltip property was
   (very sillily!) first escaped, then discarded away, displaying the
   unescaped text instead.  It now escapes properly.
 * Also make tooltips with value '0' display properly.
 r6827 at GOP (orig r3529):  trs | 2007-06-19 04:40:38 +0800
  r24704 at zot:  tom | 2007-06-18 16:40:03 -0400
  Allow app changeable cookie names
 


Modified: jifty/branches/trimclient/lib/Jifty/Config.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Config.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Config.pm	Tue Jun 19 01:51:06 2007
@@ -365,6 +365,7 @@
             Web => {
                 DefaultStaticRoot => Jifty::Util->share_root . '/web/static',
                 DefaultTemplateRoot => Jifty::Util->share_root . '/web/templates',
+                SessionCookieName => 'JIFTY_SID_$PORT',
             },
         }
     };

Modified: jifty/branches/trimclient/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Dispatcher.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Dispatcher.pm	Tue Jun 19 01:51:06 2007
@@ -160,7 +160,7 @@
 All wildcards in the C<$match> string becomes capturing regex patterns.  You
 can also pass in an array reference of matches, or a regex pattern.
 
-The C<$match> string may be qualified with a HTTP method name, such as
+The C<$match> string may be qualified with a HTTP method name or protocol, such as
 
 =over
 
@@ -176,6 +176,10 @@
 
 =item HEAD
 
+=item HTTPS
+
+=item HTTP
+
 =back
 
 =head2 on $match => $rule
@@ -263,6 +267,8 @@
 
     GET POST PUT HEAD DELETE OPTIONS
 
+    HTTPS HTTP
+
     plugin
 
     get next_rule last_rule
@@ -300,6 +306,9 @@
 sub DELETE ($)  { _qualify method => @_ }
 sub OPTIONS ($) { _qualify method => @_ }
 
+sub HTTPS ($)   { _qualify https  => @_ }
+sub HTTP ($)    { _qualify http   => @_ }
+
 sub plugin ($) { return { plugin => @_ } }
 
 our $CURRENT_STAGE;
@@ -929,6 +938,30 @@
     lc( $ENV{REQUEST_METHOD} ) eq lc($method);
 }
 
+=head2 _match_https
+
+Returns true if the current request is under SSL.
+
+=cut
+
+sub _match_https {
+    my $self = shift;
+    $self->log->debug("Matching request against HTTPS");
+    return exists $ENV{HTTPS} ? 1 : 0;
+}
+
+=head2 _match_http
+
+Returns true if the current request is not under SSL.
+
+=cut
+
+sub _match_http {
+    my $self = shift;
+    $self->log->debug("Matching request against HTTP");
+    return exists $ENV{HTTPS} ? 0 : 1;
+}
+
 sub _match_plugin {
     my ( $self, $plugin ) = @_;
     warn "Deferred check shouldn't happen";

Modified: jifty/branches/trimclient/lib/Jifty/Manual/Continuations.pod
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Manual/Continuations.pod	(original)
+++ jifty/branches/trimclient/lib/Jifty/Manual/Continuations.pod	Tue Jun 19 01:51:06 2007
@@ -167,7 +167,7 @@
 successful, calls the stored continuation, or, lacking one, redirects
 to C</protected>.
 
-As currently impelented, these redirect-from-dispatcher tangents works
+As currently implemented, these redirect-from-dispatcher tangents works
 exactly like rendered-as-links tangents, in that when they return,
 I<all> rules in the dispatcher are still executed from the start.
 Therefore the C<unless> guard in the C<before '/protected'> rule above

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/Authentication/Password/View.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/Authentication/Password/View.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/Authentication/Password/View.pm	Tue Jun 19 01:51:06 2007
@@ -8,7 +8,7 @@
 
 =head1 DESCRIPTION
 
-This code is only useful on the new Jifty "Declarative tempaltes" branch. It shouldn't get in the way 
+This code is only useful on the new Jifty "Declarative templates" branch. It shouldn't get in the way 
 if you're running a traditional (0.610 or before) Jifty.
 
 =cut

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/CompressedCSSandJS.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/CompressedCSSandJS.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/CompressedCSSandJS.pm	Tue Jun 19 01:51:06 2007
@@ -161,6 +161,12 @@
     }
 }
 
+=head2 minify_js \$js
+
+Runs the given JS through jsmin
+
+=cut
+
 sub minify_js {
     my $self = shift;
     my $input = shift;

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/Feedback/View.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/Feedback/View.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/Feedback/View.pm	Tue Jun 19 01:51:06 2007
@@ -4,6 +4,15 @@
 
 use Jifty::View::Declare -base;
 
+=head1 NAME
+
+Jifty::Plugin::Feedback::View
+
+=head1 DESCRIPTION
+
+Provides the feedback regions for L<Jifty::Plugin::Feedback>
+
+=cut
 
 template 'feedback/request_feedback' => sub {
     div {

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/OpenID.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/OpenID.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/OpenID.pm	Tue Jun 19 01:51:06 2007
@@ -4,4 +4,14 @@
 package Jifty::Plugin::OpenID;
 use base qw/Jifty::Plugin/;
 
+=head1 NAME
+
+Jifty::Plugin::OpenID
+
+=head1 DESCRIPTION
+
+Provides OpenID authentication for your app
+
+=cut
+
 1;

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Action/CreateOpenIDUser.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Action/CreateOpenIDUser.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Action/CreateOpenIDUser.pm	Tue Jun 19 01:51:06 2007
@@ -10,6 +10,12 @@
 package Jifty::Plugin::OpenID::Action::CreateOpenIDUser;
 use base qw/Jifty::Action::Record/;
 
+=head2 record_class 
+
+Returns the record class for this action
+
+=cut
+
 sub record_class {
     Jifty->app_class("Model", "User")
 }

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Dispatcher.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Dispatcher.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Dispatcher.pm	Tue Jun 19 01:51:06 2007
@@ -4,6 +4,16 @@
 package Jifty::Plugin::OpenID::Dispatcher;
 use Jifty::Dispatcher -base;
 
+=head1 NAME
+
+Jifty::Plugin::OpenID::Dispatcher
+
+=head1 DESCRIPTION
+
+Dispatcher for L<Jifty::Plugin::OpenID>.  Handles a lot of the work.
+
+=cut
+
 before qr'^/(?:openid/link)' => run {
     tangent('/openid/login') unless (Jifty->web->current_user->id)
 };

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Mixin/Model/User.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Mixin/Model/User.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/Mixin/Model/User.pm	Tue Jun 19 01:51:06 2007
@@ -5,6 +5,16 @@
 use base 'Jifty::DBI::Record::Plugin';
 use URI;
 
+=head1 NAME
+
+Jifty::Plugin::OpenID::Mixin::Model::User
+
+=head1 DESCRIPTION
+
+L<Jifty::Plugin::OpenID> mixin for the User model.  Provides an 'openid' column.
+
+=cut
+
 use Jifty::Plugin::OpenID::Record schema {
 
 our @EXPORT = qw(has_alternative_auth link_to_openid);
@@ -18,14 +28,26 @@
 
 };
 
+=head2 has_alternative_auth
+
+=cut
+
 sub has_alternative_auth { 1 }
 
+=head2 register_triggers
+
+=cut
+
 sub register_triggers {
     my $self = shift;
     $self->add_trigger(name => 'validate_openid', callback => \&validate_openid, abortable => 1);
     $self->add_trigger(name => 'canonicalize_openid', callback => \&canonicalize_openid);
 }
 
+=head2 validate_openid
+
+=cut
+
 sub validate_openid {
     my $self   = shift;
     my $openid = shift;
@@ -45,6 +67,10 @@
     return 1;
 }
 
+=head2 canonicalize_openid
+
+=cut
+
 sub canonicalize_openid {
     my $self   = shift;
     my $openid = shift;
@@ -60,6 +86,12 @@
     return $uri->canonical;
 }
 
+=head2 link_to_openid
+
+Links User's account to the specified OpenID (bypassing ACLs)
+
+=cut
+
 sub link_to_openid {
     my $self   = shift;
     my $openid = shift;

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/View.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/View.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/OpenID/View.pm	Tue Jun 19 01:51:06 2007
@@ -3,8 +3,18 @@
 use warnings;
 use Jifty::View::Declare -base;
 
+=head1 NAME
+
+Jifty::Plugin::OpenID::View
+
+=head1 DESCRIPTION
+
+The view class for L<Jifty::Plugin::OpenID>.  Provides login and create pages.
+
+=cut
+
 template 'openid/login' => page {
-    { title is _ "Login with your OpenID" }
+    { title is _("Login with your OpenID") }
     my $action = get('action');
 
     div {

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/SinglePage.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/SinglePage.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/SinglePage.pm	Tue Jun 19 01:51:06 2007
@@ -6,6 +6,20 @@
 
 __PACKAGE__->mk_accessors(qw(region_name));
 
+=head1 NAME
+
+Jifty::Plugin::SinglePage
+
+=head1 DESCRIPTION
+
+Makes your normal Jifty app into a single-page app through clever use of regions
+
+=head2 init
+
+Registers a before_new trigger to modify links and sets up the special region
+
+=cut
+
 sub init {
     my $self = shift;
     Jifty::Web::Form::Clickable->add_trigger( before_new => _sp_link($self));
@@ -33,12 +47,12 @@
                 args         => $args->{parameters}});
         }
         elsif (exists $args->{submit}) {
-	    $self->_push_onclick($args, { refresh_self => 1, submit => $args->{submit} });
-	    $args->{as_button} = 1;
-	}
+            $self->_push_onclick($args, { refresh_self => 1, submit => $args->{submit} });
+            $args->{as_button} = 1;
+        }
         if (my $form = delete $args->{_form}) {
-	    $args->{call} = $form->call;
-	}
+            $args->{call} = $form->call;
+        }
         my $onclick = $args->{onclick};
         if ( $args->{onclick} ) {
             $self->_push_onclick($args);    # make sure it's array

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/SinglePage/Dispatcher.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/SinglePage/Dispatcher.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/SinglePage/Dispatcher.pm	Tue Jun 19 01:51:06 2007
@@ -3,6 +3,16 @@
 use warnings;
 use Jifty::Dispatcher -base;
 
+=head1 NAME
+
+Jifty::Plugin::SinglePage::Dispatcher
+
+=head1 DESCRIPTION
+
+Dispatcher for L<Jifty::Plugin::SinglePage>
+
+=cut
+
 before '__jifty/webservices/*' => run {
     my (@actions) = grep { $_->class eq 'Jifty::Action::Redirect' } values %{ Jifty->web->request->{'actions'} };
     $_->active(0) for @actions;

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews.pm	Tue Jun 19 01:51:06 2007
@@ -3,5 +3,14 @@
 package Jifty::Plugin::SiteNews;
 use base qw'Jifty::Plugin';
 
+=head1 NAME
+
+Jifty::Plugin::SiteNews
+
+=head1 DESCRIPTION
+
+Provides a way to include site news in your Jifty app
+
+=cut
 
 1;

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews/Dispatcher.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews/Dispatcher.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews/Dispatcher.pm	Tue Jun 19 01:51:06 2007
@@ -4,6 +4,15 @@
 package Jifty::Plugin::SiteNews::Dispatcher;
 use base 'Jifty::Dispatcher';
 
+=head1 NAME
+
+Jifty::Plugin::SiteNews::Dispatcher
+
+=head1 DESCRIPTION
+
+Dispatcher for L<Jifty::Plugin::SiteNews>
+
+=cut
 
 
 

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews/View/News.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews/View/News.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/SiteNews/View/News.pm	Tue Jun 19 01:51:06 2007
@@ -5,10 +5,32 @@
 use Jifty::View::Declare -base;
 use Jifty::View::Declare::CRUD;
 
+=head1 NAME
+
+Jifty::Plugin::SiteNews::View::News
+
+=head1 DESCRIPTION
+
+The /news pages for L<Jifty::Plugin::SiteNews>
+
+=cut
+
 import_templates Jifty::View::Declare::CRUD under '/';
 
+=head2 object_type
+
+News
+
+=cut
+
 sub object_type { 'News' }
 
+=head2 fragment_base_path
+
+/news
+
+=cut
+
 sub fragment_base_path {'/news'}
 
 

Modified: jifty/branches/trimclient/lib/Jifty/View/Declare/Page.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/View/Declare/Page.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/View/Declare/Page.pm	Tue Jun 19 01:51:06 2007
@@ -21,6 +21,12 @@
 __PACKAGE__->mk_accessors(qw(content_code done_header _title));
 use constant allow_single_page => 1;
 
+=head2 new
+
+Sets up a new page class
+
+=cut
+
 sub new {
     my $class = shift;
     my $self = $class->SUPER::new(@_);
@@ -127,6 +133,12 @@
     };
 }
 
+=head2 render_title
+
+Renders the in-page title
+
+=cut
+
 sub render_title {
     my $self = shift;
     my $oldt = get('title');
@@ -135,12 +147,23 @@
     set( title => $oldt );
 }
 
+=head2 render_footer
+
+Renders the page footer and prepends the header to the L<Template::Declare> buffer.
+
+=cut
+
 sub render_footer {
     my $self = shift;
     outs_raw('</html>');
     Template::Declare->buffer->data( $self->done_header . Template::Declare->buffer->data );
 }
 
+=head2 render_pre_content_hook
+
+Renders the AdminMode alert (if AdminMode is on)
+
+=cut
 
 sub render_pre_content_hook {
     if ( Jifty->config->framework('AdminMode') ) {
@@ -156,6 +179,12 @@
     }
 }
 
+=head2 render_jifty_page_detritus
+
+Renders the keybinding and PubSub javascript as well as the wait message
+
+=cut
+
 sub render_jifty_page_detritus {
 
     show('keybindings');

Modified: jifty/branches/trimclient/lib/Jifty/Web.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Web.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Web.pm	Tue Jun 19 01:51:06 2007
@@ -127,10 +127,6 @@
                 path => undef,
                 @_);
 
-    if ($args{'scheme'}) {
-        $self->log->error("Jifty->web->url no longer accepts a 'scheme' argument");
-    }
-
     my $uri;
 
     # Try to get a host out of the environment, useful in remote testing.
@@ -167,6 +163,10 @@
       $uri->port($port);
     }
 
+    if ( defined $args{'scheme'} ) {
+        $uri->scheme( $args{'scheme'} );
+    }
+
     if (defined $args{path}) {
       my $path = $args{path};
       # strip off leading '/' because ->canonical provides one

Modified: jifty/branches/trimclient/lib/Jifty/Web/Form/Link.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Web/Form/Link.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Web/Form/Link.pm	Tue Jun 19 01:51:06 2007
@@ -101,12 +101,12 @@
 
     my $tooltip = $self->tooltip;
     $tooltip = Jifty->web->escape( $tooltip )
-        if ( $tooltip and $self->escape_label );
+        if ( defined $tooltip and $self->escape_label );
 
     Jifty->web->out(qq(<a));
     Jifty->web->out(qq( id="@{[$self->id]}"))         if $self->id;
     Jifty->web->out(qq( class="@{[$self->class]}"))   if $self->class;
-    Jifty->web->out(qq( title="@{[$self->tooltip]}")) if $tooltip;
+    Jifty->web->out(qq( title="@{[$tooltip]}"))       if defined $tooltip;
     Jifty->web->out(qq( target="@{[$self->target]}")) if $self->target;
     Jifty->web->out(qq( accesskey="@{[$self->key_binding]}")) if $self->key_binding;
     Jifty->web->out(qq( href="@{[Jifty->web->escape($self->url)]}"));

Modified: jifty/branches/trimclient/lib/Jifty/Web/Session.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Web/Session.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Web/Session.pm	Tue Jun 19 01:51:06 2007
@@ -10,7 +10,14 @@
 
 Jifty::Web::Session - A Jifty session handler
 
-=cut
+=head1 SYNOPSIS
+
+In your F<etc/config.yml> (optional):
+
+  framework:
+    Web:
+      # The default ($PORT is replaced by the port the app is running on)
+      SessionCookieName: JIFTY_SID_$PORT
 
 =head2 new
 
@@ -22,12 +29,13 @@
     my $class = shift;
 
     my $session_class = Jifty->config->framework('Web')->{'SessionClass'};
+    my $cookie_name   = Jifty->config->framework('Web')->{'SessionCookieName'};
     if ($session_class and $class ne $session_class) {
         Jifty::Util->require( $session_class );
         return $session_class->new(@_);
     }
     else {
-        return bless {}, $class;
+        return bless { _cookie_name => $cookie_name }, $class;
     }
 }
 
@@ -302,7 +310,9 @@
 
 sub cookie_name {
     my $self = shift;
-    my $cookie_name = "JIFTY_SID_" . ( $ENV{'SERVER_PORT'} || 'NOPORT' );
+    my $cookie_name = $self->{'_cookie_name'};
+    my $port = ( $ENV{'SERVER_PORT'} || 'NOPORT' );
+    $cookie_name =~ s/\$PORT/$port/g;
     return ($cookie_name);
 }
 

Modified: jifty/branches/trimclient/t/TestApp/lib/TestApp/Dispatcher.pm
==============================================================================
--- jifty/branches/trimclient/t/TestApp/lib/TestApp/Dispatcher.pm	(original)
+++ jifty/branches/trimclient/t/TestApp/lib/TestApp/Dispatcher.pm	Tue Jun 19 01:51:06 2007
@@ -82,4 +82,16 @@
     }
 };
 
+on HTTPS '/dispatch/protocol' => run {
+    set content => 'HTTPS';
+};
+
+on HTTP '/dispatch/protocol' => run {
+    set content => 'NOT HTTPS';
+};
+
+on '/dispatch/protocol' => run {
+    set footer => 'normal';
+};
+
 1;

Added: jifty/branches/trimclient/t/TestApp/share/web/templates/dispatch/protocol
==============================================================================
--- (empty file)
+++ jifty/branches/trimclient/t/TestApp/share/web/templates/dispatch/protocol	Tue Jun 19 01:51:06 2007
@@ -0,0 +1,3 @@
+<&| /_elements/wrapper, title => "Test of protocol adjectives" &>
+<% Jifty::YAML::Dump(\%ARGS) %>
+</&>

Added: jifty/branches/trimclient/t/TestApp/t/02-dispatch-http.t
==============================================================================
--- (empty file)
+++ jifty/branches/trimclient/t/TestApp/t/02-dispatch-http.t	Tue Jun 19 01:51:06 2007
@@ -0,0 +1,23 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+# Just in case
+BEGIN { delete $ENV{HTTPS}; }
+
+use lib 't/lib';
+use Jifty::SubTest;
+use Jifty::Test tests => 5;
+use Jifty::Test::WWW::Mechanize;
+
+my $server  = Jifty::Test->make_server;
+
+isa_ok($server, 'Jifty::Server');
+
+my $URL     = $server->started_ok;
+my $mech    = Jifty::Test::WWW::Mechanize->new();
+
+$mech->get_ok("$URL/dispatch/protocol", "Got /dispatch/protocol");
+$mech->content_contains("NOT HTTPS");
+$mech->content_contains("normal");
+

Added: jifty/branches/trimclient/t/TestApp/t/02-dispatch-https.t
==============================================================================
--- (empty file)
+++ jifty/branches/trimclient/t/TestApp/t/02-dispatch-https.t	Tue Jun 19 01:51:06 2007
@@ -0,0 +1,24 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+BEGIN { $ENV{HTTPS} = 1; }
+
+use lib 't/lib';
+use Jifty::SubTest;
+use Jifty::Test tests => 6;
+use Jifty::Test::WWW::Mechanize;
+
+my $server  = Jifty::Test->make_server;
+
+isa_ok($server, 'Jifty::Server');
+
+my $URL     = $server->started_ok;
+my $mech    = Jifty::Test::WWW::Mechanize->new();
+
+$mech->get_ok("$URL/dispatch/protocol", "Got /dispatch/protocol");
+$mech->content_contains("HTTPS");
+$mech->content_lacks("NOT");
+$mech->content_contains("normal");
+
+


More information about the Jifty-commit mailing list