el_finder 1.0.17 → 1.0.18
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/README.rdoc +30 -0
- data/lib/el_finder/action.rb +19 -0
- data/lib/el_finder/version.rb +1 -1
- data/lib/el_finder.rb +1 -0
- data/test/test_el_finder_action.rb +32 -0
- metadata +8 -7
data/README.rdoc
CHANGED
@@ -62,6 +62,36 @@ the defaults.
|
|
62
62
|
render (r.empty? ? {:nothing => true} : {:text => r.to_json}), :layout => false
|
63
63
|
end
|
64
64
|
|
65
|
+
* Or, use ElFinder::Action and el_finder, which handles most of the boilerplate for an ElFinder action:
|
66
|
+
|
67
|
+
require 'el_finder/action'
|
68
|
+
class MyController < ApplicationController
|
69
|
+
include ElFinder::Action
|
70
|
+
|
71
|
+
el_finder(:action_name) do
|
72
|
+
{
|
73
|
+
:root => File.join(Rails.public_path, 'system', 'elfinder'),
|
74
|
+
:url => '/system/elfinder',
|
75
|
+
:perms => {
|
76
|
+
/^(Welcome|README)$/ => {:read => true, :write => false, :rm => false},
|
77
|
+
'.' => {:read => true, :write => false, :rm => false}, # '.' is the proper way to specify the home/root directory.
|
78
|
+
/^test$/ => {:read => true, :write => true, :rm => false},
|
79
|
+
'logo.png' => {:read => true},
|
80
|
+
/\.png$/ => {:read => false} # This will cause 'logo.png' to be unreadable.
|
81
|
+
# Permissions err on the safe side. Once false, always false.
|
82
|
+
},
|
83
|
+
:extractors => {
|
84
|
+
'application/zip' => ['unzip', '-qq', '-o'], # Each argument will be shellescaped (also true for archivers)
|
85
|
+
'application/x-gzip' => ['tar', '-xzf'],
|
86
|
+
},
|
87
|
+
:archivers => {
|
88
|
+
'application/zip' => ['.zip', 'zip', '-qr9'], # Note first argument is archive extension
|
89
|
+
'application/x-gzip' => ['.tgz', 'tar', '-czf'],
|
90
|
+
},
|
91
|
+
}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
65
95
|
* Add the appropriate route to config/routes.rb such as:
|
66
96
|
|
67
97
|
match 'elfinder' => 'home#elfinder'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ElFinder
|
2
|
+
module Action
|
3
|
+
class << self
|
4
|
+
def included(klass)
|
5
|
+
klass.send(:extend, ElFinder::ActionClass)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module ActionClass
|
11
|
+
def el_finder(name = :elfinder, &block)
|
12
|
+
self.send(:define_method, :elfinder) do
|
13
|
+
h, r = ElFinder::Connector.new(instance_eval(&block)).run(params)
|
14
|
+
headers.merge!(h)
|
15
|
+
render (r.empty? ? {:nothing => true} : {:text => r.to_json}), :layout => false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/el_finder/version.rb
CHANGED
data/lib/el_finder.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'el_finder_test_case'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class TestElFinderAction < Test::Unit::TestCase
|
5
|
+
include ElFinderTestCase
|
6
|
+
|
7
|
+
def test_create_basic_action
|
8
|
+
test_class = Class.new do
|
9
|
+
include ElFinder::Action
|
10
|
+
|
11
|
+
el_finder do
|
12
|
+
{ :root => '/tmp/elfinder', :url => "/elfinder" }
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_accessor :params, :headers, :render_opts
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@headers = {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def render(*opts)
|
22
|
+
@render_opts = opts
|
23
|
+
end
|
24
|
+
end.new
|
25
|
+
|
26
|
+
assert test_class.respond_to?(:elfinder)
|
27
|
+
|
28
|
+
test_class.params = { :cmd => 'open' }
|
29
|
+
test_class.elfinder
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: el_finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 51
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 18
|
10
|
+
version: 1.0.18
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Philip Hallstrom
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-08-11 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: image_size
|
@@ -52,6 +51,7 @@ files:
|
|
52
51
|
- TODO
|
53
52
|
- el_finder.gemspec
|
54
53
|
- lib/el_finder.rb
|
54
|
+
- lib/el_finder/action.rb
|
55
55
|
- lib/el_finder/connector.rb
|
56
56
|
- lib/el_finder/image.rb
|
57
57
|
- lib/el_finder/mime_type.rb
|
@@ -70,13 +70,13 @@ files:
|
|
70
70
|
- test/files/pjkh.png
|
71
71
|
- test/files/sample.zip
|
72
72
|
- test/test_el_finder.rb
|
73
|
+
- test/test_el_finder_action.rb
|
73
74
|
- test/test_el_finder_archivers.rb
|
74
75
|
- test/test_el_finder_extractors.rb
|
75
76
|
- test/test_el_finder_hash.rb
|
76
77
|
- test/test_el_finder_permissions.rb
|
77
78
|
- test/test_el_finder_symlink.rb
|
78
79
|
- test/test_el_finder_thumbs.rb
|
79
|
-
has_rdoc: true
|
80
80
|
homepage: http://github.com/phallstrom/el_finder
|
81
81
|
licenses: []
|
82
82
|
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
107
107
|
- ImageMagick
|
108
108
|
rubyforge_project: el_finder
|
109
|
-
rubygems_version: 1.
|
109
|
+
rubygems_version: 1.8.7
|
110
110
|
signing_key:
|
111
111
|
specification_version: 3
|
112
112
|
summary: elFinder server side connector for Ruby.
|
@@ -124,6 +124,7 @@ test_files:
|
|
124
124
|
- test/files/pjkh.png
|
125
125
|
- test/files/sample.zip
|
126
126
|
- test/test_el_finder.rb
|
127
|
+
- test/test_el_finder_action.rb
|
127
128
|
- test/test_el_finder_archivers.rb
|
128
129
|
- test/test_el_finder_extractors.rb
|
129
130
|
- test/test_el_finder_hash.rb
|