X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FApp%2FIdiotBox.pm;h=0d7956a8eb7c14fad4d7beb5963eb00c68c4e6ca;hb=71a02d85ebece24abbc547892dd252836cf1bf6d;hp=c59240cd04f2859acf0d60d643255e5f06feb28e;hpb=d9702c6d2c59be57383275e22cbc7c8b11c54ba6;p=catagits%2FApp-IdiotBox.git diff --git a/lib/App/IdiotBox.pm b/lib/App/IdiotBox.pm index c59240c..0d7956a 100644 --- a/lib/App/IdiotBox.pm +++ b/lib/App/IdiotBox.pm @@ -33,9 +33,23 @@ use HTML::Zoom; } default_config( - template_dir => $FindBin::Bin.'/../share/html' + template_dir => 'share/html', + store => 'SQLite', + db_file => 'var/lib/idiotbox.db', ); +sub BUILD { + my $self = shift; + my $store; + ($store = $self->config->{store}) =~ /^(\w+)$/ + or die "Store config should be just a name, got ${store} instead"; + my $store_class = "App::IdiotBox::Store::${store}"; + eval "require ${store_class}; 1" + or die "Couldn't load ${store} store: $@"; + $store_class->bind($self); +} + + dispatch { sub (/) { $self->show_front_page }, subdispatch sub (/*/...) { @@ -44,7 +58,7 @@ dispatch { sub (/) { $self->show_bucket($bucket) }, - sub (/*) { + sub (/*/) { $self->show_video($bucket->videos->get({ slug => $_[1] })); } ] @@ -53,6 +67,8 @@ dispatch { method recent_announcements { $self->{recent_announcements} } +method buckets { $self->{buckets} } + method show_front_page { my $ann = $self->recent_announcements; $self->html_response(