File Coverage

blib/lib/RapidApp/View/Viewport.pm
Criterion Covered Total %
statement 35 37 94.5
branch 4 8 50.0
condition 3 7 42.8
subroutine 6 6 100.0
pod 1 1 100.0
total 49 59 83.0


line stmt bran cond sub pod time code
1             package RapidApp::View::Viewport;
2              
3 4     4   2145 use strict;
  4         9  
  4         107  
4 4     4   21 use warnings;
  4         8  
  4         237  
5              
6 4     4   22 use base 'Catalyst::View::TT';
  4         8  
  4         406  
7              
8 4     4   36 use RapidApp::Util qw(:all);
  4         8  
  4         3339  
9              
10             __PACKAGE__->config(TEMPLATE_EXTENSION => '.tt');
11              
12             sub process {
13 1     1 1 1694 my ($self, $c)= @_;
14              
15 1         20 $c->response->header('Cache-Control' => 'no-cache');
16 1         201 $c->stash->{template} = 'templates/rapidapp/ext_viewport.tt';
17            
18 1         61 my @img = ();
19            
20 1         8 push @img, $self->_get_asset_controller_urls(
21             $c->controller('Assets::ExtJS'), (qw(
22             resources/images/gray/qtip/tip-sprite.gif
23             resources/images/gray/qtip/tip-anchor-sprite.gif
24             resources/images/gray/tabs/tab-strip-bg.gif
25             resources/images/gray/tabs/tab-close.gif
26             resources/images/gray/tabs/tabs-sprite.gif
27             resources/images/gray/panel/white-top-bottom.gif
28             resources/images/gray/panel/tool-sprites.gif
29             resources/images/default/grid/loading.gif
30             resources/images/gray/tree/arrows.gif
31             resources/images/gray/window/left-corners.png
32             resources/images/gray/window/right-corners.png
33             resources/images/gray/window/top-bottom.png
34             resources/images/gray/window/left-right.png
35             resources/images/gray/button/btn.gif
36             resources/images/gray/qtip/bg.gif
37             resources/images/gray/progress/progress-bg.gif
38             resources/images/gray/window/icon-warning.gif
39             resources/images/default/shadow.png
40             resources/images/default/shadow-lr.png
41             resources/images/default/shadow-c.png
42             resources/images/gray/panel/corners-sprite.gif
43             resources/images/gray/panel/top-bottom.gif
44             resources/images/gray/panel/left-right.gif
45             ))
46             );
47            
48 1         668 push @img, $self->_get_asset_controller_urls(
49             $c->controller('Assets::RapidApp::Icons'), (qw(
50             warning.png
51             loading.gif
52             refresh.gif
53             refresh_24x24.png
54             ))
55             );
56            
57 1         485 push @img, $self->_get_asset_controller_urls(
58             $c->controller('Assets::RapidApp::Misc'), (qw(
59             images/rapidapp_powered_logo_tiny.png
60             ))
61             );
62            
63             # Misc static images:
64 1   50     683 my $pfx = $c->mount_url || '';
65 1         3 push @{$c->stash->{precache_imgs}}, map { "$pfx$_" } (qw(
  1         6  
  2         66  
66             /assets/rapidapp/misc/static/icon-error.gif
67             /assets/rapidapp/misc/static/s.gif
68             ));
69            
70            
71 1   50     4 $c->stash->{precache_imgs} ||= [];
72 1         55 @{$c->stash->{precache_imgs}} = uniq(@{$c->stash->{precache_imgs}},@img);
  1         3  
  1         4  
73            
74             die "ERROR: stash params 'config_url' and 'panel_cfg' cannot be used together"
75 1 50 33     59 if($c->stash->{config_url} && $c->stash->{panel_cfg});
76              
77             # make sure config_params is a string of JSON
78 1 50       146 if (ref $c->stash->{config_params}) {
79 0         0 $c->stash->{config_params}= RapidApp::JSON::MixedEncoder::encode_json($c->stash->{config_params});
80             }
81              
82 1 50       58 if (ref $c->stash->{panel_cfg}) {
83 0         0 $c->stash->{panel_cfg}= RapidApp::JSON::MixedEncoder::encode_json($c->stash->{panel_cfg});
84             }
85              
86 1         60 return $self->next::method($c);
87             }
88              
89              
90             sub _get_asset_controller_urls {
91 3     3   213 my ($self, $controller, @paths)= @_;
92 3 50       11 return () unless ($controller);
93 3         5 return map { $controller->asset_path($_) } @paths;
  28         16651  
94             }
95              
96              
97             1;
98              
99              
100             __END__
101              
102             =head1 NAME
103              
104             RapidApp::View::Viewport - Render a Module within an ExtJS Viewport
105              
106             =head1 DESCRIPTION
107              
108             This is the main View for rendering a top-level RapidApp Module within the browser. This
109             component class is used internally by plugins like L<TabGui|Catalyst::Plugin::RapidApp::TabGui>.
110              
111             The JavaScript function C<Ext.ux.RapidApp.AutoPanel> is used to fetch and decode the
112             configured Module URL via Ajax.
113              
114             More documentation TDB...
115              
116             =head1 SEE ALSO
117              
118             =over
119              
120             =item *
121              
122             L<RapidApp::Manual::Modules>
123              
124             =back
125              
126             =head1 AUTHOR
127              
128             Henry Van Styn <vanstyn@cpan.org>
129              
130             =head1 COPYRIGHT AND LICENSE
131              
132             This software is copyright (c) 2013 by IntelliTree Solutions llc.
133              
134             This is free software; you can redistribute it and/or modify it under
135             the same terms as the Perl 5 programming language system itself.
136              
137             =cut