[Jifty-commit] r2832 - in jifty/branches/template-declare: . lib/Jifty/Plugin/AdminUI lib/Jifty/View/Declare share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/_elements share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/action share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/model share/web

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Feb 23 17:25:49 EST 2007


Author: jesse
Date: Fri Feb 23 17:25:48 2007
New Revision: 2832

Added:
   jifty/branches/template-declare/lib/Jifty/Plugin/AdminUI/View-not-yet.pm
      - copied unchanged from r2831, /jifty/branches/template-declare/lib/Jifty/Plugin/AdminUI/View.pm
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/_elements/
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/_elements/nav   (contents, props changed)
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/action/
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/action/dhandler
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/autohandler
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/header
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/list
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/new_item
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/search
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/update
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/view
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/index.html
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/model/
   jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/model/dhandler
   jifty/branches/template-declare/share/web/transform_templates
Removed:
   jifty/branches/template-declare/lib/Jifty/Plugin/AdminUI/View.pm
   jifty/branches/template-declare/lib/Jifty/View/Declare/Yullio.pm
Modified:
   jifty/branches/template-declare/   (props changed)
   jifty/branches/template-declare/lib/Jifty/Handler.pm

Log:
 r48501 at 233:  jesse | 2007-02-23 17:21:17 -0500
 * Working admin UI on the T::D branch
 


Modified: jifty/branches/template-declare/lib/Jifty/Handler.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Handler.pm	(original)
+++ jifty/branches/template-declare/lib/Jifty/Handler.pm	Fri Feb 23 17:25:48 2007
@@ -138,7 +138,7 @@
     for my $plugin (Jifty->plugins) {
         my $comp_root = $plugin->template_root;
         unless  ( $comp_root and -d $comp_root) {
-            Jifty->log->debug( "Plugin @{[ref($plugin)]} doesn't appear to have a valid mason template component root ($comp_root)");
+            Jifty->log->debug( "Plugin @{[ref($plugin)]} doesn't appear to have a valid mason template component root (@{[$comp_root ||'']})");
             next;
         }
         push @{ $config{comp_root} }, [ ref($plugin)."-".Jifty->web->serial => $comp_root ];

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/_elements/nav
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/_elements/nav	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,11 @@
+<%init>
+
+my $nav = Jifty->web->navigation->child("Administration" => url => '/__jifty/admin/');
+foreach my $model (Jifty->class_loader->models) {
+    next unless $model->isa('Jifty::Record');
+    next unless ($model =~ /^(?:.*)::(.*?)$/);
+    my $type = $1;
+    $nav->child($type   => url => '/__jifty/admin/model/'.$type);
+}
+return;
+</%init>

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/action/dhandler
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/action/dhandler	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,27 @@
+<%init>
+my $action_class = Jifty->api->qualify($m->dhandler_arg);
+
+my $action = Jifty->web->new_action(
+    class   => $action_class,
+    moniker => "run-$action_class",
+);
+
+$action->sticky_on_failure(1);
+
+</%init>
+<&|/_elements/wrapper &>
+
+<% Jifty->web->form->start %>
+
+% for ($action->argument_names) {
+<% $action->form_field($_) %>
+% }
+
+<% Jifty->web->form->submit( label => _("Run the action") ) %>
+
+<% Jifty->web->form->end %>
+
+<h2>Done?</h2>
+<% Jifty->web->link( url => "/__jifty/admin/", label => _('Back to the admin console')) %>
+
+</&>

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/autohandler
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/autohandler	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,10 @@
+<%init>
+
+# If "AdminMode" is turned off in Jifty's config file, don't let people at the admin UI.
+unless (Jifty->config->framework('AdminMode')) {
+    $m->redirect('/__jifty/error/permission_denied'); 
+    $m->abort();
+}
+$m->comp('_elements/nav');
+$m->call_next();
+</%init>

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/header
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/header	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,61 @@
+<%args>
+$object_type
+$mask_val => ""
+$mask_field => ""
+$sort_by => ""
+$order => ""
+$list_path
+</%args>
+<%init>
+my $record_class = Jifty->app_class("Model", $object_type);
+my $record = $record_class->new();
+ my $update = Jifty->web->new_action(class => 'Update'.$object_type);
+</%init>
+<div class="jifty_admin_header">
+
+% foreach my $argument ($update->argument_names) {
+% unless( $argument eq $mask_field ||  $argument eq 'id' || $argument =~ /_confirm$/i
+%        && lc $update->arguments->{$argument}{render_as} eq 'password') {
+<span class="<% ($sort_by && !$order && $sort_by eq $argument)?'up_select':'up' %>">
+<%
+    Jifty->web->link(
+        label   => _("asc"),
+        onclick => 
+            { 
+            replace_with => $list_path.'list' ,
+            args   => {
+                object_type => $object_type,
+                limit_val => $mask_val,
+                limit_field => $mask_field,
+                list_path => $list_path,
+                sort_by => $argument,
+                order => undef
+                },
+            },
+        #as_button => 1
+        )
+%></span>
+<span class="<% ($sort_by && $order && $sort_by eq $argument )?'down_select':'down' %>">
+<%
+    Jifty->web->link(
+        label   => _("desc"),
+        onclick => 
+            {
+            replace_with => $list_path.'list',
+            args   => {
+                object_type => $object_type,
+                limit_val => $mask_val,
+                limit_field => $mask_field,
+                list_path => $list_path,
+                sort_by => $argument,
+                order => 'D'
+                },
+            },
+        #as_button => 1
+        )
+%></span>
+<span class="field"><% $argument %></span>
+% }
+% }
+<hr />
+</div>

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/list
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/list	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,128 @@
+<%doc>
+
+You can copy this fragment directory to your app.
+And use it in a page like this :
+
+<% Jifty->web->region(name => "admin-subdomain",
+                      path => "/admin/fragments/list/list",
+                      defaults => { object_type => 'SubDomain',
+                                    list_path => '/admin/fragments/list/',
+                                    limit_field => 'domain',
+                                    limit_val => $domain,
+                                    search_slot => 0
+                                    per_page => 5,
+                                    render_submit => 1 }) %>
+
+limit_field, limit_val allow add to your sql query 
+ ... WHERE $limit_field = $limit_val
+so you can make "sub views" on a table limited by limit_field / limit_val
+
+</%doc>
+<%args>
+$object_type
+$page => 1
+$new_slot => 1
+$search_slot => 1
+$item_path => "/__jifty/admin/fragments/list/view"
+$list_path => "/__jifty/admin/fragments/list/"
+$limit_field => ""
+$limit_val => ""
+$per_page => 25
+$sort_by => undef
+$order => undef
+</%args>
+<%init>
+my $collection_class = Jifty->app_class("Model", $object_type."Collection");
+my $search = Jifty->web->response->result('search');
+my $collection = $collection_class->new();
+
+if(!$search) {
+   if ( $limit_field && $limit_val ) {
+      $collection->limit(column => $limit_field, value => $limit_val);
+   } else {
+      $collection->unlimit();
+   }
+   $collection->order_by(column => $sort_by, order=>'ASC') if ($sort_by && !$order);
+   $collection->order_by(column => $sort_by, order=>'DESC') if ($sort_by && $order);
+} else {
+    $collection = $search->content('search');
+    warn $collection->build_select_query;
+}
+
+$collection->set_page_info( current_page => $page,
+                            per_page     => $per_page
+                           );
+</%init>
+% if ($search_slot) {
+<%perl>    
+my $search_region = Jifty::Web::PageRegion->new(
+   name     => 'search',
+   path     => '/__jifty/empty',
+);
+</%perl>
+
+<% Jifty->web->link(
+    onclick => [{
+        region       => $search_region->qualified_name,
+        replace_with => $list_path.'search',
+        toggle       => 1,
+        args         => { object_type => $object_type }
+    },
+    ],
+    label => _('Toggle search')
+  )
+%>
+
+<% $search_region->render %>
+% }
+
+% if ($collection->pager->last_page > 1) {
+    <span class="page-count"><%_('Page %1 of %2', $page, $collection->pager->last_page) %></span>   
+% }
+
+<div class="list">
+% if ($collection->pager->total_entries == 0) {
+ <% _('No items found') %>
+% } else {
+  <% _('%1 entries', $collection-> count) %> 
+  <& $list_path.'header', object_type => $object_type, list_path => $list_path, 
+    mask_field => $limit_field, mask_val => $limit_val, sort_by => $sort_by, order => $order &>
+% }
+
+<%perl>
+while ( my $item = $collection->next ) {
+    Jifty->web->region(
+        name     => 'item-' . $item->id,
+        path     => $item_path,
+        defaults => { id => $item->id, object_type => $object_type, list_path => $list_path,
+                      mask_field => $limit_field , mask_val => $limit_val }
+    );
+}
+
+</%perl>
+</div>
+
+<div class="paging">
+% if ($collection->pager->previous_page) {
+<span class="prev-page">
+  <% Jifty->web->link( label => _("Previous Page"), onclick => { args => { page => $collection->pager->previous_page } } ) %>
+</span>
+% }
+% if ($collection->pager->next_page) {
+<span class="next-page">
+  <% Jifty->web->link( label => _("Next Page"), onclick => { args => { page => $collection->pager->next_page } } ) %>
+</span>
+% }
+</div>
+
+% if ($new_slot) {
+<% Jifty->web->region(
+        name => 'new_item',
+        path => $list_path.'new_item',
+        defaults => {   object_type => $object_type, list_path => $list_path,
+                     mask_field => $limit_field , mask_val => $limit_val },
+        ) %>
+
+% }
+
+

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/new_item
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/new_item	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,47 @@
+<%args>
+$object_type 
+$region
+$mask_field => ""
+$mask_val => ""
+$list_path
+</%args>
+<%init>
+my $record_class = Jifty->app_class("Model", $object_type);
+my $create = Jifty->web->new_action(class => 'Create'.$object_type);
+</%init>
+% if ($mask_field) {
+  <% $create->hidden($mask_field,$mask_val) %>
+% }
+<div class="jifty_admin create item inline">
+% foreach my $argument ($create->argument_names) {
+%  if ( $argument ne $mask_field ) {
+        <%$create->form_field($argument)%>
+%  }
+%}
+</div>
+<%
+
+Jifty->web->form->submit(
+    label    => _('Create'),
+    onclick  => [
+                 { submit => $create },
+                 { refresh_self => 1 },
+                 {
+                   element => $region->parent->get_element('div.list'),
+                   append => $list_path.'view',
+                   args   => { 
+                              object_type => $object_type,
+                              list_path => $list_path,
+                              id          => { result_of => $create, name => 'id' },
+                             },
+                 },
+                ]
+    ) %>
+
+<%doc>
+
+When you hit "save" and create a item, you want to put a fragment
+containing the new item in the associated list and refresh the current
+fragment
+
+</%doc>

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/search
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/search	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,27 @@
+<%args>
+$object_type
+</%args>
+<%init>
+my $search = Jifty->web->new_action(
+    class             => "Search".$object_type,
+    moniker           => "search",
+    sticky_on_success => 1,
+);
+
+</%init>
+<div class="jifty_admin">
+% for my $arg ($search->argument_names) {
+ <% $search->form_field($arg) %>
+% }
+
+<% $search->button(
+    label   => _('Search'),
+    onclick => {
+        submit  => $search,
+        refresh => Jifty->web->current_region->parent,
+        args    => { page => 1}
+    }
+  )
+%>
+<hr />
+</div>

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/update
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/update	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,52 @@
+<%args>
+$id => undef
+$object_type
+$mask_field => ""
+$mask_val => ""
+$list_path
+</%args>
+<%init>
+my $record_class = Jifty->app_class("Model", $object_type);
+my $record = $record_class->new();
+$record->load($id);
+my $update = Jifty->web->new_action(
+    class   => "Update".$object_type,
+    moniker => "update-" . Jifty->web->serial,
+    record  => $record
+);
+</%init>
+<div class="jifty_admin update item inline <%$object_type%>">
+<div class="editlink">
+  <% Jifty->web->link(
+      label   => _('Save'),
+      onclick => [
+          { submit => $update },
+          {   replace_with => $list_path.'view',
+              args         => { object_type => $object_type, id => $id, list_path => $list_path }
+          }
+      ]
+      ) %>
+
+  <% Jifty->web->link(
+      label     => _('Cancel'),
+      onclick   => {
+          replace_with => $list_path.'view',
+          args         => { object_type => $object_type, id => $id, list_path => $list_path }
+        },
+      as_button => 1
+  ) %>
+
+</div>
+
+% if ($mask_field) {
+<% $update->hidden($mask_field, $mask_val) %>
+% }
+% foreach my $argument ($update->argument_names) {
+%  if ( $argument ne $mask_field ) {
+<%$update->form_field($argument)%>
+%  }
+%}
+
+<hr />
+</div>
+

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/view
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/fragments/list/view	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,61 @@
+<%args>
+$id => undef
+$object_type
+$mask_field => ""
+$mask_val => ""
+$list_path
+</%args>
+<%init>
+my $record_class = Jifty->app_class("Model", $object_type);
+my $record = $record_class->new();
+$record->load($id);
+my $update = Jifty->web->new_action(
+    class   => "Update".$object_type,
+    moniker => "update-" . Jifty->web->serial,
+    record  => $record
+);
+my $delete = Jifty->web->new_action(
+    class   => "Delete".$object_type,
+    moniker => "delete-" . Jifty->web->serial,
+    record  => $record
+);
+
+</%init>
+<div class="jifty_admin read item inline">
+  
+<%
+    Jifty->web->form->submit(
+        class   => "editlink",
+        label   => _('Delete'),
+        onclick => [
+         { confirm => _("Confirm delete?")},
+         { submit => $delete },
+         { delete =>  Jifty->web->current_region->qualified_name }
+        ]
+        )
+%> 
+
+<%
+    Jifty->web->link(
+        label   => _('Edit'),
+        class   => "editlink",
+        onclick => {
+            replace_with => $list_path.'update',
+            args         => { object_type => $object_type, id => $id, list_path => $list_path,
+                            mask_field => $mask_field, mask_val => $mask_val }
+            },
+   #     as_button => 1
+        )
+%>
+
+<% $delete->hidden('id',$id) %>
+% foreach my $argument ($update->argument_names) {
+% unless( $argument eq $mask_field ||  $argument =~ /_confirm$/
+%        && lc $update->arguments->{$argument}{render_as} eq 'password') {
+  <%$update->form_field($argument, render_mode => 'read')%>
+% }
+% }
+
+<hr />
+</div>
+

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/index.html
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/index.html	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,31 @@
+<&| /_elements/wrapper, title => _('Jifty Administrative Console') &>
+
+<h1><% _('Database Administration') %></h1>
+
+<p><% _('This console lets you manage the records in your Jifty database. Below, you should see a list of all your database tables. Feel free to go through and add, delete or modify records.') %></p>
+
+<p><% _('To disable this administrative console, add "AdminMode: 0" under the "framework:" settings in the config file (etc/config.yml).') %></p>
+    
+<h2><% _('Models') %></h2>
+<ul>
+% foreach my $model (Jifty->class_loader->models) {
+% next unless $model->isa('Jifty::Record');
+% next unless ($model =~ /^(?:.*)::(.*?)$/);
+% my $type = $1;
+<li><% Jifty->web->link( url => '/__jifty/admin/model/'.$type, label => $type)%>
+%}
+</ul>
+
+<h2><% _('Actions') %></h2>
+<ul>
+% foreach my $action (Jifty->api->actions) {
+% Jifty::Util->require($action);
+% next if ( $action->can('autogenerated') and $action->autogenerated);
+<li><% Jifty->web->link( url => '/__jifty/admin/action/'.$action, label => $action) %></li>
+% }
+</ul>
+
+<h2><% _('Done?') %></h2>
+<% Jifty->web->return( to => "/", label => _('Back to the application')) %>
+
+</&>

Added: jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/model/dhandler
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/plugins/Jifty/Plugin/AdminUI/web/templates/__jifty/admin/model/dhandler	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,23 @@
+<%init>
+my $object_type = $m->dhandler_arg;
+
+my $collection_class =  Jifty->app_class("Model", $object_type."Collection");
+my $records = $collection_class->new();
+$records->unlimit;
+</%init>
+
+<&| /_elements/wrapper, title => _("Manage %1 records", $object_type) &>
+
+<h1><% _('Manage records:') %> <%$object_type%></h1>
+
+<% Jifty->web->form->start %>
+<% Jifty->web->region(name => "admin-$object_type",
+                      path => "/__jifty/admin/fragments/list/list", 
+                      defaults => { object_type => $object_type , 
+                                    render_submit => 1 }) %>
+<% Jifty->web->form->end %>
+
+<h2> <% _('Done?') %> </h2>
+<% Jifty->web->link( url => "/__jifty/admin/", label => _('Back to the admin console')) %>
+
+</&>

Added: jifty/branches/template-declare/share/web/transform_templates
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/web/transform_templates	Fri Feb 23 17:25:48 2007
@@ -0,0 +1,9 @@
+#!/usr/bin/perl 
+
+use warnings;
+use strict;
+
+my $lines = (join('',<STDIN>));
+$lines =~ s/\<(\w*?) (?:class="(.*?)")? (?:id="(.*?)")?\>/with { class => $2, id => $3 }, $1 { /g;
+print $lines;
+


More information about the Jifty-commit mailing list