Changeset 232

Show
Ignore:
Timestamp:
06/11/07 23:47:52 (3 years ago)
Author:
eevee
Message:

Inserted some DTRT magic into the flavor text/main page split; now viewing a flavor page will ensure that you get a flavor page for the next Pokemon you enter in the lookup.

Files:
1 modified

Legend:

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

    r222 r232  
    101101    if    ($entry =~ /^tm ?(\d{1,2})$/i) { $c->res->redirect( $c->uri('Dex', 'tms', $1      ) ); return } 
    102102    elsif ($entry =~ /^hm ?(\d{1,2})$/i) { $c->res->redirect( $c->uri('Dex', 'tms', $1 + 100) ); return } 
    103     elsif ($entry =~ /^random(?: (pokemon|move|type))?$/i) { $c->res->redirect( $c->uri('Dex', plural($1 || 'pokemon'), 'random') ); return } 
     103    elsif ($entry =~ /^random(?: (pokemon|move|type))?$/i) { 
     104        my $url = $c->uri('Dex', plural($1 || 'pokemon'), 'random'); 
     105        $url .= '/' . $c->session->{last_pokemon_view} if $c->session->{last_pokemon_view}; 
     106        $c->res->redirect($url); 
     107        return; 
     108    } 
    104109 
    105110    # the usual suspects 
     
    107112    my $fuzzy_value = $FuzzyMatches{ lc $entry }; 
    108113    if ($fuzzy_value) { 
    109         $c->res->redirect( $c->uri('Dex', plural($fuzzy_value->{type}), lc $fuzzy_value->{name}) ); 
     114        my $url = $c->uri('Dex', plural($fuzzy_value->{type}), lc $fuzzy_value->{name}); 
     115        $url .= '/' . $c->session->{last_pokemon_view} if $c->session->{last_pokemon_view}; 
     116        $c->res->redirect($url); 
    110117        return; 
    111118    } 
     
    123130        } 
    124131 
    125         my $name; 
     132        my ($name, $suffix); 
    126133        if ($class eq 'pokemon') { 
    127134            $name = lc $PokemonNames[$result]; 
     135            $suffix = '/' . $c->session->{last_pokemon_view} if $c->session->{last_pokemon_view}; 
    128136        } elsif ($class eq 'move') { 
    129137            $name = lc $MoveData[$result]->name; 
     
    132140        } 
    133141 
    134         $c->res->redirect( $c->uri('Dex', plural($class), $name) ); 
     142        $c->res->redirect( $c->uri('Dex', plural($class), $name) . $suffix ); 
    135143        return; 
    136144    } 
     
    386394    $c->vee_abort('There is no such Pokémon ', $c->req->args->[0], '.  If you are messing with my URLs, please stop.  If you came here via a link, please inform its owner that it is invalid.') unless $row; 
    387395 
     396    delete $c->session->{last_pokemon_view}; 
     397 
    388398    $s->{page_title}  = $row->name . ' - Pokémon #' . $row->real_id; 
    389399    $s->{page_header} = $row->name; 
     
    716726    $c->vee_abort('There is no such Pokémon ', $poke, '.  If you are messing with my URLs, please stop.  If you came here via a link, please inform its owner that it is invalid.') unless $row; 
    717727 
     728    $c->session->{last_pokemon_view} = 'flavor'; 
     729 
    718730    $s->{this} = $row; 
    719731    $s->{flavors} = {