el_vfs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +28 -0
  4. data/app/assets/images/el_vfs/elfinder/arrows-active.png +0 -0
  5. data/app/assets/images/el_vfs/elfinder/arrows-normal.png +0 -0
  6. data/app/assets/images/el_vfs/elfinder/dialogs.png +0 -0
  7. data/app/assets/images/el_vfs/elfinder/icons-big.png +0 -0
  8. data/app/assets/images/el_vfs/elfinder/icons-small.png +0 -0
  9. data/app/assets/images/el_vfs/elfinder/logo.png +0 -0
  10. data/app/assets/images/el_vfs/elfinder/progress.gif +0 -0
  11. data/app/assets/images/el_vfs/elfinder/quicklook-bg.png +0 -0
  12. data/app/assets/images/el_vfs/elfinder/quicklook-icons.png +0 -0
  13. data/app/assets/images/el_vfs/elfinder/resize.png +0 -0
  14. data/app/assets/images/el_vfs/elfinder/spinner-mini.gif +0 -0
  15. data/app/assets/images/el_vfs/elfinder/toolbar.png +0 -0
  16. data/app/assets/images/el_vfs/ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  17. data/app/assets/images/el_vfs/ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  18. data/app/assets/images/el_vfs/ui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  19. data/app/assets/images/el_vfs/ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  20. data/app/assets/images/el_vfs/ui/ui-bg_glass_75_dadada_1x400.png +0 -0
  21. data/app/assets/images/el_vfs/ui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  22. data/app/assets/images/el_vfs/ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  23. data/app/assets/images/el_vfs/ui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  24. data/app/assets/images/el_vfs/ui/ui-icons_222222_256x240.png +0 -0
  25. data/app/assets/images/el_vfs/ui/ui-icons_2e83ff_256x240.png +0 -0
  26. data/app/assets/images/el_vfs/ui/ui-icons_454545_256x240.png +0 -0
  27. data/app/assets/images/el_vfs/ui/ui-icons_888888_256x240.png +0 -0
  28. data/app/assets/images/el_vfs/ui/ui-icons_cd0a0a_256x240.png +0 -0
  29. data/app/assets/javascripts/el_vfs/elfinder.js +9601 -0
  30. data/app/assets/javascripts/el_vfs/i18n/elfinder.LANG.js +281 -0
  31. data/app/assets/javascripts/el_vfs/i18n/elfinder.ar.js +280 -0
  32. data/app/assets/javascripts/el_vfs/i18n/elfinder.ru.js +280 -0
  33. data/app/assets/stylesheets/el_vfs/el_vfs.sass +4 -0
  34. data/app/assets/stylesheets/el_vfs/elfinder.sass +1645 -0
  35. data/app/assets/stylesheets/el_vfs/jquery_ui.sass +1482 -0
  36. data/app/assets/stylesheets/el_vfs/reset.sass +3 -0
  37. data/app/assets/stylesheets/el_vfs/theme.sass +82 -0
  38. data/app/controllers/el_vfs/el_finder_controller.rb +17 -0
  39. data/app/helpers/el_vfs/application_helper.rb +4 -0
  40. data/app/models/el_vfs/directory.rb +30 -0
  41. data/app/models/el_vfs/entry.rb +91 -0
  42. data/app/models/el_vfs/file.rb +35 -0
  43. data/app/models/el_vfs/root.rb +36 -0
  44. data/app/views/el_vfs/directories/_form.html.erb +17 -0
  45. data/app/views/el_vfs/directories/edit.html.erb +6 -0
  46. data/app/views/el_vfs/directories/index.html.erb +21 -0
  47. data/app/views/el_vfs/directories/new.html.erb +5 -0
  48. data/app/views/el_vfs/directories/show.html.erb +5 -0
  49. data/app/views/el_vfs/files/_form.html.erb +17 -0
  50. data/app/views/el_vfs/files/edit.html.erb +6 -0
  51. data/app/views/el_vfs/files/index.html.erb +21 -0
  52. data/app/views/el_vfs/files/new.html.erb +5 -0
  53. data/app/views/el_vfs/files/show.html.erb +5 -0
  54. data/app/views/layouts/el_vfs/application.html.erb +14 -0
  55. data/config/dragonfly.rb +45 -0
  56. data/config/routes.rb +6 -0
  57. data/db/migrate/20111111111111_create_el_vfs_entries.rb +19 -0
  58. data/lib/el_finder_api/el_vfs/command.rb +66 -0
  59. data/lib/el_finder_api/el_vfs/command/change_working_directory.rb +36 -0
  60. data/lib/el_finder_api/el_vfs/command/copy_entries.rb +44 -0
  61. data/lib/el_finder_api/el_vfs/command/create_directory.rb +21 -0
  62. data/lib/el_finder_api/el_vfs/command/create_file.rb +24 -0
  63. data/lib/el_finder_api/el_vfs/command/create_thumbnail.rb +3 -0
  64. data/lib/el_finder_api/el_vfs/command/destroy_entries.rb +24 -0
  65. data/lib/el_finder_api/el_vfs/command/duplicate_entries.rb +24 -0
  66. data/lib/el_finder_api/el_vfs/command/get_ancestors.rb +22 -0
  67. data/lib/el_finder_api/el_vfs/command/get_descendants.rb +19 -0
  68. data/lib/el_finder_api/el_vfs/command/list_names.rb +14 -0
  69. data/lib/el_finder_api/el_vfs/command/pack_entries.rb +3 -0
  70. data/lib/el_finder_api/el_vfs/command/ping.rb +12 -0
  71. data/lib/el_finder_api/el_vfs/command/read_file_body.rb +17 -0
  72. data/lib/el_finder_api/el_vfs/command/rename_entry.rb +25 -0
  73. data/lib/el_finder_api/el_vfs/command/resize_image.rb +3 -0
  74. data/lib/el_finder_api/el_vfs/command/send_file.rb +15 -0
  75. data/lib/el_finder_api/el_vfs/command/unknown.rb +14 -0
  76. data/lib/el_finder_api/el_vfs/command/unpack_entry.rb +3 -0
  77. data/lib/el_finder_api/el_vfs/command/update_file_body.rb +28 -0
  78. data/lib/el_finder_api/el_vfs/command/upload_files.rb +22 -0
  79. data/lib/el_finder_api/el_vfs/connector.rb +22 -0
  80. data/lib/el_finder_api/el_vfs/model.rb +38 -0
  81. data/lib/el_vfs.rb +4 -0
  82. data/lib/el_vfs/engine.rb +28 -0
  83. data/lib/el_vfs/version.rb +3 -0
  84. data/lib/tasks/el_vfs_tasks.rake +4 -0
  85. metadata +290 -0
@@ -0,0 +1,3 @@
1
+ body
2
+ background-color: #fff
3
+
@@ -0,0 +1,82 @@
1
+ /**
2
+ * MacOS X like theme for elFinder.
3
+ * Required jquery ui "smoothness" theme.
4
+ *
5
+ * @author Dmitry (dio) Levashov
6
+ *
7
+
8
+ /* dialogs
9
+
10
+ .std42-dialog
11
+ background-color: #ededed
12
+ background-image: none
13
+ .ui-widget-content
14
+ background-color: #ededed
15
+ background-image: none
16
+
17
+ /* navbar
18
+
19
+ .elfinder .elfinder-navbar
20
+ background: #dde4eb
21
+
22
+ .elfinder-navbar
23
+ .ui-state-hover
24
+ background: transparent
25
+ border-color: transparent
26
+ .ui-state-active
27
+ background: #3875d7
28
+ border-color: #3875d7
29
+ color: #fff
30
+
31
+ /* disabled elfinder
32
+
33
+ .elfinder-disabled .elfinder-navbar .ui-state-active
34
+ background: #dadada
35
+ border-color: #aaa
36
+ color: #fff
37
+
38
+ /* current directory
39
+ /* selected file in "icons" view
40
+
41
+ .elfinder-cwd-view-icons .elfinder-cwd-file .ui-state-hover
42
+ background: #ccc
43
+
44
+ /* list view
45
+
46
+ .elfinder-cwd table tr
47
+ &:nth-child(odd)
48
+ background-color: #edf3fe
49
+ border-top: 1px solid #fff
50
+
51
+ /* common selected background/color
52
+
53
+ .elfinder-cwd-view-icons .elfinder-cwd-file .elfinder-cwd-filename.ui-state-hover, .elfinder-cwd table td.ui-state-hover, .elfinder-button-menu .ui-state-hover
54
+ background: #3875d7
55
+ color: #fff
56
+
57
+ /* disabled elfinder
58
+
59
+ .elfinder-disabled
60
+ .elfinder-cwd-view-icons .elfinder-cwd-file .elfinder-cwd-filename.ui-state-hover, .elfinder-cwd table td.ui-state-hover
61
+ background: #dadada
62
+
63
+ /* statusbar
64
+
65
+ .elfinder .elfinder-statusbar
66
+ color: #555
67
+ a
68
+ text-decoration: none
69
+ color: #555
70
+
71
+ .std42-dialog .elfinder-help
72
+ background: #fff
73
+ .ui-widget-content
74
+ background: #fff
75
+
76
+ /* contextmenu
77
+
78
+ .elfinder-contextmenu .ui-state-hover
79
+ background: #3875d7
80
+ color: #fff
81
+ .elfinder-contextmenu-arrow
82
+ background-image: url('elfinder/arrows-active.png')
@@ -0,0 +1,17 @@
1
+ module ElVfs
2
+ class ElFinderController < ApplicationController
3
+ respond_to :json, :html
4
+
5
+ def run
6
+ command = Connector.new.command_for(params)
7
+ command.run
8
+ command.headers.each { |h,v| headers[h] = v }
9
+ json = command.result.try(:el_hash)
10
+ respond_to do | format |
11
+ format.html { render :json => json }
12
+ format.json { render :json => json }
13
+ end
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,4 @@
1
+ module ElVfs
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,30 @@
1
+ module ElVfs
2
+ class Directory < Entry
3
+ default_values :entry_mime_type => 'directory', :entry_size => 0
4
+
5
+ def el_vfs_path
6
+ "#{parent.el_vfs_path}/#{entry_name}"
7
+ end
8
+
9
+ protected
10
+
11
+ def name_of_copy(number)
12
+ "#{entry_name} copy#{number}"
13
+ end
14
+
15
+ def relative_entry_path
16
+ entry_path[root.entry_path.length..-2]
17
+ end
18
+
19
+ def el_entry
20
+ super.tap do | hash |
21
+ hash[:dirs] = directories.any? ? 1 : 0
22
+ end
23
+ end
24
+
25
+ def set_entry_path
26
+ self.entry_path = "#{parent.entry_path}#{entry_name}/"
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,91 @@
1
+ module ElVfs
2
+ class Entry < ActiveRecord::Base
3
+ validates_presence_of :entry_name
4
+ has_ancestry :cache_depth => true
5
+ before_save :set_entry_path
6
+ before_save :set_entry_path_hash
7
+
8
+ scope :only_files, where("type not in ('ElVfs::Directory', 'ElVfs::Root')")
9
+ scope :only_directories, where(:type => ['ElVfs::Directory', 'ElVfs::Root'])
10
+
11
+ delegate :entry_path_hash, :to => :parent, :allow_nil => true, :prefix => true
12
+
13
+ def directories
14
+ children.only_directories
15
+ end
16
+
17
+ def files
18
+ children.only_files
19
+ end
20
+
21
+ def self.root
22
+ Root.find_or_create_by_entry_name('root')
23
+ end
24
+
25
+ def el_hash
26
+ el_entry.merge(el_permissions)
27
+ end
28
+
29
+ def target
30
+ entry_path_hash
31
+ end
32
+
33
+ def duplicate
34
+ Entry.transaction do
35
+ dup.tap do | entry |
36
+ entry.update_attributes! :entry_name => entry.duplicate_name
37
+ self.copy_descendants_to(entry)
38
+ end
39
+ end
40
+ end
41
+
42
+ def url
43
+ ::Rails.application.routes.url_helpers.entry_url(self, ::Rails.application.config.action_mailer[:default_url_options])
44
+ end
45
+
46
+ def to_s
47
+ entry_path
48
+ end
49
+
50
+ alias :inspect :to_s
51
+
52
+ protected
53
+ def copy_descendants_to(entry)
54
+ self.children.each do |child|
55
+ child_copy = child.dup
56
+ child_copy.update_attributes! :parent => entry
57
+ child.copy_descendants_to(child_copy)
58
+ end
59
+ end
60
+
61
+ def duplicate_name
62
+ i = 0
63
+ begin i += 1 end while parent.children.find_by_entry_name(name_of_copy(i))
64
+ name_of_copy(i)
65
+ end
66
+
67
+ def el_permissions
68
+ {
69
+ :read => 1,
70
+ :write => 1,
71
+ :locked => 0
72
+ }
73
+ end
74
+
75
+ def el_entry
76
+ {
77
+ :name => entry_name,
78
+ :mime => entry_mime_type,
79
+ :date => I18n.l(updated_at),
80
+ :size => entry_size,
81
+ :hash => entry_path_hash,
82
+ :phash => parent_entry_path_hash.to_s,
83
+ :url => url
84
+ }
85
+ end
86
+
87
+ def set_entry_path_hash
88
+ self.entry_path_hash = "#{root.root_name}_#{Base64.urlsafe_encode64(relative_entry_path).strip.tr('=', '')}"
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,35 @@
1
+ module ElVfs
2
+ class File < Entry
3
+ file_accessor :entry
4
+
5
+ def entry_uid
6
+ entry_path
7
+ end
8
+
9
+ def entry_uid=(uid)
10
+ self.entry_path=(uid)
11
+ end
12
+
13
+ protected
14
+ def ext_entry_name
15
+ ::File.extname entry_name
16
+ end
17
+
18
+ def base_entry_name
19
+ ::File.basename entry_name, ext_entry_name
20
+ end
21
+
22
+ def name_of_copy(number)
23
+ "#{base_entry_name} copy#{number}#{ext_entry_name}"
24
+ end
25
+
26
+ def relative_entry_path
27
+ entry_path[root.entry_path.length..-1]
28
+ end
29
+
30
+ def set_entry_path
31
+ self.entry_path = "#{parent.entry_path}#{entry_name}"
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,36 @@
1
+ module ElVfs
2
+ class Root < Entry
3
+ default_values :entry_mime_type => 'directory', :entry_size => 0
4
+ scope :ordered, order(:root_number)
5
+
6
+ def root_name
7
+ ['r', root_number].join
8
+ end
9
+
10
+ def el_vfs_path
11
+ entry_name
12
+ end
13
+
14
+ protected
15
+ def relative_entry_path
16
+ '/'
17
+ end
18
+
19
+ def el_entry
20
+ super.tap do | hash |
21
+ hash[:dirs] = directories.any? ? 1 : 0
22
+ hash[:volumeid] = "#{root_name}_"
23
+ end
24
+ end
25
+
26
+ def set_root_number
27
+ self.root_number = Root.ordered.last.try(:root_number).to_i + 1
28
+ end
29
+
30
+ def set_entry_path
31
+ set_root_number
32
+ self.entry_path = "r#{root_number}/"
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ <%= form_for(@folder) do |f| %>
2
+ <% if @folder.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@folder.errors.count, "error") %> prohibited this folder from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @folder.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="actions">
15
+ <%= f.submit %>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing folder</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @folder %> |
6
+ <%= link_to 'Back', folders_path %>
@@ -0,0 +1,21 @@
1
+ <h1>Listing folders</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th></th>
6
+ <th></th>
7
+ <th></th>
8
+ </tr>
9
+
10
+ <% @folders.each do |folder| %>
11
+ <tr>
12
+ <td><%= link_to 'Show', folder %></td>
13
+ <td><%= link_to 'Edit', edit_folder_path(folder) %></td>
14
+ <td><%= link_to 'Destroy', folder, confirm: 'Are you sure?', method: :delete %></td>
15
+ </tr>
16
+ <% end %>
17
+ </table>
18
+
19
+ <br />
20
+
21
+ <%= link_to 'New Folder', new_folder_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New folder</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', folders_path %>
@@ -0,0 +1,5 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+
4
+ <%= link_to 'Edit', edit_folder_path(@folder) %> |
5
+ <%= link_to 'Back', folders_path %>
@@ -0,0 +1,17 @@
1
+ <%= form_for(@file) do |f| %>
2
+ <% if @file.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@file.errors.count, "error") %> prohibited this file from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @file.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="actions">
15
+ <%= f.submit %>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing file</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @file %> |
6
+ <%= link_to 'Back', files_path %>
@@ -0,0 +1,21 @@
1
+ <h1>Listing files</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th></th>
6
+ <th></th>
7
+ <th></th>
8
+ </tr>
9
+
10
+ <% @files.each do |file| %>
11
+ <tr>
12
+ <td><%= link_to 'Show', file %></td>
13
+ <td><%= link_to 'Edit', edit_file_path(file) %></td>
14
+ <td><%= link_to 'Destroy', file, confirm: 'Are you sure?', method: :delete %></td>
15
+ </tr>
16
+ <% end %>
17
+ </table>
18
+
19
+ <br />
20
+
21
+ <%= link_to 'New File', new_file_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New file</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', files_path %>
@@ -0,0 +1,5 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+
4
+ <%= link_to 'Edit', edit_file_path(@file) %> |
5
+ <%= link_to 'Back', files_path %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>ElVfs</title>
5
+ <%= stylesheet_link_tag "el_vfs/application" %>
6
+ <%= javascript_include_tag "el_vfs/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>