Skip to content
Browse files

Merge master into archive

  • Loading branch information...
1 parent e716f73 commit 25758966d4aebeefb8c26725cd0d51e0556f42b9 @robinsmidsrod robinsmidsrod committed Jul 1, 2012
View
39 lib/PresentingPerl/Web/Controller/Admin.pm
@@ -5,6 +5,10 @@ use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller::ActionRole' }
+## If the admin user edits or adds a video, we create a pending announcement and stuff it in their session
+## thereafter the UI should display the pending announcement and a link to releasing it
+## currently announcements are tied to buckets.. sane or not sane?
+
## This thing runs on HTML::Zoom, look in View::Zoom::Admin to see how the stash is applied to the templates.
sub begin : Private {
my ($self, $c) = @_;
@@ -82,6 +86,7 @@ sub edit_bucket :Chained('bucket') :PathPart('') :Args(0) {
my $name = $c->req->param('new_name');
my $title = $c->req->param('title');
my $author = $c->req->param('author');
+ my $embed_link = $c->req->param('external_embed_link');
$c->stash($c->req->params);
if(!$name && !$title && !$author) {
@@ -93,12 +98,32 @@ sub edit_bucket :Chained('bucket') :PathPart('') :Args(0) {
$c->stash->{bucket}->update({ name => $name });
} else {
+ if($embed_link && $embed_link =~ m{^https?://(?:www\.)?youtube\.com/.*v=(\w+)}) {
+ $embed_link = "http://www.youtube.com/embed/$1";
+ } else {
+ $c->log->debug($c->user->get_object->username . " tried to embed a link to $embed_link but it's not a youtube video");
+ $embed_link = '';
+ }
+
+ ## fetch/create pending announcement
+ my $announce_id = $c->session->{announcement_id};
+ if(!$announce_id) {
+ my $announce = $c->model('DB::Announcement')->create({
+ made_at => DateTime->now,
+ bucket_slug => $c->stash->{bucket}->slug,
+ });
+ $c->session->{announcement_id} = $announce->id;
+ $announce_id = $announce->id;
+ }
+
## This will currently fail as we have no announcement id!
- (my $slug = lc $name) =~ s/ /-/g;
+ (my $slug = lc $title) =~ s/ /-/g;
$c->stash->{videos_rs}->create({
author => $author,
name => $title,
slug => $slug,
+ external_embed_link => $embed_link,
+ announcement_id => $announce_id,
});
}
}
@@ -116,18 +141,24 @@ sub edit_video :Chained('bucket') :PathPart('') :Args(1) {
}
if($c->req->param) {
- my ($title, $author) = ($c->req->param('title'),
- $c->req->param('author') );
+ my ($title, $author, $embed_link) = ($c->req->param('title'),
+ $c->req->param('author'),
+ $c->req->param('external_embed_link'));
$c->stash($c->req->params);
if(!$title || !$author) {
$c->stash('error', 'Please fill in both an author and a title for the video');
return;
}
-
+
+ if($embed_link && $embed_link !~ m{^https?://(www\.)?youtube}) {
+ $c->log->debug($c->user->get_object->username . " tried to embed a link to $embed_link but it's not a youtube video");
+ $embed_link = '';
+ }
$c->stash->{video}->update({
name => $title,
author => $author,
+ external_embed_link => $embed_link
});
}
View
15 lib/PresentingPerl/Web/Controller/Root.pm
@@ -69,13 +69,22 @@ sub video :Path :Args(2) {
} @{ $c->config->{SupportedFormats} };
$c->log->debug("File: $video_file, row: $videorow");
- return $c->forward('default') if(!$videorow || !$video_file);
+ return $c->forward('default') if(!$videorow || (!$video_file && !$videorow->external_embed_link));
- $video_file = $c->req->base . 'static/' . $video_file;
+ if($video_file) {
+ $video_file = $c->req->base . 'static/' . $video_file;
+ }
$c->stash->{current_view} = 'Zoom';
$c->stash->{video} = $videorow;
- $c->stash->{video_file} = $video_file;
+ if($videorow->external_embed_link) {
+ $c->log->debug("Got a youtube video");
+ $c->stash->{video_file} = $videorow->external_embed_link;
+ $c->stash->{video_type} = 'youtube';
+ } else {
+ $c->stash->{video_type} = 'local';
+ $c->stash->{video_file} = $video_file;
+ }
}
View
2 lib/PresentingPerl/Web/View/Zoom/Admin.pm
@@ -29,7 +29,7 @@ sub all_buckets {
$_->select('.bucket-slug')->replace_content($obj->slug)
->select('.bucket-name')->replace_content($obj->name)
->select('.edit-link')->set_attribute(
- 'href' => $obj->slug.'/'
+ 'href' => 'buckets/' . $obj->slug.'/'
)
->select('.delete-link')->set_attribute(
'href' => $obj->slug.'/delete/'
View
21 lib/PresentingPerl/Web/View/Zoom/Root.pm 100644 → 100755
@@ -39,7 +39,8 @@ sub front_page {
# ->select('.new-videos')->replace_content($obj->video_count)
->select('.total-videos')->replace_content(
$obj->bucket->video_count
- )
+ );
+
}
} $announcements->all ];
@@ -83,17 +84,31 @@ sub video {
my $zoom = $_;
+ # FIXME: I don't have a $c, so what should I be calling ->path_to on?
+ ## Also, mr ugly code: the 1st c_z line works for the local script template
+ ## the 2nd line works for the youtube iframe template
+ ## they seem to happily no-op on the "wrong" ones.. !
+ 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 "CZ: ", $container_zoom->to_html, "\n";
+
+
$zoom = $zoom->select('.video-name')->replace_content($video->name)
->select('.author-name')->replace_content($video->author)
->select('.bucket-link')->set_attribute(
href => '../'
)
->select('.bucket-name')->replace_content($video->bucket->name)
->select('.video-details')->replace_content($video->details)
- ->select('script')->template_text_raw({ video_url => $video_url });
+ ->select('.videocontainer')->template_text_raw({ container => $container_zoom->to_html });
+
+
+# ->select('script')->template_text_raw({ video_url => $video_url });
$self->wrap($zoom, $stash);
-
+
}
1;
View
1 presentingperl_web.conf 100644 → 100755
@@ -32,3 +32,4 @@ SupportedFormats avi
</default>
</Plugin::Authentication>
+
View
2 root/admin/edit_bucket
@@ -23,6 +23,8 @@
<br /><br />
<label for="author">Video author: </label> <input type="text" name="author" id="author"/>
<br /><br />
+ <label for="author">Video to embed(optional): </label> <input type="text" name="external_embed_link"/>
+ <br /><br />
<input type="submit" value="Add Video"/>
</form>
View
2 root/admin/edit_video
@@ -13,6 +13,8 @@
<br /><br />
<label for="author">Author: </label> <input type="text" name="author"/>
<br /><br />
+ <label for="author">Video to embed(optional): </label> <input type="text" name="external_embed_link"/>
+ <br /><br />
<!--
<label for="new_file">Upload new file to bucket</label> <input type="file" name="new_file" accept="*.flv,*.m4v"/>
<br /><br />
View
12 root/video
@@ -4,17 +4,7 @@
<h1 class="video-name">Title here</h1>
<a href="../"><h3 class="bucket-name">Event name here</h3></a>
- <div id="mvcontainer"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
- <script type="text/javascript" src="http://media.dreamhost.com/mp4/swfobject.js"></script>
-
- <script type="text/javascript">
- var s1 = new SWFObject("http://media.dreamhost.com/mp4/player.swf","mp1","640","480","9","#FFFFFF");
- s1.addParam("allowfullscreen","true");
- s1.addParam("allowscriptaccess","always");
- s1.addParam("flashvars","&file=[% video_url %]");
- s1.write("mvcontainer");
- </script>
-
+ <div class="videocontainer">[% container %]</div>
<p class="video-license">
This work is licensed under a

0 comments on commit 2575896

Please sign in to comment.
Something went wrong with that request. Please try again.