7 |
use lib 'lib'; |
use lib 'lib'; |
8 |
use App::RoomReservation::Room; |
use App::RoomReservation::Room; |
9 |
|
|
10 |
|
sub room { |
11 |
|
App::RoomReservation::Room->new; |
12 |
|
} |
13 |
|
|
14 |
|
around 'title' => sub { |
15 |
|
my ( $real_title, $self ) = @_; |
16 |
|
return ( 'Seat Reservation' ); |
17 |
|
}; |
18 |
|
|
19 |
|
sub form_header { |
20 |
|
my $self = shift; |
21 |
|
$self->room->description; |
22 |
|
} |
23 |
|
|
24 |
|
sub form_footer { |
25 |
|
qq| |
26 |
|
<div style="font-size:75%; color: #888; clear: left;"> |
27 |
|
Insert some standard disclamer for every page here |
28 |
|
</div> |
29 |
|
|; |
30 |
|
} |
31 |
|
|
32 |
sub dsn { 'DBI:Pg:dbname=room-reservation' } |
sub dsn { 'DBI:Pg:dbname=room-reservation' } |
33 |
|
|
34 |
|
=head1 DEPLOY |
35 |
|
|
36 |
|
createdb --encoding=utf-8 room-reservation |
37 |
|
|
38 |
|
perl -Ilib -MFrey::Class::Schematize \ |
39 |
|
-e 'print Frey::Class::Schematize->new( class => "App::RoomReservation::Reservation" )->create_table,$/;' \ |
40 |
|
| psql room-reservation |
41 |
|
|
42 |
|
=cut |
43 |
|
|
44 |
our $dbh; |
our $dbh; |
45 |
sub dbh { |
sub dbh { |
46 |
my ($self) = @_; |
my ($self) = @_; |
60 |
my $url = $self->url_for( 'Reservation/create_as_markup' ); |
my $url = $self->url_for( 'Reservation/create_as_markup' ); |
61 |
|
|
62 |
return |
return |
63 |
App::RoomReservation::Room->new->room_as_markup |
$self->room->room_as_markup |
64 |
. qq|<a target="App::RoomReservation::Reservation" href="$url">seat reservation</a>| |
. qq|<a target="App::RoomReservation::Reservation" href="$url">seat reservation</a>| |
65 |
; |
; |
66 |
} |
} |
67 |
|
|
68 |
# my $url = $self->uri_for( 'Reservation/create_as_makrup' ); |
# my $url = $self->uri_for( 'Reservation/create_as_makrup' ); |
69 |
|
|
70 |
|
sub url_mapping {{ |
71 |
|
"App::RoomReservation/as_markup" => 'zimbardo', |
72 |
|
"App::RoomReservation::Reservation/create_as_markup" => 'zimbardo/create', |
73 |
|
"App::RoomReservation::Confirmation/verify_as_markup?token=" => 'zimbardo/verify/', |
74 |
|
"App::RoomReservation::Confirmation/cancel_as_markup?token=" => 'zimbardo/cancel/', |
75 |
|
}} |
76 |
|
|
77 |
|
our $urls; |
78 |
|
use Data::Dump qw/dump/; |
79 |
|
|
80 |
sub url_for { |
sub url_for { |
81 |
my ( $self, $to ) = @_; |
my $self = shift; |
82 |
|
my $to = shift; |
83 |
|
my $args = join('', @_); |
84 |
my $app = ref($self); |
my $app = ref($self); |
85 |
$app =~ s{^(App::[^:]+)::.+$}{$1}; |
$app =~ s{^(App::[^:]+)::.+$}{$1}; |
86 |
$app .= '::' . $to; |
$app .= '::' . $to; |
90 |
Class::MOP::load_class( $class ); |
Class::MOP::load_class( $class ); |
91 |
die "$class doesn't implement $method" unless $class->meta->has_method($method); |
die "$class doesn't implement $method" unless $class->meta->has_method($method); |
92 |
|
|
93 |
|
$urls->{$app}++; |
94 |
|
warn "XXX urls = ",dump($urls); |
95 |
|
|
96 |
|
my $map_to = url_mapping->{$app}; |
97 |
|
$app = $map_to if $map_to; |
98 |
|
|
99 |
return |
return |
100 |
$self->request_url->scheme . '://' . $self->request_url->authority . '/' . $app; |
$self->request_url->scheme . '://' . $self->request_url->authority . '/' . $app . $args; |
101 |
} |
} |
102 |
|
|
103 |
__PACKAGE__->meta->make_immutable; |
__PACKAGE__->meta->make_immutable; |