Changeset 1412

Show
Ignore:
Timestamp:
08/19/06 18:26:07
Author:
miyagawa
Message:

Now assets_path: can be localized per plugins.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin.pm

    r1173 r1412  
    103103sub assets_dir { 
    104104    my $self = shift; 
     105    my $context = Plagger->context; 
    105106 
    106     my $context = Plagger->context; 
    107     my $assets_base = $context->conf->{assets_path} || File::Spec->catfile($FindBin::Bin, "assets"); 
     107    if ($self->conf->{assets_path}) { 
     108        return $self->conf->{assets_path}; # look at config:assets_path first 
     109    } 
     110 
     111    my $assets_base = 
     112        $context->conf->{assets_path} ||              # or global:assets_path 
     113        File::Spec->catfile($FindBin::Bin, "assets"); # or "assets" under plagger script 
     114 
    108115    return File::Spec->catfile( 
    109116        $assets_base, "plugins", $self->class_id, 
     
    133140    $vars->{context} ||= $context; 
    134141 
    135     my $template = Plagger::Template->new($context, $self->class_id); 
     142    my $template = Plagger::Template->new($context, $self); 
    136143    $template->process($file, $vars, \my $out) or $context->error($template->error); 
    137144 
  • trunk/plagger/lib/Plagger/Template.pm

    r346 r1412  
    1010 
    1111sub new { 
    12     my($class, $context, $plugin_class_id) = @_; 
     12    my($class, $context, $plugin) = @_; 
    1313 
    1414    my $path = $context->conf->{assets_path} || catfile($FindBin::Bin, "assets"); 
    15     my $paths = [ catfile($path, "plugins", $plugin_class_id), 
     15    my $paths = [ catfile($path, "plugins", $plugin->class_id), 
    1616                  catfile($path, "common") ]; 
     17 
     18    if ($plugin->conf->{assets_path}) { 
     19        unshift @$paths, $plugin->conf->{assets_path}; 
     20    } 
    1721 
    1822    return $class->SUPER::new({