Changeset 7371 for lang/perl/blosxom

Show
Ignore:
Timestamp:
03/02/08 14:32:20 (5 years ago)
Author:
nyarla
Message:

lang/perl/blosxom/blosxom.nyarla.cgi: pluginの読み込み順序を設定ファイルで指定できるように改造

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/blosxom/blosxom.nyarla.cgi

    r7365 r7371  
    3232    $datadir, $depth, $file_extension,      $flavour_dir, $default_flavour, 
    3333    # view                                  # plugins 
    34     $num_entries, $show_future_entries,     $plugin_dir, $plugin_state_dir, 
     34    $num_entries, $show_future_entries,     $plugin_dir, $plugin_state_dir, @plugin_order, 
    3535    # request 
    3636    $path_info, $path_info_yr, $path_info_mo, $path_info_mo_num, $path_info_da, $flavour, 
     
    170170 
    171171# Plugins: Start 
    172 if ( $plugin_dir && defined( my $dh = DirHandle->new( $plugin_dir ) ) ) { 
    173     for my $plugin ( grep { $_ =~ m{^\w+$} && -f "${plugin_dir}/${_}" } sort $dh->read ) { 
    174         next if ( $plugin =~ m{~$} ); # Ignore emacs backups 
    175         my ( $name, $off ) = ( $plugin =~ m{^\d*(\w+?)(_?)$} ); 
    176         my $on_off = ( $off eq '_' ) ? -1 : 1 ; 
    177         require "${plugin_dir}/$plugin"; 
    178         if ( $name->start() ) { 
    179             $plugins{$name} = $on_off; 
    180             push @plugins, $name; 
    181         } 
    182     } 
    183     $dh->close; 
    184 } 
     172if ( $plugin_dir ) { 
     173    if ( @plugin_order > 0 ) { 
     174        for my $plugin ( @plugin_order ) { 
     175            require "${plugin_dir}/${plugin}"; 
     176            if ( $plugin->start() ) { 
     177                $plugins{$plugin} = 1; 
     178                push @plugins, $plugin; 
     179            } 
     180        } 
     181    } 
     182    elsif ( defined( my $dh = DirHandle->new( $plugin_dir ) ) ) { 
     183        for my $plugin ( grep { $_ =~ m{^\w+$} && -f "${plugin_dir}/${_}" } sort $dh->read ) { 
     184            next if ( $plugin =~ m{~$} ); # Ignore emacs backup 
     185            my ( $name, $off ) = ( $plugin =~ m{^\d*(\w+?)(_?)$} ); 
     186            my $on_off = ( $off eq '_' ) ? -1 : 1 ; 
     187            require "${plugin_dir}/${plugin}"; 
     188            if ( $name->start() ) { 
     189                $plugins{$name} = $on_off; 
     190                push @plugins, $name; 
     191            } 
     192        } 
     193        $dh->close; 
     194    } 
     195} 
     196 
    185197# Plugins: Template 
    186198# Allow for the first encountered plugin::template subroutine to override the