Changeset 718

Show
Ignore:
Timestamp:
08/15/02 15:19:59
Author:
miyagawa
Message:

default

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Apache-CustomKeywords/trunk/Changes

    r712 r718  
    11Revision history for Perl extension Apache::CustomKeywords 
     2 
     30.03  Thu Aug 15 15:17:48 JST 2002 
     4        - First C<CustomKeyword> is used when command match fails 
    25 
    360.02  Wed Aug  7 17:48:25 JST 2002 
  • Apache-CustomKeywords/trunk/lib/Apache/CustomKeywords.pm

    r712 r718  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.02
     5$VERSION = 0.03
    66 
    77use Apache::Constants qw(:response); 
     
    4747    my $keyword = $cfg->{CustomKeywords} or return; 
    4848    my $query = $class->query($r); 
     49    $query =~ s/^(\S+)\s*// or return; 
     50    if (my $engine = $keyword->{$1}) { 
     51        return $class->interpolate($engine, $query); 
     52        return $engine; 
     53    } 
     54    elsif (my $default = $cfg->{CustomKeywordsDefault}) { 
     55        my $engine = $keyword->{$default}; 
     56        return $class->interpolate($engine, join(' ', $1, $query)); 
     57    } 
     58} 
    4959 
    50     # registerd command? 
    51     $query =~ s/^(\S+)\s*// or return; 
    52     my $engine = $keyword->{$1} or return; 
     60sub interpolate { 
     61    my($class, $engine, $query) = @_; 
    5362    $engine =~ s/%s/$class->escape_it($query)/eg; 
    5463    return $engine; 
     
    6978sub CustomKeyword($$$$) { 
    7079    my($cfg, $parms, $arg1, $arg2) = @_; 
     80    $cfg->{CustomKeywordsDefault} ||= $arg1; 
    7181    $cfg->{CustomKeywords} ||= {}; 
    7282    $cfg->{CustomKeywords}->{$arg1} = $arg2; 
     
    111121Location: box, then you will be redirected to the page you wanna go 
    112122to! 
     123 
     124If your command is not recognized by this module, the first 
     125C<CustomKeyword> entry is used as default. 
    113126 
    114127Here's the way this handler works: