el_finder 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/el_finder/connector.rb +8 -7
- data/lib/el_finder/pathname.rb +1 -0
- data/lib/el_finder/version.rb +1 -1
- data/test/test_el_finder_symlink.rb +81 -0
- metadata +5 -3
data/lib/el_finder/connector.rb
CHANGED
@@ -407,7 +407,6 @@ module ElFinder
|
|
407
407
|
}.merge(perms_for(pathname))
|
408
408
|
end
|
409
409
|
|
410
|
-
# TODO - Implement link, linkTo, and parent
|
411
410
|
def cdc_for(pathname)
|
412
411
|
response = {
|
413
412
|
:name => pathname.basename.to_s,
|
@@ -421,12 +420,6 @@ module ElFinder
|
|
421
420
|
:size => 0,
|
422
421
|
:mime => 'directory'
|
423
422
|
)
|
424
|
-
elsif pathname.symlink?
|
425
|
-
response.merge!(
|
426
|
-
:link => 'FIXME',
|
427
|
-
:linkTo => 'FIXME',
|
428
|
-
:parent => 'FIXME'
|
429
|
-
)
|
430
423
|
elsif pathname.file?
|
431
424
|
response.merge!(
|
432
425
|
:size => pathname.size,
|
@@ -443,6 +436,14 @@ module ElFinder
|
|
443
436
|
|
444
437
|
end
|
445
438
|
|
439
|
+
if pathname.symlink?
|
440
|
+
response.merge!(
|
441
|
+
:link => to_hash(ElFinder::Pathname.new_with_root(@root, pathname.readlink)), # hash of file to which point link
|
442
|
+
:linkTo => ElFinder::Pathname.new_with_root(@root, pathname.readlink).relative_path_from(pathname.dirname).to_s, # relative path to
|
443
|
+
:parent => to_hash(ElFinder::Pathname.new_with_root(@root, pathname.readlink.dirname)) # hash of directory in which is linked file
|
444
|
+
)
|
445
|
+
end
|
446
|
+
|
446
447
|
return response
|
447
448
|
end
|
448
449
|
|
data/lib/el_finder/pathname.rb
CHANGED
data/lib/el_finder/version.rb
CHANGED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'el_finder_test_case'
|
2
|
+
|
3
|
+
class TestElFinderSymlink < Test::Unit::TestCase
|
4
|
+
|
5
|
+
include ElFinderTestCase
|
6
|
+
|
7
|
+
################################################################################
|
8
|
+
|
9
|
+
def test_ruby_symlink_creation
|
10
|
+
File.symlink(File.join(@vroot, 'pjkh.png'), File.join(@vroot, 'symlink.png'))
|
11
|
+
assert File.symlink?(File.join(@vroot, 'symlink.png'))
|
12
|
+
assert_equal File.join(@vroot, 'pjkh.png'), File.readlink(File.join(@vroot, 'symlink.png'))
|
13
|
+
|
14
|
+
h, r = @elfinder.run(:cmd => 'open', :init => 'true', :target => '')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_same_directory
|
18
|
+
File.symlink(File.join(@vroot, 'pjkh.png'), File.join(@vroot, 'symlink.png'))
|
19
|
+
h, r = @elfinder.run(:cmd => 'open', :init => 'true', :target => '')
|
20
|
+
source = r[:cdc].find{|e| e[:name] == 'pjkh.png'}
|
21
|
+
target = r[:cdc].find{|e| e[:name] == 'symlink.png'}
|
22
|
+
assert_equal 'image/png', target[:mime]
|
23
|
+
assert_equal source[:hash], target[:link]
|
24
|
+
assert_equal 'pjkh.png', target[:linkTo]
|
25
|
+
assert_equal r[:cwd][:hash], target[:parent]
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_sub_directory
|
29
|
+
File.symlink(File.join(@vroot, 'pjkh.png'), File.join(@vroot, 'foo', 'symlink.png'))
|
30
|
+
|
31
|
+
h, r = @elfinder.run(:cmd => 'open', :init => 'true', :target => '')
|
32
|
+
home = r[:cwd]
|
33
|
+
source = r[:cdc].find{|e| e[:name] == 'pjkh.png'}
|
34
|
+
foo = r[:cdc].find{|e| e[:name] == 'foo'}
|
35
|
+
|
36
|
+
h, r = @elfinder.run(:cmd => 'open', :target => foo[:hash])
|
37
|
+
target = r[:cdc].find{|e| e[:name] == 'symlink.png'}
|
38
|
+
|
39
|
+
assert_equal source[:hash], target[:link]
|
40
|
+
assert_equal '../pjkh.png', target[:linkTo]
|
41
|
+
assert_equal home[:hash], target[:parent]
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_parent_directory
|
45
|
+
File.symlink(File.join(@vroot, 'foo', 'tom.txt'), File.join(@vroot, 'symlink.txt'))
|
46
|
+
|
47
|
+
h, r = @elfinder.run(:cmd => 'open', :init => 'true', :target => '')
|
48
|
+
target = r[:cdc].find{|e| e[:name] == 'symlink.txt'}
|
49
|
+
foo = r[:cdc].find{|e| e[:name] == 'foo'}
|
50
|
+
|
51
|
+
h, r = @elfinder.run(:cmd => 'open', :target => foo[:hash])
|
52
|
+
source = r[:cdc].find{|e| e[:name] == 'tom.txt'}
|
53
|
+
|
54
|
+
pp source
|
55
|
+
pp target
|
56
|
+
|
57
|
+
assert_equal source[:hash], target[:link]
|
58
|
+
assert_equal 'foo/tom.txt', target[:linkTo]
|
59
|
+
assert_equal foo[:hash], target[:parent]
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_sibling_directory
|
63
|
+
FileUtils.mkdir(File.join(@vroot, 'bar'))
|
64
|
+
File.symlink(File.join(@vroot, 'foo', 'tom.txt'), File.join(@vroot, 'bar', 'symlink.txt'))
|
65
|
+
|
66
|
+
h, r = @elfinder.run(:cmd => 'open', :init => 'true', :target => '')
|
67
|
+
foo = r[:cdc].find{|e| e[:name] == 'foo'}
|
68
|
+
bar = r[:cdc].find{|e| e[:name] == 'bar'}
|
69
|
+
|
70
|
+
h, r = @elfinder.run(:cmd => 'open', :target => foo[:hash])
|
71
|
+
source = r[:cdc].find{|e| e[:name] == 'tom.txt'}
|
72
|
+
|
73
|
+
h, r = @elfinder.run(:cmd => 'open', :target => bar[:hash])
|
74
|
+
target = r[:cdc].find{|e| e[:name] == 'symlink.txt'}
|
75
|
+
|
76
|
+
assert_equal source[:hash], target[:link]
|
77
|
+
assert_equal '../foo/tom.txt', target[:linkTo]
|
78
|
+
assert_equal foo[:hash], target[:parent]
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
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: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 6
|
10
|
+
version: 1.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Philip Hallstrom
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- test/test_el_finder_extractors.rb
|
75
75
|
- test/test_el_finder_hash.rb
|
76
76
|
- test/test_el_finder_permissions.rb
|
77
|
+
- test/test_el_finder_symlink.rb
|
77
78
|
has_rdoc: true
|
78
79
|
homepage: http://github.com/phallstrom/el_finder
|
79
80
|
licenses: []
|
@@ -126,3 +127,4 @@ test_files:
|
|
126
127
|
- test/test_el_finder_extractors.rb
|
127
128
|
- test/test_el_finder_hash.rb
|
128
129
|
- test/test_el_finder_permissions.rb
|
130
|
+
- test/test_el_finder_symlink.rb
|