dbrady-sinfile 0.0.6 → 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.
Files changed (2) hide show
  1. data/bin/sinfile +13 -4
  2. metadata +2 -2
data/bin/sinfile CHANGED
@@ -9,8 +9,17 @@ configure do
9
9
  set :public, File.expand_path('.')
10
10
  end
11
11
 
12
- get '/' do
13
- dir = File.expand_path('.')
14
- str = "<ul>" + (Dir[File.join(dir, '**', '*')].reject {|p| File.directory? p }.map {|p| p.sub %r{^#{dir}/}, ""}.map {|p| "<li><a href=\"#{p}\">#{p}</a></li>"} * "\n") + "</ul>"
15
- "#{dir}<br/>#{str}"
12
+ get '*' do
13
+ dir = File.expand_path(File.join('.', params["splat"]))
14
+ if File.directory?(dir)
15
+ str = ''
16
+ str += "<h2>Index of '#{params['splat']}'</h2>"
17
+ str += "<ul>"
18
+ str += "<li><a href=\"#{File.split(params['splat'][0])[0]}\">..</a</li>\n" unless params['splat'] == ['/']
19
+ str += (Dir[File.join(dir, '*')].map{|p| p + ('/' if File.directory?(p)).to_s}.map{|p| p.sub(%r{^#{dir}/}, '')}.map {|p| "<li><a href=\"#{File.join(params['splat'],p)}\">#{p}</a>"} * "\n") + "</ul>"
20
+ elsif File.exists?(dir)
21
+ 30.times { puts "Poohat!<br/>" }
22
+ else
23
+ "<h1>Path #{dir} does not exist</h1>"
24
+ end
16
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbrady-sinfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Brady
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-21 00:00:00 -08:00
12
+ date: 2009-01-25 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency