/[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 98 - (show annotations)
Fri Feb 16 22:19:53 2007 UTC (17 years, 1 month ago) by dpavlin
File size: 1659 byte(s)
additional debug point (commented)
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->web->current_user->role('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 if ( Jifty->web->current_user->role( 'admin' ) ) {
35 $top->child( 'Docs' => url => '/__jifty/online_docs/' );
36 $top->child( 'Administration' => url => '/__jifty/admin/' );
37 }
38
39 };
40
41
42 under qr{sql/(\d+)} => run {
43
44 my $q = SQLSession::Model::Query->new();
45 $q->load( $1 ) or next_rule;
46
47 # warn "q = ",dump( $q );
48
49 # Jifty->log->debug( dump($q) );
50
51 set q => $q;
52
53 show '/sql';
54
55 };
56
57 under 'list' => [
58
59 on qr{database/(\d+)} => run {
60 set on_database => $1;
61 },
62
63 on qr{date/(\d{4}-\d+-\d+)} => run {
64 set created_on => $1;
65 },
66
67 show '/list',
68 ];
69
70 on 'new' => run {
71 show '/sql';
72 };
73
74 on '/' => run {
75 redirect '/list';
76 };
77
78 on qr{^/feed/(atom|rss|rss2)}, run {
79 my $type = 'RSS';
80 $type = 'Atom' if ($1 eq 'atom');
81 set type => $type;
82 show('/feed');
83 };
84
85 1;

  ViewVC Help
Powered by ViewVC 1.1.26