file_share 0.1.0
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/Gemfile +16 -0
- data/Gemfile.lock +147 -0
- data/README +0 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/app/controllers/application_controller.rb +4 -0
- data/app/controllers/file_attachments_controller.rb +123 -0
- data/app/controllers/file_share/application_controller.rb +5 -0
- data/app/helpers/file_attachments_helper.rb +9 -0
- data/app/helpers/file_share/application_helper.rb +60 -0
- data/app/models/file_attachment.rb +104 -0
- data/app/models/file_container.rb +30 -0
- data/app/views/file-share-shared/_flash.html.erb +7 -0
- data/app/views/file-share-shared/_main_menu.html.erb +3 -0
- data/app/views/file-share-shared/_navigation.html.erb +2 -0
- data/app/views/file_attachments/_file_attachment.html.erb +17 -0
- data/app/views/file_attachments/_file_attachments.html.erb +52 -0
- data/app/views/file_attachments/_file_container_option.html.erb +4 -0
- data/app/views/file_attachments/_file_container_select.html.erb +14 -0
- data/app/views/file_attachments/_plupload_with_listing.html.erb +142 -0
- data/app/views/file_attachments/_upload_form.html.erb +22 -0
- data/app/views/file_attachments/edit.html.erb +32 -0
- data/app/views/file_attachments/index.html.erb +1 -0
- data/app/views/file_attachments/update.js.rjs +13 -0
- data/app/views/layouts/application.html.erb +56 -0
- data/config/application.rb +42 -0
- data/config/blueprint_settings.yml +9 -0
- data/config/boot.rb +13 -0
- data/config/cucumber.yml +8 -0
- data/config/database.example.yml +22 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +26 -0
- data/config/environments/production.rb +49 -0
- data/config/environments/test.rb +35 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/inflections.rb +10 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/secret_token.rb +9 -0
- data/config/initializers/session_store.rb +10 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +64 -0
- data/db/migrate/20101020002635_create_file_attachments.rb +19 -0
- data/db/schema.rb +27 -0
- data/db/seeds.rb +7 -0
- data/lib/file_share.rb +3 -0
- data/lib/file_share/engine.rb +25 -0
- data/lib/generators/file_share/install/USAGE +5 -0
- data/lib/generators/file_share/install/install_generator.rb +19 -0
- data/lib/generators/file_share/install/templates/file_share.rake +169 -0
- data/lib/tasks/blueprint.rake +25 -0
- data/lib/tasks/cucumber.rake +53 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +26 -0
- data/public/favicon.ico +0 -0
- data/public/images/rails.png +0 -0
- data/public/javascripts/file_share.js +62 -0
- data/public/javascripts/file_share_behaviors.js +131 -0
- data/public/javascripts/idselector.js +538 -0
- data/public/javascripts/jquery-1.3.2.min.js +19 -0
- data/public/javascripts/jquery-ui-1.7.2.custom.min.js +298 -0
- data/public/javascripts/jquery.clonePosition.js +27 -0
- data/public/javascripts/jquery.js +154 -0
- data/public/javascripts/jquery.qtip-1.0.0-rc3.js +2149 -0
- data/public/javascripts/jquery.qtip-1.0.0-rc3.min.js +15 -0
- data/public/javascripts/jquery.string.1.0-min.js +6 -0
- data/public/javascripts/jquery.tablesorter.min.js +2 -0
- data/public/javascripts/lowpro.jquery.js +224 -0
- data/public/javascripts/plupload/gears_init.js +86 -0
- data/public/javascripts/plupload/jquery.plupload.queue.min.js +202 -0
- data/public/javascripts/plupload/plupload.browserplus.min.js +1 -0
- data/public/javascripts/plupload/plupload.flash.min.js +1 -0
- data/public/javascripts/plupload/plupload.flash.swf +0 -0
- data/public/javascripts/plupload/plupload.full.min.js +1 -0
- data/public/javascripts/plupload/plupload.gears.min.js +1 -0
- data/public/javascripts/plupload/plupload.html4.min.js +1 -0
- data/public/javascripts/plupload/plupload.html5.min.js +1 -0
- data/public/javascripts/plupload/plupload.min.js +1 -0
- data/public/javascripts/plupload/plupload.silverlight.min.js +1 -0
- data/public/javascripts/plupload/plupload.silverlight.xap +0 -0
- data/public/javascripts/rails.js +132 -0
- data/public/robots.txt +5 -0
- data/public/stylesheets/blueprint/grid.css +290 -0
- data/public/stylesheets/blueprint/icons/cross.png +0 -0
- data/public/stylesheets/blueprint/icons/doc.png +0 -0
- data/public/stylesheets/blueprint/icons/email.png +0 -0
- data/public/stylesheets/blueprint/icons/external.png +0 -0
- data/public/stylesheets/blueprint/icons/feed.png +0 -0
- data/public/stylesheets/blueprint/icons/im.png +0 -0
- data/public/stylesheets/blueprint/icons/key.png +0 -0
- data/public/stylesheets/blueprint/icons/pdf.png +0 -0
- data/public/stylesheets/blueprint/icons/tick.png +0 -0
- data/public/stylesheets/blueprint/icons/visited.png +0 -0
- data/public/stylesheets/blueprint/icons/xls.png +0 -0
- data/public/stylesheets/blueprint/ie.css +36 -0
- data/public/stylesheets/blueprint/oldgrid.css +161 -0
- data/public/stylesheets/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/public/stylesheets/blueprint/plugins/buttons/icons/key.png +0 -0
- data/public/stylesheets/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/public/stylesheets/blueprint/plugins/buttons/readme.txt +32 -0
- data/public/stylesheets/blueprint/plugins/buttons/screen.css +97 -0
- data/public/stylesheets/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/public/stylesheets/blueprint/plugins/fancy-type/screen.css +71 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/readme.txt +18 -0
- data/public/stylesheets/blueprint/plugins/link-icons/screen.css +40 -0
- data/public/stylesheets/blueprint/plugins/rtl/readme.txt +10 -0
- data/public/stylesheets/blueprint/plugins/rtl/screen.css +110 -0
- data/public/stylesheets/blueprint/plugins/silksprite/sprite.css +1 -0
- data/public/stylesheets/blueprint/plugins/silksprite/sprites.png +0 -0
- data/public/stylesheets/blueprint/print.css +29 -0
- data/public/stylesheets/blueprint/readme.txt +12 -0
- data/public/stylesheets/blueprint/screen.css +402 -0
- data/public/stylesheets/error_messages.css +65 -0
- data/public/stylesheets/formtastic.css +138 -0
- data/public/stylesheets/formtastic_changes.css +33 -0
- data/public/stylesheets/main_elements.css +26 -0
- data/public/stylesheets/plupload/backgrounds.gif +0 -0
- data/public/stylesheets/plupload/buttons-disabled.png +0 -0
- data/public/stylesheets/plupload/buttons.png +0 -0
- data/public/stylesheets/plupload/delete.gif +0 -0
- data/public/stylesheets/plupload/done.gif +0 -0
- data/public/stylesheets/plupload/error.gif +0 -0
- data/public/stylesheets/plupload/screen.css +172 -0
- data/public/stylesheets/plupload/transp50.png +0 -0
- data/public/stylesheets/reset.css +60 -0
- data/public/stylesheets/scaffold.css +55 -0
- data/public/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/public/stylesheets/smoothness/jquery-ui-1.7.2.custom.css +406 -0
- data/public/stylesheets/tablesorter/blue/asc.gif +0 -0
- data/public/stylesheets/tablesorter/blue/bg.gif +0 -0
- data/public/stylesheets/tablesorter/blue/desc.gif +0 -0
- data/public/stylesheets/tablesorter/blue/style.css +39 -0
- data/public/stylesheets/text_and_colors.css +49 -0
- data/spec/controllers/file_attachments_controller_spec.rb +305 -0
- data/spec/fixtures/file_share_file_attachments.yml +2 -0
- data/spec/fixtures/somefile.txt +1 -0
- data/spec/helpers/file_attachments_helper_spec.rb +11 -0
- data/spec/models/file_attachment_spec.rb +57 -0
- data/spec/models/file_container_spec.rb +23 -0
- data/spec/spec_helper.rb +27 -0
- metadata +474 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module FileContainer
|
|
2
|
+
mattr_reader :types
|
|
3
|
+
|
|
4
|
+
@@types ||= []
|
|
5
|
+
|
|
6
|
+
def self.included(base)
|
|
7
|
+
@@types << base
|
|
8
|
+
|
|
9
|
+
base.instance_eval do
|
|
10
|
+
include Associations
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.all
|
|
15
|
+
types.collect do |type|
|
|
16
|
+
type.all
|
|
17
|
+
end.flatten! || []
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
module Associations
|
|
21
|
+
def self.included(base)
|
|
22
|
+
base.instance_eval do
|
|
23
|
+
has_many :file_attachments, {
|
|
24
|
+
:as => :attachable,
|
|
25
|
+
:dependent => :destroy
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%= div_for(file_attachment) do %>
|
|
2
|
+
<%= description_display(file_attachment) %>
|
|
3
|
+
<%= content_tag :p do %>
|
|
4
|
+
<%= link_to(file_attachment.name, download_file_attachment_path(file_attachment.id)) %>
|
|
5
|
+
<% end %>
|
|
6
|
+
|
|
7
|
+
<%= content_tag :p, :style => "font-size: 11px;" do %>
|
|
8
|
+
<a href="#" file_attachment_id="<%= file_attachment.id %>" file_attachment[description]="<%= file_attachment.description %>" class="file_attachment_dynamic_form_link fake_button">update description</a>
|
|
9
|
+
<%= link_to('update', edit_file_attachment_path(file_attachment.id), :class => 'fake_button') if has_authorization?(:update, file_attachment) %>
|
|
10
|
+
<%= link_to('delete', file_attachment_path(file_attachment.id), {
|
|
11
|
+
:method => :delete,
|
|
12
|
+
:confirm => "Did you mean to Delete #{file_attachment.name}?",
|
|
13
|
+
:class => 'fake_button'
|
|
14
|
+
}) if has_authorization?(:delete, file_attachment) %>
|
|
15
|
+
<% end if has_authorization?(:update, file_attachment) || has_authorization?(:delete, file_attachment) %>
|
|
16
|
+
<% end %>
|
|
17
|
+
<hr />
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<div id="file_attachments">
|
|
2
|
+
<div id="orphans" class="span-8">
|
|
3
|
+
<h2>Orphaned Files (<em><%= @orphans.count %></em>)</h2>
|
|
4
|
+
<%= render :partial => 'file_attachments/file_attachment', :collection => @orphans %>
|
|
5
|
+
</div>
|
|
6
|
+
<div id="files" class="span-8 last">
|
|
7
|
+
<h2>Files (<em><%= @files.count %></em>)</h2>
|
|
8
|
+
<% @files.group_by(&:attachable).each do |attachable, attached_files| %>
|
|
9
|
+
<div id="<%= "#{attachable.class}_#{attachable.id}" %>">
|
|
10
|
+
<h3><%= link_to attachable.name, polymorphic_path(attachable) %> (<em><%= attached_files.count %></em>)</h3>
|
|
11
|
+
<%= render :partial => 'file_attachments/file_attachment', :collection => attached_files %>
|
|
12
|
+
</div>
|
|
13
|
+
<% end %>
|
|
14
|
+
</div>
|
|
15
|
+
<div style="clear:both;"></div>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<% if has_authorization?(:update, FileAttachment.new) %>
|
|
19
|
+
<div id="blank_description_form" style="display: none; padding: 5px 0;">
|
|
20
|
+
<form class="formtastic file_attachment" id="new_description" method="post" action="#">
|
|
21
|
+
<div style="margin: 0pt; padding: 0pt; display: inline;">
|
|
22
|
+
<input type="hidden" value="put" name="_method" />
|
|
23
|
+
<input type="hidden" value="<%= form_authenticity_token %>" name="authenticity_token" />
|
|
24
|
+
</div>
|
|
25
|
+
<textarea id="file_attachment_description" style="height: 70px; width: 69%" name="file_attachment[description]"></textarea>
|
|
26
|
+
<br />
|
|
27
|
+
<input type="submit" value="Update" />
|
|
28
|
+
</form>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<% content_for(:javascript) do %>
|
|
32
|
+
<script type="text/javascript">
|
|
33
|
+
jQuery.ajaxSetup({
|
|
34
|
+
'beforeSend': function(xhr) {
|
|
35
|
+
xhr.setRequestHeader("Accept", "text/javascript");
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
jQuery(function($) {
|
|
40
|
+
$("a.file_attachment_dynamic_form_link").attach(DynamicForm, {
|
|
41
|
+
formId: 'new_description',
|
|
42
|
+
formContainer: 'blank_description_form',
|
|
43
|
+
actionPrefix: '/file_attachments',
|
|
44
|
+
targetIdName: 'file_attachment_id',
|
|
45
|
+
targetContentName: 'file_attachment[description]',
|
|
46
|
+
targetContentType: 'textarea'
|
|
47
|
+
});
|
|
48
|
+
$("#new_description").attach(Remote.Form);
|
|
49
|
+
});
|
|
50
|
+
</script>
|
|
51
|
+
<% end %>
|
|
52
|
+
<% end %>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<% value_class = file_container_option.class.to_s -%>
|
|
2
|
+
<% value = file_container_option.id -%>
|
|
3
|
+
<% selected_txt = selected == "#{value_class}_#{value}" ? ' selected="selected" ' : '' %>
|
|
4
|
+
<option value="<%= value_class -%>_<%= value -%>"<%= selected_txt %>><%= file_container_option.name %></option>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<select id="file_container_select" name="file_attachment[file_container]">
|
|
2
|
+
<option value=""></option>
|
|
3
|
+
<% @file_containers.group_by(&:class).each do |klass, file_containers| %>
|
|
4
|
+
<optgroup label="<%= klass.to_s.pluralize %>">
|
|
5
|
+
<%= render({
|
|
6
|
+
:partial => 'file_attachments/file_container_option',
|
|
7
|
+
:collection => file_containers,
|
|
8
|
+
:locals => {
|
|
9
|
+
:selected => selected
|
|
10
|
+
}
|
|
11
|
+
}) %>
|
|
12
|
+
</optgroup>
|
|
13
|
+
<% end %>
|
|
14
|
+
</select>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<% content_for(:javascript) do %>
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
jQuery.ajaxSetup({
|
|
4
|
+
'beforeSend': function(xhr) {
|
|
5
|
+
xhr.setRequestHeader("Accept", "text/javascript");
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
function bindCallbacks(plupload) {
|
|
9
|
+
plupload.bind('FileUploaded', function(up, file, response) {
|
|
10
|
+
if( $('#file_container_select').val() ) {
|
|
11
|
+
$("#" + $('#file_container_select').val() ).append(response.response);
|
|
12
|
+
} else {
|
|
13
|
+
$("#orphans").append(response.response);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
plupload.bind('UploadProgress', function() {
|
|
17
|
+
if( plupload.files.length == plupload.total.failed + plupload.total.uploaded ) {
|
|
18
|
+
$('span.plupload_upload_status').hide();
|
|
19
|
+
$('div.plupload_buttons').show();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
plupload.bind('UploadFile', function(up, file) {
|
|
23
|
+
attachable_params = $('#file_container_select').val().split('_');
|
|
24
|
+
$.extend(up.settings.multipart_params, {
|
|
25
|
+
attachable_id: attachable_params[1],
|
|
26
|
+
attachable_type: attachable_params[0]
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// Convert divs to queue widgets when the DOM is ready
|
|
31
|
+
$(function() {
|
|
32
|
+
// Setup html5 version
|
|
33
|
+
$("#multiple_uploads").pluploadQueue({
|
|
34
|
+
// General settings
|
|
35
|
+
runtimes : 'html5', // use only html5
|
|
36
|
+
url : '<%= file_attachments_path %>',
|
|
37
|
+
dragdrop: false,
|
|
38
|
+
setup: bindCallbacks,
|
|
39
|
+
multipart: true,
|
|
40
|
+
multipart_params: {
|
|
41
|
+
authenticity_token: '<%= form_authenticity_token %>'
|
|
42
|
+
},
|
|
43
|
+
required_features: 'multipart', // disable uploader if html5+multipart not available - webkit doesn't support html5+multipart
|
|
44
|
+
max_file_size : '50mb',
|
|
45
|
+
unique_names : true,
|
|
46
|
+
|
|
47
|
+
// Resize images on clientside if we can
|
|
48
|
+
resize : {width : 320, height : 240, quality : 90},
|
|
49
|
+
|
|
50
|
+
// Specify what files to browse for
|
|
51
|
+
filters : [
|
|
52
|
+
{title : "Image files", extensions : "jpg,gif,png,svg"},
|
|
53
|
+
{title : "Zip files", extensions : "zip"},
|
|
54
|
+
{title : "PDF documents", extensions : "pdf"},
|
|
55
|
+
{title : "Word documents", extensions : "doc"},
|
|
56
|
+
{title : "Power Point presentations", extensions : "ppt"},
|
|
57
|
+
{title : "Excel spreadsheets", extensions : "xls"},
|
|
58
|
+
{title : "Plain text files", extensions : "txt"}
|
|
59
|
+
],
|
|
60
|
+
|
|
61
|
+
// Flash settings
|
|
62
|
+
// flash_swf_url : '/plupload/js/plupload.flash.swf'
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
$(window).load(function() {
|
|
67
|
+
<% if !params[:std].nil? %>
|
|
68
|
+
$('#linker').hide();
|
|
69
|
+
$('#unlinker').show();
|
|
70
|
+
$('#file_block').show();
|
|
71
|
+
<% else %>
|
|
72
|
+
$('#linker').show();
|
|
73
|
+
$('#unlinker').hide();
|
|
74
|
+
$('#file_block').hide();
|
|
75
|
+
<% end %>
|
|
76
|
+
});
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
<% end %>
|
|
81
|
+
|
|
82
|
+
<h3>Downloadable Resources<hr /></h3>
|
|
83
|
+
|
|
84
|
+
<%= render :partial => 'file_attachments/file_attachments' %>
|
|
85
|
+
|
|
86
|
+
<% if has_authorization?(:create, FileAttachment.new) %>
|
|
87
|
+
|
|
88
|
+
<p id="linker" class="upload_block_linker" style="display:none; text-align: right;">
|
|
89
|
+
<a href="<%= url_for(:controller => controller_name, :action => action_name) %>?show=upload_files_block&toggle=upload_block_unlinker&hide=upload_block_linker" class="show_hide_link fake_button">Upload Files</a>
|
|
90
|
+
</p>
|
|
91
|
+
<p id="unlinker" class="upload_block_unlinker" style="display:none; text-align: right;">
|
|
92
|
+
<%= link_to "Cancel", url_for({
|
|
93
|
+
:controller => controller_name,
|
|
94
|
+
:action => action_name,
|
|
95
|
+
# show=upload_files_block&toggle=upload_block_unlinker&hide=upload_block_linker
|
|
96
|
+
:show => 'upload_block_linker',
|
|
97
|
+
:toggle => 'upload_block_unlinker',
|
|
98
|
+
:hide => 'upload_files_block'
|
|
99
|
+
}), :class => 'show_hide_link fake_button' %>
|
|
100
|
+
</p>
|
|
101
|
+
|
|
102
|
+
<div id="file_block" class="upload_files_block" style="">
|
|
103
|
+
<h4>Upload Files<hr /></h4>
|
|
104
|
+
|
|
105
|
+
<p>
|
|
106
|
+
<%= link_to_unless params[:std] == '1', "One at a time", url_for(:controller => controller_name, :action => action_name, :std => 1), :class => 'fake_button' %>
|
|
107
|
+
<%= link_to_if params[:std] == '1', "Several at once", url_for(:controller => controller_name, :action => action_name, :std => 0), :class => 'fake_button' %>
|
|
108
|
+
</p>
|
|
109
|
+
|
|
110
|
+
<% if @file_containers.present? %>
|
|
111
|
+
<p>
|
|
112
|
+
<%= render({
|
|
113
|
+
:partial => 'file_attachments/file_container_select',
|
|
114
|
+
:locals => {
|
|
115
|
+
:selected => "#{params[:attachable_type]}_#{params[:attachable_id]}"
|
|
116
|
+
}
|
|
117
|
+
}) %>
|
|
118
|
+
</p>
|
|
119
|
+
<% elsif instance_variable_defined?("@#{controller_name.singularize}") %>
|
|
120
|
+
<% instance = instance_variable_get("@#{controller_name.singularize}") %>
|
|
121
|
+
<%= hidden_field_tag 'file_attachment[file_container]', "#{instance.class}_#{instance.id}", {
|
|
122
|
+
:id => 'file_container_select'
|
|
123
|
+
} %>
|
|
124
|
+
<% else %>
|
|
125
|
+
<%= hidden_field_tag 'file_attachment[file_container]', nil, {
|
|
126
|
+
:id => 'file_container_select'
|
|
127
|
+
} %>
|
|
128
|
+
<% end %>
|
|
129
|
+
|
|
130
|
+
<% if params[:std] && params[:std] == '1' %>
|
|
131
|
+
<div id="single_upload" style="width: 33%;">
|
|
132
|
+
<%= render :partial => 'file_attachments/upload_form', :locals => {:container => instance} if defined?(instance) %>
|
|
133
|
+
<%= render :partial => 'file_attachments/upload_form' unless defined?(instance) %>
|
|
134
|
+
</div>
|
|
135
|
+
<% elsif params[:std].nil? || params[:std] == '0' %>
|
|
136
|
+
<div id="multiple_uploads">
|
|
137
|
+
You browser doesn't support native upload. Try Firefox 3 or Safari 4.
|
|
138
|
+
</div>
|
|
139
|
+
<% end %>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<% end %>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<% if defined?(container) && container %>
|
|
2
|
+
<% new_file_attachment = FileAttachment.new(:attachable => container) %>
|
|
3
|
+
<% else %>
|
|
4
|
+
<% new_file_attachment = FileAttachment.new %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<% semantic_form_for new_file_attachment, :html => { :multipart => true } do |f| %>
|
|
7
|
+
|
|
8
|
+
<%=
|
|
9
|
+
# todo replace f.error_messages
|
|
10
|
+
#f.error_messages
|
|
11
|
+
%>
|
|
12
|
+
|
|
13
|
+
<% f.inputs do %>
|
|
14
|
+
<%= f.input :attachable_id, :as => :hidden %>
|
|
15
|
+
<%= f.input :attachable_type, :as => :hidden %>
|
|
16
|
+
<%= f.input :name, :label => 'Name' %>
|
|
17
|
+
<%= f.input :description, :label => 'Description' %>
|
|
18
|
+
<%= f.input :uploaded_file, :as => :file, :label => 'Filepath' %>
|
|
19
|
+
<% end %>
|
|
20
|
+
|
|
21
|
+
<%= f.buttons %>
|
|
22
|
+
<% end %>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<%
|
|
2
|
+
#if @file_attachment.event_id.nil?
|
|
3
|
+
%>
|
|
4
|
+
<p><%= link_to '< back', file_attachments_path, :class => 'fake_button' %></p>
|
|
5
|
+
<%
|
|
6
|
+
#else
|
|
7
|
+
%>
|
|
8
|
+
<!-- <p><%=
|
|
9
|
+
#link_to '< back', event_path(@file_attachment.event.id), :class => 'fake_button'
|
|
10
|
+
%>
|
|
11
|
+
</p> -->
|
|
12
|
+
<%
|
|
13
|
+
#end
|
|
14
|
+
%>
|
|
15
|
+
<%= content_tag :div do %>
|
|
16
|
+
<%= semantic_form_for @file_attachment do |form| %>
|
|
17
|
+
<%= form.inputs do %>
|
|
18
|
+
<%= form.input :name, :hint => 'something memorable' %>
|
|
19
|
+
<%= render({
|
|
20
|
+
:partial => 'file_container_select',
|
|
21
|
+
:locals => {
|
|
22
|
+
:selected => "#{@file_attachment.attachable_type}_#{@file_attachment.attachable_id}"
|
|
23
|
+
}
|
|
24
|
+
}) %>
|
|
25
|
+
<%=
|
|
26
|
+
#form.input :event, :hint => 'does this file belong somewhere else?'
|
|
27
|
+
%>
|
|
28
|
+
<%= form.input :description, :hint => "of file contents, purpose, etc" %>
|
|
29
|
+
<% end %>
|
|
30
|
+
<%= form.buttons %>
|
|
31
|
+
<% end %>
|
|
32
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= render :partial => 'file_attachments/plupload_with_listing', :locals => {:file_attachments => @file_attachments} %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
if @file_attachment.valid?
|
|
2
|
+
page << %Q{
|
|
3
|
+
$('#blank_description_form').hide();
|
|
4
|
+
$('#file_attachment_#{@file_attachment.id}_description').replaceWith('#{description_display(@file_attachment)}');
|
|
5
|
+
$('#file_attachment_#{@file_attachment.id}').effect('highlight', {
|
|
6
|
+
color: '#C3D9FF'
|
|
7
|
+
}, 2500)
|
|
8
|
+
}
|
|
9
|
+
else
|
|
10
|
+
page << %Q{
|
|
11
|
+
alert("The file description could not be saved.");
|
|
12
|
+
}
|
|
13
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
|
5
|
+
<!-- <link rel="icon" type="image/png" href="/images/favorite.png"/> -->
|
|
6
|
+
<title>FileShare</title>
|
|
7
|
+
<%= stylesheet_link_tag "blueprint/screen", :media => "screen, projection" %>
|
|
8
|
+
<%= stylesheet_link_tag "plupload/screen", :media => "screen, projection" %>
|
|
9
|
+
<%= stylesheet_link_tag "blueprint/print", :media => "print" %>
|
|
10
|
+
<!--[if lt IE 8]>
|
|
11
|
+
<%= stylesheet_link_tag "blueprint/ie", :media => "screen, projection" %>
|
|
12
|
+
<![endif]-->
|
|
13
|
+
<%= stylesheet_link_tag "tablesorter/blue/style", :media => "screen" %>
|
|
14
|
+
<%= stylesheet_link_tag "smoothness/jquery-ui-1.7.2.custom.css" %>
|
|
15
|
+
|
|
16
|
+
<%= stylesheet_link_tag 'error_messages', 'formtastic', 'formtastic_changes',
|
|
17
|
+
'main_elements', 'text_and_colors' %>
|
|
18
|
+
|
|
19
|
+
<%= javascript_include_tag file_share_javascript_includes %>
|
|
20
|
+
|
|
21
|
+
<%= csrf_meta_tag %>
|
|
22
|
+
|
|
23
|
+
<%= yield :javascript %>
|
|
24
|
+
</head>
|
|
25
|
+
<body>
|
|
26
|
+
|
|
27
|
+
<div class="container">
|
|
28
|
+
<div class="top-banner span-24 last">
|
|
29
|
+
<div class="header span-14">
|
|
30
|
+
<h1>FileShare</h1>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<div class="base_content span-20">
|
|
35
|
+
<%= render :partial => 'file-share-shared/flash', :object => flash %>
|
|
36
|
+
<div class="inner_content">
|
|
37
|
+
<%= yield %>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div class="span-4 last">
|
|
42
|
+
<div id="main_menu">
|
|
43
|
+
<ul>
|
|
44
|
+
<li><%= link_to "Files", file_attachments_path %></li>
|
|
45
|
+
</ul>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div class="sidebar">
|
|
49
|
+
<%= yield :sidebar %>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'rails/all'
|
|
4
|
+
|
|
5
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
|
6
|
+
# you've limited to :test, :development, or :production.
|
|
7
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
|
8
|
+
|
|
9
|
+
module FileShare
|
|
10
|
+
class Application < Rails::Application
|
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
12
|
+
# Application configuration should go into files in config/initializers
|
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
14
|
+
|
|
15
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
|
16
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
|
17
|
+
|
|
18
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
19
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
|
20
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
21
|
+
|
|
22
|
+
# Activate observers that should always be running.
|
|
23
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
24
|
+
|
|
25
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
26
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
27
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
28
|
+
|
|
29
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
30
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
31
|
+
# config.i18n.default_locale = :de
|
|
32
|
+
|
|
33
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
|
34
|
+
config.action_view.javascript_expansions[:defaults] = %w()
|
|
35
|
+
|
|
36
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
|
37
|
+
config.encoding = "utf-8"
|
|
38
|
+
|
|
39
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
|
40
|
+
config.filter_parameters += [:password]
|
|
41
|
+
end
|
|
42
|
+
end
|