social_stream-documents 0.14.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +1,19 @@
1
1
  class DocumentsController < ApplicationController
2
- include ActionView::Helpers::SanitizeHelper
3
2
  include SocialStream::Controllers::Objects
4
3
 
5
- belongs_to_subjects :optional => true
6
-
7
4
  before_filter :profile_subject!, :only => :index
8
5
 
9
- PER_PAGE=20
10
-
11
6
  def index
12
- super do |format|
13
- format.json { render :json => collection.map{|a| a.activity_objects.first.document} }
14
- if params[:no_layout].present?
15
- format.html { render :action => :index, :layout => false }
16
- else
17
- format.html { render :action => :index }
18
- end
7
+ respond_to do |format|
8
+ format.html {
9
+ collection
10
+
11
+ if params[:no_layout].present?
12
+ render :layout => false
13
+ end
14
+ }
15
+
16
+ format.json { render :json => collection }
19
17
  end
20
18
  end
21
19
 
@@ -64,31 +62,9 @@ class DocumentsController < ApplicationController
64
62
 
65
63
  private
66
64
 
67
- def collection
68
- @activities = profile_subject.wall(:profile,
69
- :for => current_subject,
70
- :object_type => Array(self.class.index_object_type))
71
- if params[:q].present?
72
- @activities = @activities.joins(:activity_objects).where('activity_objects.title LIKE ? OR activity_objects.description LIKE ?', get_search_query, get_search_query)
73
- end
74
- @activities = @activities.page(params[:page]).per(PER_PAGE)
75
- end
76
-
77
65
  class << self
78
66
  def index_object_type
79
67
  [ :Audio, :Video, :Picture, :Document ]
80
68
  end
81
69
  end
82
-
83
- def get_search_query
84
- search_query = ""
85
- param = strip_tags(params[:q]) || ""
86
- bare_query = param unless bare_query.html_safe?
87
- search_query_words = bare_query.strip.split
88
- search_query_words.each_index do |i|
89
- search_query+= search_query_words[i] + " " if i < (search_query_words.size - 1)
90
- search_query+= "%" + search_query_words[i] + "% " if i == (search_query_words.size - 1)
91
- end
92
- return search_query.strip
93
- end
94
70
  end
@@ -1,2 +1,8 @@
1
1
  class PicturesController < DocumentsController
2
+ before_filter :default_style
3
+
4
+ protected
5
+ def default_style
6
+ params[:style] ||= 'original'
7
+ end
2
8
  end
@@ -6,6 +6,8 @@ class Document < ActiveRecord::Base
6
6
  has_attached_file :file,
7
7
  :url => '/:class/:id.:extension',
8
8
  :path => ':rails_root/documents/:class/:id_partition/:style/:filename.:extension'
9
+
10
+ paginates_per 20
9
11
 
10
12
  validates_attachment_presence :file
11
13
  validates_presence_of :title
@@ -18,8 +20,6 @@ class Document < ActiveRecord::Base
18
20
  activity_object_index
19
21
 
20
22
  indexes file_file_name, :as => :file_name
21
-
22
- where "type IS NULL"
23
23
  end
24
24
 
25
25
  class << self
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%= render :partial => 'common_documents/index', :locals => { :documents => @audios } %>
@@ -1,25 +1,30 @@
1
1
  <% content_for :title do %>
2
- <%= profile_subject.name + ": " + t('repository.title') %>
2
+ <%= "#{ profile_subject && profile_subject.name + ': ' }#{ t('repository.title') }" %>
3
3
  <% end %>
4
4
 
5
5
  <% sidebar %>
6
6
 
7
- <%if profile_subject_is_current?%>
8
- <%= location(
9
- link_to(t('repository.title'), polymorphic_path(controller.controller_name),:remote => true)
10
- ) %>
11
- <%else%>
12
- <%= location(
13
- link_to(profile_subject.name, polymorphic_path(profile_subject),:remote => true),
14
- link_to(t('repository.title'), polymorphic_path([profile_subject, controller.controller_name]),:remote => true)
15
- ) %>
16
- <%end%>
7
+ <% if profile_subject %>
8
+ <%= location(
9
+ link_to(profile_subject.name, polymorphic_path(profile_subject),:remote => true),
10
+ link_to(t('repository.title'), polymorphic_path([profile_subject, controller.controller_name]),:remote => true)
11
+ ) %>
12
+ <% else %>
13
+ <%= location(
14
+ link_to(t('repository.title'), polymorphic_path(controller.controller_name),:remote => true)
15
+ ) %>
16
+ <% end %>
17
+
18
+ <% if profile_subject %>
19
+ <% toolbar :profile, :subject => profile_subject %>
20
+ <% elsif user_signed_in? %>
21
+ <% toolbar %>
22
+ <% end %>
17
23
 
18
- <% toolbar :profile, :subject => profile_subject %>
19
24
  <br class="clearfloat" />
20
25
  <div class="space_center"></div>
21
26
  <div id="repository_filter">
22
- <%= text_field_tag :filter_query, nil,:autocomplete => :off, :id => :repository_filter_input %>
27
+ <%= text_field_tag :q, nil,:autocomplete => :off, :id => :repository_filter_input %>
23
28
  <div id="order_by"><%= t('repository.order.by') %>: <%= t('repository.order.last_modified') %> · <%= t('repository.order.most_popular') %> </div>
24
29
  </div>
25
30
  <div class="space_center"></div>
@@ -38,7 +43,7 @@ $(document).ready(function() {
38
43
  $("#documents_grid").html("<center><%= escape_javascript(image_tag('loading.gif', :class => :loading)) %></center>");
39
44
  $.ajax({
40
45
  type : "GET",
41
- url : "<%= polymorphic_url([current_subject, Document.new]) %>?no_layout=true",
46
+ url : "<%= polymorphic_path([ profile_subject, Document.new ], :action => :search) %>",
42
47
  success : function(html) {
43
48
  if ($("#repository_filter_input").val()==searchstring){ //Only show if input value is still the same
44
49
  $("#documents_grid").html(html);
@@ -54,7 +59,7 @@ $(document).ready(function() {
54
59
  $("#documents_grid").html("<center><%= escape_javascript(image_tag('loading.gif', :class => :loading)) %></center>");
55
60
  $.ajax({
56
61
  type : "GET",
57
- url : "<%= polymorphic_url([current_subject, Document.new]) %>?q=" + searchstring + "&no_layout=true",
62
+ url : "<%= polymorphic_path([ profile_subject, Document.new ], :action => :search) %>?q=" + searchstring,
58
63
  success : function(html) {
59
64
  if ($("#repository_filter_input").val()==searchstring){ //Only show if input value is still the same
60
65
  $("#documents_grid").html(html);
@@ -1,14 +1,13 @@
1
- <% unless params[:no_layout].present? %>
1
+ <% if params[:no_layout].blank? %>
2
2
  <%= render :partial => "common_documents/headers" %>
3
3
  <div id="documents_grid">
4
4
  <% end %>
5
5
 
6
- <% @activities.each do |a| %>
7
- <% document = a.activity_objects.first.document %>
6
+ <% documents.each do |document| %>
8
7
  <div class="attachment_tile" id="<%= dom_id(document)%>">
9
8
  <div class="attachment_tile_thumb">
10
9
  <%= link_to thumb_for(document,48),
11
- document_path(document),
10
+ document,
12
11
  :type => document.type,
13
12
  :title => document.file_file_name,
14
13
  :path => document_path(document) %>
@@ -57,10 +56,10 @@ $(document).ready(function(){
57
56
  <% end %>
58
57
  <% end %>
59
58
 
60
- <% if @activities.size == DocumentsController::PER_PAGE %>
59
+ <% unless documents.last_page? %>
61
60
  <% next_url = url_for(:no_layout => true,
62
61
  :page => params[:page].present? ? params[:page].to_i + 1 : 2,
63
- :query => params[:query].present? ? params[:query] : "") %>
62
+ :q => params[:q]) %>
64
63
  <%= content_tag(:span, "", :class => "screw screw-after", :rel => next_url)%>
65
64
  <% end %>
66
65
 
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%= render :partial => 'common_documents/index', :locals => { :documents => collection } %>
@@ -0,0 +1,3 @@
1
+ <% params[:no_layout] = true %>
2
+ <%= render :partial => 'common_documents/index',
3
+ :locals => { :documents => @documents } %>
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%= render :partial => 'common_documents/index', :locals => { :documents => @pictures } %>
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%= render :partial => 'common_documents/index', :locals => { :documents => @videos } %>
data/config/routes.rb CHANGED
@@ -4,6 +4,7 @@ Rails.application.routes.draw do
4
4
  resources :videos
5
5
 
6
6
  resources :documents do
7
+ get "search", :on => :collection
7
8
  get "download", :on => :member
8
9
  end
9
10
 
@@ -15,6 +16,7 @@ Rails.application.routes.draw do
15
16
  resources :videos
16
17
 
17
18
  resources :documents do
19
+ get "search", :on => :collection
18
20
  get "download", :on => :member
19
21
  end
20
22
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Documents
3
- VERSION = "0.14.0".freeze
3
+ VERSION = "0.14.1".freeze
4
4
  end
5
5
  end
@@ -6,31 +6,14 @@ namespace :db do
6
6
 
7
7
  desc "Add documents to populate data"
8
8
  task :create_documents => :read_environment do
9
- puts 'Documents population'
10
- docs_start = Time.now
9
+ SS_DOCS_PATH=Gem::Specification.find_by_name('social_stream-documents').full_gem_path
10
+ doc_files = Forgery::Extensions::Array.new(Dir.glob(File.join(SS_DOCS_PATH, 'lib', 'samples', "*")))
11
11
 
12
- doc_files = Forgery::Extensions::Array.new(Dir.glob(File.join(Rails.root, 'lib', 'documents', "*")))
13
-
14
- 50.times do
15
- updated = Time.at(rand(Time.now.to_i))
16
- author = Actor.all[rand(Actor.all.size)]
17
- owner = author
18
- user_author = ( author.subject_type == "User" ? author : author.user_author )
19
-
20
- d = Document.create! :file => File.open(doc_files.random, "r"),
21
- :title => Forgery::LoremIpsum.words(1+rand(4),:random => true),
22
- :created_at => Time.at(rand(updated.to_i)),
23
- :updated_at => updated,
24
- :author_id => author.id,
25
- :owner_id => owner.id,
26
- :user_author_id => user_author.id,
27
- :relation_ids => [Relation::Public.instance.id]
28
- d.save!
12
+ SocialStream::Population::ActivityObject.new Document do |d|
13
+ d.file = File.open(doc_files.random, "r")
14
+ d.title = Forgery::LoremIpsum.words(rand(4), :random => true)
15
+ d.description = Forgery::LoremIpsum.sentences(rand(4), :random => true)
29
16
  end
30
-
31
- docs_end = Time.now
32
- puts ' -> ' + (docs_end - docs_start).round(4).to_s + 's'
33
17
  end
34
18
  end
35
19
  end
36
-
@@ -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.20.0')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.20.1')
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.14.0
4
+ version: 0.14.1
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-04-23 00:00:00.000000000Z
13
+ date: 2012-05-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: social_stream-base
17
- requirement: &84319120 !ruby/object:Gem::Requirement
17
+ requirement: &79325680 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 0.20.0
22
+ version: 0.20.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *84319120
25
+ version_requirements: *79325680
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: paperclip-ffmpeg
28
- requirement: &84318870 !ruby/object:Gem::Requirement
28
+ requirement: &79325360 !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: *84318870
36
+ version_requirements: *79325360
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: paperclip
39
- requirement: &84318640 !ruby/object:Gem::Requirement
39
+ requirement: &78886570 !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: *84318640
47
+ version_requirements: *78886570
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: delayed_paperclip
50
- requirement: &84318410 !ruby/object:Gem::Requirement
50
+ requirement: &78886040 !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: *84318410
58
+ version_requirements: *78886040
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: sqlite3-ruby
61
- requirement: &84318220 !ruby/object:Gem::Requirement
61
+ requirement: &78885730 !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: *84318220
69
+ version_requirements: *78885730
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec-rails
72
- requirement: &84317940 !ruby/object:Gem::Requirement
72
+ requirement: &78884960 !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: *84317940
80
+ version_requirements: *78884960
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: factory_girl
83
- requirement: &84317690 !ruby/object:Gem::Requirement
83
+ requirement: &78884650 !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: *84317690
91
+ version_requirements: *78884650
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: forgery
94
- requirement: &84317460 !ruby/object:Gem::Requirement
94
+ requirement: &78884370 !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: *84317460
102
+ version_requirements: *78884370
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: capybara
105
- requirement: &84317230 !ruby/object:Gem::Requirement
105
+ requirement: &78884080 !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: *84317230
113
+ version_requirements: *78884080
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
 
@@ -202,6 +202,7 @@ files:
202
202
  - app/views/documents/_new_activity_fields.html.erb
203
203
  - app/views/documents/destroy.js.erb
204
204
  - app/views/documents/index.html.erb
205
+ - app/views/documents/search.html.erb
205
206
  - app/views/documents/show.html.erb
206
207
  - app/views/pictures/_new.html.erb
207
208
  - app/views/pictures/_picture.html.erb
@@ -233,6 +234,12 @@ files:
233
234
  - lib/delayed_paperclip/social_stream-documents.rb
234
235
  - lib/generators/social_stream/documents/install_generator.rb
235
236
  - lib/paperclip/social_stream-documents.rb
237
+ - lib/samples/car.jpg
238
+ - lib/samples/house.jpg
239
+ - lib/samples/loremipsum.odt
240
+ - lib/samples/loremipsum.pdf
241
+ - lib/samples/siren.mp3
242
+ - lib/samples/water.mp3
236
243
  - lib/social_stream-documents.rb
237
244
  - lib/social_stream/documents/dependencies.rb
238
245
  - lib/social_stream/documents/engine.rb
@@ -324,10 +331,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
331
  version: '0'
325
332
  requirements: []
326
333
  rubyforge_project:
327
- rubygems_version: 1.8.12
334
+ rubygems_version: 1.8.15
328
335
  signing_key:
329
336
  specification_version: 3
330
337
  summary: File capabilities for Social Stream, the core for building social network
331
338
  websites
332
339
  test_files: []
333
- has_rdoc: