X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FApp%2FIdiotBox.pm;fp=lib%2FApp%2FIdiotBox.pm;h=dff116bbb82888e4d51f0d2ed43abbbe6d3fdc57;hb=998cc52c6620a1c21669d7a3c28eb305c1c8f9ea;hp=4a11aca0e1596251396a93f8af203e1a71ebda75;hpb=eca3a074385094d645c983dc5b62f61ef9c2f3d3;p=catagits%2FApp-IdiotBox.git diff --git a/lib/App/IdiotBox.pm b/lib/App/IdiotBox.pm index 4a11aca..dff116b 100644 --- a/lib/App/IdiotBox.pm +++ b/lib/App/IdiotBox.pm @@ -4,6 +4,7 @@ use Web::Simple __PACKAGE__; use Method::Signatures::Simple; use FindBin; use HTML::Zoom; +use HTML::Zoom::FilterBuilder::Template; { package App::IdiotBox::Announcement; @@ -30,12 +31,17 @@ use HTML::Zoom; sub author { shift->{author} } sub details { shift->{details} } sub bucket { shift->{bucket} } + sub file_name { + (my $s = join(' ', @{+shift}{qw(author name)})) =~ s/ /-/g; + $s; + } } default_config( template_dir => 'share/html', store => 'SQLite', db_file => 'var/lib/idiotbox.db', + base_url => 'http://localhost:3000/', ); sub BUILD { @@ -108,6 +114,10 @@ method show_bucket ($bucket) { method show_video ($video) { $self->html_response(video => sub { + my $video_url = + $self->base_url + .join('/', $video->bucket->slug, $video->slug, $video->file_name.'.flv'); + $_->select('.video-name')->replace_content($video->name) ->select('.author-name')->replace_content($video->author) ->select('.bucket-link')->set_attribute( @@ -115,6 +125,7 @@ method show_video ($video) { ) ->select('.bucket-name')->replace_content($video->bucket->name) ->select('.video-details')->replace_content($video->details) + ->select('script')->template_text_raw({ video_url => $video_url }); }); } @@ -147,4 +158,11 @@ method _zoom_for ($template_name, $selectors) { })->apply($selectors); } +method base_url { + $self->{base_url} ||= do { + (my $u = $self->config->{base_url}) =~ s/\/$//; + "${u}/"; + } +} + 1;