Permalink
Browse files

Support for video entries

  • Loading branch information...
1 parent 1b5078b commit 290f1cad3e80a873c07af19f6c6f9bc4dfae207f @maximecurioni committed Mar 11, 2012
View
@@ -1,5 +1,4 @@
Priority
- video support (flash)
automatic generation of image + link (checkbox for files)
Features
@@ -18,6 +17,7 @@ Features
Circular Wrap around
Stop slideshows when not in viewport (see http://www.appelsiini.net/projects/viewport)
Upgrade to jQuery 1.7
+ Automate video thumbnail
Idea
Commit on the fly
@@ -27,6 +27,7 @@ def load_settings
@slideshows_path = AssetsFolder.slideshows
@files_path = AssetsFolder.files
@images_path = AssetsFolder.images
+ @videos_path = AssetsFolder.videos
@results_path = AssetsFolder.results
end
end
@@ -19,7 +19,7 @@ def serve
if !FileTest.exists? cache_file
case params[:entry_type]
- when 'files'
+ when 'files', 'videos'
Generator.bake_file asset_file, cache_file
when 'slideshows'
Generator.bake_slideshow asset_file, cache_file, params[:size]
@@ -16,6 +16,10 @@ def images
ImageEntry.path
end
+ def videos
+ VideoEntry.path
+ end
+
def results
return_if_exist(root + 'results') if root
end
@@ -0,0 +1,25 @@
+class VideoEntry < Entry
+
+ def height
+ metadata['height']
+ end
+
+ def width
+ metadata['width']
+ end
+
+ def metadata
+ return @metadata if @metadata
+
+ root = AssetsFolder.root
+ filename = assets.keys.first
+ path = assets.values.first
+
+ @metadata = %x(mdls '#{root}/#{path}/#{filename}' | grep Pixel).lstrip.rstrip.split("\n").inject({}) do |result, datum|
+ k,v = datum.split("=")
+ k = k.gsub('kMDItemPixel','').strip.downcase
+ result[k] = v.strip
+ result
+ end
+ end
+end
@@ -0,0 +1,3 @@
+- video_entry.assets.each do |filename, path|
+ %video{:class => 'video-js vjs-default-skin', :controls => true, :preload => 'auto', :height => video_entry.height, :width => video_entry.width, :'data-setup' => '{}'}
+ %source{:src => blog_asset_path(path, filename), :type => 'video/mp4'}
@@ -0,0 +1 @@
+= f.input :value, :collection => VideoEntry.folders, :label => 'Folder'
@@ -12,7 +12,9 @@
= button_to_function 'Add slideshow', 'Entry.add("slideshow")'
= button_to_function 'Add file', 'Entry.add("file")'
= button_to_function 'Add image', 'Entry.add("image")'
+ = button_to_function 'Add video', 'Entry.add("video")'
= new_entry :text
= new_entry :slideshow
= new_entry :file
- = new_entry :image
+ = new_entry :image
+ = new_entry :video
@@ -1,10 +1,10 @@
- if @assets_path.blank?
The assets folder does not exist
- else
- - [:slideshows, :files, :images, :results].each do |folder|
+ - [:slideshows, :files, :images, :videos, :results].each do |folder|
:ruby
folder_path = instance_variable_get "@#{folder}_path"
- if folder_path.present?
.status.present #{folder_name folder} is present.
- else
- .status.missing #{folder_name folder} has not been created under #{folder_name @assets_path}.
+ .status.missing #{folder_name folder} has not been created under #{folder_name @assets_path}
View
@@ -6,7 +6,7 @@
:entry_type => /slideshows|images/
match '/assets/:entry_type/*asset', :controller => :assets,
:action => :serve,
- :entry_type => /files|images/
+ :entry_type => /files|images|videos/
resources :settings do
collection do
@@ -129,6 +129,22 @@ def generate(root, options = {})
print "."
end
end
+
+ generating "videos"
+ VideoEntry.all.each do |video_entry|
+ sub_generating video_entry
+ video_entry.assets.each do |filename, path|
+ create_dir asset_dir, path
+
+ from = blog_asset_pathname(path, filename, :root => AssetsFolder.root)
+ to = blog_asset_pathname(path, filename, :root => asset_dir)
+
+ bake_file from, to
+
+ print "."
+ end
+ end
+
print "\n"
end
@@ -165,6 +181,7 @@ def setup_dirs(root)
create_dir root, 'assets/slideshows'
create_dir root, 'assets/files'
create_dir root, 'assets/images'
+ create_dir root, 'assets/videos'
end
def create_dir(root, name=nil)

0 comments on commit 290f1ca

Please sign in to comment.