3 use Web::Simple __PACKAGE__;
4 use Method::Signatures::Simple;
7 sub (/) { $self->show_front_page },
8 subdispatch sub (/*/...) {
9 my $bucket = $self->buckets->get({ slug => $_[1] });
12 $self->show_bucket($bucket)
15 $self->show_video($bucket->videos->get({ slug => $_[1] });
21 method show_front_page {
22 my $ann = $self->recent_announcements;
25 '#announcement-list' => {
27 data => $ann->map(sub { +{
28 '#fill-bucket-name' => { -replace_content => $_->bucket->name },
29 '#fill-bucket-link' => {
30 -set_attribute => { name => 'href', value => '/'.$_->slug.'/' }
32 '#fill-new-videos' => $_->videos->count,
33 '#fill-total-videos' => $_->bucket->videos->count,
41 method html_response ($template_name, $selectors) {
42 my $io = $self->_zoom_for($template_name => $selectors)->as_io;
43 return [ 200, [ 'Content-Type' => 'text/html' ], $io ]
47 $self->{layout_zoom} ||= HTML::Zoom->from_filename(
48 $self->_teamplate_filename_for('layout')
52 method _zoom_for ($template_name, $selectors) {
53 ($self->{zoom_for_template}{$template_name} ||= do {
55 HTML::Zoom->from_filename(
56 $self->_template_filename_for($template_name);
59 '#main-content' => { -capture_events_into => \@body }
62 my @all = $self->_layout_zoom->with_selectors(
64 -replace_content_events => \@body
67 HTML::Zoom->from_events(\@all)
68 })->with_selectors(@$selectors)