Permalink
Browse files

video stuff

  • Loading branch information...
1 parent 859f69b commit 8a82d490f66e6c735e7c754f57e67fd2f5c8ac0d Quynh Pham committed Jan 29, 2012
@@ -16,8 +16,12 @@ def create
end
@interview_data[:user_id] = @user.id
@interview = Interview.new @interview_data
-
-
+ @video = Video.new
+ if params[:Filedata]
+
+ @video = @interview.videos.create(:file_data => params[:Filedata])
+ @video.save
+
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @interview }
View
@@ -0,0 +1,32 @@
+require 'video_upload'
+
+class AdVideo < ActiveRecord::Base
+ AVAILABLE_MIME_TYPES = ['video/quicktime', 'video/mpeg', 'video/x-msvideo', 'video/mp4', 'video/mpeg4', 'video/x-ms-asf', 'video/x-ms-wmv', 'video/x-flv']
+
+ belongs_to :interview
+
+
+
+ # Validations
+ validates_attachment_content_type :video,
+ :content_type => AVAILABLE_MIME_TYPES,
+ :message => 'Video file must have an extension .mov, .mp4, or .avi.'
+ validates_attachment_size :video, :in => 1..512.megabyte
+
+ attr_protected :video_file_name, :video_content_type, :video_size
+ attr_accessor :file_data
+
+ before_create :upload_to_youtube
+ def upload_to_youtube
+ unless self.youtube_code.blank?
+ self.youtube_code = self.youtube_code[/v=([^&.]*)/,1] || self.youtube_code
+ else
+ client = YouTubeG::Upload::VideoUpload.new
+ self.youtube_code = client.upload(self.file_data, self.interview)
+ end
+ end
+
+ def thumbnail(size = :small)
+ "http://img.youtube.com/vi/#{self.youtube_code}/#{size == :small ? 1 : 0}.jpg"
+ end
+end
@@ -0,0 +1,57 @@
+<!-- image uploadify -->
+<input id="upload-photo" name="upload-photo" type="file" />
+<!-- end of image uploadify -->
+
+<br /><br />
+
+<div id="thumbnails">
+ <% if ad and ad.ad_images %>
+ <% for ad_image in ad.ad_images %>
+ <%= render :partial => 'ad_images/thumb_preview', :locals => {:ad_image => ad_image} %>
+ <% end %>
+ <% end %>
+ <div class="clear">&nbsp;</div>
+</div>
+<!-- end of image uploader -->
+
+<div class="blank3">&nbsp;</div>
+<div class="form-lable"><h4>Add Videos (optional):</h4></div>
+
+<div class="form-lable2">
+ Do you have a youtube video?
+ <%= radio_button_tag 'youtube_yes', 'yes', false, :id => 'youtube_yes' %> <%= label_tag 'youtube_yes', 'Yes' %>
+ <%= radio_button_tag 'youtube_yes', 'no', true, :id => 'youtube_no' %> <%= label_tag 'youtube_no', 'No' %>
+</div>
+
+<div class="upload-cancel-btns" id="video_upload">
+ <br />
+
+ <!-- video uploadify -->
+ <input id="upload-video" name="upload-video" type="file" />
+ <!-- end of video uploadify -->
+ <br />
+ <div class="lable-txt pd-extra-txt">We accept videos in .FLV, .WMV, .AVI, .MOV, .MP4 and .MPG. format. Please be patient while your video is uploaded. Do not try to upload again once the upload is completed.</div>
+ <div class="clear">&nbsp;</div>
+</div>
+
+<br /><br />
+
+<div id="existing_video_upload" style="display: none;">
+ <div class="lable-txt"><b>Enter youtube video URL or code below</b></div>
+ <div class="form-input">
+ <%= text_field_tag 'youtube_code' %>
+ </div>
+ <div class="blank0">&nbsp;</div>
+</div>
+
+<br /><br /><br />
+
+<div id="thumbnails_video_preview">
+ <% if ad and ad.ad_videos %>
+ <% for ad_video in ad.ad_videos %>
+ <%= render :partial => 'ad_videos/thumb_preview', :locals => {:ad_video => ad_video} %>
+ <% end %>
+ <% end %>
+ <div class="clear">&nbsp;</div>
+</div>
+<!-- end of video uploader -->
@@ -0,0 +1,22 @@
+class CreateVideo < ActiveRecord::Migration
+
+ def self.up
+ create_table :videos do |t|
+ t.integer :interview_id, :null => false
+ t.text :url
+ t.text :title
+ t.text :description
+ t.text :location
+ t.text :category
+ t.timestamps
+ end
+
+ add_index :videos, :interview_id
+ end
+
+ def self.down
+ drop_table :videos
+ end
+
+
+end
@@ -0,0 +1,52 @@
+/*
+Uploadify v2.1.4
+Release Date: November 8, 2010
+
+Copyright (c) 2010 Ronnie Garcia, Travis Nickels
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+.uploadifyQueueItem {
+ background-color: #F5F5F5;
+ border: 2px solid #E5E5E5;
+ font: 11px Verdana, Geneva, sans-serif;
+ margin-top: 5px;
+ padding: 10px;
+ width: 350px;
+}
+.uploadifyError {
+ background-color: #FDE5DD !important;
+ border: 2px solid #FBCBBC !important;
+}
+.uploadifyQueueItem .cancel {
+ float: right;
+}
+.uploadifyQueue .completed {
+ background-color: #E5E5E5;
+}
+.uploadifyProgress {
+ background-color: #E5E5E5;
+ margin-top: 10px;
+ width: 100%;
+}
+.uploadifyProgressBar {
+ background-color: #0099FF;
+ height: 3px;
+ width: 1px;
+}

0 comments on commit 8a82d49

Please sign in to comment.