Browse files

Added archive controller and view

It is basically just the same as front_page, but with all conferences
listed and no mention of new videos, only totals.
  • Loading branch information...
1 parent 97731b3 commit 51c5c7c50dadf64fe3a473f62902d1f0f0c63d4e @robinsmidsrod robinsmidsrod committed Jun 30, 2012
View
53 lib/PresentingPerl/Web/Controller/Archive.pm
@@ -0,0 +1,53 @@
+package PresentingPerl::Web::Controller::Archive;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller'; }
+
+=head1 NAME
+
+PresentingPerl::Web::Controller::Archive - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 index
+
+The archive page (/archive)
+
+=cut
+
+sub index :Path :Args(0) {
+ my ($self, $c) = @_;
+
+ $c->stash->{current_view} = 'Zoom';
+ $c->stash->{announcements} = $c->model('DB::Announcement')->search(
+ {},
+ {
+ 'group_by' => 'bucket_slug',
+ 'order_by' => { -desc => 'made_at' },
+ },
+ );
+}
+
+
+=head1 AUTHOR
+
+Robin Smidsrød,,,
+
+=head1 LICENSE
+
+This library is free software. You can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+
+1;
View
50 lib/PresentingPerl/Web/View/Zoom/Archive.pm
@@ -0,0 +1,50 @@
+package PresentingPerl::Web::View::Zoom::Archive;
+use Moose;
+
+use Data::Dumper;
+use HTML::Zoom::FilterBuilder::Template;
+
+sub wrap {
+ my ($self, $zoom, $stash) = @_;
+
+ my @body;
+
+ $zoom->select('#main-content')->collect_content({into => \@body})->run;
+
+ my $layout_zoom = HTML::Zoom->from_file($stash->{wrapper_template});
+ # This does *not* modify $layout_zoom, but rather returns the modified version!
+ return $layout_zoom->select('#main-content')->replace_content(\@body);
+}
+
+sub index {
+ my ($self, $stash) = @_;
+
+ my $zoom = $_;
+
+ if (!$ENV{TEST_NO_DB}) {
+ my $dt_formatter = sub {
+ my ($dt) = @_;
+ return '' unless blessed($dt) and $dt->isa('DateTime');
+ return $dt->ymd('-');
+ };
+ my $announcements = $stash->{announcements};
+ my $ann_list = [
+ map {
+ my $obj = $_;
+ sub {
+ $_->select('.bucket-name')->replace_content( $obj->bucket->name )->select('.made-at')
+ ->replace_content( $dt_formatter->($obj->made_at) )->select('.bucket-link')
+ ->set_attribute( 'href' => '/' . $obj->bucket->slug . '/' )
+ #->select('.new-videos')->replace_content($obj->video_count)
+ ->select('.total-videos')->replace_content( $obj->bucket->video_count );
+ }
+ } $announcements->all
+ ];
+
+ $zoom = $zoom->select('#announcement-list')->repeat_content($ann_list);
+ }
+
+ $self->wrap($zoom, $stash);
+}
+
+1;
View
48 root/archive/index
@@ -0,0 +1,48 @@
+ <div id="main-content">
+
+ <h1>
+ Full archive of Presenting Perl
+ </h1>
+
+ <div id="navbar">
+ <ul>
+ <li><a href="/">Home</a></li>
+ <li><a href="/archive/">Archive</a></li>
+ </ul>
+ </div>
+
+
+ <div id="custom-html">
+
+ <p>
+ Perl talks and Perl presentations about the
+ <a href="http://www.perl.org/">Perl programming language</a>.
+ Videos and audio from conferences and workshops around the world.
+ </p>
+
+ <h2 class="author-name">
+ List of videos available
+ </h2>
+ <ul id="announcement-list">
+ <li class="announcement">
+ <span class="made-at">1st March 2010</span>
+ <a class="bucket-link">
+ <span class="bucket-name">Some Random Event</span>
+ (<span class="total-videos">4</span> videos)
+ </a>
+ </li>
+ </ul>
+
+ <h2>Licences</h2>
+ <p>
+ All of the material has a licence on the page it is on. The general site
+ licence is a "Creative Commons Attribution - Noncommercial - No Derivative
+ Works 3.0 Unported Licence", other material provided by authors may have their
+ own restrictions and conditions. If you wish to use any of the material at
+ another location then please contact the site owners to confirm usage.
+ </p>
+
+ </div>
+
+<!-- END MAIN CONTENT -->
+ </div>
View
1 root/front_page
@@ -7,6 +7,7 @@
<div id="navbar">
<ul>
<li><a href="/">Home</a></li>
+ <li><a href="/archive/">Archive</a></li>
</ul>
</div>
View
10 t/controller_Archive.t
@@ -0,0 +1,10 @@
+use strict;
+use warnings;
+use Test::More;
+
+
+use Catalyst::Test 'PresentingPerl::Web';
+use PresentingPerl::Web::Controller::Archive;
+
+ok( request('/archive')->is_success, 'Request should succeed' );
+done_testing();

0 comments on commit 51c5c7c

Please sign in to comment.