file_share 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/controllers/file_attachments_controller.rb +1 -0
- data/app/controllers/file_share/application_controller.rb +2 -1
- data/app/helpers/file_attachments_helper.rb +11 -2
- data/app/helpers/file_share/application_helper.rb +64 -7
- data/app/views/file-share-shared/_main_menu.html.erb +1 -1
- data/app/views/file_attachments/_file_attachment.html.erb +2 -15
- data/app/views/file_attachments/_file_attachments.html.erb +5 -4
- data/app/views/file_attachments/_upload_form.html.erb +3 -1
- data/app/views/file_attachments/edit.html.erb +1 -3
- data/app/views/file_attachments/show.html.erb +5 -0
- data/app/views/layouts/application.html.erb +1 -1
- data/config/blueprint_settings.yml +1 -0
- data/public/javascripts/file_share_behaviors.js +1 -1
- data/public/stylesheets/blueprint/readme.txt +2 -2
- data/public/stylesheets/blueprint/screen.css +5 -1
- data/public/stylesheets/main_elements.css +1 -1
- data/spec/controllers/file_attachments_controller_spec.rb +16 -1
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
@@ -2,10 +2,11 @@ class FileShare::ApplicationController < ApplicationController
|
|
2
2
|
helper_method :has_authorization?
|
3
3
|
|
4
4
|
private
|
5
|
-
|
5
|
+
unless private_method_defined?(:has_authorization?)
|
6
6
|
def has_authorization?(*args)
|
7
7
|
true
|
8
8
|
end
|
9
|
+
end
|
9
10
|
protected
|
10
11
|
public
|
11
12
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module FileAttachmentsHelper
|
2
2
|
|
3
3
|
def description_display(file_attachment)
|
4
|
+
return unless has_authorization?(:read, file_attachment)
|
4
5
|
content_tag :p, {
|
5
6
|
:id => "file_attachment_#{file_attachment.id}_description",
|
6
7
|
:style => "max-width: 70%; float: right;",
|
@@ -15,8 +16,16 @@ module FileAttachmentsHelper
|
|
15
16
|
:id => "file_attachment_#{file_attachment.id}_name",
|
16
17
|
:class => 'file_attachment_name'
|
17
18
|
} do
|
18
|
-
|
19
|
+
link_to_download_file_attachment(file_attachment)
|
19
20
|
end
|
20
21
|
end
|
21
|
-
|
22
|
+
|
23
|
+
def file_container_data(file_attachment)
|
24
|
+
return unless has_authorization?(:update, file_attachment)
|
25
|
+
content_tag :span, file_attachment.file_container, {
|
26
|
+
:id => "file_attachment_#{file_attachment.id}_file_container",
|
27
|
+
:class => "file_attachment_file_container",
|
28
|
+
:style => "display:none;"
|
29
|
+
}
|
30
|
+
end
|
22
31
|
end
|
@@ -20,19 +20,76 @@ module FileShare
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def link_to_file_attachments(wrapper_options={})
|
23
|
+
def link_to_file_attachments(wrapper_options={}, link_options={})
|
24
24
|
link_wrapper(file_attachments_path, wrapper_options, {
|
25
25
|
:link_text => 'List / Upload Files'
|
26
|
-
})
|
26
|
+
}.merge!(link_options))
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
29
|
+
def links_to_edit_and_delete_file_attachment(file_attachment, wrapper_options={}, link_options={})
|
30
|
+
return unless has_authorization?(:update, file_attachment) || has_authorization?(:delete, file_attachment)
|
31
|
+
content_tag :p do
|
32
|
+
link_to_edit_file_attachment(file_attachment) + " " +
|
33
|
+
link_to_delete_file_attachment(file_attachment)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def link_to_edit_file_attachment(file_attachment, wrapper_options={}, link_options={})
|
38
|
+
return unless has_authorization?(:update, file_attachment)
|
39
|
+
link_wrapper(edit_file_attachment_path(file_attachment), {
|
40
|
+
:no_wrapper => true
|
41
|
+
}.merge!(wrapper_options), {
|
42
|
+
:link_text => 'update',
|
43
|
+
:class => 'file_attachment_dynamic_form_link fake_button'
|
44
|
+
}.merge!(link_options))
|
45
|
+
end
|
46
|
+
|
47
|
+
def link_to_delete_file_attachment(file_attachment, wrapper_options={}, link_options={})
|
48
|
+
return unless has_authorization?(:delete, file_attachment)
|
49
|
+
link_wrapper(file_attachment_path(file_attachment), {
|
50
|
+
:no_wrapper => true
|
51
|
+
}.merge!(wrapper_options), {
|
52
|
+
:link_text => 'delete',
|
53
|
+
:method => :delete,
|
54
|
+
:confirm => "Did you mean to Delete #{file_attachment.name}?",
|
55
|
+
:class => 'fake_button'
|
56
|
+
}.merge!(link_options))
|
57
|
+
end
|
58
|
+
|
59
|
+
def link_to_download_file_attachment(file_attachment, wrapper_options={}, link_options={})
|
60
|
+
return unless has_authorization?(:read, file_attachment)
|
61
|
+
link_wrapper(download_file_attachment_path(file_attachment), {
|
62
|
+
:no_wrapper => true
|
63
|
+
}.merge!(wrapper_options), {
|
64
|
+
:link_text => file_attachment.name
|
65
|
+
}.merge!(link_options))
|
31
66
|
end
|
32
67
|
|
33
|
-
def
|
34
|
-
|
68
|
+
def link_to_attachable(attachable, wrapper_options={}, link_options={})
|
69
|
+
return unless has_authorization?(:read, attachable)
|
70
|
+
link_wrapper(polymorphic_path(attachable), {
|
71
|
+
:no_wrapper => true
|
72
|
+
}.merge!(wrapper_options), {
|
73
|
+
:link_text => attachable.name
|
74
|
+
}.merge!(link_options))
|
35
75
|
end
|
76
|
+
|
77
|
+
def link_to_attachable_or_file_attachments(attachable, wrapper_options={}, link_options={})
|
78
|
+
unless attachable.blank?
|
79
|
+
return link_to_attachable(attachable), {
|
80
|
+
:no_wrapper => false
|
81
|
+
}, {
|
82
|
+
:link_text => '< back',
|
83
|
+
:class => 'fake_button'
|
84
|
+
}
|
85
|
+
else
|
86
|
+
return link_to_file_attachments({}, {
|
87
|
+
:link_text => '< back',
|
88
|
+
:class => 'fake_button'
|
89
|
+
})
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
36
93
|
def file_share_javascript_includes
|
37
94
|
list = [
|
38
95
|
"jquery-ui-1.7.2.custom.min.js",
|
@@ -55,6 +112,6 @@ module FileShare
|
|
55
112
|
list.unshift("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js")
|
56
113
|
end
|
57
114
|
list
|
58
|
-
end
|
115
|
+
end
|
59
116
|
end
|
60
117
|
end
|
@@ -1,20 +1,7 @@
|
|
1
1
|
<%= div_for(file_attachment) do %>
|
2
|
-
<%=
|
3
|
-
:id => "file_attachment_#{file_attachment.id}_file_container",
|
4
|
-
:class => "file_attachment_file_container",
|
5
|
-
:style => "display:none;"
|
6
|
-
} if has_authorization?(:update, file_attachment) %>
|
2
|
+
<%= file_container_data(file_attachment) %>
|
7
3
|
<%= description_display(file_attachment) %>
|
8
4
|
<%= name_display(file_attachment) %>
|
9
|
-
<%=
|
10
|
-
<%= link_to "update", edit_file_attachment_path(file_attachment), {
|
11
|
-
:class => 'file_attachment_dynamic_form_link fake_button'
|
12
|
-
} %>
|
13
|
-
<%= link_to('delete', file_attachment_path(file_attachment.id), {
|
14
|
-
:method => :delete,
|
15
|
-
:confirm => "Did you mean to Delete #{file_attachment.name}?",
|
16
|
-
:class => 'fake_button'
|
17
|
-
}) if has_authorization?(:delete, file_attachment) %>
|
18
|
-
<% end if has_authorization?(:update, file_attachment) || has_authorization?(:delete, file_attachment) %>
|
5
|
+
<%= links_to_edit_and_delete_file_attachment(file_attachment) %>
|
19
6
|
<% end %>
|
20
7
|
<hr />
|
@@ -4,18 +4,18 @@
|
|
4
4
|
<h2>Orphaned Files</h2>
|
5
5
|
<%= render :partial => 'file_attachments/file_attachment', :collection => orphans %>
|
6
6
|
</div>
|
7
|
-
<div class="span-8 last">
|
7
|
+
<div id="files" class="span-8 last">
|
8
8
|
<h2>Attached Files</h2>
|
9
9
|
<% files.group_by(&:attachable).each do |attachable, attached_files| %>
|
10
10
|
<div id="<%= "#{attachable.class}_#{attachable.id}" %>">
|
11
|
-
<h3><%=
|
11
|
+
<h3><%= link_to_attachable(attachable) %></h3>
|
12
12
|
<%= render :partial => 'file_attachments/file_attachment', :collection => attached_files %>
|
13
13
|
</div>
|
14
14
|
<% end %>
|
15
15
|
</div>
|
16
16
|
<div style="clear:both;"></div>
|
17
17
|
<% else %>
|
18
|
-
<div>
|
18
|
+
<div id="files">
|
19
19
|
<% if files.present? || orphans.present? %>
|
20
20
|
<%= render :partial => 'file_attachments/file_attachment', :collection => files.present? ? files : orphans %>
|
21
21
|
<% end %>
|
@@ -24,6 +24,7 @@
|
|
24
24
|
</div>
|
25
25
|
|
26
26
|
<% if has_authorization?(:update, FileAttachment.new) %>
|
27
|
+
<%- @file_containers = FileContainer.all unless defined?(@file_containers) %>
|
27
28
|
<form id="file_attachment_dynamic_form" class="formtastic" method="post" action="<%= file_attachments_path %>" style="display: none; padding: 5px 0;">
|
28
29
|
<div style="margin: 0pt; padding: 0pt; display: inline;">
|
29
30
|
<input type="hidden" value="put" name="_method" />
|
@@ -42,7 +43,7 @@
|
|
42
43
|
<% end %>
|
43
44
|
<textarea id="file_attachment_description" style="height: 70px; width: 69%" name="file_attachment[description]"></textarea>
|
44
45
|
<br />
|
45
|
-
<input type="submit" value="Update" /> | <a href="#" class="cancel_dynamic_form">Cancel</a>
|
46
|
+
<input type="submit" value="Update" /> | <a href="#" class="cancel_dynamic_form fake_button">Cancel</a>
|
46
47
|
</form>
|
47
48
|
|
48
49
|
<% content_for(:javascript) do %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if defined?(container) && container %>
|
1
|
+
<% if defined?(container) && container.present? %>
|
2
2
|
<% new_file_attachment = FileAttachment.new(:attachable => container) %>
|
3
3
|
<% else %>
|
4
4
|
<% new_file_attachment = FileAttachment.new %>
|
@@ -11,8 +11,10 @@
|
|
11
11
|
%>
|
12
12
|
|
13
13
|
<% f.inputs do %>
|
14
|
+
<% if new_file_attachment.attachable.present? %>
|
14
15
|
<%= f.input :attachable_id, :as => :hidden %>
|
15
16
|
<%= f.input :attachable_type, :as => :hidden %>
|
17
|
+
<% end %>
|
16
18
|
<%= f.input :name, :label => 'Name' %>
|
17
19
|
<%= f.input :description, :label => 'Description' %>
|
18
20
|
<%= f.input :uploaded_file, :as => :file, :label => 'Filepath' %>
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
file_attachments_path : polymorphic_path(@file_attachment.attachable_id) -%>
|
3
|
-
<p><%= link_to '< back', back_path, :class => 'fake_button' %></p>
|
1
|
+
<p><%= link_to_attachable_or_file_attachments(@file_attachment.attachable) %></p>
|
4
2
|
|
5
3
|
<%= content_tag :div do %>
|
6
4
|
<%= semantic_form_for @file_attachment do |form| %>
|
@@ -166,7 +166,7 @@ DynamicForm = $.klass({
|
|
166
166
|
// get resource attr names from form input ids
|
167
167
|
var resourceAttrContainer = resourceContainer.find('.'+this.id);
|
168
168
|
// get resource attr vals from w/in resource container
|
169
|
-
this.value = resourceAttrContainer.text();
|
169
|
+
this.value = $.trim(resourceAttrContainer.text());
|
170
170
|
});
|
171
171
|
|
172
172
|
this.formElement.show();
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Event styles
|
2
2
|
|
3
3
|
Credits
|
4
4
|
----------------------------------------------------------------
|
@@ -9,4 +9,4 @@ Usage
|
|
9
9
|
----------------------------------------------------------------
|
10
10
|
|
11
11
|
1) Add this line to your HTML:
|
12
|
-
<link rel="stylesheet" href="css/blueprint/plugins/
|
12
|
+
<link rel="stylesheet" href="css/blueprint/plugins/events/screen.css" type="text/css" media="screen, projection">
|
@@ -399,4 +399,8 @@ table.tiny_table td {padding:0px 2px;margin:0px 2px;font-size:9px;}
|
|
399
399
|
table.tablesorter {width:auto;}
|
400
400
|
table.tablesorter tbody td {padding:4px 12px;}
|
401
401
|
table.tablesorter th.header {padding-right:24px;}
|
402
|
-
table.tablesorter thead tr th {font-size:13px;}
|
402
|
+
table.tablesorter thead tr th {font-size:13px;}
|
403
|
+
|
404
|
+
/* files */
|
405
|
+
div.file_attachment {margin-bottom:10px;}
|
406
|
+
p.description_file_attachment {float:right;max-width:70%;}
|
@@ -167,6 +167,21 @@ describe FileAttachmentsController do
|
|
167
167
|
|
168
168
|
end
|
169
169
|
|
170
|
+
describe ":show, :id => int" do
|
171
|
+
before(:each) do
|
172
|
+
FileAttachment.stub(:find).and_return(mock_file_attachment)
|
173
|
+
end
|
174
|
+
it "loads a @file_attachment" do
|
175
|
+
FileAttachment.should_receive(:find).with('1').and_return(mock_file_attachment)
|
176
|
+
get :show, :id => "1"
|
177
|
+
assigns[:file_attachment].should eql mock_file_attachment
|
178
|
+
end
|
179
|
+
it "renders the show template" do
|
180
|
+
get :show, :id => "1"
|
181
|
+
response.should render_template("file_attachments/show")
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
170
185
|
describe ":edit, :id => integer" do
|
171
186
|
|
172
187
|
before(:each) do
|
@@ -176,7 +191,7 @@ describe FileAttachmentsController do
|
|
176
191
|
it "loads a file_attachment as @file_attachment" do
|
177
192
|
FileAttachment.should_receive(:find).with('1').and_return(mock_file_attachment)
|
178
193
|
get :edit, :id => "1"
|
179
|
-
assigns[:file_attachment].should
|
194
|
+
assigns[:file_attachment].should eql @mock_file_attachment
|
180
195
|
end
|
181
196
|
|
182
197
|
it "loads potential containers as @file_containers" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file_share
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jason LaPier
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-12-
|
19
|
+
date: 2010-12-15 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -295,6 +295,7 @@ files:
|
|
295
295
|
- app/views/file_attachments/_upload_form.html.erb
|
296
296
|
- app/views/file_attachments/edit.html.erb
|
297
297
|
- app/views/file_attachments/index.html.erb
|
298
|
+
- app/views/file_attachments/show.html.erb
|
298
299
|
- app/views/file_attachments/update.js.rjs
|
299
300
|
- app/views/layouts/application.html.erb
|
300
301
|
- config/application.rb
|