social_stream-documents 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/assets/javascripts/documents.js.erb +6 -0
- data/app/assets/stylesheets/documents.css.scss +5 -0
- data/app/controllers/documents_controller.rb +31 -4
- data/app/views/common/_headers.html.erb +76 -0
- data/app/views/common/_index.html.erb +16 -30
- data/config/routes.rb +1 -1
- data/lib/social_stream/documents/version.rb +1 -1
- data/social_stream-documents.gemspec +1 -1
- metadata +8 -7
@@ -1,4 +1,5 @@
|
|
1
1
|
class DocumentsController < InheritedResources::Base
|
2
|
+
include ActionView::Helpers::SanitizeHelper
|
2
3
|
respond_to :html, :js
|
3
4
|
|
4
5
|
belongs_to_subjects :optional => true
|
@@ -7,7 +8,19 @@ class DocumentsController < InheritedResources::Base
|
|
7
8
|
|
8
9
|
load_and_authorize_resource :except => :index
|
9
10
|
|
11
|
+
PER_PAGE=20
|
10
12
|
SEND_FILE_METHOD = :default
|
13
|
+
|
14
|
+
def index
|
15
|
+
super do |format|
|
16
|
+
if params[:no_layout].present?
|
17
|
+
format.html { render :action => :index, :layout => false }
|
18
|
+
else
|
19
|
+
format.html { render :action => :index }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
11
24
|
def create
|
12
25
|
super do |format|
|
13
26
|
format.all {redirect_to request.referer || home_path}
|
@@ -64,10 +77,12 @@ class DocumentsController < InheritedResources::Base
|
|
64
77
|
|
65
78
|
def collection
|
66
79
|
@activities = profile_subject.wall(:profile,
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
80
|
+
:for => current_subject,
|
81
|
+
:object_type => Array(self.class.index_object_type))
|
82
|
+
if params[:query].present?
|
83
|
+
@activities = @activities.joins(:activity_objects => :document).where('documents.title LIKE ?', get_search_query)
|
84
|
+
end
|
85
|
+
@activities.page(params[:page]).per(PER_PAGE)
|
71
86
|
end
|
72
87
|
|
73
88
|
class << self
|
@@ -75,4 +90,16 @@ class DocumentsController < InheritedResources::Base
|
|
75
90
|
[ :Audio, :Video, :Picture, :Document ]
|
76
91
|
end
|
77
92
|
end
|
93
|
+
|
94
|
+
def get_search_query
|
95
|
+
search_query = ""
|
96
|
+
param = strip_tags(params[:query]) || ""
|
97
|
+
bare_query = param unless bare_query.html_safe?
|
98
|
+
search_query_words = bare_query.strip.split
|
99
|
+
search_query_words.each_index do |i|
|
100
|
+
search_query+= search_query_words[i] + " " if i < (search_query_words.size - 1)
|
101
|
+
search_query+= "%" + search_query_words[i] + "% " if i == (search_query_words.size - 1)
|
102
|
+
end
|
103
|
+
return search_query.strip
|
104
|
+
end
|
78
105
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
<% content_for :title do %>
|
2
|
+
<%= profile_subject.name + ": " + t('repository.title') %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<% content_for :sidebar do %>
|
6
|
+
<%= render :partial => 'home/sidebar' %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<%if profile_subject_is_current?%>
|
10
|
+
<%= location(
|
11
|
+
link_to(t('repository.title'), polymorphic_path(controller.controller_name),:remote => true)
|
12
|
+
) %>
|
13
|
+
<%else%>
|
14
|
+
<%= location(
|
15
|
+
link_to(profile_subject.name, polymorphic_path(profile_subject),:remote => true),
|
16
|
+
link_to(t('repository.title'), polymorphic_path([profile_subject, controller.controller_name]),:remote => true)
|
17
|
+
) %>
|
18
|
+
<%end%>
|
19
|
+
|
20
|
+
<% toolbar :profile => profile_subject %>
|
21
|
+
<br class="clearfloat" />
|
22
|
+
<div class="space_center"></div>
|
23
|
+
<div id="repository_filter">
|
24
|
+
<form action="<%= search_path%>" method="get" id="repository_filter">
|
25
|
+
<%= text_field_tag :filter_query, nil,:autocomplete => :off, :id => :repository_filter_input %>
|
26
|
+
</form>
|
27
|
+
<div id="order_by"><%= t('repository.order.by') %>: <%= t('repository.order.last_modified') %> · <%= t('repository.order.most_popular') %> </div>
|
28
|
+
</div>
|
29
|
+
<div class="space_center"></div>
|
30
|
+
|
31
|
+
<%= javascript_tag do %>
|
32
|
+
$(document).ready(function() {
|
33
|
+
var last_search = "";
|
34
|
+
|
35
|
+
|
36
|
+
$("#repository_filter_input").Watermark("<%= escape_javascript(I18n.t('search.name')) %>");
|
37
|
+
|
38
|
+
$("#repository_filter_input").keyup(function() {
|
39
|
+
var searchstring = $(this).val();
|
40
|
+
if((searchstring=="")){
|
41
|
+
if (last_search!=searchstring){last_search=searchstring;}
|
42
|
+
$("#documents_grid").html("<center><%= escape_javascript(image_tag('loading.gif', :class => :loading)) %></center>");
|
43
|
+
$.ajax({
|
44
|
+
type : "GET",
|
45
|
+
url : "<%= polymorphic_url([current_subject, Document.new]) %>?no_layout=true",
|
46
|
+
success : function(html) {
|
47
|
+
if ($("#repository_filter_input").val()==searchstring){ //Only show if input value is still the same
|
48
|
+
$("#documents_grid").html(html);
|
49
|
+
}
|
50
|
+
},
|
51
|
+
error: function(){
|
52
|
+
$("#header_search_display").html("<center><%= escape_javascript(content_tag(:span,I18n.t('search.wrong'), :class => :warning)) %></center>");
|
53
|
+
}
|
54
|
+
});
|
55
|
+
} else {
|
56
|
+
if (last_search!=searchstring){
|
57
|
+
last_search=searchstring;
|
58
|
+
$("#documents_grid").html("<center><%= escape_javascript(image_tag('loading.gif', :class => :loading)) %></center>");
|
59
|
+
$.ajax({
|
60
|
+
type : "GET",
|
61
|
+
url : "<%= polymorphic_url([current_subject, Document.new]) %>?query=" + searchstring + "&no_layout=true",
|
62
|
+
success : function(html) {
|
63
|
+
if ($("#repository_filter_input").val()==searchstring){ //Only show if input value is still the same
|
64
|
+
$("#documents_grid").html(html);
|
65
|
+
}
|
66
|
+
},
|
67
|
+
error: function(){
|
68
|
+
$("#header_search_display").html("<center><%= escape_javascript(content_tag(:span,I18n.t('search.wrong'), :class => :warning)) %></center>");
|
69
|
+
}
|
70
|
+
});
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return false;
|
74
|
+
});
|
75
|
+
})
|
76
|
+
<% end %>
|
@@ -1,32 +1,7 @@
|
|
1
|
-
<%
|
2
|
-
<%=
|
3
|
-
|
4
|
-
|
5
|
-
<% content_for :sidebar do %>
|
6
|
-
<%= render :partial => 'home/sidebar' %>
|
7
|
-
<% end %>
|
8
|
-
|
9
|
-
<%if profile_subject_is_current?%>
|
10
|
-
<%= location(
|
11
|
-
link_to(t('repository.title'), polymorphic_path(controller.controller_name),:remote => true)
|
12
|
-
) %>
|
13
|
-
<%else%>
|
14
|
-
<%= location(
|
15
|
-
link_to(profile_subject.name, polymorphic_path(profile_subject),:remote => true),
|
16
|
-
link_to(t('repository.title'), polymorphic_path([profile_subject, controller.controller_name]),:remote => true)
|
17
|
-
) %>
|
18
|
-
<%end%>
|
19
|
-
|
20
|
-
<% toolbar :profile => profile_subject %>
|
21
|
-
<br class="clearfloat" />
|
22
|
-
<div class="space_center"></div>
|
23
|
-
<div id="repository_filter">
|
24
|
-
<form action="<%= search_path%>" method="get" id="repository_filter">
|
25
|
-
<%= text_field_tag :filter_query, nil,:autocomplete => :off, :id => :repository_filter_input %>
|
26
|
-
</form>
|
27
|
-
<div id="order_by"><%= t('repository.order.by') %>: <%= t('repository.order.last_modified') %> · <%= t('repository.order.most_popular') %> </div>
|
28
|
-
</div>
|
29
|
-
<div class="space_center"></div>
|
1
|
+
<% unless params[:no_layout].present? %>
|
2
|
+
<%= render :partial => "common/headers" %>
|
3
|
+
<div id="documents_grid">
|
4
|
+
<% end %>
|
30
5
|
|
31
6
|
<% @activities.each do |a| %>
|
32
7
|
<% document = a.activity_objects.first.document %>
|
@@ -46,4 +21,15 @@
|
|
46
21
|
:path => document_path(document) %>
|
47
22
|
</div>
|
48
23
|
</div>
|
49
|
-
<% end %>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<% if @activities.size == DocumentsController::PER_PAGE %>
|
27
|
+
<% next_url = url_for(:no_layout => true,
|
28
|
+
:page => params[:page].present? ? params[:page].to_i + 1 : 2,
|
29
|
+
:query => params[:query].present? ? params[:query] : "") %>
|
30
|
+
<%= content_tag(:span, "", :class => "screw screw-after", :rel => next_url)%>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
<% unless params[:no_layout].present? %>
|
34
|
+
</div>
|
35
|
+
<% end %>
|
data/config/routes.rb
CHANGED
@@ -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.9.
|
15
|
+
s.add_runtime_dependency('social_stream-base', '~> 0.9.25')
|
16
16
|
s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.7.0')
|
17
17
|
s.add_runtime_dependency('paperclip','2.3.11')
|
18
18
|
s.add_runtime_dependency('delayed_paperclip','>= 0.7.2')
|
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: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
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-
|
19
|
+
date: 2011-11-04 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -27,12 +27,12 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - ~>
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
30
|
+
hash: 9
|
31
31
|
segments:
|
32
32
|
- 0
|
33
33
|
- 9
|
34
|
-
-
|
35
|
-
version: 0.9.
|
34
|
+
- 25
|
35
|
+
version: 0.9.25
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id001
|
38
38
|
- !ruby/object:Gem::Dependency
|
@@ -258,6 +258,7 @@ files:
|
|
258
258
|
- app/views/audios/show.html.erb
|
259
259
|
- app/views/common/_document_info.html.erb
|
260
260
|
- app/views/common/_edit_form.html.erb
|
261
|
+
- app/views/common/_headers.html.erb
|
261
262
|
- app/views/common/_index.html.erb
|
262
263
|
- app/views/common/_show.html.erb
|
263
264
|
- app/views/documents/_document.html.erb
|