[Jifty-commit] r1028 - in jifty/branches/jifty-jsan: . doc lib/Jifty/Script lib/Jifty/Web/Form share/web/static/css share/web/static/js share/web/templates/__jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue May 9 18:34:12 EDT 2006


Author: trs
Date: Tue May  9 18:34:10 2006
New Revision: 1028

Added:
   jifty/branches/jifty-jsan/doc/plugins-restated-assumptions
Modified:
   jifty/branches/jifty-jsan/   (props changed)
   jifty/branches/jifty-jsan/lib/Jifty/Action.pm
   jifty/branches/jifty-jsan/lib/Jifty/Config.pm
   jifty/branches/jifty-jsan/lib/Jifty/Handler.pm
   jifty/branches/jifty-jsan/lib/Jifty/Result.pm
   jifty/branches/jifty-jsan/lib/Jifty/Script/App.pm
   jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field.pm
   jifty/branches/jifty-jsan/share/web/static/css/base.css
   jifty/branches/jifty-jsan/share/web/static/css/forms.css
   jifty/branches/jifty-jsan/share/web/static/js/jifty.js
   jifty/branches/jifty-jsan/share/web/templates/__jifty/validator.xml

Log:
 r10393 at zot (orig r1024):  jesse | 2006-05-08 22:37:38 -0400
  r13323 at hualien:  jesse | 2006-05-08 22:36:22 -0400
  Support for "warnings" in addition to the existing "errors" and "validators" from Sean E. Millichamp
 
 r10394 at zot (orig r1025):  alexmv | 2006-05-09 13:20:24 -0400
  r12936 at zoq-fot-pik:  chmrr | 2006-05-09 13:19:53 -0400
   * We don't need a session directory anymore
 
 r10395 at zot (orig r1026):  jesse | 2006-05-09 14:10:39 -0400
  r13338 at hualien:  jesse | 2006-05-09 14:09:34 -0400
  * more plugin comments
 
 r10396 at zot (orig r1027):  jesse | 2006-05-09 14:10:47 -0400
  r13339 at hualien:  jesse | 2006-05-09 14:10:04 -0400
  
 


Added: jifty/branches/jifty-jsan/doc/plugins-restated-assumptions
==============================================================================
--- (empty file)
+++ jifty/branches/jifty-jsan/doc/plugins-restated-assumptions	Tue May  9 18:34:10 2006
@@ -0,0 +1,80 @@
+* Plugins should be able to provide
+
+    * New actions
+    * New templates
+    * New models?
+
+* Plugins should be configurable
+    * should be able to be told about your  
+        * actions
+        * templates
+        * models
+
+* Plugins should be able to add dispatcher rules
+
+* The application should be able to spec what order 
+  dispatcher rules are run in. This gets sticky. 
+
+* If you don't spec explicit dispatcher rule ordering, what do you get?
+
+    for each of (before, on, after) {
+        run the plugin rules in the order plugins are defined
+        run my app's rules
+
+    }
+
+
+
+        before plugin Jifty::Login => {
+            before 'login' => {
+                .....
+            }
+        }
+
+
+
+Plugins provide templates.
+
+
+    auto/Jifty/Plugin/Login/share  (module::sharedir. wherever it puts stuff)
+
+
+    plugins have a default path they expose templates at.
+
+    so, Plugin::Login would expose templates at
+
+    /=/Login/
+
+    That path is 100% overridable by the app when it loads the plugin
+
+    An app's content always overrides a plugin's content.
+
+    If two plugins provide PO files or (templates to the same location,
+        either a built in location or an app-driven location), the most
+        recently loaded plugin's content override the older plugin's
+        content.
+
+
+Anatomy of a plugin -  In the end, plugins are apps. and apps are plugins.
+
+
+Jifty::Plugin::<name>
+
+    t/
+    lib/
+        Jifty/
+            Plugin/
+                <name>.pm
+                <name>/
+                        Dispatcher.pm
+                        Action/
+                        Model/ 
+    share/
+        po/
+        web/
+            static/
+            templates/
+~
+
+We're defining mount points for templates
+

Modified: jifty/branches/jifty-jsan/lib/Jifty/Action.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Action.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Action.pm	Tue May  9 18:34:10 2006
@@ -507,6 +507,20 @@
   return 'errors-' . $self->form_field_name($field_name);
 }
 
+=head2 warning_div_id ARGUMENT
+
+Turn one of this action's L<arguments|Jifty::Manual::Glossary/arguments> into
+the id for the div in which its warnings live; takes name of the field
+as an argument.
+
+=cut
+
+sub warning_div_id {
+  my $self = shift;
+  my $field_name = shift;
+  return 'warnings-' . $self->form_field_name($field_name);
+}
+
 
 =head1 VALIDATION METHODS
 
@@ -821,6 +835,27 @@
     return 0;
 }
 
+=head2 validation_warning ARGUMENT => WARNING TEXT
+
+Used to report a warning during validation.  Inside a validator you
+should write:
+
+  return $self->validation_warning( $field => "warning");
+
+..where C<$field> is the name of the argument which is at fault.
+
+=cut
+
+sub validation_warning {
+    my $self = shift;
+    my $field = shift;
+    my $warning = shift;
+  
+    $self->result->field_warning($field => $warning); 
+  
+    return 0;
+}
+
 =head2 validation_ok ARGUMENT
 
 Used to report that a field B<does> validate.  Inside a validator you

Modified: jifty/branches/jifty-jsan/lib/Jifty/Config.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Config.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Config.pm	Tue May  9 18:34:10 2006
@@ -235,7 +235,6 @@
             Web        => {
                 Port => '8888',
                 BaseURL => 'http://localhost',
-                SessionDir  => "var/session",
                 DataDir     => "var/mason",
                 StaticRoot   => "share/web/static",
                 TemplateRoot => "share/web/templates",

Modified: jifty/branches/jifty-jsan/lib/Jifty/Handler.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Handler.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Handler.pm	Tue May  9 18:34:10 2006
@@ -62,15 +62,14 @@
 
 =head2 create_cache_directories
 
-Attempts to create our app's session storage and mason cache directories.
+Attempts to create our app's mason cache directory.
 
 =cut
 
 sub create_cache_directories {
     my $self = shift;
 
-    for ( Jifty->config->framework('Web')->{'SessionDir'},
-          Jifty->config->framework('Web')->{'DataDir'}) {
+    for ( Jifty->config->framework('Web')->{'DataDir'} ) {
         Jifty::Util->make_path( Jifty::Util->absolute_path($_) );
     }
 }

Modified: jifty/branches/jifty-jsan/lib/Jifty/Result.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Result.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Result.pm	Tue May  9 18:34:10 2006
@@ -109,6 +109,32 @@
     return %{$self->{field_errors}};
 }
 
+=head2 field_warning FIELD [WARNING]
+
+Gets or sets the warning string for a specific field on the action.
+
+=cut
+
+sub field_warning {
+    my $self = shift;
+    my $field = shift;
+
+    $self->{field_warnings}{ $field } = shift if @_;
+    return $self->{field_warnings}{ $field };
+}
+
+=head2 field_warnings
+
+Returns a hash which maps L<argument|Jifty::Manual::Glossary/argument>
+name to warning.
+
+=cut
+
+sub field_warnings {
+    my $self = shift;
+    return %{$self->{field_warnings}};
+}
+
 =head2 content [KEY [, VALUE]]
 
 Gets or sets the content C<KEY>.  This is used when actions need to

Modified: jifty/branches/jifty-jsan/lib/Jifty/Script/App.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Script/App.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Script/App.pm	Tue May  9 18:34:10 2006
@@ -130,7 +130,6 @@
         doc
         log
         var
-        var/sessions
         var/mason
         share
         share/po

Modified: jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field.pm	Tue May  9 18:34:10 2006
@@ -279,8 +279,8 @@
 =head2 render
 
 Outputs this form element in a span with class C<form_field>.  This
-outputs the label, the widget itself, any hints, and any errors, using
-L</render_label>, L</render_widget>, L</render_hints>,
+outputs the label, the widget itself, any hints, any errors, and any
+warnings using L</render_label>, L</render_widget>, L</render_hints>,
 L</render_errors> respectively.  Returns an empty string.
 
 This is also what C<Jifty::Web::Form::Field>s do when stringified.
@@ -300,6 +300,7 @@
         $self->render_key_binding();
         $self->render_hints();
         $self->render_errors();
+        $self->render_warnings();
     } elsif ($self->render_mode eq 'read'){ 
         $self->render_value();
     }
@@ -512,4 +513,22 @@
     return '';
 }
 
+=head2 render_warnings
+
+Outputs a <div> with any warnings for this action, even if there are
+none -- AJAX could fill it in.
+
+=cut
+
+sub render_warnings {
+    my $self = shift;
+
+    return unless $self->action;
+
+    Jifty->web->out(
+qq!<span class="warning @{[$self->classes]}" id="@{[$self->action->warning_div_id($self->name)]}">@{[  $self->action->result->field_warning( $self->name ) || '']}</span>\n!
+    );
+    return '';
+}
+
 1;

Modified: jifty/branches/jifty-jsan/share/web/static/css/base.css
==============================================================================
--- jifty/branches/jifty-jsan/share/web/static/css/base.css	(original)
+++ jifty/branches/jifty-jsan/share/web/static/css/base.css	Tue May  9 18:34:10 2006
@@ -8,6 +8,10 @@
     color: #a00000;
 }
 
+.warning {
+    color: #00a0a0;
+}
+
 hr {
     clear: both;
 } 

Modified: jifty/branches/jifty-jsan/share/web/static/css/forms.css
==============================================================================
--- jifty/branches/jifty-jsan/share/web/static/css/forms.css	(original)
+++ jifty/branches/jifty-jsan/share/web/static/css/forms.css	Tue May  9 18:34:10 2006
@@ -31,7 +31,7 @@
     color: #999999;
 }
 
-div.form_field .error {
+div.form_field .error, div.form_field .warning {
     float: right;
     width: 88%;
     text-align: left;

Modified: jifty/branches/jifty-jsan/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/jifty-jsan/share/web/static/js/jifty.js	(original)
+++ jifty/branches/jifty-jsan/share/web/static/js/jifty.js	Tue May  9 18:34:10 2006
@@ -110,8 +110,9 @@
                             for (var field = action.firstChild; field != null; field = field.nextSibling) {
                                 // Possibilities for field.nodeName: it could be #text (whitespace),
                                 // or 'blank' (the field was blank, don't mess with the error div), or 'ok'
-                                // (clear the error div!) or 'error' (fill in the error div!)
-                                if (field.nodeName == 'error') {
+                                // (clear the error and warning div!) or 'error' (fill in the error div, clear 
+				// the warning div!) or 'warning' (fill in the warning div and clear the error div!)
+                                if (field.nodeName == 'error' || field.nodeName == 'warning') {
                                     var err_div = document.getElementById(field.getAttribute("id"));
                                     if (err_div != null) {
                                         err_div.innerHTML = field.firstChild.data;

Modified: jifty/branches/jifty-jsan/share/web/templates/__jifty/validator.xml
==============================================================================
--- jifty/branches/jifty-jsan/share/web/templates/__jifty/validator.xml	(original)
+++ jifty/branches/jifty-jsan/share/web/templates/__jifty/validator.xml	Tue May  9 18:34:10 2006
@@ -12,17 +12,28 @@
     for my $arg ( $action->argument_names ) {
         if ( not $action->arguments->{$arg}->{ajax_validates} ) {
             $writer->emptyTag( "ignored", id => $action->error_div_id($arg) );
+            $writer->emptyTag( "ignored", id => $action->warning_div_id($arg) );
         } elsif ( not defined $action->argument_value($arg)
             or length $action->argument_value($arg) == 0 ) {
             $writer->emptyTag( "blank", id => $action->error_div_id($arg) );
+            $writer->emptyTag( "blank", id => $action->warning_div_id($arg) );
         } elsif ( $action->result->field_error($arg) ) {
             $writer->dataElement(
                 "error",
                 $action->result->field_error($arg),
                 id => $action->error_div_id($arg)
             );
+            $writer->emptyTag( "ok", id => $action->warning_div_id($arg) );
+        } elsif ( $action->result->field_warning($arg) ) {
+            $writer->dataElement(
+                "warning",
+                $action->result->field_warning($arg),
+                id => $action->warning_div_id($arg)
+            );
+            $writer->emptyTag( "ok", id => $action->error_div_id($arg) );
         } else {
             $writer->emptyTag( "ok", id => $action->error_div_id($arg) );
+            $writer->emptyTag( "ok", id => $action->warning_div_id($arg) );
         }
     }
     $writer->endTag();


More information about the Jifty-commit mailing list