| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Articulate::FrameworkAdapter::Dancer2; |
|
2
|
1
|
|
|
1
|
|
1226
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use Moo; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'Articulate::Role::Component'; |
|
8
|
|
|
|
|
|
|
require Dancer2; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Articulate::FramwworkAdapter::Dancer1 - Access Dancer1 features though a common interface |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# declare it in your config |
|
17
|
|
|
|
|
|
|
plugins: |
|
18
|
|
|
|
|
|
|
Articulate: |
|
19
|
|
|
|
|
|
|
components: |
|
20
|
|
|
|
|
|
|
framework: |
|
21
|
|
|
|
|
|
|
Articulate::FramwworkAdapter::Dancer2 |
|
22
|
|
|
|
|
|
|
appname: MyApp |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# then use it in your other components |
|
26
|
|
|
|
|
|
|
my $appdir = $component->framework->appdir |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The following methods are implemented: |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head3 user_id |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head3 appdir |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head3 session |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head3 status |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head3 template_process |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head3 declare_route |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item * L |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item * L |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item * L |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * L |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=back |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has appname => |
|
61
|
|
|
|
|
|
|
is => 'rw', |
|
62
|
|
|
|
|
|
|
default => sub { undef }; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has d2app => |
|
65
|
|
|
|
|
|
|
is => 'rw', |
|
66
|
|
|
|
|
|
|
lazy => 1, |
|
67
|
|
|
|
|
|
|
default => sub { |
|
68
|
|
|
|
|
|
|
my $self = shift; |
|
69
|
|
|
|
|
|
|
Dancer2->import ( appname => $self->appname ); |
|
70
|
|
|
|
|
|
|
my @apps = grep { $_->name eq $self->appname } @{ Dancer2::runner()->apps }; |
|
71
|
|
|
|
|
|
|
return $apps[0]; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
; |
|
74
|
|
|
|
|
|
|
sub user_id { |
|
75
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
76
|
0
|
|
|
|
|
|
Dancer2::Core::DSL::session( $self->d2app, user_id => @_ ); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub appdir { |
|
80
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
81
|
0
|
|
|
|
|
|
Dancer2::config()->{appdir}; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub session { |
|
85
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
86
|
0
|
|
|
|
|
|
Dancer2::Core::DSL::session( $self->d2app, @_ ); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub set_content_type { |
|
90
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
91
|
0
|
|
|
|
|
|
Dancer2::Core::DSL::content_type( $self->d2app, @_ ); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub send_file { |
|
95
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
96
|
0
|
|
|
|
|
|
Dancer2::Core::DSL::send_file( $self->d2app, @_ ); |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub upload { |
|
100
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
101
|
0
|
|
|
|
|
|
return (map { |
|
102
|
0
|
|
|
|
|
|
$_->file_handle->binmode(':raw'); |
|
103
|
0
|
|
|
|
|
|
Articulate::File->new ( { |
|
104
|
|
|
|
|
|
|
content_type => $_->type, |
|
105
|
|
|
|
|
|
|
headers => $_->headers, |
|
106
|
|
|
|
|
|
|
filename => $_->filename, |
|
107
|
|
|
|
|
|
|
io => $_->file_handle, |
|
108
|
|
|
|
|
|
|
} ) |
|
109
|
|
|
|
|
|
|
} Dancer2::Core::DSL::upload( $self->d2app, @_) )[0]; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub status { |
|
113
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
114
|
0
|
|
|
|
|
|
Dancer2::Core::DSL::status( $self->d2app, @_ ); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub template_process { |
|
118
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
119
|
0
|
|
|
|
|
|
$self->d2app->template_engine->process( @_ ); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub declare_route { |
|
123
|
0
|
|
|
0
|
1
|
|
my ($self, $verb, $path, $code) = @_; |
|
124
|
0
|
|
|
|
|
|
$self->d2app; |
|
125
|
0
|
0
|
|
|
|
|
if ($verb =~ m/^(get|put|post|patch|del|any|options)$/) {#'Dancer2::Core::DSL::'.lc $1;/ge) { |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
1
|
|
|
1
|
|
639
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
73
|
|
|
|
0
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$self->d2app->add_route( method => $verb, regexp => $path, code => $code ); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
else { |
|
132
|
0
|
|
|
|
|
|
die ('Unknown HTTP verb '.$verb); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |