/[SQLSession]/trunk/lib/SQLSession/Dispatcher.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/SQLSession/Dispatcher.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 57 - (show annotations)
Thu Jan 25 12:33:38 2007 UTC (17 years, 2 months ago) by dpavlin
File size: 1317 byte(s)
be less chatty
1 package SQLSession::Dispatcher;
2
3 use strict;
4 use warnings;
5
6 use Jifty::Dispatcher -base;
7
8 use Data::Dump qw/dump/;
9
10 before '*' => run {
11 my $top = Jifty->web->navigation;
12 my $edit = Jifty->config->app('edit');
13 $top->child( 'New' => url => '/new' ) if ($edit);
14 my $l = $top->child( 'List' => url => '/list' );
15
16 my $databases = SQLSession::Model::DatabaseCollection->new();
17 $databases->unlimit;
18 while ( my $db = $databases->next ) {
19 my $label = $db->name;
20 # $label .= ' [' . $db->dsn . ']' if ($edit);
21 my $url = '/list/database/' . $db->id;
22 my $path = Jifty->web->request->path;
23 # warn "url: $url path: $path\n";
24 $l->child( $label => url => $url => active => ( $url eq $path ) );
25 }
26
27 if ( Jifty->web->current_user->id ) {
28 $top->child( 'Logout' => url => '/logout' );
29 } else {
30 $top->child( 'Login' => url => '/login' );
31 $top->child( 'Signup' => url => '/signup' );
32 }
33
34 };
35
36
37
38 under qr{sql/(\d+)} => run {
39
40 my $q = SQLSession::Model::Query->new();
41 $q->load( $1 ) or next_rule;
42
43 warn "q = ",dump( $q );
44
45 set sql_query => $q->sql_query;
46 set name => $q->name;
47 set database => $q->on_database->id;
48
49 show '/sql';
50
51 };
52
53 under 'list' => [
54
55 on qr{database/(\d+)} => run {
56 set database_id => $1;
57 },
58
59 show '/list',
60 ];
61
62 on 'new' => run {
63 show '/sql';
64 };
65
66 on '/' => run {
67 redirect '/list';
68 };
69
70 1;

  ViewVC Help
Powered by ViewVC 1.1.26