Allow creating of new buckets by using the importer
[catagits/App-IdiotBox.git] / lib / App / IdiotBox.pm
index 88e90c6..081327e 100644 (file)
@@ -1,5 +1,6 @@
 package App::IdiotBox;
 
+use App::IdiotBox::Common qw(@SupportedFormats);
 use Web::Simple __PACKAGE__;
 use FindBin;
 use HTML::Zoom;
@@ -41,6 +42,8 @@ use List::Util qw(first);
   }
 }
 
+has $_ => (is => 'ro') for qw(recent_announcements buckets);
+
 sub default_config {
   template_dir => 'share/html',
   store => 'SQLite',
@@ -74,10 +77,6 @@ sub dispatch_request {
   }
 }
 
-sub recent_announcements { shift->{recent_announcements} }
-
-sub buckets { shift->{buckets} }
-
 sub show_front_page {
   my $self = shift;
   my $ann = $self->recent_announcements;
@@ -89,9 +88,9 @@ sub show_front_page {
             sub {
               $_->select('.bucket-name')->replace_content($obj->bucket->name)
                 ->select('.made-at')->replace_content($obj->made_at)
-                ->select('.bucket-link')->set_attribute({
-                    name => 'href', value => $obj->bucket->slug.'/'
-                  })
+                ->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
@@ -112,7 +111,7 @@ sub show_bucket {
             $_->select('.video-name')->replace_content($video->name)
               ->select('.video-author')->replace_content($video->author)
               ->select('.video-link')->set_attribute(
-                  { name => 'href', value => $video->slug.'/' }
+                  href => $video->slug.'/'
                 )
           }
         }))
@@ -125,7 +124,7 @@ sub show_video {
     -e join('/', $self->config->{base_dir}, $_)
   } map {
     join('/', $video->bucket->slug, $video->slug, $video->file_name.".$_")
-  } qw(flv m4v);
+  } @SupportedFormats;
   $self->html_response(video => sub {
     my $video_url = 
       $self->base_url
@@ -134,7 +133,7 @@ sub show_video {
     $_->select('.video-name')->replace_content($video->name)
       ->select('.author-name')->replace_content($video->author)
       ->select('.bucket-link')->set_attribute(
-          { name => 'href', value => '../' }
+          href => '../'
         )
       ->select('.bucket-name')->replace_content($video->bucket->name)
       ->select('.video-details')->replace_content($video->details)