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.
- data/app/controllers/documents_controller.rb +10 -34
- data/app/controllers/pictures_controller.rb +6 -0
- data/app/models/document.rb +2 -2
- data/app/views/audios/index.html.erb +1 -1
- data/app/views/common_documents/_headers.html.erb +20 -15
- data/app/views/common_documents/_index.html.erb +5 -6
- data/app/views/documents/index.html.erb +1 -1
- data/app/views/documents/search.html.erb +3 -0
- data/app/views/pictures/index.html.erb +1 -1
- data/app/views/videos/index.html.erb +1 -1
- data/config/routes.rb +2 -0
- data/lib/samples/car.jpg +0 -0
- data/lib/samples/house.jpg +0 -0
- data/lib/samples/loremipsum.odt +0 -0
- data/lib/samples/loremipsum.pdf +0 -0
- data/lib/samples/siren.mp3 +0 -0
- data/lib/samples/water.mp3 +0 -0
- data/lib/social_stream/documents/version.rb +1 -1
- data/lib/tasks/db/populate_documents.rake +6 -23
- data/social_stream-documents.gemspec +1 -1
- metadata +29 -23
@@ -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
|
-
|
13
|
-
format.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
data/app/models/document.rb
CHANGED
@@ -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
|
1
|
+
<%= render :partial => 'common_documents/index', :locals => { :documents => @audios } %>
|
@@ -1,25 +1,30 @@
|
|
1
1
|
<% content_for :title do %>
|
2
|
-
<%= profile_subject.name +
|
2
|
+
<%= "#{ profile_subject && profile_subject.name + ': ' }#{ t('repository.title') }" %>
|
3
3
|
<% end %>
|
4
4
|
|
5
5
|
<% sidebar %>
|
6
6
|
|
7
|
-
<%if
|
8
|
-
<%= location(
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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 :
|
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 : "<%=
|
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 : "<%=
|
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
|
-
<%
|
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
|
-
<%
|
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
|
-
|
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
|
-
<%
|
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
|
-
:
|
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
|
1
|
+
<%= render :partial => 'common_documents/index', :locals => { :documents => collection } %>
|
@@ -1 +1 @@
|
|
1
|
-
<%=render
|
1
|
+
<%= render :partial => 'common_documents/index', :locals => { :documents => @pictures } %>
|
@@ -1 +1 @@
|
|
1
|
-
<%=render
|
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
|
data/lib/samples/car.jpg
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -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
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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.
|
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.
|
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-
|
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: &
|
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.
|
22
|
+
version: 0.20.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *79325680
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: paperclip-ffmpeg
|
28
|
-
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: *
|
36
|
+
version_requirements: *79325360
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: paperclip
|
39
|
-
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: *
|
47
|
+
version_requirements: *78886570
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: delayed_paperclip
|
50
|
-
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: *
|
58
|
+
version_requirements: *78886040
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: sqlite3-ruby
|
61
|
-
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: *
|
69
|
+
version_requirements: *78885730
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rspec-rails
|
72
|
-
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: *
|
80
|
+
version_requirements: *78884960
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: factory_girl
|
83
|
-
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: *
|
91
|
+
version_requirements: *78884650
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: forgery
|
94
|
-
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: *
|
102
|
+
version_requirements: *78884370
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: capybara
|
105
|
-
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: *
|
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.
|
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:
|