| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Helper::View::Seamstress; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3111
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
68
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Catalyst::Helper::View::Seamstress - Helper for Seamstress Views |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
script/create.pl view Seamstress Seamstress [ comp_root skeleton ] |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Helper module for |
|
16
|
|
|
|
|
|
|
L<Catalyst::View::Seamstress|Catalyst::View::Seamstress>. |
|
17
|
|
|
|
|
|
|
It will create 3 (three) configuration variables in |
|
18
|
|
|
|
|
|
|
C<MyApp::View::Seamstress>: |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=over |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item * comp_root |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
C<comp_root> is the directory I<above> the directory where the HTML files |
|
25
|
|
|
|
|
|
|
that Seamstress will process are. This directory is usually a I<sister> |
|
26
|
|
|
|
|
|
|
directory to F<root>, F<scripts>, and so forth. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
If you don't set this, the helper script will create code that will |
|
29
|
|
|
|
|
|
|
come up with a sensible default for this directory. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item * skeleton |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
A skeleton is a Seamstress-style Perl class as discussed in |
|
35
|
|
|
|
|
|
|
L<HTML::Seamstress/"The_meat-skeleton_paradigm">. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item * meat_pack |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
C<meat_pack> is a subroutine which will pack meat into the skeleton. |
|
40
|
|
|
|
|
|
|
It is also discussed along with the skeleton at the above link. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=back |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Note that although the helper will create B<3> configuration variables, |
|
45
|
|
|
|
|
|
|
only B<2> can be set from the command line. The default C<meat_pack> |
|
46
|
|
|
|
|
|
|
routine cannot be over-ridden from the command line helper script because |
|
47
|
|
|
|
|
|
|
no sensible substitute routine could be handled well in one-line. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub default_comp_root { |
|
53
|
1
|
|
|
1
|
|
5
|
use File::Spec; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
220
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
0
|
|
File::Spec->rel2abs('root'); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub comp_root_logic { |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
0
|
|
q/do { my ($appname) = split '::', __PACKAGE__; $appname->config->{root} } / |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub mk_compclass { |
|
65
|
0
|
|
|
0
|
0
|
|
my ( $self, $helper, $comp_root, $skeleton ) = @_; |
|
66
|
0
|
|
|
|
|
|
my $file = $helper->{file}; |
|
67
|
0
|
0
|
|
|
|
|
unless ($comp_root) { |
|
68
|
0
|
|
|
|
|
|
$comp_root = comp_root_logic; |
|
69
|
0
|
|
|
|
|
|
print STDERR '$comp_root not supplied... defaulting to ' . $comp_root; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$helper->render_file( |
|
73
|
0
|
|
|
|
|
|
'compclass', |
|
74
|
|
|
|
|
|
|
$file, { |
|
75
|
|
|
|
|
|
|
comp_root => $comp_root, |
|
76
|
|
|
|
|
|
|
skeleton => $skeleton, |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
L<Catalyst::View::Seamstress>, |
|
85
|
|
|
|
|
|
|
L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>, |
|
86
|
|
|
|
|
|
|
L<Catalyst::Response>, L<Catalyst::Helper>, |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Terrence Brannon <metaperl@gmail.com> |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 LICENSE |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This library is free software . You can redistribute it and/or modify |
|
96
|
|
|
|
|
|
|
it under the same terms as perl itself. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__DATA__ |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__compclass__ |
|
105
|
|
|
|
|
|
|
package [% class %]; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
use strict; |
|
108
|
|
|
|
|
|
|
#use base 'Catalyst::Base'; |
|
109
|
|
|
|
|
|
|
#use base 'Catalyst::View::Seamstress'; |
|
110
|
|
|
|
|
|
|
#use base qw(Class::Prototyped HTML::Seamstress); |
|
111
|
|
|
|
|
|
|
use base qw(Catalyst::View::Seamstress HTML::Seamstress); |
|
112
|
|
|
|
|
|
|
use vars qw($comp_root); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
BEGIN { |
|
115
|
|
|
|
|
|
|
# edit this to '/ernest/dev/catalyst-simpleapp/root' |
|
116
|
|
|
|
|
|
|
# or something along those lines... wherever the |
|
117
|
|
|
|
|
|
|
# HTML for Seamstress to rewrite is. |
|
118
|
|
|
|
|
|
|
$comp_root = [% comp_root %]; |
|
119
|
|
|
|
|
|
|
$comp_root .= '/' unless $comp_root =~ m![/]$!; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub comp_root { $comp_root } |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__PACKAGE__->config( |
|
125
|
|
|
|
|
|
|
comp_root => $comp_root, |
|
126
|
|
|
|
|
|
|
fixup => sub { } , |
|
127
|
|
|
|
|
|
|
skeleton => '[% skeleton %]', |
|
128
|
|
|
|
|
|
|
meat_pack => sub { |
|
129
|
|
|
|
|
|
|
my ($self, $c, $stash, $meat, $skeleton) = @_; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $body_elem = $skeleton->look_down('_tag' => 'body'); |
|
132
|
|
|
|
|
|
|
my $meat_body = $skeleton->look_down(seamstress => 'replace'); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
unless ($meat_body) { |
|
135
|
|
|
|
|
|
|
warn "could not find meat_body"; |
|
136
|
|
|
|
|
|
|
die $meat->as_HTML; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$meat_body->replace_content($meat->content_list); |
|
140
|
|
|
|
|
|
|
} # default sub, only runs if skeleton is true |
|
141
|
|
|
|
|
|
|
) ; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
use lib $comp_root; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 NAME |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
[% class %] - Catalyst Seamstress View |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
See L<[% app %]> |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Catalyst Seamstress View. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 METHODS |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 comp_root |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This method returns the root of your html file tree which is normally something |
|
166
|
|
|
|
|
|
|
like /full/path/to/MyApp/root/ |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 AUTHOR |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
[% author %] |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 LICENSE |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify |
|
176
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |