social_stream-documents 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/audios_controller.rb +13 -0
- data/app/controllers/documents_controller.rb +2 -1
- data/app/controllers/videos_controller.rb +1 -1
- data/app/models/audio.rb +14 -1
- data/app/models/document.rb +3 -1
- data/app/views/audios/_audio.html.erb +3 -1
- data/app/worker/audioencoder.rb +7 -0
- data/social_stream-documents.gemspec +1 -1
- metadata +5 -4
@@ -1,3 +1,16 @@
|
|
1
1
|
class AudiosController < CommonDocumentsController
|
2
2
|
respond_to :html,:js
|
3
|
+
|
4
|
+
def show
|
5
|
+
path = @audio.file.path(params[:style])
|
6
|
+
if(params[:style].present?) && Document::STYLE_FORMAT[params[:style]]
|
7
|
+
path = path.split('.')[0]+'.'+Document::STYLE_FORMAT[params[:style]]
|
8
|
+
end
|
9
|
+
respond_to do |format|
|
10
|
+
format.all {send_file path,
|
11
|
+
:type => Document::STYLE_MIMETYPE[params[:style]], # CANT USE: @video.file_content_type because it is allways video/mp4 and breaks explorer and firefox
|
12
|
+
:disposition => "inline"}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
3
16
|
end
|
@@ -9,10 +9,11 @@ class DocumentsController < CommonDocumentsController
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
#TODO: we have to add the mimetype as in videos_controller
|
12
13
|
def download
|
13
14
|
path = @document.file.path(params[:style])
|
14
15
|
head(:bad_request) and return unless File.exist?(path)
|
15
|
-
send_file_options = {:filename=>@document.file_file_name}
|
16
|
+
send_file_options = {:filename=>@document.file_file_name, :type => @document.file_content_type}
|
16
17
|
|
17
18
|
case SEND_FILE_METHOD
|
18
19
|
when :apache then send_file_options[:x_sendfile] = true
|
@@ -10,7 +10,7 @@ class VideosController < CommonDocumentsController
|
|
10
10
|
end
|
11
11
|
respond_to do |format|
|
12
12
|
format.all {send_file path,
|
13
|
-
:type => params[:style]
|
13
|
+
:type => Document::STYLE_MIMETYPE[params[:style]], # CANT USE: @video.file_content_type because it is allways video/mp4 and breaks explorer and firefox
|
14
14
|
:disposition => "inline"}
|
15
15
|
end
|
16
16
|
end
|
data/app/models/audio.rb
CHANGED
@@ -1,7 +1,20 @@
|
|
1
1
|
class Audio < Document
|
2
|
-
|
2
|
+
after_save :audioprocess
|
3
|
+
|
4
|
+
has_attached_file :file,
|
5
|
+
:url => '/:class/:id.:extension',
|
6
|
+
:path => ':rails_root/documents/:class/:id_partition/:style.:extension',
|
7
|
+
:styles => {:webma => {:format => 'webm'}
|
8
|
+
},:processors => [:ffmpeg]
|
9
|
+
|
10
|
+
def audioprocess
|
11
|
+
Resque.enqueue(Audioencoder, self.id)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
3
15
|
# Thumbnail file
|
4
16
|
def thumb(size, helper)
|
5
17
|
"#{ size.to_s }/audio.png"
|
6
18
|
end
|
19
|
+
|
7
20
|
end
|
data/app/models/document.rb
CHANGED
@@ -3,7 +3,9 @@ class Document < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
IMAGE_FORMATS = ["doc","ppt","xls","rar","zip","mpeg","plain","pdf"]
|
5
5
|
|
6
|
-
STYLE_FORMAT = {"webm" =>"webm", "flv"=>"flv", "thumb"=>"png", "thumb0"=>"png"}
|
6
|
+
STYLE_FORMAT = {"webm" =>"webm", "flv"=>"flv", "thumb"=>"png", "thumb0"=>"png", "webma"=>"webm"}
|
7
|
+
|
8
|
+
STYLE_MIMETYPE = {"webm" =>"video/webm", "flv"=>"video/x-flv", "thumb"=>"image/png", "thumb0"=>"image/png", "mp3"=>"audio/mpeg", "webma"=>"audio/webm"}
|
7
9
|
|
8
10
|
has_attached_file :file,
|
9
11
|
:url => '/:class/:id.:extension',
|
@@ -3,9 +3,11 @@
|
|
3
3
|
$("#jpId<%=audio.id%>").jPlayer( {
|
4
4
|
ready: function () {
|
5
5
|
$(this).jPlayer("setMedia", {
|
6
|
-
|
6
|
+
webma: "<%= audio_path(audio) + "?style=webma" %>" // Defines the webma url
|
7
7
|
});
|
8
8
|
},
|
9
|
+
supplied: "webma",
|
10
|
+
preload: "none",
|
9
11
|
swfPath: "assets",
|
10
12
|
cssSelectorAncestor: "#jp_interface_<%=audio.id%>"
|
11
13
|
});
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "social_stream-documents"
|
3
|
-
s.version = "0.2.
|
3
|
+
s.version = "0.2.4"
|
4
4
|
s.authors = ["Víctor Sánchez Belmar", "GING - DIT - UPM"]
|
5
5
|
s.summary = "File capabilities for Social Stream, the core for building social network websites"
|
6
6
|
s.description = "Social Stream is a Ruby on Rails engine providing your application with social networking features and activity streams.\n\nThis gem allow you upload almost any kind of file as new social stream activity."
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_stream-documents
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "V\xC3\xADctor S\xC3\xA1nchez Belmar"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-08-
|
19
|
+
date: 2011-08-04 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: social_stream-base
|
@@ -255,6 +255,7 @@ files:
|
|
255
255
|
- app/views/videos/destroy.js.erb
|
256
256
|
- app/views/videos/index.html.erb
|
257
257
|
- app/views/videos/show.html.erb
|
258
|
+
- app/worker/audioencoder.rb
|
258
259
|
- app/worker/videoencoder.rb
|
259
260
|
- config/locales/en.yml
|
260
261
|
- config/routes.rb
|