[Jifty-commit] r2895 - in jifty/branches/template-declare: .
lib/Jifty/Plugin lib/Jifty/Plugin/CompressedCSSandJS
lib/Jifty/Plugin/OnlineDocs lib/Jifty/Plugin/OnlineDocs/share
lib/Jifty/Plugin/User/Model lib/Jifty/View/Declare
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Mar 3 12:57:06 EST 2007
Author: jesse
Date: Sat Mar 3 12:57:05 2007
New Revision: 2895
Removed:
jifty/branches/template-declare/lib/Jifty/Plugin/OnlineDocs/View.pm
jifty/branches/template-declare/lib/Jifty/Plugin/OnlineDocs/share/
Modified:
jifty/branches/template-declare/ (props changed)
jifty/branches/template-declare/lib/Jifty/Dispatcher.pm
jifty/branches/template-declare/lib/Jifty/Plugin/AdminUI.pm
jifty/branches/template-declare/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm
jifty/branches/template-declare/lib/Jifty/Plugin/OnlineDocs.pm
jifty/branches/template-declare/lib/Jifty/Plugin/User/Model/User.pm
jifty/branches/template-declare/lib/Jifty/View/Declare/BaseClass.pm
jifty/branches/template-declare/lib/Jifty/View/Declare/Handler.pm
jifty/branches/template-declare/lib/Jifty/View/Declare/Helpers.pm
Log:
r52954 at pinglin: jesse | 2007-03-03 17:55:04 +0000
* First push at POD for all of the T::D branch
Modified: jifty/branches/template-declare/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Dispatcher.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Dispatcher.pm Sat Mar 3 12:57:05 2007
@@ -1139,7 +1139,7 @@
my $template = shift;
eval {
- my( $val) = Jifty->handler->declare_handler->resolve_template($template);
+ my( $val) = Jifty->handler->declare_handler->template_exists($template);
if ($val) {
Jifty->handler->declare_handler->show($template);
} else {
Modified: jifty/branches/template-declare/lib/Jifty/Plugin/AdminUI.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin/AdminUI.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/AdminUI.pm Sat Mar 3 12:57:05 2007
@@ -4,6 +4,19 @@
package Jifty::Plugin::AdminUI;
use base qw/Jifty::Plugin/;
+
+=head2 NAME
+
+Jifty::Plugin::AdminUI
+
+=head2 DESCRIPTION
+
+This plugin provides a basic administrative CRUD view for your application. It's included in every jifty application
+by default. While it's only accessible to the superuser, it's currently a bug that you can't disable it.
+
+=cut
+
+
# Your plugin goes here. If takes any configuration or arguments, you
# probably want to override L<Jifty::Plugin/init>.
Modified: jifty/branches/template-declare/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm Sat Mar 3 12:57:05 2007
@@ -1,8 +1,19 @@
+use warnings;
+use strict;
package Jifty::Plugin::CompressedCSSandJS::Dispatcher;
-use warnings;
-use strict;
+=head1 NAME
+
+Jifty::Plugin::CompressedCSSandJS::Dispatcher
+
+=head1 DESCRIPTION
+
+Adds dispatcher rules for C</__jifty/js/*> and C</__jifty/css/*/>,
+which serve out compiled and compressed CSS and Javascript rules.
+
+=cut
+
use Jifty::Dispatcher -base;
Modified: jifty/branches/template-declare/lib/Jifty/Plugin/OnlineDocs.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin/OnlineDocs.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/OnlineDocs.pm Sat Mar 3 12:57:05 2007
@@ -7,4 +7,14 @@
# Your plugin goes here. If takes any configuration or arguments, you
# probably want to override L<Jifty::Plugin/init>.
+=head1 NAME
+
+Jifty::Plugin::OnlineDocs
+
+=head1 DESCRIPTION
+
+This plugin provides superusers with online documentation for Jifty and your application's API. It's included by default when using Jifty. (That's a bug).
+
+=cut
+
1;
Modified: jifty/branches/template-declare/lib/Jifty/Plugin/User/Model/User.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin/User/Model/User.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/User/Model/User.pm Sat Mar 3 12:57:05 2007
@@ -4,6 +4,29 @@
package Jifty::Plugin::User::Model::User;
use Jifty::DBI::Schema;
+
+=head1 NAME
+
+Jifty::Plugin::User::Model::User
+
+=DESCRIPTION
+
+package MyApp::Model::User;
+
+use Jifty::DBI::Schema;
+
+use MyApp::Record schema {
+
+ # column definitions
+
+};
+
+use Jifty::Plugin::User::Model::User; # Imports two columns: name and username
+
+
+=cut
+
+
use base 'Jifty::DBI::Record::Plugin';
use Jifty::Plugin::User::Record schema {
column name => type is 'text', label is 'How should I display your name?';
Modified: jifty/branches/template-declare/lib/Jifty/View/Declare/BaseClass.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/View/Declare/BaseClass.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/View/Declare/BaseClass.pm Sat Mar 3 12:57:05 2007
@@ -25,4 +25,27 @@
}
}
+
+
1;
+__DATA__
+
+=head1 NAME
+
+Jifty::View::Declare::BaseClass
+
+=head1 DESCRIPTION
+
+This class provides a baseclass for your C<Template::Declare> derived view classes.
+
+
+=head1 METHODS
+
+=head2 show templatename arguments
+
+Render a C<Template::Declare> template.
+
+
+=cut
+
+=cut
Modified: jifty/branches/template-declare/lib/Jifty/View/Declare/Handler.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/View/Declare/Handler.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/View/Declare/Handler.pm Sat Mar 3 12:57:05 2007
@@ -9,7 +9,17 @@
__PACKAGE__->mk_accessors(qw/root_class/);
-=head2 show $package $template
+=head1 NAME
+
+Jifty::View::Declare::Handler
+
+=head1 METHODS
+
+
+=head2 new
+
+
+Initialize C<Template::Declare>. Passes all arguments to Template::Declare->init
=cut
@@ -22,16 +32,24 @@
return $self;
}
+
+=head2 show TEMPLATENAME
+
+Render a template. Expects that the template and any jifty methods called internally will end up being returned as a scalar, which we then print to STDOUT
+
+
+=cut
+
sub show {
my $self = shift;
- my $code_template = shift;
+ my $template = shift;
no warnings qw/redefine utf8/;
local *Jifty::Web::out = sub {
shift; # Turn the method into a function
goto &Template::Declare::Tags::outs_raw;
};
- my $content =Template::Declare::Tags::show($code_template);
+ my $content =Template::Declare::Tags::show($template);
unless ( Jifty->handler->apache->http_header_sent ||Jifty->web->request->is_subrequest ) {
Jifty->handler->apache->send_http_header();
}
@@ -39,6 +57,12 @@
return undef;
}
-sub resolve_template { my $pkg =shift; return Template::Declare->resolve_template(@_);}
+=head2 template_exists TEMPLATENAME
+
+Given a template name, returns true if the template is in any of our Template::Declare template libraries. Otherwise returns false.
+
+=cut
+
+sub template_exists { my $pkg =shift; return Template::Declare->resolve_template(@_);}
1;
Modified: jifty/branches/template-declare/lib/Jifty/View/Declare/Helpers.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/View/Declare/Helpers.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/View/Declare/Helpers.pm Sat Mar 3 12:57:05 2007
@@ -1,43 +1,98 @@
use warnings;
use strict;
+
package Jifty::View::Declare::Helpers;
use base qw/Exporter/;
use Template::Declare::Tags;
use base qw/Template::Declare/;
-our @EXPORT = (qw(form hyperlink tangent redirect new_action form_submit form_next_page page wrapper request get set render_param current_user render_action render_region ), @Template::Declare::Tags::EXPORT);
+our @EXPORT = (
+ qw(form hyperlink tangent redirect new_action form_submit form_next_page page wrapper request get set render_param current_user render_action render_region ),
+ @Template::Declare::Tags::EXPORT
+);
+
+
+=head1 NAME
+
+Jifty::View::Declare::Helpers
+
+=head1 DESCRIPTION
+
+This library provides mixins to help build your application's user interface.
+
+=head1 METHODS
+
+
+
+=cut
{
-no warnings qw/redefine/;
-sub form (&){
- my $code = shift;
- outs_raw(Jifty->web->form->start);
- $code->();
- outs_raw(Jifty->web->form->end);
- return ''
-}
+ no warnings qw/redefine/;
+
+
+=head2 form CODE
+
+Takes a subroutine reference or block of perl as its only argument and renders it as a Jifty C<form>.
+Bug: you can't currently specify arguments to form->start.
+
+
+=cut
+
+ sub form (&) {
+ my $code = shift;
+ outs_raw( Jifty->web->form->start );
+ $code->();
+ outs_raw( Jifty->web->form->end );
+ return '';
+ }
}
+=head2 hyperlink
+
+Shortcut for L<Jifty::Web/link>.
+
+=cut
+
sub hyperlink(@) {
- outs_raw(Jifty->web->link(@_));
+ outs_raw( Jifty->web->link(@_) );
return '';
}
+=head2 tangent
+
+Shortcut for L<Jifty::Web/tangent>.
+
+=cut
+
+
sub tangent(@) {
- outs_raw(Jifty->web->tangent(@_));
+ outs_raw( Jifty->web->tangent(@_) );
return '';
}
+
+=head2 redirect
+
+Shortcut for L<Jifty::Web/redirect>.
+
+=cut
+
sub redirect(@) {
Jifty->web->redirect(@_);
- return ''
+ return '';
}
-sub new_action(@){
+=head2 new_action
+
+Shortcut for L<Jifty::Web/new_action>.
+
+=cut
+
+sub new_action(@) {
return Jifty->web->new_action(@_);
}
-sub render_region(@){
+sub render_region(@) {
unshift @_, 'name' if @_ % 2;
Template::Declare->new_buffer_frame;
Jifty::Web::PageRegion->new(@_)->render;
@@ -46,51 +101,75 @@
Jifty->web->out($content);
}
-sub render_action(@){
- my ($action, $fields, $field_args) = @_;
+sub render_action(@) {
+ my ( $action, $fields, $field_args ) = @_;
my @f = $fields && @$fields ? @$fields : $action->argument_names;
foreach my $argument (@f) {
- outs_raw($action->form_field($argument, %$field_args));
+ outs_raw( $action->form_field( $argument, %$field_args ) );
}
}
-sub form_submit(@){
- outs_raw( Jifty->web->form->submit(@_));
+=head2 form_submit
+
+Shortcut for L<Jifty::Web::Form/submit>.
+
+=cut
+
+sub form_submit(@) {
+ outs_raw( Jifty->web->form->submit(@_) );
'';
}
-sub form_next_page(@){
+=head2 form_next_page
+
+Shortcut for L<Jifty::Web::Form/next_page>.
+
+=cut
+
+
+sub form_next_page(@) {
Jifty->web->form->next_page(@_);
}
+=head2 request
+
+Shortcut for L<Jifty::Web/request>.
+
+=cut
+
sub request {
Jifty->web->request;
}
+=head2 current_user
+
+Shortcut for L<Jifty::Web/current_user>.
+
+=cut
+
+
sub current_user {
Jifty->web->current_user;
}
sub get {
if (wantarray) {
- map { request->argument($_) } @_;
- }
- else {
- request->argument($_[0]);
+ map { request->argument($_) } @_;
+ } else {
+ request->argument( $_[0] );
}
}
sub set {
- while (my ($arg, $val) = (shift @_, shift @_)){
- request->argument($arg => $val);
+ while ( my ( $arg, $val ) = ( shift @_, shift @_ ) ) {
+ request->argument( $arg => $val );
}
}
-
sub render_param {
my $action = shift;
- outs_raw($action->form_field(@_));
+ outs_raw( $action->form_field(@_) );
return '';
}
@@ -104,7 +183,6 @@
};
}
-
sub wrapper ($) {
my $content_code = shift;
@@ -122,11 +200,9 @@
$done_header = Template::Declare->buffer->data;
Template::Declare->end_buffer_frame;
-
'';
};
-
my $wrapped_content_code = sub {
no warnings qw( uninitialized redefine once );
@@ -156,19 +232,19 @@
url => '/__jifty/admin/'
)
);
- }
+ }
}
Jifty->web->render_messages;
- $wrapped_content_code->();
+ $wrapped_content_code->();
show('/_elements/keybindings');
with( id => "jifty-wait-message", style => "display: none" ),
- div { _('Loading...') };
+ div { _('Loading...') };
# Jifty::Mason::Halo->render_component_tree if ( Jifty->config->framework('DevelMode') );
- # This is required for jifty server push. If you maintain your own
- # wrapper, make sure you have this as well.
+ # This is required for jifty server push. If you maintain your own
+ # wrapper, make sure you have this as well.
if ( Jifty->config->framework('PubSub')->{'Enable'}
&& Jifty::Subs->list )
{
@@ -177,12 +253,14 @@
};
};
- Template::Declare->buffer->data( $done_header . Template::Declare->buffer->data);
+ Template::Declare->buffer->data(
+ $done_header . Template::Declare->buffer->data );
}
sub render_header {
my ($title) = @_;
- outs_raw('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
+ outs_raw(
+ '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
. '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">' );
with( title => $title ), show('/_elements/header');
div {
@@ -191,9 +269,8 @@
url => "/",
label => _( Jifty->config->framework('ApplicationName') )
);
- with( class => "title" ), h1 { $title };
+ with( class => "title" ), h1 {$title};
};
}
-
1;
More information about the Jifty-commit
mailing list