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