social_stream-documents 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,11 +8,12 @@ SocialStream.Video = (function(SS, $, undefined){
8
8
  $(this).jPlayer("setMedia", {
9
9
  webmv: $(this).closest(".video").find(".video-webm").attr("href"), // Defines the webm url
10
10
  flv: $(this).closest(".video").find(".video-flv").attr("href") // Defines the flv url
11
+ mp4: $(this).closest(".video").find(".video-mp4").attr("href") // Defines the mp4 url
11
12
  });
12
13
  },
13
14
  solution:"flash, html",
14
15
  preload: "none",
15
- supplied: "webmv, flv",
16
+ supplied: "webmv, flv, mp4",
16
17
  swfPath: "<%= asset_path "" %>",
17
18
  cssSelectorAncestor: "#" + $(this).closest(".video-full").attr("id")
18
19
  })
@@ -11,6 +11,7 @@ class DocumentsController < ApplicationController
11
11
 
12
12
  def index
13
13
  super do |format|
14
+ format.json { render :json => collection.map{|a| a.activity_objects.first.document.to_json} }
14
15
  if params[:no_layout].present?
15
16
  format.html { render :action => :index, :layout => false }
16
17
  else
@@ -21,6 +22,7 @@ class DocumentsController < ApplicationController
21
22
 
22
23
  def create
23
24
  super do |format|
25
+ format.json { render :json => resource }
24
26
  format.all {redirect_to request.referer || home_path}
25
27
  end
26
28
  end
@@ -34,8 +36,9 @@ class DocumentsController < ApplicationController
34
36
 
35
37
  def show
36
38
  respond_to do |format|
39
+ format.json {render :json => resource }
37
40
  format.html {render :action => :show}
38
- format.all {
41
+ format.any {
39
42
  path = resource.file.path(params[:style] || params[:format])
40
43
 
41
44
  send_file path,
@@ -68,6 +68,16 @@ class Document < ActiveRecord::Base
68
68
  "#{ size.to_s }/default.png"
69
69
  end
70
70
  end
71
+
72
+ # JSON, generic version for most documents
73
+ def to_json me=self
74
+ {:id => activity_object_id,
75
+ :title => title,
76
+ :description => description,
77
+ :author => author.name,
78
+ :src => file.to_s
79
+ }.to_json
80
+ end
71
81
 
72
82
  protected
73
83
 
data/app/models/video.rb CHANGED
@@ -4,7 +4,9 @@ class Video < Document
4
4
  :path => ':rails_root/documents/:class/:id_partition/:style',
5
5
  :styles => {
6
6
  :webm => {:format => 'webm'},
7
- :flv => { :format => 'flv' },
7
+ :flv => {:format => 'flv'},
8
+ :mp4 => {:format => 'mp4'},
9
+ :poster => {:format => 'png', :time => 5},
8
10
  :thumb48sq => {:geometry => "48x48" , :format => 'png', :time => 5},
9
11
  :thumbwall => {:geometry => "130x97#", :format => 'png', :time => 5}
10
12
  },
@@ -25,5 +27,19 @@ class Video < Document
25
27
  def thumb(size, helper)
26
28
  "#{ size.to_s }/video.png"
27
29
  end
30
+
31
+ # JSON, special edition for video files
32
+ def to_json me=self
33
+ {:id => activity_object_id,
34
+ :title => title,
35
+ :description => description,
36
+ :author => author.name,
37
+ :poster => file(:poster).to_s,
38
+ :sources => [ { :type => Mime::WEBM.to_s, :src => file(:webm).to_s },
39
+ { :type => Mime::MP4.to_s, :src => file(:mp4).to_s },
40
+ { :type => Mime::FLV.to_s, :src => file(:flv).to_s }
41
+ ]
42
+ }.to_json
43
+ end
28
44
 
29
45
  end
@@ -20,6 +20,7 @@
20
20
  <div class="video-format-links">
21
21
  <%= link_to "WebM", video_path(video, :format => :webm), :class => "video-webm" %>
22
22
  <%= link_to "FLV", video_path(video, :format => :flv), :class => "video-flv" %>
23
+ <%= link_to "MP4", video_path(video, :format => :mp4), :class => "video-mp4" %>
23
24
  </div>
24
25
  </div>
25
26
 
@@ -54,11 +54,12 @@
54
54
  $(this).jPlayer("setMedia", {
55
55
  webmv: "<%= video_url(video, :format => 'webm' ) %>", // Defines the webm url
56
56
  flv: "<%= video_url(video, :format => 'flv') %>"
57
+ mp4: "<%= video_url(video, :format => 'mp4') %>"
57
58
  });
58
59
  },
59
60
  solution:"flash, html",
60
61
  preload: "none",
61
- supplied: "webmv, flv",
62
+ supplied: "webmv, flv, mp4",
62
63
  swfPath: "assets",
63
64
  cssSelectorAncestor: "#jp_interface_<%=video.id%>"
64
65
  });
@@ -1,6 +1,6 @@
1
1
  class CreateSocialStreamDocuments < ActiveRecord::Migration
2
-
3
- def self.up
2
+
3
+ def change
4
4
  create_table "documents", :force => true do |t|
5
5
  t.string "type"
6
6
  t.integer "activity_object_id"
@@ -9,16 +9,14 @@ class CreateSocialStreamDocuments < ActiveRecord::Migration
9
9
  t.string "file_file_name"
10
10
  t.string "file_content_type"
11
11
  t.string "file_file_size"
12
+ t.boolean "file_processing"
13
+ t.string "title"
14
+ t.text "description"
12
15
  end
13
-
14
- add_index "documents", "activity_object_id"
16
+
17
+ add_index "documents", ["activity_object_id"], :name => "index_documents_on_activity_object_id"
18
+
15
19
  add_foreign_key "documents", "activity_objects", :name => "documents_on_activity_object_id"
16
-
20
+
17
21
  end
18
-
19
- def self.down
20
- remove_foreign_key "documents", :name => "documents_on_activity_object_id"
21
- drop_table :documents
22
- end
23
-
24
22
  end
@@ -51,6 +51,7 @@ module SocialStream
51
51
  # Video
52
52
  Mime::Type.register "video/x-flv", :flv
53
53
  Mime::Type.register "video/webm", :webm
54
+ Mime::Type.register "video/mp4", :mp4
54
55
  end
55
56
 
56
57
  initializer "social_stream-documents.views.toolbar" do
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Documents
3
- VERSION = "0.12.1".freeze
3
+ VERSION = "0.13.0".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.18.1')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.19.0')
16
16
  s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.7.0')
17
17
  s.add_runtime_dependency('paperclip','= 2.4.5')
18
18
  s.add_runtime_dependency('delayed_paperclip','2.4.5.1')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-documents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-27 00:00:00.000000000Z
13
+ date: 2012-04-02 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: social_stream-base
17
- requirement: &79323420 !ruby/object:Gem::Requirement
17
+ requirement: &76316010 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 0.18.1
22
+ version: 0.19.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *79323420
25
+ version_requirements: *76316010
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: paperclip-ffmpeg
28
- requirement: &79322390 !ruby/object:Gem::Requirement
28
+ requirement: &76315650 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.7.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *79322390
36
+ version_requirements: *76315650
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: paperclip
39
- requirement: &79314790 !ruby/object:Gem::Requirement
39
+ requirement: &76315090 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - =
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 2.4.5
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *79314790
47
+ version_requirements: *76315090
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: delayed_paperclip
50
- requirement: &79180400 !ruby/object:Gem::Requirement
50
+ requirement: &76314400 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - =
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 2.4.5.1
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *79180400
58
+ version_requirements: *76314400
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: sqlite3-ruby
61
- requirement: &78348460 !ruby/object:Gem::Requirement
61
+ requirement: &76313960 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *78348460
69
+ version_requirements: *76313960
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec-rails
72
- requirement: &78332420 !ruby/object:Gem::Requirement
72
+ requirement: &76313300 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 2.6.0
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *78332420
80
+ version_requirements: *76313300
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: factory_girl
83
- requirement: &78331350 !ruby/object:Gem::Requirement
83
+ requirement: &76312700 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: 1.3.2
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *78331350
91
+ version_requirements: *76312700
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: forgery
94
- requirement: &78330170 !ruby/object:Gem::Requirement
94
+ requirement: &76311960 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ~>
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: 0.4.2
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *78330170
102
+ version_requirements: *76311960
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: capybara
105
- requirement: &78328590 !ruby/object:Gem::Requirement
105
+ requirement: &76311140 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ~>
@@ -110,7 +110,7 @@ dependencies:
110
110
  version: 0.3.9
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *78328590
113
+ version_requirements: *76311140
114
114
  description: ! 'Social Stream is a Ruby on Rails engine providing your application
115
115
  with social networking features and activity streams.
116
116
 
@@ -228,10 +228,7 @@ files:
228
228
  - config/locales/en.yml
229
229
  - config/locales/es.yml
230
230
  - config/routes.rb
231
- - db/migrate/20110615143707_create_social_stream_documents.rb
232
- - db/migrate/20110922173707_add_file_processing_to_document.rb
233
- - db/migrate/20111005112707_add_title_and_description_to_document.rb
234
- - db/migrate/20120109155431_document_object_type.rb
231
+ - db/migrate/20120109155431_create_social_stream_documents.rb
235
232
  - db/migrate/20120208143721_documents_group_title_and_description_in_activity_object.rb
236
233
  - lib/delayed_paperclip/social_stream-documents.rb
237
234
  - lib/generators/social_stream/documents/install_generator.rb
@@ -1,9 +0,0 @@
1
- class AddFileProcessingToDocument < ActiveRecord::Migration
2
- def self.up
3
- add_column :documents, :file_processing, :boolean
4
- end
5
-
6
- def self.down
7
- remove_column :documents, :file_processing
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- class AddTitleAndDescriptionToDocument < ActiveRecord::Migration
2
- def self.up
3
- add_column :documents, :title, :string
4
- add_column :documents, :description, :text
5
- end
6
-
7
- def self.down
8
- remove_column :documents, :title
9
- remove_column :documents, :description
10
- end
11
- end
@@ -1,16 +0,0 @@
1
- class DocumentObjectType < ActiveRecord::Migration
2
- class ActivityObjectMigration < ActiveRecord::Base
3
- self.record_timestamps = false
4
- set_table_name "activity_objects"
5
- end
6
-
7
- def up
8
- ActivityObjectMigration.where(:object_type => %w( Picture Audio Video )).each do |a|
9
- a.object_type = "Document"
10
- a.save!
11
- end
12
- end
13
-
14
- def down
15
- end
16
- end