Permalink
Browse files

Much messing with urls, to get the correct one for videos

Some video file names with odd (eg "?") chars it still fail
  • Loading branch information...
1 parent 050ca46 commit b973083caed8050a9d2f7322b96d417513de461e Unknown committed Sep 22, 2012
Showing with 14 additions and 3 deletions.
  1. +13 −2 lib/PresentingPerl/Web/Controller/Root.pm
  2. +1 −1 lib/PresentingPerl/Web/View/Zoom/Root.pm
@@ -4,6 +4,7 @@ use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller' }
use List::Util qw(first);
+use URI::Escape;
#
@@ -32,6 +33,10 @@ sub auto :Private {
my ($self, $c) = @_;
$c->stash->{wrapper_template} = $c->path_to('root/pp-tempates/html/layout.html');
+
+# my $base_uri = $c->req->base;
+# $base_uri =~ s/\.index.psgi//;
+# $c->req->base($base_uri);
}
=head2 front_page
@@ -69,14 +74,20 @@ sub video :Path :Args(2) {
my $video_file = first {
-e join('/', $c->path_to('root/static'), $_)
} map {
- join('/', 'videos', $videorow->bucket->slug, $videorow->slug, $videorow->file_name.".$_")
+ join('/', 'videos', $videorow->bucket->slug, $videorow->slug, uri_escape($videorow->file_name).".$_")
} @{ $c->config->{SupportedFormats} };
$c->log->debug("File: $video_file, row: $videorow");
return $c->forward('default') if(!$videorow || (!$video_file && !$videorow->external_embed_link));
if($video_file) {
- $video_file = $c->req->base . 'static/' . $video_file;
+ my $base_uri = $c->req->base->as_string;
+ $base_uri =~ s{index.psgi/}{};
+# $video_file = uri_escape($video_file);
+ $c->log->debug("Setting video url using: $base_uri\n");
+ $video_file = $base_uri . 'static/' . $video_file;
+# $video_file = $c->req->base . 'static/' . $video_file;
+# $video_file = $c->uri_for('/static/' . $video_file);
}
$c->stash->{current_view} = 'Zoom';
@@ -91,7 +91,7 @@ sub video {
my $container_zoom = HTML::Zoom->from_file(PresentingPerl::Web->path_to('root/'.$stash->{video_type}));
$container_zoom = $container_zoom->select('*')->template_text_raw( { video_file => $video_url } );
$container_zoom = $container_zoom->select('iframe')->set_attribute( src => $video_url );
-# print STDERR "Video file: $video_url\n";
+ print STDERR "Video file: $video_url\n";
# print STDERR "CZ: ", $container_zoom->to_html, "\n";

0 comments on commit b973083

Please sign in to comment.