social_stream-documents 0.17.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,6 +20,7 @@ class DocumentsController < ApplicationController
20
20
  def create
21
21
  super do |format|
22
22
  format.json { render :json => resource }
23
+ format.js
23
24
  format.all {redirect_to request.referer || home_path}
24
25
  end
25
26
  end
data/app/models/audio.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  class Audio < Document
2
2
  has_attached_file :file,
3
- :url => '/:class/:id.:extension',
3
+ :url => '/:class/:id.:content_type_extension',
4
4
  :path => ':rails_root/documents/:class/:id_partition/:style',
5
- :styles => {:webma => {:format => 'webm'}
6
- },:processors => [:ffmpeg]
5
+ :styles => SocialStream::Documents.audio_styles,
6
+ :processors => [ :ffmpeg ]
7
7
 
8
8
  process_in_background :file
9
9
 
@@ -4,7 +4,7 @@ class Document < ActiveRecord::Base
4
4
  IMAGE_FORMATS = ["doc","ppt","xls","rar","zip","mpeg","plain","pdf"]
5
5
 
6
6
  has_attached_file :file,
7
- :url => '/:class/:id.:extension',
7
+ :url => '/:class/:id.:content_type_extension',
8
8
  :path => ':rails_root/documents/:class/:id_partition/:style/:filename.:extension'
9
9
 
10
10
  paginates_per 20
@@ -82,5 +82,3 @@ class Document < ActiveRecord::Base
82
82
  self.title = file_file_name if self.title.blank?
83
83
  end
84
84
  end
85
-
86
- ActiveSupport.run_load_hooks(:document, Document)
@@ -1,13 +1,8 @@
1
1
  class Picture < Document
2
2
  has_attached_file :file,
3
- :url => '/:class/:id.:extension',
3
+ :url => '/:class/:id.:content_type_extension',
4
4
  :path => ':rails_root/documents/:class/:id_partition/:style',
5
- :styles => {:thumb48sq => ["48x48"],
6
- :thumbwall => ["130x97#"],
7
- # midwall preserves A4 proportion: 210x297
8
- :midwall => ["80x113#"],
9
- :preview => ["500>"]
10
- }
5
+ :styles => SocialStream::Documents.picture_styles
11
6
 
12
7
  define_index do
13
8
  activity_object_index
@@ -28,6 +23,8 @@ class Picture < Document
28
23
  helper.picture_path self, :format => format, :style => 'thumbwall'
29
24
  when 500
30
25
  helper.picture_path self, :format => format, :style => 'preview'
26
+ when 1000
27
+ helper.picture_path self, :format => format, :style => 'original'
31
28
  end
32
29
  end
33
30
 
data/app/models/video.rb CHANGED
@@ -1,16 +1,9 @@
1
1
  class Video < Document
2
2
  has_attached_file :file,
3
- :url => '/:class/:id.:extension',
3
+ :url => '/:class/:id.:content_type_extension',
4
4
  :default_url => 'missing_:style.png',
5
5
  :path => ':rails_root/documents/:class/:id_partition/:style',
6
- :styles => {
7
- :webm => {:format => 'webm'},
8
- :flv => {:format => 'flv'},
9
- :mp4 => {:format => 'mp4'},
10
- :poster => {:format => 'png', :time => 5},
11
- :thumb48sq => {:geometry => "48x48" , :format => 'png', :time => 5},
12
- :thumbwall => {:geometry => "130x97#", :format => 'png', :time => 5}
13
- },
6
+ :styles => SocialStream::Documents.video_styles,
14
7
  :processors => [:ffmpeg]
15
8
 
16
9
  process_in_background :file
@@ -53,7 +53,7 @@
53
53
  ready: function () {
54
54
  $(this).jPlayer("setMedia", {
55
55
  webmv: "<%= video_url(video, :format => 'webm' ) %>", // Defines the webm url
56
- flv: "<%= video_url(video, :format => 'flv') %>"
56
+ flv: "<%= video_url(video, :format => 'flv') %>",
57
57
  mp4: "<%= video_url(video, :format => 'mp4') %>"
58
58
  });
59
59
  },
@@ -10,8 +10,6 @@ class CreateSocialStreamDocuments < ActiveRecord::Migration
10
10
  t.string "file_content_type"
11
11
  t.string "file_file_size"
12
12
  t.boolean "file_processing"
13
- t.string "title"
14
- t.text "description"
15
13
  end
16
14
 
17
15
  add_index "documents", ["activity_object_id"], :name => "index_documents_on_activity_object_id"
@@ -1,18 +1,13 @@
1
- # Monkey-patch https://github.com/jstorimer/delayed_paperclip/commit/3e0e3451147e96f378cda4695546d9633944cc5c
1
+ # Monkey-patch https://github.com/jstorimer/delayed_paperclip/issues/67
2
2
  #
3
- # Remove with delayed_paperclip > 2.4.5.1
3
+ # Remove with delayed_paperclip > 2.4.5.2 ???
4
4
  require 'delayed_paperclip'
5
5
 
6
6
  module DelayedPaperclip::Attachment::InstanceMethods
7
- def post_process_styles_with_processing(*args)
8
- post_process_styles_without_processing(*args)
9
-
10
- # update_column is available in rails 3.1 instead we can do this to update the attribute without callbacks
11
-
12
- #instance.update_column("#{name}_processing", false) if instance.respond_to?(:"#{name}_processing?")
13
- if instance.respond_to?(:"#{name}_processing?")
14
- instance.send("#{name}_processing=", false)
15
- instance.class.update_all({ "#{name}_processing" => false }, instance.class.primary_key => instance.id)
16
- end
7
+ def process_delayed!
8
+ self.job_is_processing = true
9
+ self.post_processing = true
10
+ reprocess!
11
+ self.job_is_processing = false
17
12
  end
18
13
  end
@@ -3,6 +3,10 @@ class SocialStream::Documents::InstallGenerator < Rails::Generators::Base
3
3
 
4
4
  source_root File.expand_path('../templates', __FILE__)
5
5
 
6
+ def create_initializer_file
7
+ template 'initializer.rb', 'config/initializers/social_stream-documents.rb'
8
+ end
9
+
6
10
  def create_migration_file
7
11
  require 'rake'
8
12
  Rails.application.load_tasks
@@ -0,0 +1,26 @@
1
+ SocialStream::Documents.setup do |config|
2
+ # Configure picture thumbnails
3
+ #
4
+ # config.picture_styles = {
5
+ # :thumb48sq => ["48x48"],
6
+ # :thumbwall => ["130x97#"],
7
+ # # midwall preserves A4 proportion: 210x297
8
+ # :midwall => ["80x113#"],
9
+ # :preview => ["500>"]
10
+ # }
11
+
12
+ # Configure audio thumbnails
13
+ #
14
+ # config.audio_styles = { :webma => {:format => 'webm'} }
15
+
16
+ # Configure video thumbnails
17
+ #
18
+ # @@video_styles = {
19
+ # :webm => { :format => 'webm' },
20
+ # :flv => { :format => 'flv' },
21
+ # :mp4 => { :format => 'mp4' },
22
+ # :poster => { :format => 'png', :time => 5 },
23
+ # :thumb48sq => { :geometry => "48x48" , :format => 'png', :time => 5 },
24
+ # :thumbwall => { :geometry => "130x97#", :format => 'png', :time => 5 }
25
+ # }
26
+ end
@@ -8,6 +8,35 @@ module SocialStream
8
8
  end
9
9
 
10
10
  module Documents
11
+ # Picture thumbnails
12
+ mattr_accessor :picture_styles
13
+ @@picture_styles = {
14
+ :thumb48sq => ["48x48"],
15
+ :thumbwall => ["130x97#"],
16
+ # midwall preserves A4 proportion: 210x297
17
+ :midwall => ["80x113#"],
18
+ :preview => ["500>"]
19
+ }
20
+
21
+ mattr_accessor :audio_styles
22
+ @@audio_styles = { :webma => {:format => 'webm'} }
23
+
24
+ mattr_accessor :video_styles
25
+ @@video_styles = {
26
+ :webm => { :format => 'webm' },
27
+ :flv => { :format => 'flv' },
28
+ :mp4 => { :format => 'mp4' },
29
+ :poster => { :format => 'png', :time => 5 },
30
+ :thumb48sq => { :geometry => "48x48" , :format => 'png', :time => 5 },
31
+ :thumbwall => { :geometry => "130x97#", :format => 'png', :time => 5 }
32
+ }
33
+
34
+ class << self
35
+ def setup
36
+ yield self
37
+ end
38
+ end
39
+
11
40
  # Add :document to SocialStream.objects and SocialStream.activity_forms by default
12
41
  # It can be configured by users at application's config/initializers/social_stream.rb
13
42
  [ :picture, :video, :audio, :document].each do |o|
@@ -1,6 +1,5 @@
1
1
  require 'social_stream-base'
2
2
  require 'paperclip'
3
- require 'paperclip/social_stream-documents'
4
3
  require 'paperclip-ffmpeg'
5
4
  require 'delayed_paperclip'
6
5
  require 'delayed_paperclip/social_stream-documents'
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Documents
3
- VERSION = "0.17.0".freeze
3
+ VERSION = "0.18.0".freeze
4
4
  end
5
5
  end
@@ -12,10 +12,10 @@ 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.23.0')
16
- s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.7.0')
17
- s.add_runtime_dependency('paperclip','= 2.4.5')
18
- s.add_runtime_dependency('delayed_paperclip','2.4.5.1')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.24.0')
16
+ s.add_runtime_dependency('paperclip','~> 3.3.0')
17
+ s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.9.0')
18
+ s.add_runtime_dependency('delayed_paperclip','>= 2.4.5.2')
19
19
  # Development Gem dependencies
20
20
  s.add_development_dependency('sqlite3-ruby')
21
21
  if RUBY_VERSION < '1.9'
@@ -72,10 +72,6 @@ Devise.setup do |config|
72
72
  # If true, extends the user's remember period when remembered via cookie.
73
73
  # config.extend_remember_period = false
74
74
 
75
- # If true, uses the password salt as remember token. This should be turned
76
- # to false if you are not using database authenticatable.
77
- config.use_salt_as_remember_token = true
78
-
79
75
  # ==> Configuration for :validatable
80
76
  # Range for password length. Default is 6..20.
81
77
  # config.password_length = 6..20
@@ -163,6 +159,10 @@ Devise.setup do |config|
163
159
  config.omniauth :linkedin, "ekxfXU8nueVSMQ9fc5KJAryBkyztUlCBYMW3DoQPzbE79WhivvzhQloRNHCHgPeB", "WYiHFT-KKFgjd45W3-pEAficmXRHmN6_6DGwj1C_ZILJlSO1gBvv6VNYXU9tybGY"
164
160
 
165
161
  config.omniauth :facebook, "129571360447856","eef39dce5e20e76f77495c59623bdb38"
162
+
163
+ #re state_less token removal
164
+ #https://github.com/plataformatec/devise/issues/1499
165
+ config.skip_session_storage << :token_auth
166
166
 
167
167
  # ==> Warden configuration
168
168
  # If you want to use other strategies, that are not supported by Devise, or
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.17.0
4
+ version: 0.18.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-03 00:00:00.000000000 Z
13
+ date: 2012-10-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: social_stream-base
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 0.23.0
22
+ version: 0.24.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,15 +27,15 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- version: 0.23.0
30
+ version: 0.24.0
31
31
  - !ruby/object:Gem::Dependency
32
- name: paperclip-ffmpeg
32
+ name: paperclip
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  none: false
35
35
  requirements:
36
36
  - - ~>
37
37
  - !ruby/object:Gem::Version
38
- version: 0.7.0
38
+ version: 3.3.0
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,39 +43,39 @@ dependencies:
43
43
  requirements:
44
44
  - - ~>
45
45
  - !ruby/object:Gem::Version
46
- version: 0.7.0
46
+ version: 3.3.0
47
47
  - !ruby/object:Gem::Dependency
48
- name: paperclip
48
+ name: paperclip-ffmpeg
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - '='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 2.4.5
54
+ version: 0.9.0
55
55
  type: :runtime
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements:
60
- - - '='
60
+ - - ~>
61
61
  - !ruby/object:Gem::Version
62
- version: 2.4.5
62
+ version: 0.9.0
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: delayed_paperclip
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  none: false
67
67
  requirements:
68
- - - '='
68
+ - - ! '>='
69
69
  - !ruby/object:Gem::Version
70
- version: 2.4.5.1
70
+ version: 2.4.5.2
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
- - - '='
76
+ - - ! '>='
77
77
  - !ruby/object:Gem::Version
78
- version: 2.4.5.1
78
+ version: 2.4.5.2
79
79
  - !ruby/object:Gem::Dependency
80
80
  name: sqlite3-ruby
81
81
  requirement: !ruby/object:Gem::Requirement
@@ -275,11 +275,10 @@ files:
275
275
  - config/locales/en.yml
276
276
  - config/locales/es.yml
277
277
  - config/routes.rb
278
- - db/migrate/20120109155431_create_social_stream_documents.rb
279
- - db/migrate/20120208143721_documents_group_title_and_description_in_activity_object.rb
278
+ - db/migrate/20120208143721_create_social_stream_documents.rb
280
279
  - lib/delayed_paperclip/social_stream-documents.rb
281
280
  - lib/generators/social_stream/documents/install_generator.rb
282
- - lib/paperclip/social_stream-documents.rb
281
+ - lib/generators/social_stream/documents/templates/initializer.rb
283
282
  - lib/samples/car.jpg
284
283
  - lib/samples/house.jpg
285
284
  - lib/samples/loremipsum.odt
@@ -383,3 +382,4 @@ specification_version: 3
383
382
  summary: File capabilities for Social Stream, the core for building social network
384
383
  websites
385
384
  test_files: []
385
+ has_rdoc:
@@ -1,28 +0,0 @@
1
- class DocumentsGroupTitleAndDescriptionInActivityObject < ActiveRecord::Migration
2
- def up
3
- ao_ts = ActivityObject.record_timestamps
4
- ActivityObject.record_timestamps = false
5
-
6
- # Fix 'documents' table
7
- d_ts = Document.record_timestamps
8
- Document.record_timestamps = false
9
-
10
- Document.all.each do |d|
11
- d.activity_object.title = d.read_attribute(:title)
12
- d.activity_object.description = d.read_attribute(:description)
13
- d.save!
14
- end
15
- change_table :documents do |t|
16
- t.remove :title
17
- t.remove :description
18
- end
19
- Document.reset_column_information
20
- Document.record_timestamps = d_ts
21
-
22
- ActivityObject.record_timestamps = ao_ts
23
- end
24
-
25
- def down
26
- raise ActiveRecord::IrreversibleMigration # Due to trans-gem oddities
27
- end
28
- end
@@ -1,62 +0,0 @@
1
- # Monkey patch https://github.com/thoughtbot/paperclip/issues/293#issuecomment-2484541
2
- # Monkey patch https://github.com/thoughtbot/paperclip/commit/2583a27df497e72ec7a200b6aa707948e88fd166
3
- #
4
- # Remove with paperclip > 2.5.0
5
- require 'paperclip'
6
-
7
- module Paperclip::ClassMethods
8
- def has_attached_file name, options = {}
9
- include Paperclip::InstanceMethods
10
-
11
- if attachment_definitions.nil?
12
- if respond_to?(:class_attribute)
13
- self.attachment_definitions = {}
14
- else
15
- write_inheritable_attribute(:attachment_definitions, {})
16
- end
17
- else
18
- self.attachment_definitions = self.attachment_definitions.dup
19
- end
20
-
21
- attachment_definitions[name] = {:validations => []}.merge(options)
22
- Paperclip.classes_with_attachments << self.name
23
- Paperclip.check_for_url_clash(name,attachment_definitions[name][:url],self.name)
24
-
25
- after_save :save_attached_files
26
- before_destroy :prepare_for_destroy
27
- after_destroy :destroy_attached_files
28
-
29
- define_paperclip_callbacks :post_process, :"#{name}_post_process"
30
-
31
- define_method name do |*args|
32
- a = attachment_for(name)
33
- (args.length > 0) ? a.to_s(args.first) : a
34
- end
35
-
36
- define_method "#{name}=" do |file|
37
- attachment_for(name).assign(file)
38
- end
39
-
40
- define_method "#{name}?" do
41
- attachment_for(name).file?
42
- end
43
-
44
- validates_each(name) do |record, attr, value|
45
- attachment = record.attachment_for(name)
46
- attachment.send(:flush_errors)
47
- end
48
- end
49
-
50
- def validates_attachment_presence name, options = {}
51
- message = options[:message] || :empty
52
- validates_each :"#{name}_file_name" do |record, attr, value|
53
- if_clause_passed = options[:if].nil? || (options[:if].respond_to?(:call) ? options[:if].call(record) != false : record.send(options[:if]))
54
- unless_clause_passed = options[:unless].nil? || (options[:unless].respond_to?(:call) ? !!options[:unless].call(record) == false : !record.send(options[:unless]))
55
-
56
- if if_clause_passed && unless_clause_passed && value.blank?
57
- record.errors.add(name, message)
58
- record.errors.add("#{name}_file_name", message)
59
- end
60
- end
61
- end
62
- end