Namazu-devel-ja(旧)


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: フィルタの優先順位設定 Re:tar.pl作成



臼田です。

Tadamasa Teranishi wrote:

> Yukio USUDA wrote:
> > 
> > > これの代わりに
> > >
> > > > %use_filters = (
> > > >  'aplication/excel' => ['xxxx.pl','excel.pl','XXXX.pl'],
> > > >  'application/ichitaro5' => ['taro.pl','taro56.pl'],
> > > >  'application/ichitaro6' => ['taro.pl','taro56.pl']
> > > > );
> > > >
> > > > となるようにしてみたdiffを添付しています。
> > >
> > > これをそのまま rc ファイルに記述するので良いのでは?
> > > 十分シンプルだと思いますが。
> > > --
一応こちらの方法でも試してみました。
diffをつけています。
HEADに入れるのならば設定ファイルを変えてしまうまでの暫定措置だと
思います。
お好きなほうを選んでください。

優先順位を変えて試していて taro.pl の返す mediatype が
taro56, taro7_10に比べて不足していることに気づきました。
自分で動作チェックできないのでこのフィルタはあまり触り
たくないですが。。


Index: pl/conf.pl.in
===================================================================
RCS file: /storage/cvsroot/namazu/pl/conf.pl.in,v
retrieving revision 1.46
diff -u -r1.46 conf.pl.in
--- pl/conf.pl.in	27 Apr 2004 15:19:56 -0000	1.46
+++ pl/conf.pl.in	8 May 2004 02:00:54 -0000
@@ -51,6 +51,42 @@
 #
 $DENY_FILE = ".*\\.(gif|png|jpg|jpeg)|.*\\.tar\\.gz|core|.*\\.bak|.*~|\\..*|\x23.*";
 
+%USE_FILTERS = (
+  'application/excel' => ['excel.pl'],  
+  'application/ichitaro5' => ['taro.pl', 'taro56.pl'],
+  'application/ichitaro6' => ['taro.pl', 'taro56.pl'],
+  'application/ichitaro7' => ['taro.pl', 'taro7_10.pl'],
+  'application/macbinary' => ['macbinary.pl'],
+  'application/msword' => ['msword.pl'],
+  'application/pdf' => ['pdf.pl'],
+  'application/postscript' => ['postscript.pl'],
+  'application/powerpoint' => ['powerpoint.pl'],
+  'application/rtf' => ['rtf.pl'],
+  'application/vnd.sun.xml.calc' => ['ooo.pl'],
+  'application/vnd.sun.xml.draw' => ['ooo.pl'],
+  'application/vnd.sun.xml.impress' => ['ooo.pl'],
+  'application/vnd.sun.xml.writer' => ['ooo.pl'],
+  'application/x-apache-cache' => ['apachecache.pl'],
+  'application/x-bzip2' => ['bzip2.pl'],
+  'application/x-compress' => ['compress.pl'],
+  'application/x-deb' => ['deb.pl'],
+  'application/x-dvi' => ['dvi.pl'],
+  'application/x-gzip' => ['gzip.pl'],
+  'application/x-js-taro' => ['taro.pl', 'taro7_10.pl'],
+  'application/x-rpm' => ['rpm.pl'],
+  'application/x-tex' => ['tex.pl'],
+  'audio/mpeg' => ['mp3.pl'],
+  'message/news' => ['mailnews.pl'],
+  'message/rfc822' => ['mailnews.pl'],
+  'text/hnf' => ['hnf.pl'],
+  'text/html' => ['html.pl'],		# don't remove this line.
+  'text/html; x-type=mhonarc' => ['mhonarc.pl'],
+  'text/plain; x-type=rfc' => ['rfc.pl'],
+  'text/x-hdml' => ['hdml.pl'],
+  'text/x-roff' => ['man.pl'],
+  'x-test/x-test' => ['testfilter.pl'], # for tests/mknmz-12
+);
+
 #
 # This pattern specifies PATHNAMEs which will NOT be targeted.
 # NOTE: Usually specified by --exclude=regex option.
Index: scripts/mknmz.in
===================================================================
RCS file: /storage/cvsroot/namazu/scripts/mknmz.in,v
retrieving revision 1.138
diff -u -r1.138 mknmz.in
--- scripts/mknmz.in	1 May 2004 23:12:51 -0000	1.138
+++ scripts/mknmz.in	8 May 2004 02:00:55 -0000
@@ -423,34 +423,46 @@
 
 sub load_filters (@) {
     my @filters = @_;
-   
-    for my $filter (@filters) {
-	$filter =~ m!([-\w]+)\.pl$!;
-	my $module = $1;
-	require "$module.pl" || die "unable to require \"$module.pl\"\n";;
-	my (@mtypes, $status, $recursive, $pre_codeconv, $post_codeconv);
-
-	eval "\@mtypes =    ${module}::mediatype();";
-	die $@ if $@;  # eval error
-	eval "\$status =    ${module}::status();";
-	die $@ if $@;
-	eval "\$recursive = ${module}::recursive();";
-	die $@ if $@;
-	eval "\$pre_codeconv  = ${module}::pre_codeconv();";
-	die $@ if $@;
-	eval "\$post_codeconv  = ${module}::post_codeconv();";
-	die $@ if $@;
-	eval "${module}::add_magic(\$Magic);";
-	die $@ if $@;
-
-	for my $mt (@mtypes) {
-        next if (defined $var::Supported{$mt} && 
-                 $var::Supported{$mt} eq 'yes' && $status eq 'no');
-	    $var::Supported{$mt} = $status;
-	    $var::REQUIRE_ACTIONS{$mt} = $module;
-	    $var::RECURSIVE_ACTIONS{$mt} = $recursive;
-	    $var::REQUIRE_PRE_CODECONV{$mt} = $pre_codeconv;
-	    $var::REQUIRE_POST_CODECONV{$mt} = $post_codeconv;
+ 
+    my $mediatype;
+    foreach $mediatype (keys %conf::USE_FILTERS){
+        my $filter;
+        foreach $filter (@{$conf::USE_FILTERS{$mediatype}}){
+
+	    $filter = "$FILTERDIR/$filter";
+	    my $exists = grep {/$filter/} @filters;
+	    next if ($exists == 0);
+	    
+            $filter =~ m!([-\w]+)\.pl$!;
+            my $module = $1;
+            next if (defined $var::Supported{$mediatype} &&
+                     $var::Supported{$mediatype} eq 'yes');
+            require "$module.pl" || die "unable to require \"$module.pl\"\n";;
+            my (@mtypes, $status, $recursive, $pre_codeconv, $post_codeconv);
+
+            eval "\@mtypes =    ${module}::mediatype();";
+            die $@ if $@;  # eval error
+            eval "\$status =    ${module}::status();";
+            die $@ if $@;
+            eval "\$recursive = ${module}::recursive();";
+            die $@ if $@;
+            eval "\$pre_codeconv  = ${module}::pre_codeconv();";
+            die $@ if $@;
+            eval "\$post_codeconv  = ${module}::post_codeconv();";
+            die $@ if $@;
+            eval "${module}::add_magic(\$Magic);";
+            die $@ if $@;
+
+	    $exists = grep {/$mediatype/} @mtypes;
+	    next if ($exists == 0);
+
+	    next if (defined $var::Supported{$mediatype} &&
+		    $var::Supported{$mediatype} eq 'yes' && $status eq 'no');
+	    $var::Supported{$mediatype} = $status;
+	    $var::REQUIRE_ACTIONS{$mediatype} = $module;
+	    $var::RECURSIVE_ACTIONS{$mediatype} = $recursive;
+	    $var::REQUIRE_PRE_CODECONV{$mediatype} = $pre_codeconv;
+	    $var::REQUIRE_POST_CODECONV{$mediatype} = $post_codeconv;
 	}
     }
 }
@@ -2660,6 +2672,7 @@
      $var::RECURSIVE_ACTIONS, $conf::META_TAGS, $var::USE_NKF_MODULE,
      $conf::ADDRESS, $var::MAILING_ADDRESS,
      $conf::FILE_SIZE_MAX,
+     $conf::USE_FILTERS,
      $var::SupportedScheme, $var::RECURSIVE_SCHEME,
      $var::SupportedArchive, $var::RECURSIVE_ARCHIVE,
      );

臼田幸生