/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 118 - (hide annotations)
Sun Jun 1 00:34:09 2008 UTC (14 years, 8 months ago) by dpavlin
File size: 1728 byte(s)
use more modern Jifty User plugin
1 dpavlin 20 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 dpavlin 33 before '*' => run {
11     my $top = Jifty->web->navigation;
12 dpavlin 58 my $edit = Jifty->web->current_user->role('edit');
13 dpavlin 33 $top->child( 'New' => url => '/new' ) if ($edit);
14 dpavlin 40 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 dpavlin 49 my $url = '/list/database/' . $db->id;
22     my $path = Jifty->web->request->path;
23 dpavlin 57 # warn "url: $url path: $path\n";
24 dpavlin 49 $l->child( $label => url => $url => active => ( $url eq $path ) );
25 dpavlin 40 }
26    
27 dpavlin 46 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 dpavlin 108 $top->child( 'Password reminder' => url => '/passwordreminder' );
33 dpavlin 46 }
34    
35 dpavlin 58 if ( Jifty->web->current_user->role( 'admin' ) ) {
36     $top->child( 'Docs' => url => '/__jifty/online_docs/' );
37     $top->child( 'Administration' => url => '/__jifty/admin/' );
38     }
39    
40 dpavlin 33 };
41    
42    
43 dpavlin 20 under qr{sql/(\d+)} => run {
44    
45     my $q = SQLSession::Model::Query->new();
46     $q->load( $1 ) or next_rule;
47    
48 dpavlin 102 set parent => $1;
49     set q => $q;
50 dpavlin 20
51 dpavlin 118 Jifty->log->debug( "parent = $1, q = ",dump($q) );
52 dpavlin 98
53 dpavlin 22 show '/sql';
54 dpavlin 20
55     };
56    
57 dpavlin 39 under 'list' => [
58    
59     on qr{database/(\d+)} => run {
60 dpavlin 84 set on_database => $1;
61 dpavlin 39 },
62    
63 dpavlin 87 on qr{date/(\d{4}-\d+-\d+)} => run {
64     set created_on => $1;
65 dpavlin 91 },
66 dpavlin 87
67 dpavlin 39 show '/list',
68     ];
69    
70 dpavlin 22 on 'new' => run {
71     show '/sql';
72 dpavlin 21 };
73    
74 dpavlin 108 on '/' => redirect '/list';
75 dpavlin 22
76 dpavlin 79 on qr{^/feed/(atom|rss|rss2)}, run {
77     my $type = 'RSS';
78     $type = 'Atom' if ($1 eq 'atom');
79     set type => $type;
80     show('/feed');
81     };
82    
83 dpavlin 20 1;

  ViewVC Help
Powered by ViewVC 1.1.26