Changeset 396

Show
Ignore:
Timestamp:
04/24/07 02:48:24 (1 year ago)
Author:
miya
Message:

Config support for extract plugins.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • SVN-TracWiki/examples/config.yaml

    r391 r396  
    88  username: foo 
    99  password: bar 
     10 
     11plugins: 
     12  PowerPoint: 
     13    ppthtml: /usr/local/bin/ppthtml 
  • SVN-TracWiki/lib/SVN/TracWiki.pm

    r394 r396  
    6161 
    6262        Encode::_utf8_off($text) if Encode::is_utf8($text); 
    63  
    6463        next if $r->mime_type eq 'text/plain' or $r->mime_type eq 'text/html'; 
    6564 
     
    7574 
    7675    my @plugins; 
    77     for ( $self->plugins ) { 
    78         next unless $_ =~ /SVN::TracWiki::Plugin::Extract::/; 
    79         my $plugin = $_->new; 
    80  
    81         my $e = $self->{extractor}; 
    82         my $ext = $plugin->ext; 
    83         $e->magic->add_file_ext($ext, $plugin->mime_type) if $ext; 
    84         $e->register_processor($_); 
     76    for my $class ( $self->plugins ) { 
     77        my ( $name ) = ( $class =~ /SVN::TracWiki::Plugin::Extract::(.+)/ ); 
     78        next unless $name; 
     79 
     80        my $e         = $self->{extractor}; 
     81        my $ext       = $class->ext; 
     82        my $mime_type = $class->mime_type; 
     83        $e->magic->add_file_ext($ext, $mime_type) if $ext; 
     84        $e->register_processor($class); 
     85 
     86        $class->mk_classdata('conf'); 
     87        $class->conf( $self->{config}->{plugins}->{$name} ); 
    8588    } 
    8689} 
  • SVN-TracWiki/lib/SVN/TracWiki/Plugin/Extract.pm

    r394 r396  
    33use strict; 
    44use warnings; 
    5 use base qw( File::Extract SVN::TracWiki::Plugin ); 
     5use base qw( File::Extract SVN::TracWiki::Plugin Class::Data::Inheritable ); 
    66 
    77sub mime_type { } 
  • SVN-TracWiki/lib/SVN/TracWiki/Plugin/Extract/PowerPoint.pm

    r394 r396  
    1313    my ( $self, $file ) = @_; 
    1414 
    15     my $html = `/usr/local/bin/ppthtml $file`; 
    16     my $text = $self->strip_html($html); 
     15    my $ppthtml = $self->conf->{ppthtml} || '/usr/bin/ppthtml'; 
     16    my $html    = `/usr/local/bin/ppthtml $file`; 
     17    my $text    = $self->strip_html($html); 
    1718 
    1819    $text = Encode::decode('utf8', $text);