/[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 118 - (show annotations)
Sun Jun 1 00:34:09 2008 UTC (14 years, 6 months ago) by dpavlin
File size: 1728 byte(s)
use more modern Jifty User plugin
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 $top->child( 'Password reminder' => url => '/passwordreminder' );
33 }
34
35 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 };
41
42
43 under qr{sql/(\d+)} => run {
44
45 my $q = SQLSession::Model::Query->new();
46 $q->load( $1 ) or next_rule;
47
48 set parent => $1;
49 set q => $q;
50
51 Jifty->log->debug( "parent = $1, q = ",dump($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 '/' => redirect '/list';
75
76 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 1;

  ViewVC Help
Powered by ViewVC 1.1.26