--- lib/A3C/Dispatcher.pm 2008/05/22 20:48:42 125 +++ lib/A3C/Dispatcher.pm 2008/06/16 22:56:14 186 @@ -3,6 +3,16 @@ use strict; use warnings; +=head1 NAME + +A3C::Displatcher + +=head1 DESCRIPTION + +Create top-level menu navigation + +=cut + use Jifty::Dispatcher -base; use Data::Dump qw/dump/; @@ -17,14 +27,36 @@ # Jifty->log->debug("current_user = ", dump( $user )); - $top->child( _('People') => url => 'people' ); - $top->child( _('Organizations') => url => 'organizations' ); - - $top->child( _('Sync') => url => 'sync' ); - $top->child( _('LDAP') => url => 'ldap' ); + $top->child( _('People') => url => '/people' ); + my $o = $top->child( _('Organizations') => url => '/organizations' ); + $o->child( _('New') => url => '/organizations/new' ); + + $top->child( _('Sync') => url => '/sync' ); + $top->child( _('LDAP') => url => '/ldap' ); + my $strix = $top->child( _('Strix') => url => '/strix' ); + $strix->child( _('Name differences') => url => '/strix/name_diff' ); + $strix->child( _('SQL') => url => '/strix/sql' ); + $strix->child( _('Sitemap') => url => '/strix/sitemap' ); + $strix->child( _('Layout') => url => '/strix/layout' ); # $top->child( 'Prefs' => url => '/prefs' ) if Jifty->web->current_user->id; }; +sub first_instance { + my $selection = A3C::Model::StrixInstanceSelectionCollection->new; + $selection->unlimit; + my $instance = $selection->first->instance->instance; + warn "# using default instance $instance"; + return $instance; +} + +before '/strix/' => run { + + if ( ! get('instance') ) { + set 'instance' => first_instance; + } + +}; + 1;