Changeset 184

Show
Ignore:
Timestamp:
05/28/07 01:03:11 (3 years ago)
Author:
eevee
Message:

Fixed wildcard lookup. (#43)

Location:
veekun/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee/Controller/Dex.pm

    r182 r184  
    154154     
    155155    $s->{page_title} = 'Wildcard Lookup'; 
     156    $s->{crumbs}     = [ '<a href="' . $c->uri('Dex') . '">Pok&eacute;dex</a>', 'Wildcard Lookup' ]; 
    156157     
    157158    (my $test = $entry) =~ s/[^-_ 0-9a-zA-Z]//g; 
     
    171172    my %results; 
    172173     
    173     # TODO: cleaner and slightly future-proofer way to do this? 
    174     # TODO: bomb if zero 
    175     $results{pokemon} = [ grep { $PokemonNames[$_] =~ $re } 1 .. $#PokemonNames ]; 
    176     $results{types} = [ grep { $TypeNames[$_] =~ $re } 0 .. $#TypeNames ]; 
    177     $results{moves} = [ grep { $MoveData[$_]->name =~ $re } 1 .. $#MoveData ]; 
     174    # TODO: use %FuzzyMatches somehow 
     175    $results{abilities} = [ grep { $AbilityNames[$_] =~ $re } 1 .. $#AbilityNames ]; 
     176    $results{pokemon}   = [ grep { $PokemonNames[$_] =~ $re } 1 .. $#PokemonNames ]; 
     177    $results{types}     = [ grep { $TypeNames[$_] =~ $re } 0 .. $#TypeNames ]; 
     178    $results{moves}     = [ grep { $MoveData[$_]->name =~ $re } 1 .. $#MoveData ]; 
    178179     
    179180    my $total = 0; 
    180181    $total += $#{$results{$_}} + 1 for keys %results; 
    181     $c->vee_stop('No match for ', $orig, ' was found.  You may wish to try the <a href="' . $c->uri('Dex', 'pokemon_list') . '">Pok&eacute;mon list</a>, <a href="' . $c->uri('Dex', 'move_list') . '">move list</a>, or <a href="' . $c->uri('Dex', 'type_list') . '">type list</a> to find what you are looking for.'); 
    182      
    183     $s->{results} = \%results; 
     182    $c->vee_stop('No match for ', $orig, ' was found.  You may wish to try the <a href="' . $c->uri('Dex', 'pokemon_list') . '">Pok&eacute;mon list</a>, <a href="' . $c->uri('Dex', 'move_list') . '">move list</a>, <a href="' . $c->uri('Dex', 'type_list') . '">type list</a>, etc. to find what you are looking for.') unless $total; 
     183    $c->vee_stop('', $orig, ' returned too many matches.  Please try something more specific.') if $total > 50; 
     184     
     185    $s->{results}  = \%results; 
    184186    $s->{template} = 'dex/lookup/wildcard.tt'; 
    185187} 
  • veekun/trunk/templates/dex/lookup/wildcard.tt

    r1 r184  
    1 <p>TODO: needs a message here  8)</p> 
    2 <p>TODO: what to do if nothing is found?</p> 
    3 <p>normal fuzzy search and clean this up too</p> 
     1<h1>Wildcard Lookup Results</h1> 
    42 
    5 COMMIT SOMETHING NOOB 
    6  
    7 error handling could stand to be less ugly 
    8 clean up basic post-create script 
    9 thread creation?  whoa there fella 
    10  
    11 <h1>Fuzzy Search Results</h1> 
     3[%# TODO: this should not need manual separate chunks!  or maybe it should? %] 
     4[%# TODO: sort better? %] 
    125 
    136[% IF results.pokemon.size %] 
     
    158<ul> 
    169[%     FOREACH p IN results.pokemon.nsort %] 
    17 <li><a href="[% dex_uri('pokemon', PokemonNames.$p) %]">#[% p %]: [% PokemonNames.$p %]</a></li> 
     10<li><a href="[% dex_uri('pokemon', PokemonNames.$p) %]"><img src="/dex-images/icons/[% p.pad(3) %].png" alt=""/> [% PokemonNames.$p %]</a></li> 
    1811[%     END %] 
    1912</ul> 
     
    2922[% END %] 
    3023 
     24[% IF results.abilities.size %] 
     25<h2>Abilities</h2> 
     26<ul> 
     27[%     FOREACH a IN results.abilities.nsort %] 
     28<li><a href="[% dex_uri('ability', AbilityNames.$a) %]">[% AbilityNames.$a %]</a></li> 
     29[%     END %] 
     30</ul> 
     31[% END %] 
     32 
    3133[% IF results.types.size %] 
    3234<h2>Types</h2>