working bucket and video renders
Matt S Trout [Mon, 18 Jan 2010 21:20:06 +0000 (21:20 +0000)]
lib/App/IdiotBox.pm
share/html/video.html
t/show/bucket.t [new file with mode: 0644]

index 4d880c7..12393e8 100644 (file)
@@ -17,6 +17,15 @@ use HTML::Zoom;
   sub slug { shift->{slug} }
   sub name { shift->{name} }
   sub video_count { shift->{video_count} }
+  sub videos { shift->{videos} }
+
+  package App::IdiotBox::Video;
+
+  sub slug { shift->{slug} }
+  sub name { shift->{name} }
+  sub author { shift->{author} }
+  sub details { shift->{details} }
+  sub bucket { shift->{bucket} }
 }
 
 default_config(
index 3ec5555..a8cd02e 100644 (file)
@@ -3,7 +3,7 @@
   <div id="main-content">
     <h2 class="fill-video-name">Really Imaginative Video Name</h2>
     <h4 class="fill-author-name">Just Another Audience Hacker</h4>
-    <a href="fill-bucket-link">
+    <a class="fill-bucket-link">
       To go back to the
       <b class="fill-bucket-name">Some Random Event</b>
       group of videos, click here.
diff --git a/t/show/bucket.t b/t/show/bucket.t
new file mode 100644 (file)
index 0000000..5f1df83
--- /dev/null
@@ -0,0 +1,59 @@
+use strict;
+use warnings FATAL => 'all';
+use Test::More;
+
+use App::IdiotBox;
+use Data::Perl::Collection::Set;
+use Scalar::Util qw(weaken);
+
+my $idiotbox = App::IdiotBox->new({
+ config => { template_dir => 'share/html' }
+});
+
+my $bucket = bless({
+  slug => 'lpw2009',
+  name => 'London Perl Workshop 2009',
+}, 'App::IdiotBox::Bucket');
+
+my %vid;
+
+$bucket->{videos} = Data::Perl::Collection::Set->new(
+    members => [ map {
+      my $o = bless(
+        { %$_, bucket => $bucket, details => ''  },
+        'App::IdiotBox::Video'
+      );
+      weaken($o->{bucket});
+      $vid{$o->{slug}} = $o
+    }
+      { name => 'The M Word', slug => 'm-word', author => 'davorg' },
+      { name => 'Dreamcasting', slug => 'dream', author => 'mst' },
+  ]
+);
+
+sub slurp_html {
+  my $string;
+  my $fh = $_[0]->[-1];
+  while (defined (my $chunk = $fh->getline)) {
+    $string .= $chunk;
+  }
+  $string;
+} 
+
+my $bucket_result = $idiotbox->show_bucket($bucket);
+
+my $html = slurp_html($bucket_result);
+
+warn $html;
+
+warn "\n\n------\n\n";
+
+my $video_result = $idiotbox->show_video($vid{dream});
+
+$html = slurp_html($video_result);
+
+warn $html;
+
+pass;
+
+done_testing;