X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FApp-IdiotBox.git;a=blobdiff_plain;f=lib%2FApp%2FIdiotBox.pm;fp=lib%2FApp%2FIdiotBox.pm;h=c91d6c8a26682c2e4526c0bef6992f87de097b50;hp=497cb98997124f5869aa8e38f603249f6dee34d0;hb=847de56a0b78dea62c1cb4317c055a91236e6449;hpb=6df0509024f4a9c2c545615b6648ca1365689cfc diff --git a/lib/App/IdiotBox.pm b/lib/App/IdiotBox.pm index 497cb98..c91d6c8 100644 --- a/lib/App/IdiotBox.pm +++ b/lib/App/IdiotBox.pm @@ -1,7 +1,6 @@ package App::IdiotBox; use Web::Simple __PACKAGE__; -use Method::Signatures::Simple; use FindBin; use HTML::Zoom; use HTML::Zoom::FilterBuilder::Template; @@ -76,11 +75,12 @@ dispatch { } }; -method recent_announcements { $self->{recent_announcements} } +sub recent_announcements { shift->{recent_announcements} } -method buckets { $self->{buckets} } +sub buckets { shift->{buckets} } -method show_front_page { +sub show_front_page { + my $self = shift; my $ann = $self->recent_announcements; $self->html_response( front_page => sub { @@ -103,7 +103,8 @@ method show_front_page { ); } -method show_bucket ($bucket) { +sub show_bucket { + my ($self, $bucket) = @_; $self->html_response(bucket => sub { $_->select('.bucket-name')->replace_content($bucket->name) ->select('#video-list')->repeat_content($bucket->videos->map(sub { @@ -119,7 +120,8 @@ method show_bucket ($bucket) { }); } -method show_video ($video) { +sub show_video { + my ($self, $video) = @_; my $video_file = first { -e join('/', $self->config->{base_dir}, $_) } map { @@ -141,22 +143,26 @@ method show_video ($video) { }); } -method html_response ($template_name, $selectors) { +sub html_response { + my ($self, $template_name, $selectors) = @_; my $io = $self->_zoom_for($template_name => $selectors)->to_fh; return [ 200, [ 'Content-Type' => 'text/html' ], $io ] } -method _template_filename_for ($name) { +sub _template_filename_for { + my ($self, $name) = @_; $self->{config}{template_dir}.'/'.$name.'.html'; } -method _layout_zoom { +sub _layout_zoom { + my $self = shift; $self->{layout_zoom} ||= HTML::Zoom->from_file( $self->_template_filename_for('layout') ) } -method _zoom_for ($template_name, $selectors) { +sub _zoom_for { + my ($self, $template_name, $selectors) = @_; ($self->{zoom_for_template}{$template_name} ||= do { my @body; HTML::Zoom->from_file( @@ -170,21 +176,24 @@ method _zoom_for ($template_name, $selectors) { })->apply($selectors); } -method base_url { +sub base_url { + my $self = shift; $self->{base_url} ||= do { (my $u = $self->config->{base_url}) =~ s/\/$//; "${u}/"; } } -method _run_cli { +sub _run_cli { + my $self = shift; unless (@ARGV == 1 && $ARGV[0] eq 'import') { return $self->SUPER::_run_cli(@_); } $self->cli_import; } -method _cli_usage { +sub _cli_usage { + my $self = shift; "To import data into your idiotbox install, chdir into a directory\n". "containing video files and run:\n". "\n". @@ -193,7 +202,8 @@ method _cli_usage { $self->SUPER::_cli_usage(@_); } -method cli_import { +sub cli_import { + my $self = shift; require App::IdiotBox::Importer; App::IdiotBox::Importer->run($self); }