1 package SCSite::SidebarFilter;
7 has _page_set => (is => 'ro', required => 1);
10 my ($class, $site) = @_;
11 $class->new(_page_set => $site->pages);
16 ->get({ path => '/news/archive' })
17 ->children(at_depth => 3)
22 sub _latest_news_archives {
24 ->get({ path => '/news/archive' })
25 ->${\sub { # archive page plus three latest per-month
27 ($o, $o->children(at_depth => 2)->latest(3)->flatten)
31 sub _latest_blog_posts {
33 ->get({ path => '/blog' })
34 ->children(min_depth => 2, max_depth => 0)
39 has _sidebar_structure => (is => 'lazy');
41 sub _build__sidebar_structure {
45 [ 'Latest News Items', $self->_latest_news ],
46 [ 'Archives', $self->_latest_news_archives ],
49 [ 'Latest Blog Posts', $self->_latest_blog_posts ],
55 my ($self, $stream) = @_;
56 my @blocks = @{$self->_sidebar_structure};
57 $stream->select('.sidebar.block')->repeat([
58 map { my ($t, @seg) = @$_; sub {
59 $_->select('.sidebar.title')->replace_content($t)
60 ->select('.sidebar.segment')->repeat([
61 map { my ($s, @e) = @$_; sub {
62 $_->select('.sidebar.subtitle')->replace_content($s)
63 ->select('.sidebar.entries')->repeat_content([
64 map { my $e = $_; sub {
65 $_->select('.entry.title')
66 ->replace_content($e->title)
67 ->select('.entry.link')
68 ->set_attribute(href => $e->path)