[Jifty-commit] r3108 - in jifty/trunk: lib/Jifty
lib/Jifty/View/Declare lib/Jifty/View/Mason
plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Apr 6 12:11:45 EDT 2007
Author: jesse
Date: Fri Apr 6 12:11:45 2007
New Revision: 3108
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Handler.pm
jifty/trunk/lib/Jifty/View/Declare/Handler.pm
jifty/trunk/lib/Jifty/View/Mason/Handler.pm
jifty/trunk/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm
Log:
r54528 at dhcp207: jesse | 2007-04-07 00:49:58 +0900
*more refactorign to extract templating stuff
Modified: jifty/trunk/lib/Jifty/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/Handler.pm Fri Apr 6 12:11:45 2007
@@ -83,8 +83,8 @@
sub setup_view_handlers {
my $self = shift;
- $self->declare_handler( Jifty::View::Declare::Handler->new( $self->templatedeclare_config));
- $self->mason( Jifty::View::Mason::Handler->new( $self->mason_config ) );
+ $self->declare_handler( Jifty::View::Declare::Handler->new());
+ $self->mason( Jifty::View::Mason::Handler->new());
$self->static_handler(Jifty::View::Static::Handler->new());
}
@@ -104,84 +104,6 @@
}
-=head2 mason_config
-
-Returns our Mason config. We use the component root specified in the
-C<Web/TemplateRoot> framework configuration variable (or C<html> by
-default). Additionally, we set up a C<jifty> component root, as
-specified by the C<Web/DefaultTemplateRoot> configuration. All
-interpolations are HTML-escaped by default, and we use the fatal error
-mode.
-
-=cut
-
-sub mason_config {
- my %config = (
- static_source => 1,
- use_object_files => 1,
- preprocess => sub {
- # Force UTF-8 semantics on all our components by
- # prepending this block to all components as Mason
- # components defaults to parse the text as Latin-1
- ${$_[0]} =~ s!^!<\%INIT>use utf8;</\%INIT>\n!;
- },
- data_dir => Jifty::Util->absolute_path( Jifty->config->framework('Web')->{'DataDir'} ),
- allow_globals => [
- qw[ $JiftyWeb ],
- @{Jifty->config->framework('Web')->{'Globals'} || []},
- ],
- comp_root => [
- [application => Jifty::Util->absolute_path( Jifty->config->framework('Web')->{'TemplateRoot'} )],
- ],
- %{ Jifty->config->framework('Web')->{'MasonConfig'} },
- );
-
- for my $plugin (Jifty->plugins) {
- my $comp_root = $plugin->template_root;
- unless ( $comp_root and -d $comp_root) {
- next;
- }
- Jifty->log->debug( "Plugin @{[ref($plugin)]} mason component root added: (@{[$comp_root ||'']})");
- push @{ $config{comp_root} }, [ ref($plugin)."-".Jifty->web->serial => $comp_root ];
- }
- push @{$config{comp_root}}, [jifty => Jifty->config->framework('Web')->{'DefaultTemplateRoot'}];
-
- # In developer mode, we want halos, refreshing and all that other good stuff.
- if (Jifty->config->framework('DevelMode') ) {
- push @{$config{'plugins'}}, 'Jifty::Mason::Halo';
- $config{static_source} = 0;
- $config{use_object_files} = 0;
- }
- return %config;
-
-}
-
-
-=head2 templatedeclare_config
-
-=cut
-
-sub templatedeclare_config {
-
- my %config = (
- %{ Jifty->config->framework('Web')->{'TemplateDeclareConfig'} ||{}},
- );
-
- for my $plugin ( Jifty->plugins ) {
- my $comp_root = $plugin->template_class;
- Jifty::Util->require($comp_root);
- unless (defined $comp_root and $comp_root->isa('Template::Declare') ){
- next;
- }
- Jifty->log->debug( "Plugin @{[ref($plugin)]}::View added as a Template::Declare root");
- push @{ $config{roots} }, $comp_root ;
- }
-
- push @{$config{roots}}, Jifty->config->framework('TemplateClass');
-
- return %config;
-}
-
=head2 cgi
Returns the L<CGI> object for the current request, or C<undef> if
Modified: jifty/trunk/lib/Jifty/View/Declare/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/View/Declare/Handler.pm Fri Apr 6 12:11:45 2007
@@ -28,11 +28,37 @@
my $class = shift;
my $self = {};
bless $self,$class;
- Template::Declare->init(@_);
+
+ Template::Declare->init(@_ || $self->config());
return $self;
}
+=head2 config
+
+=cut
+
+sub config {
+
+ my %config = (
+ %{ Jifty->config->framework('Web')->{'TemplateDeclareConfig'} ||{}},
+ );
+
+ for my $plugin ( Jifty->plugins ) {
+ my $comp_root = $plugin->template_class;
+ Jifty::Util->require($comp_root);
+ unless (defined $comp_root and $comp_root->isa('Template::Declare') ){
+ next;
+ }
+ Jifty->log->debug( "Plugin @{[ref($plugin)]}::View added as a Template::Declare root");
+ push @{ $config{roots} }, $comp_root ;
+ }
+
+ push @{$config{roots}}, Jifty->config->framework('TemplateClass');
+
+ return %config;
+}
+
=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
Modified: jifty/trunk/lib/Jifty/View/Mason/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Mason/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/View/Mason/Handler.pm Fri Apr 6 12:11:45 2007
@@ -54,7 +54,7 @@
sub new {
my $package = shift;
- my %p = @_;
+ my %p = @_ || $package->config;
my $self = $package->SUPER::new( request_class => 'HTML::Mason::Request::Jifty',
out_method => \&out_method,
%p );
@@ -66,6 +66,57 @@
}
+=head2 config
+
+Returns our Mason config. We use the component root specified in the
+C<Web/TemplateRoot> framework configuration variable (or C<html> by
+default). Additionally, we set up a C<jifty> component root, as
+specified by the C<Web/DefaultTemplateRoot> configuration. All
+interpolations are HTML-escaped by default, and we use the fatal error
+mode.
+
+=cut
+
+sub config {
+ my %config = (
+ static_source => 1,
+ use_object_files => 1,
+ preprocess => sub {
+ # Force UTF-8 semantics on all our components by
+ # prepending this block to all components as Mason
+ # components defaults to parse the text as Latin-1
+ ${$_[0]} =~ s!^!<\%INIT>use utf8;</\%INIT>\n!;
+ },
+ data_dir => Jifty::Util->absolute_path( Jifty->config->framework('Web')->{'DataDir'} ),
+ allow_globals => [
+ qw[ $JiftyWeb ],
+ @{Jifty->config->framework('Web')->{'Globals'} || []},
+ ],
+ comp_root => [
+ [application => Jifty::Util->absolute_path( Jifty->config->framework('Web')->{'TemplateRoot'} )],
+ ],
+ %{ Jifty->config->framework('Web')->{'MasonConfig'} },
+ );
+
+ for my $plugin (Jifty->plugins) {
+ my $comp_root = $plugin->template_root;
+ unless ( $comp_root and -d $comp_root) {
+ next;
+ }
+ Jifty->log->debug( "Plugin @{[ref($plugin)]} mason component root added: (@{[$comp_root ||'']})");
+ push @{ $config{comp_root} }, [ ref($plugin)."-".Jifty->web->serial => $comp_root ];
+ }
+ push @{$config{comp_root}}, [jifty => Jifty->config->framework('Web')->{'DefaultTemplateRoot'}];
+
+ # In developer mode, we want halos, refreshing and all that other good stuff.
+ if (Jifty->config->framework('DevelMode') ) {
+ push @{$config{'plugins'}}, 'Jifty::Mason::Halo';
+ $config{static_source} = 0;
+ $config{use_object_files} = 0;
+ }
+ return %config;
+}
+
=head2 out_method
The default output method. Sets the content-type to C<text/html;
Modified: jifty/trunk/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm
==============================================================================
--- jifty/trunk/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm (original)
+++ jifty/trunk/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm Fri Apr 6 12:11:45 2007
@@ -104,7 +104,7 @@
my $path = $self->argument_value('source_path');
my $type = $self->argument_value('file_type');
my $out = '';
- my %cfg = Jifty->handler->mason_config;
+ my %cfg = Jifty->handler->mason->config;
my($local_template_base, $qualified_path);
if ($type eq "mason_component") {
More information about the Jifty-commit
mailing list