search spec components factored out of T365
[catagits/Reaction.git] / lib / Reaction / UI / Widget / SiteLayout.pm
CommitLineData
8a293e2e 1package Reaction::UI::Widget::SiteLayout;
2
3use Reaction::UI::WidgetClass;
4use aliased 'Reaction::UI::Widget::Container';
659899df 5use MooseX::Types::Moose 'HashRef';
8a293e2e 6
bae75bee 7use namespace::clean -except => [ qw(meta) ];
8extends Container;
414f3276 9
bae75bee 10after fragment widget {
11 arg static_base => $_{viewport}->static_base_uri;
12 arg title => $_{viewport}->title;
8a293e2e 13};
14
bae75bee 15implements fragment meta_info {
16 my $self = shift;
17 if ( $_{viewport}->meta_info->{'http_header'} ) {
1ef7b9da 18 my $http_header = delete $_{viewport}->meta_info->{'http_header'};
19 arg 'http_header' => $http_header;
20 render 'meta_http_header' => over [keys %$http_header];
bae75bee 21 }
22 render 'meta_member' => over [keys %{$_{viewport}->meta_info}];
23};
24
25implements fragment meta_http_header {
26 arg 'meta_name' => $_;
1ef7b9da 27 arg 'meta_value' => $_{'http_header'}->{$_};
bae75bee 28};
29
30implements fragment meta_member {
31 arg 'meta_name' => $_;
32 arg 'meta_value' => $_{viewport}->meta_info->{$_};
33};
34
35__PACKAGE__->meta->make_immutable;
36
8a293e2e 371;
f9b32c83 38
39__END__
40
41=head1 NAME
42
43Reaction::UI::Widget::SiteLayout - The layout of the site as a whole
44
45=head1 DESCRIPTION
46
47This is a subclass of L<Reaction::UI::Widget::Container>. It is generally
48used as the widget surrounding the site's content.
49
50=head1 FRAGMENTS
51
52=head2 widget
53
54Additionally provides these arguments after the parent widget fragment
55has been rendered:
56
57=over 4
58
59=item static_base
60
61The C<static_base_uri> of the viewport.
62
63=item title
64
65The C<title> attribute value of the viewport.
66
67=back
68
69=head2 meta_info
70
71If the viewports C<meta_info> contains a value for C<http_header>, It will
72be removed and set as C<http_header> argument. Next, the C<meta_http_header>
73fragment will be rendered for each key of the C<http_header> hash reference.
74
75After the C<http_header> processing, the remaining keys of the viewports
76C<meta_info> attribute hash reference will be rendered via the C<meta_member>
77fragment.
78
79=head2 meta_http_header
80
81Additionally provides these arguments:
82
83=over 4
84
85=item meta_name
86
87The current value of the C<_> argument, which will be set to the key of
88the C<http_header> argument hash reference when rendered by the
89C<meta_info> fragment.
90
91=item meta_value
92
93The value of the C<meta_name> key in the C<http_header> argument hash
94reference.
95
96=back
97
98=head2 meta_member
99
100Additionally provides these arguments:
101
102=over 4
103
104=item meta_name
105
106The current value of the C<_> argument, which will be set to the key of
107the viewport's C<meta_info> attribte value when rendered by the
108C<meta_info> fragment.
109
110=item meta_value
111
112The value of the C<meta_name> key in the viewport's C<meta_info> attribute
113hash reference.
114
115=back
116
117=head1 LAYOUT SETS
118
119=head2 base
120
121 share/skin/base/layout/site_layout.tt
122
123The base layout set will provide the following layouts:
124
125=over 4
126
127=item widget
128
129This layout will render the C<doctype> fragment at the top of the page. Then
130the traditional HTML layout with a C<html> element containing C<head> (rendering
131the C<head> fragment and C<body> (rendering the C<body> fragment) elements.
132
133=item head
134
135Will render the C<title> argument in a C<title> element. After that it will render
136the C<head_meta>, C<head_scripts> and C<head_style> fragments.
137
138=item head_meta
139
140Renders the C<meta_info> fragment.
141
142=item meta_http_header
143
144Renders a C<meta> element where the value of the C<http-equiv> attribute is set to
145the C<meta_name> argument and the C<content> attribute is set to the C<meta_value>
146argument.
147
148=item meta_member
149
150Renders a C<meta> element where the C<name> attribute is set to the C<meta_name>
151argument and the C<content> attribute is set to the C<meta_value> argument.
152
153=item head_scripts
154
155Is empty by default.
156
157=item head_style
158
159Is empty by default.
160
161=item doctype
162
163By default this renders an C<XHTML 1.0 Transitional> doctype.
164
165=item body
166
167This will render the C<inner> viewports in the focus stack.
168
169=back
170
171=head2 default
172
173 share/skin/default/layout/site_layout.tt
174
175The C<site_layout> layout set in the C<default> skin extends the one in the
176C<base> skin documented above.
177
178The following layouts are provided:
179
180=over 4
181
182=item widget
183
184This layout is mostly the same as the one in the C<base> skin, except that
185the C<html> element has C<xmlns> and C<xml:lang> attributes set.
186
187=back
188
189=head1 AUTHORS
190
191See L<Reaction::Class> for authors.
192
193=head1 LICENSE
194
195See L<Reaction::Class> for the license.
196
197=cut