| 1 | use warnings; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | package Jifty::Plugin::SkeletonApp::Dispatcher; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Jifty::Plugin::SkeletonApp::Dispatcher - Dispatcher for SkeletonApp plugin | ||
| 9 | |||
| 10 | =head1 DESCRIPTION | ||
| 11 | |||
| 12 | Elementary things for a basic app. | ||
| 13 | |||
| 14 | =cut | ||
| 15 | |||
| 16 | use Jifty::Dispatcher -base; | ||
| 17 | |||
| 18 | =head1 RULES | ||
| 19 | |||
| 20 | =head2 on '**' | ||
| 21 | |||
| 22 | Add 'Home' item to the top navigation unless it's there already. | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | on '**' => run { | ||
| 27 | my $top = Jifty->web->navigation; | ||
| 28 | |||
| 29 | # Do not override the 'Home' menu item if the app had set it already | ||
| 30 | unless ( $top->child('Home') ) { | ||
| 31 | $top->child( Home => url => "/", sort_order => 1, label => _('Home') ); | ||
| 32 | } | ||
| 33 | return (); | ||
| 34 | }; | ||
| 35 | |||
| 36 | =head2 before '**' | ||
| 37 | |||
| 38 | Sets language of the current session if the request has '_jifty_lang' argument. | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | before '**' => run { | ||
| 43 | if (my $lang = Jifty->web->request->arguments->{_jifty_lang}) { | ||
| 44 | Jifty->web->session->set(jifty_lang => $lang); | ||
| 45 | } | ||
| 46 | }; | ||
| 47 | |||
| 48 | 1; |