directory_listing 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -2
- data/LICENSE +18 -9
- data/README.md +9 -4
- data/lib/sinatra/directory_listing/page.rb +2 -1
- data/lib/sinatra/directory_listing/resource.rb +3 -1
- data/lib/sinatra/directory_listing/version.rb +1 -1
- data/lib/sinatra/directory_listing.rb +2 -0
- data/test/public/should_show_file_exts/test.txt +0 -0
- data/test/test_directory_listing.rb +8 -0
- data/test/test_directory_listing_app.rb +6 -0
- metadata +22 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dafec9303b09bba3b378369ea69caf916042d0d0
|
4
|
+
data.tar.gz: 8c7fbc3853f6abaa6c64bd9df2267baffa94a636
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbb6f227915de4813952c2829d4e143a476aed24ddc1b175d015a8011a8c3feafb706681ff2843d39ccbf87c454fe1b96f8173678ffc32f37119f5893cb7bd62
|
7
|
+
data.tar.gz: 2d64dd51da5c6d7e66cedc3757a5f2ebeaf956b1172f9d83c723c2c20933af347160b327ec8d233b9dc65b4dc1c634e03c062fbbfd6cce0acba4be973eca5e63
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
directory_listing (0.4.
|
4
|
+
directory_listing (0.4.3)
|
5
5
|
filesize (>= 0.0.2)
|
6
|
+
sinatra
|
6
7
|
truncate (>= 0.0.4)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: http://rubygems.org/
|
10
11
|
specs:
|
11
|
-
filesize (0.0.
|
12
|
+
filesize (0.0.3)
|
12
13
|
rack (1.5.2)
|
14
|
+
rack-protection (1.5.2)
|
15
|
+
rack
|
13
16
|
rack-test (0.6.2)
|
14
17
|
rack (>= 1.0)
|
15
18
|
rake (10.1.0)
|
19
|
+
sinatra (1.4.4)
|
20
|
+
rack (~> 1.4)
|
21
|
+
rack-protection (~> 1.4)
|
22
|
+
tilt (~> 1.3, >= 1.3.4)
|
23
|
+
tilt (1.4.1)
|
16
24
|
truncate (0.1.0)
|
17
25
|
yard (0.8.7)
|
18
26
|
|
data/LICENSE
CHANGED
@@ -1,13 +1,22 @@
|
|
1
|
-
|
2
|
-
Version 2, December 2004
|
1
|
+
The MIT License
|
3
2
|
|
4
|
-
Copyright (
|
3
|
+
Copyright (c) 2013 Richard Myers <rick.myers@me.com>
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
12
15
|
|
13
|
-
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -68,6 +68,7 @@ Available options:
|
|
68
68
|
- ```stylesheet``` - a stylesheet to style the generated directory listing with, relative to your ```public_folder```
|
69
69
|
- ```readme``` - an HTML string that will be appended at the footer of the generated directory listing
|
70
70
|
- ```should_list_invisibles``` - whether the directory listing should include invisibles (dotfiles) - true or false, defaults to false
|
71
|
+
- ```should_show_file_exts``` - whether the directory listing should show file extensions - true or false, defaults to true
|
71
72
|
- ```last_modified_format``` - [format](http://www.ruby-doc.org/core-2.0/Time.html) for last modified date - defaults to ```%Y-%m-%d %H:%M:%S```
|
72
73
|
- ```filename_truncate_length``` - length to truncate file names to - integer, defaults to 40
|
73
74
|
|
@@ -122,11 +123,15 @@ Here are the latest [commits](https://github.com/movesmyers/directory_listing/co
|
|
122
123
|
### Contributing
|
123
124
|
|
124
125
|
1. Fork it
|
125
|
-
2. Create your feature branch
|
126
|
-
3. Commit your changes (```git commit -am 'Add some feature'```
|
127
|
-
4. Push to the branch
|
126
|
+
2. Create your feature branch: ```git checkout -b my-new-feature```
|
127
|
+
3. Commit your changes (remember to include a test!): ```git commit -am 'Add some feature'```
|
128
|
+
4. Push to the branch: ```git push origin my-new-feature```
|
128
129
|
5. Create new Pull Request
|
129
130
|
|
131
|
+
#### Note:
|
132
|
+
|
133
|
+
Out of the box, the test suite will fail, as one of the tests tries to sort via mtime, and [git doesn't preserve mtimes](https://git.wiki.kernel.org/index.php/GitFaq#Why_isn.27t_Git_preserving_modification_time_on_files.3F). You'll want to touch those files in the following order to make them pass - ```2k.dat```, ```3k.dat```, ```1k.dat```.
|
134
|
+
|
130
135
|
### License
|
131
136
|
|
132
|
-
```directory_listing``` is licensed under the
|
137
|
+
```directory_listing``` is licensed under the MIT license. See the LICENSE file for details.
|
@@ -54,10 +54,12 @@ class Resource
|
|
54
54
|
def set_name(file)
|
55
55
|
|
56
56
|
##
|
57
|
-
# Make sure we're working with an unescaped file name
|
57
|
+
# Make sure we're working with an unescaped file name.
|
58
|
+
# Remove the extension if neccesary and truncate it.
|
58
59
|
# URI.unescape seems to work best to decode uris.
|
59
60
|
|
60
61
|
file = URI.unescape(file)
|
62
|
+
file = file.gsub(File.extname(file), "") if @page.should_show_file_exts == false
|
61
63
|
file_truncated = file.truncate(@page.filename_truncate_length, '...')
|
62
64
|
|
63
65
|
##
|
@@ -23,6 +23,7 @@ module Sinatra
|
|
23
23
|
|
24
24
|
options = {
|
25
25
|
:should_list_invisibles => false,
|
26
|
+
:should_show_file_exts => true,
|
26
27
|
:last_modified_format => "%Y-%m-%d %H:%M:%S",
|
27
28
|
:filename_truncate_length => 40,
|
28
29
|
:stylesheet => "",
|
@@ -34,6 +35,7 @@ module Sinatra
|
|
34
35
|
|
35
36
|
page = Page.new
|
36
37
|
page.should_list_invisibles = options[:should_list_invisibles]
|
38
|
+
page.should_show_file_exts = options[:should_show_file_exts]
|
37
39
|
page.last_modified_format = options[:last_modified_format]
|
38
40
|
page.filename_truncate_length = options[:filename_truncate_length]
|
39
41
|
page.public_folder = settings.public_folder
|
File without changes
|
@@ -60,6 +60,14 @@ class DirectoryListingTest < Test::Unit::TestCase
|
|
60
60
|
assert (last_response.body.include?('/should_list_invisibles/.') and
|
61
61
|
last_response.body.include?('/should_list_invisibles/..'))
|
62
62
|
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# test showing file extensions
|
66
|
+
|
67
|
+
def test_should_show_file_exts
|
68
|
+
get '/should_show_file_exts'
|
69
|
+
assert !(last_response.body.include?('test.txt'))
|
70
|
+
end
|
63
71
|
|
64
72
|
##
|
65
73
|
# test sorting
|
@@ -20,6 +20,12 @@ get '/should_list_invisibles' do
|
|
20
20
|
})
|
21
21
|
end
|
22
22
|
|
23
|
+
get '/should_show_file_exts' do
|
24
|
+
list({
|
25
|
+
:should_show_file_exts => false
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
23
29
|
get '*' do |path|
|
24
30
|
if File.exist?(File.join(settings.public_folder, path))
|
25
31
|
if File.directory?(File.join(settings.public_folder, path))
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: directory_listing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Myers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: filesize
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.0.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.0.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: truncate
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.0.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.0.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rack-test
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.6.2
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.6.2
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: yard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 0.8.7
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.8.7
|
111
111
|
description: A Sinatra extension for generating easy, CSS-styled, Apache-like directory
|
@@ -115,7 +115,7 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
-
|
118
|
+
- .gitignore
|
119
119
|
- Gemfile
|
120
120
|
- Gemfile.lock
|
121
121
|
- LICENSE
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- test/public/level1/test
|
135
135
|
- test/public/readme/test.txt
|
136
136
|
- test/public/should_list_invisibles/test.txt
|
137
|
+
- test/public/should_show_file_exts/test.txt
|
137
138
|
- test/public/sorting/1k.dat
|
138
139
|
- test/public/sorting/2k.dat
|
139
140
|
- test/public/sorting/3k.dat
|
@@ -150,17 +151,17 @@ require_paths:
|
|
150
151
|
- lib
|
151
152
|
required_ruby_version: !ruby/object:Gem::Requirement
|
152
153
|
requirements:
|
153
|
-
- -
|
154
|
+
- - '>='
|
154
155
|
- !ruby/object:Gem::Version
|
155
156
|
version: '0'
|
156
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
158
|
requirements:
|
158
|
-
- -
|
159
|
+
- - '>='
|
159
160
|
- !ruby/object:Gem::Version
|
160
161
|
version: '0'
|
161
162
|
requirements: []
|
162
163
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.
|
164
|
+
rubygems_version: 2.0.3
|
164
165
|
signing_key:
|
165
166
|
specification_version: 4
|
166
167
|
summary: Easy, CSS-styled, Apache-like directory listings for Sinatra.
|
@@ -172,6 +173,7 @@ test_files:
|
|
172
173
|
- test/public/level1/test
|
173
174
|
- test/public/readme/test.txt
|
174
175
|
- test/public/should_list_invisibles/test.txt
|
176
|
+
- test/public/should_show_file_exts/test.txt
|
175
177
|
- test/public/sorting/1k.dat
|
176
178
|
- test/public/sorting/2k.dat
|
177
179
|
- test/public/sorting/3k.dat
|