hstatic 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/Guardfile +14 -0
- data/Rakefile +9 -0
- data/hstatic.gemspec +3 -0
- data/lib/hstatic/app.rb +41 -44
- data/lib/hstatic/version.rb +1 -1
- data/res/style.css +6 -0
- data/test/dummy_folder/index.html +9 -0
- data/test/dummy_folder/sample.haml +6 -0
- data/test/dummy_folder/sample.slim +6 -0
- data/test/index_test.rb +33 -0
- data/test/listing_test.rb +64 -0
- data/test/template_test.rb +36 -0
- data/test/test_helper.rb +12 -0
- data/views/index.slim +76 -0
- metadata +63 -5
- data/views/index.haml +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc6c94e2c7443c787a8f337d732043cec4a42148
|
4
|
+
data.tar.gz: 6c0e6225987069a69316b783bca50a87cb7b6809
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a496aaf963162bac12600556f8e4fc8d9a80c931cee789ec1fefbb8d0d98a474deffa06018296fe125bb63a7073261e3c6413f1f0ef40798c1812c87b4985c3
|
7
|
+
data.tar.gz: 1384c6eaeb79655ee6d4e251307ff394409ece790182be5e5a79cfbab21499a69772a6368c7dd9136e3bb4b385577971f50b6e9e536f496155e84b82e60d2027
|
data/.rubocop.yml
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :minitest do
|
5
|
+
# with Minitest::Unit
|
6
|
+
watch(%r{^test/(.*)_test\.rb$}) { 'test' }
|
7
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { 'test' }
|
8
|
+
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
9
|
+
|
10
|
+
# with Minitest::Spec
|
11
|
+
# watch(%r{^spec/(.*)_spec\.rb$})
|
12
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
13
|
+
# watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
|
14
|
+
end
|
data/Rakefile
CHANGED
data/hstatic.gemspec
CHANGED
@@ -22,6 +22,9 @@ It features a nice directory listing and automatic publishing of your index.html
|
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rack-test"
|
26
|
+
spec.add_development_dependency "guard"
|
27
|
+
spec.add_development_dependency "guard-minitest"
|
25
28
|
|
26
29
|
spec.add_runtime_dependency "sinatra"
|
27
30
|
spec.add_runtime_dependency "haml"
|
data/lib/hstatic/app.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
require 'pathname'
|
1
2
|
require 'sinatra/base'
|
2
3
|
require 'haml'
|
3
4
|
require 'slim'
|
4
5
|
|
5
6
|
# Main gem namespace
|
6
7
|
module Hstatic
|
7
|
-
BASEDIR =
|
8
|
+
BASEDIR = Pathname.new(__FILE__).dirname.join('..', '..')
|
8
9
|
|
9
10
|
# Main Sinatra Application
|
10
11
|
#
|
@@ -12,7 +13,7 @@ module Hstatic
|
|
12
13
|
# templates files
|
13
14
|
class App < Sinatra::Base
|
14
15
|
configure do
|
15
|
-
set :views,
|
16
|
+
set :views, BASEDIR + 'views'
|
16
17
|
set :environment, :development
|
17
18
|
enable :logging
|
18
19
|
end
|
@@ -33,14 +34,14 @@ module Hstatic
|
|
33
34
|
# Finally every Tilt supported template is rendered
|
34
35
|
helpers do
|
35
36
|
def render_file(path)
|
36
|
-
if template = Tilt[path]
|
37
|
+
if (template = Tilt[path])
|
37
38
|
ext, _ = Tilt.mappings.find { |k, v| v.include? template }
|
38
39
|
|
39
40
|
if self.respond_to? ext.to_sym
|
40
41
|
method = self.method(ext)
|
41
|
-
basename =
|
42
|
+
basename = path.basename(path.extname).to_s.to_sym
|
42
43
|
|
43
|
-
return method.call basename, :views =>
|
44
|
+
return method.call basename, :views => path.dirname
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
@@ -49,62 +50,58 @@ module Hstatic
|
|
49
50
|
end
|
50
51
|
|
51
52
|
# Going around bootstrap
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
get '/.res/jquery-1.10.2.min.js' do
|
61
|
-
send_file(File.join(BASEDIR, 'res/jquery-1.10.2.min.js'))
|
62
|
-
end
|
63
|
-
|
64
|
-
get '/fonts/glyphicons-halflings-regular.woff' do
|
65
|
-
send_file(File.join(BASEDIR, 'res/glyphicons-halflings-regular.woff'))
|
66
|
-
end
|
67
|
-
|
68
|
-
get '/fonts/glyphicons-halflings-regular.ttf' do
|
69
|
-
send_file(File.join(BASEDIR, 'res/glyphicons-halflings-regular.ttf'))
|
53
|
+
%w(
|
54
|
+
/.res/bootstrap.min.css
|
55
|
+
/.res/style.css
|
56
|
+
/.res/jquery-1.10.2.min.js
|
57
|
+
).each do |uri|
|
58
|
+
get uri do
|
59
|
+
send_file BASEDIR + uri.gsub(/^\/\./, '')
|
60
|
+
end
|
70
61
|
end
|
71
62
|
|
72
|
-
|
73
|
-
|
63
|
+
%w(
|
64
|
+
/fonts/glyphicons-halflings-regular.woff
|
65
|
+
/fonts/glyphicons-halflings-regular.tff
|
66
|
+
/fonts/glyphicons-halflings-regular.svg
|
67
|
+
).each do |uri|
|
68
|
+
get uri do
|
69
|
+
send_file BASEDIR + uri.gsub(/^\/fonts/, 'res')
|
70
|
+
end
|
74
71
|
end
|
75
72
|
|
76
73
|
# Catch all route
|
77
74
|
get '*' do
|
78
|
-
|
75
|
+
# resource absolute path
|
76
|
+
path = Pathname.new(Dir.pwd).join(unescape(request.path_info).gsub(/^\//, ''))
|
77
|
+
path_info = Pathname.new request.path_info
|
79
78
|
|
80
|
-
if
|
79
|
+
if path.file?
|
81
80
|
render_file path
|
82
|
-
elsif
|
83
|
-
|
84
|
-
|
85
|
-
|
81
|
+
elsif path.directory?
|
82
|
+
%w(index.htm index.html).each do |file|
|
83
|
+
redirect(path_info + file) if (path + file).file?
|
84
|
+
end
|
85
|
+
# FIXME: ^^ using halt call inside redirect for control flow
|
86
|
+
# Building data for directory listing
|
86
87
|
@folders = Array.new
|
87
88
|
@files = Array.new
|
88
|
-
@parent =
|
89
|
-
|
90
|
-
Dir.foreach(path) do |entry|
|
91
|
-
next if entry == '.' || entry == '..'
|
89
|
+
@parent = path_info.dirname
|
92
90
|
|
93
|
-
|
94
|
-
link =
|
95
|
-
filename = File.expand_path(File.join(path, entry))
|
91
|
+
path.each_child do |entry|
|
92
|
+
link = path_info + entry.basename
|
96
93
|
|
97
|
-
if
|
98
|
-
@folders << { name
|
94
|
+
if entry.directory?
|
95
|
+
@folders << { :name => entry.basename, :href => link }
|
99
96
|
else
|
100
|
-
@files << { name
|
101
|
-
size
|
102
|
-
href
|
97
|
+
@files << { :name => entry.basename,
|
98
|
+
:size => dynamic_size(entry.size),
|
99
|
+
:href => link }
|
103
100
|
end
|
104
101
|
end
|
105
102
|
|
106
103
|
# Render view
|
107
|
-
|
104
|
+
slim :index
|
108
105
|
else
|
109
106
|
[404, 'File not found']
|
110
107
|
end
|
data/lib/hstatic/version.rb
CHANGED
data/res/style.css
CHANGED
data/test/index_test.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
# Class for testing index.html redirection
|
4
|
+
class IndexTest < Minitest::Test
|
5
|
+
include Rack::Test::Methods
|
6
|
+
|
7
|
+
CONTENT = <<-BODY.strip_heredoc
|
8
|
+
<!DOCTYPE html>
|
9
|
+
<html>
|
10
|
+
<head>
|
11
|
+
<title>Dummy Demo Index</title>
|
12
|
+
</head>
|
13
|
+
<body>
|
14
|
+
<p>This is a demo page</p>
|
15
|
+
</body>
|
16
|
+
</html>
|
17
|
+
BODY
|
18
|
+
|
19
|
+
def app
|
20
|
+
Dir.chdir Pathname.new(__FILE__).dirname
|
21
|
+
Hstatic::App.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_index_redirect
|
25
|
+
get '/dummy_folder'
|
26
|
+
|
27
|
+
assert_equal last_response.status, 302, 'Redirect failed'
|
28
|
+
|
29
|
+
follow_redirect!
|
30
|
+
assert_equal 200, last_response.status, 'Request status failed'
|
31
|
+
assert_equal last_response.body, CONTENT, 'Body content mismatched'
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
# Class for testing directory listing
|
4
|
+
class ListTest < Minitest::Test
|
5
|
+
include Rack::Test::Methods
|
6
|
+
|
7
|
+
TEST_LISTING = <<-BODY.strip_heredoc
|
8
|
+
<!DOCTYPE html><html><head><meta content="width=device-width, initial-scale=1.0" name="viewport" /><!--Bootstrap--><link href="/.res/bootstrap.min.css" rel="stylesheet" /><link href="/.res/style.css" rel="stylesheet" /><script src="/.res/jquery-1.10.2.min.js" type="text/javascript"></script></head><body><div class="container-fluid"><div class="row"><div class="col-md-4 col-md-offset-4"><input autofocus="" class="form-control" placeholder="Search" type="text" /></div></div><div class="row"><div class="col-lg-3 col-md-3 col-sm-3"><div class="panel panel-default"><div class="panel-heading">Folders<a class="pull-right" href="/"><span class="glyphicon glyphicon-arrow-up"></span>Up</a></div><div class="list-group"><a class="list-group-item folder" href="/dummy_folder" title="dummy_folder">dummy_folder</a></div></div></div><div class="col-lg-9 col-md-9 col-sm-9"><div class="panel panel-default"><div class="panel-heading">Files</div><table class="table table-hover"><thead><tr><th>#</th><th>Name</th><th>Size</th></tr></thead><tbody><tr><td>1</td><td><a href="/test_helper.rb">test_helper.rb</a></td><td> 0.00 kB</td></tr><tr><td>2</td><td><a href="/template_test.rb">template_test.rb</a></td><td> 0.00 kB</td></tr><tr><td>3</td><td><a href="/index_test.rb">index_test.rb</a></td><td> 0.00 kB</td></tr><tr><td>4</td><td><a href="/listing_test.rb">listing_test.rb</a></td><td> 2.00 kB</td></tr></tbody></table></div></div></div></div><script type="text/javascript">$(document).ready(function () {
|
9
|
+
var re = new RegExp;
|
10
|
+
/!* filtering */
|
11
|
+
$('input').on('input', function () {
|
12
|
+
value = $(this).val();
|
13
|
+
$('a.list-group-item, tr:has(a)').show();
|
14
|
+
if (value == "") {
|
15
|
+
return false;
|
16
|
+
}
|
17
|
+
re.compile(value, "i");
|
18
|
+
$.each($('a.list-group-item'), function(i, e){
|
19
|
+
if (! re.test(e.innerHTML)) {
|
20
|
+
$(e).hide();
|
21
|
+
}
|
22
|
+
});
|
23
|
+
$.each($('tr:has(a)'), function(i, e){
|
24
|
+
if (! re.test($('a', e).html())) {
|
25
|
+
$(e).hide();
|
26
|
+
}
|
27
|
+
});
|
28
|
+
});
|
29
|
+
$('input').on('keyup', function (event) {
|
30
|
+
if (event.which == 27) {
|
31
|
+
$('input').val("");
|
32
|
+
$('input').trigger('input');
|
33
|
+
}
|
34
|
+
});
|
35
|
+
});</script></body></html>
|
36
|
+
BODY
|
37
|
+
|
38
|
+
def app
|
39
|
+
Dir.chdir Pathname.new(__FILE__).dirname
|
40
|
+
Hstatic::App.new
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_root
|
44
|
+
get '/'
|
45
|
+
|
46
|
+
assert last_response.ok?
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_resources
|
50
|
+
%w(/.res/style.css /.res/bootstrap.min.css /.res/jquery-1.10.2.min.js).each do |uri|
|
51
|
+
get uri
|
52
|
+
|
53
|
+
assert_equal last_response.status, 200, 'Request status failed'
|
54
|
+
assert last_response.body != 'File not found', 'Body content mismatched'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_content
|
59
|
+
get '/'
|
60
|
+
|
61
|
+
assert_equal 200, last_response.status, 'Request status failed'
|
62
|
+
assert_equal last_response.body, TEST_LISTING.rstrip, 'Body content mismatched'
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
# Class for testing template rendering
|
4
|
+
class TemplateTest < Minitest::Test
|
5
|
+
include Rack::Test::Methods
|
6
|
+
|
7
|
+
HAML_CONTENT = <<-BODY.strip_heredoc
|
8
|
+
<p>This is a haml sample</p>
|
9
|
+
<p>This is another paragraph sample</p>
|
10
|
+
<ul>
|
11
|
+
<li>First item</li>
|
12
|
+
<li>Second item</li>
|
13
|
+
</ul>
|
14
|
+
BODY
|
15
|
+
|
16
|
+
SLIM_CONTENT = '<p>This is a haml sample</p><p>This is another paragraph sample</p><ul><li>First item</li><li>Second item</li></ul>'
|
17
|
+
|
18
|
+
def app
|
19
|
+
Dir.chdir Pathname.new(__FILE__).dirname
|
20
|
+
Hstatic::App.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_haml_rendering
|
24
|
+
get '/dummy_folder/sample.haml'
|
25
|
+
|
26
|
+
assert_equal 200, last_response.status, 'Request status failed'
|
27
|
+
assert_equal last_response.body, HAML_CONTENT, 'Body content mismatched'
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_slim_rendering
|
31
|
+
get '/dummy_folder/sample.slim'
|
32
|
+
|
33
|
+
assert_equal 200, last_response.status, 'Request status failed'
|
34
|
+
assert_equal last_response.body, SLIM_CONTENT, 'Body content mismatched'
|
35
|
+
end
|
36
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative '../lib/hstatic'
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'rack/test'
|
5
|
+
|
6
|
+
# Migrated activesuport String#strip_heredoc patching
|
7
|
+
class String
|
8
|
+
def strip_heredoc
|
9
|
+
indent = scan(/^[ \t]*(?=\S)/).min.size || 0
|
10
|
+
gsub(/^[ \t]{#{indent}}/, '')
|
11
|
+
end
|
12
|
+
end
|
data/views/index.slim
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
/ UTF-8:
|
2
|
+
|
3
|
+
doctype 5
|
4
|
+
html
|
5
|
+
head
|
6
|
+
meta(name="viewport" content="width=device-width, initial-scale=1.0")
|
7
|
+
|
8
|
+
/! Bootstrap
|
9
|
+
link(href="/.res/bootstrap.min.css" rel="stylesheet")
|
10
|
+
link(href="/.res/style.css" rel="stylesheet")
|
11
|
+
script(src="/.res/jquery-1.10.2.min.js" type="text/javascript")
|
12
|
+
body
|
13
|
+
div.container-fluid
|
14
|
+
div.row
|
15
|
+
div.col-md-4.col-md-offset-4
|
16
|
+
input.form-control(type="text" placeholder="Search" autofocus)
|
17
|
+
div.row
|
18
|
+
div.col-lg-3.col-md-3.col-sm-3
|
19
|
+
div.panel.panel-default
|
20
|
+
div.panel-heading
|
21
|
+
| Folders
|
22
|
+
a.pull-right(href="#{@parent}")
|
23
|
+
span.glyphicon.glyphicon-arrow-up
|
24
|
+
| Up
|
25
|
+
div.list-group
|
26
|
+
- @folders.each do |folder|
|
27
|
+
a.list-group-item.folder(href="#{folder[:href]}" title="#{folder[:name]}") #{folder[:name]}
|
28
|
+
|
29
|
+
div.col-lg-9.col-md-9.col-sm-9
|
30
|
+
div.panel.panel-default
|
31
|
+
div.panel-heading Files
|
32
|
+
table.table.table-hover
|
33
|
+
thead
|
34
|
+
tr
|
35
|
+
th #
|
36
|
+
th Name
|
37
|
+
th Size
|
38
|
+
tbody
|
39
|
+
- i = 1
|
40
|
+
- @files.each do |file|
|
41
|
+
tr
|
42
|
+
td= i
|
43
|
+
td
|
44
|
+
a(href="#{file[:href]}") #{file[:name]}
|
45
|
+
td= file[:size]
|
46
|
+
- i += 1
|
47
|
+
|
48
|
+
javascript:
|
49
|
+
$(document).ready(function () {
|
50
|
+
var re = new RegExp;
|
51
|
+
/!* filtering */
|
52
|
+
$('input').on('input', function () {
|
53
|
+
value = $(this).val();
|
54
|
+
$('a.list-group-item, tr:has(a)').show();
|
55
|
+
if (value == "") {
|
56
|
+
return false;
|
57
|
+
}
|
58
|
+
re.compile(value, "i");
|
59
|
+
$.each($('a.list-group-item'), function(i, e){
|
60
|
+
if (! re.test(e.innerHTML)) {
|
61
|
+
$(e).hide();
|
62
|
+
}
|
63
|
+
});
|
64
|
+
$.each($('tr:has(a)'), function(i, e){
|
65
|
+
if (! re.test($('a', e).html())) {
|
66
|
+
$(e).hide();
|
67
|
+
}
|
68
|
+
});
|
69
|
+
});
|
70
|
+
$('input').on('keyup', function (event) {
|
71
|
+
if (event.which == 27) {
|
72
|
+
$('input').val("");
|
73
|
+
$('input').trigger('input');
|
74
|
+
}
|
75
|
+
});
|
76
|
+
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hstatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erick Pérez Castellanos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,48 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rack-test
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
41
83
|
- !ruby/object:Gem::Dependency
|
42
84
|
name: sinatra
|
43
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,7 +134,9 @@ extensions: []
|
|
92
134
|
extra_rdoc_files: []
|
93
135
|
files:
|
94
136
|
- ".gitignore"
|
137
|
+
- ".rubocop.yml"
|
95
138
|
- Gemfile
|
139
|
+
- Guardfile
|
96
140
|
- LICENSE.txt
|
97
141
|
- README.md
|
98
142
|
- Rakefile
|
@@ -109,7 +153,14 @@ files:
|
|
109
153
|
- res/glyphicons-halflings-regular.woff
|
110
154
|
- res/jquery-1.10.2.min.js
|
111
155
|
- res/style.css
|
112
|
-
-
|
156
|
+
- test/dummy_folder/index.html
|
157
|
+
- test/dummy_folder/sample.haml
|
158
|
+
- test/dummy_folder/sample.slim
|
159
|
+
- test/index_test.rb
|
160
|
+
- test/listing_test.rb
|
161
|
+
- test/template_test.rb
|
162
|
+
- test/test_helper.rb
|
163
|
+
- views/index.slim
|
113
164
|
homepage: https://github.com/erick2red/hstatic
|
114
165
|
licenses:
|
115
166
|
- MIT
|
@@ -130,9 +181,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
181
|
version: '0'
|
131
182
|
requirements: []
|
132
183
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.2.
|
184
|
+
rubygems_version: 2.2.2
|
134
185
|
signing_key:
|
135
186
|
specification_version: 4
|
136
187
|
summary: An HTTP server for you static files
|
137
|
-
test_files:
|
188
|
+
test_files:
|
189
|
+
- test/dummy_folder/index.html
|
190
|
+
- test/dummy_folder/sample.haml
|
191
|
+
- test/dummy_folder/sample.slim
|
192
|
+
- test/index_test.rb
|
193
|
+
- test/listing_test.rb
|
194
|
+
- test/template_test.rb
|
195
|
+
- test/test_helper.rb
|
138
196
|
has_rdoc:
|
data/views/index.haml
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
-# UTF-8:
|
2
|
-
|
3
|
-
!!! 5
|
4
|
-
%html
|
5
|
-
%head
|
6
|
-
%meta(name="viewport" content="width=device-width, initial-scale=1.0")
|
7
|
-
|
8
|
-
/ Bootstrap
|
9
|
-
%link(href="/.res/bootstrap.min.css" rel="stylesheet")
|
10
|
-
%link(href="/.res/style.css" rel="stylesheet")
|
11
|
-
%script(src="/.res/jquery-1.10.2.min.js" type="text/javascript")
|
12
|
-
%body
|
13
|
-
%div.container-fluid
|
14
|
-
%div.row
|
15
|
-
%div.col-md-4.col-md-offset-4
|
16
|
-
%input.form-control(type="text" placeholder="Search" autofocus)
|
17
|
-
%div.row
|
18
|
-
%div.col-lg-3.col-md-3.col-sm-3
|
19
|
-
%div.panel.panel-default
|
20
|
-
%div.panel-heading
|
21
|
-
Folders
|
22
|
-
%a.pull-right(href="#{@parent}")
|
23
|
-
%span.glyphicon.glyphicon-arrow-up
|
24
|
-
Up
|
25
|
-
%div.list-group
|
26
|
-
- @folders.each do |folder|
|
27
|
-
%a.list-group-item(href="#{folder[:href]}") #{folder[:name]}
|
28
|
-
|
29
|
-
%div.col-lg-9.col-md-9.col-sm-9
|
30
|
-
%div.panel.panel-default
|
31
|
-
%div.panel-heading Files
|
32
|
-
%table.table.table-hover
|
33
|
-
%thead
|
34
|
-
%tr
|
35
|
-
%th #
|
36
|
-
%th Name
|
37
|
-
%th Size
|
38
|
-
%tbody
|
39
|
-
- i = 1
|
40
|
-
- @files.each do |file|
|
41
|
-
%tr
|
42
|
-
%td= i
|
43
|
-
%td
|
44
|
-
%a(href="#{file[:href]}") #{file[:name]}
|
45
|
-
%td= file[:size]
|
46
|
-
- i += 1
|
47
|
-
|
48
|
-
:javascript
|
49
|
-
$(document).ready(function () {
|
50
|
-
var re = new RegExp;
|
51
|
-
/* filtering */
|
52
|
-
$('input').on('input', function () {
|
53
|
-
value = $(this).val();
|
54
|
-
$('a.list-group-item, tr:has(a)').show();
|
55
|
-
if (value == "") {
|
56
|
-
return false;
|
57
|
-
}
|
58
|
-
re.compile(value, "i");
|
59
|
-
$.each($('a.list-group-item'), function(i, e){
|
60
|
-
if (! re.test(e.innerHTML)) {
|
61
|
-
$(e).hide();
|
62
|
-
}
|
63
|
-
});
|
64
|
-
$.each($('tr:has(a)'), function(i, e){
|
65
|
-
if (! re.test($('a', e).html())) {
|
66
|
-
$(e).hide();
|
67
|
-
}
|
68
|
-
});
|
69
|
-
});
|
70
|
-
$('input').on('keyup', function (event) {
|
71
|
-
if (event.which == 27) {
|
72
|
-
$('input').val("");
|
73
|
-
$('input').trigger('input');
|
74
|
-
}
|
75
|
-
});
|
76
|
-
});
|
77
|
-
|
78
|
-
|