marcinbunsch-quick_serve 0.3.2 → 0.3.3
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 +5 -16
- data/VERSION +1 -1
- data/lib/quick_serve/handlers/directory.rb +74 -0
- data/lib/quick_serve/{snapshot/handler.rb → handlers/snapshot.rb} +2 -2
- data/lib/quick_serve/server.rb +4 -3
- data/quick_serve.gemspec +3 -2
- metadata +5 -3
data/README.rdoc
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
= quick_serve
|
|
2
2
|
|
|
3
|
-
quick_serve is a super-simple way of serving static files for development. It was made mainly for javascript development, but might have other uses.
|
|
3
|
+
quick_serve is a super-simple way of serving static files for development. It was made mainly for javascript and css development, but might have other uses.
|
|
4
4
|
|
|
5
5
|
=== General usage
|
|
6
6
|
|
|
7
|
-
Type 'qs' or 'quick_serve'. By default it will use port 5000, but if you run 'qs -p 4000' it will use 4000 (or any other you specify)
|
|
8
|
-
|
|
9
|
-
*Options:*
|
|
10
|
-
* *-p PORT, --port PORT* Specify port (default: 5000)
|
|
11
|
-
* *--dir DIRECTORY* Specify directory to act as docroot (default: current directory)
|
|
12
|
-
* *--host HOST* Specify host (default: 0.0.0.0)
|
|
13
|
-
* *-s URL, --snapshot URL* Specify url for snapshot
|
|
14
|
-
* *-q* quit deamon (if present)
|
|
15
|
-
* *-d, --deamon* Run as a deamon process
|
|
7
|
+
Type 'qs' or 'quick_serve'. It will start a mongrel web server using the current directory as docroot. By default it will use port 5000, but if you run 'qs -p 4000' it will use 4000 (or any other you specify). Type 'qs -h' for more options.
|
|
16
8
|
|
|
17
9
|
=== Snapshot mode usage
|
|
18
10
|
|
|
@@ -36,13 +28,10 @@ Keep in mind, it will run only in development mode.
|
|
|
36
28
|
|
|
37
29
|
* Fork the project.
|
|
38
30
|
* Make your feature addition or bug fix.
|
|
39
|
-
* Add tests for it. This is important so I don't break it in a
|
|
40
|
-
future version unintentionally.
|
|
41
31
|
* Commit, do not mess with rakefile, version, or history.
|
|
42
|
-
(if you want to have your own version, that is fine but
|
|
43
|
-
|
|
44
|
-
* Send me a pull request. Bonus points for topic branches.
|
|
32
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
|
33
|
+
* Send me a pull request.
|
|
45
34
|
|
|
46
35
|
== Copyright
|
|
47
36
|
|
|
48
|
-
Copyright (c) 2009 Marcin Bunsch. See LICENSE for details.
|
|
37
|
+
Copyright (c) 2009 Marcin Bunsch . See LICENSE for details.
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.3
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
module QuickServe
|
|
2
|
+
module Handlers
|
|
3
|
+
class Directory < Mongrel::DirHandler
|
|
4
|
+
|
|
5
|
+
STYLESHEET = <<-stylesheet
|
|
6
|
+
html, body {
|
|
7
|
+
font-family: "Lucida Grande", Verdana, sans-serif;
|
|
8
|
+
font-size: 90%;
|
|
9
|
+
font-weight: normal;
|
|
10
|
+
line-height: auto;
|
|
11
|
+
}
|
|
12
|
+
html {
|
|
13
|
+
background-color: #F0F0F0;
|
|
14
|
+
}
|
|
15
|
+
#body {
|
|
16
|
+
-moz-border-radius-bottomleft:10px;
|
|
17
|
+
-moz-border-radius-bottomright:10px;
|
|
18
|
+
-moz-border-radius-topleft:10px;
|
|
19
|
+
-moz-border-radius-topright:10px;
|
|
20
|
+
background-color: #fff;
|
|
21
|
+
border:1px solid #E1E1E1;
|
|
22
|
+
color:-moz-fieldtext;
|
|
23
|
+
width: 70%;
|
|
24
|
+
margin:4em auto;
|
|
25
|
+
padding:3em;
|
|
26
|
+
}
|
|
27
|
+
h1 {
|
|
28
|
+
font-size: 130%;
|
|
29
|
+
border-bottom: 1px solid #999;
|
|
30
|
+
padding: 3px;
|
|
31
|
+
}
|
|
32
|
+
a {
|
|
33
|
+
color: #666;
|
|
34
|
+
text-decoration: none
|
|
35
|
+
}
|
|
36
|
+
a:hover { color: #000 }
|
|
37
|
+
h3 {
|
|
38
|
+
font-size: 115%;
|
|
39
|
+
margin-bottom: 10px;
|
|
40
|
+
}
|
|
41
|
+
stylesheet
|
|
42
|
+
|
|
43
|
+
def send_dir_listing(base, dir, response)
|
|
44
|
+
# take off any trailing / so the links come out right
|
|
45
|
+
base = Mongrel::HttpRequest.unescape(base)
|
|
46
|
+
base.chop! if base[-1] == "/"[-1]
|
|
47
|
+
|
|
48
|
+
if @listing_allowed
|
|
49
|
+
response.start(200) do |head,out|
|
|
50
|
+
head[Mongrel::Const::CONTENT_TYPE] = "text/html"
|
|
51
|
+
|
|
52
|
+
out << "<html><head><title>Directory Listing for #{dir}</title><style type=\"text/css\">#{STYLESHEET}</style></head><body><div id=\"body\"><h1>Directory Listing for #{dir}</h1>"
|
|
53
|
+
entries = Dir.entries(dir)
|
|
54
|
+
entries = entries - ['..']
|
|
55
|
+
out << "<h3><a href=\"#{base}/..\">Up to higher level directory</a></h3>"
|
|
56
|
+
entries.each do |child|
|
|
57
|
+
next if child == "."
|
|
58
|
+
out << "<a href=\"#{base}/#{ Mongrel::HttpRequest.escape(child)}\">"
|
|
59
|
+
out << child
|
|
60
|
+
out << "</a><br/>"
|
|
61
|
+
end
|
|
62
|
+
out << "</div></body></html>"
|
|
63
|
+
end
|
|
64
|
+
else
|
|
65
|
+
response.start(403) do |head,out|
|
|
66
|
+
out.write("Directory listings not allowed")
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
data/lib/quick_serve/server.rb
CHANGED
|
@@ -34,10 +34,11 @@ module QuickServe
|
|
|
34
34
|
config = Mongrel::Configurator.new :host => options[:host], :port => options[:port] do
|
|
35
35
|
listener do
|
|
36
36
|
if options[:url]
|
|
37
|
-
require 'quick_serve/snapshot
|
|
38
|
-
uri "/", :handler => QuickServe::Snapshot
|
|
37
|
+
require 'quick_serve/handlers/snapshot'
|
|
38
|
+
uri "/", :handler => QuickServe::Handlers::Snapshot.new(options[:url])
|
|
39
39
|
else
|
|
40
|
-
|
|
40
|
+
require 'quick_serve/handlers/directory'
|
|
41
|
+
uri "/", :handler => QuickServe::Handlers::Directory.new(options[:dir])
|
|
41
42
|
end
|
|
42
43
|
end
|
|
43
44
|
trap("INT") { stop }
|
data/quick_serve.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{quick_serve}
|
|
5
|
-
s.version = "0.3.
|
|
5
|
+
s.version = "0.3.3"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["Marcin Bunsch"]
|
|
@@ -23,13 +23,14 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
"bin/qs",
|
|
24
24
|
"bin/quick_serve",
|
|
25
25
|
"lib/quick_serve.rb",
|
|
26
|
+
"lib/quick_serve/handlers/directory.rb",
|
|
27
|
+
"lib/quick_serve/handlers/snapshot.rb",
|
|
26
28
|
"lib/quick_serve/rails.rb",
|
|
27
29
|
"lib/quick_serve/rails/ext/mongrel.rb",
|
|
28
30
|
"lib/quick_serve/rails/ext/rails.rb",
|
|
29
31
|
"lib/quick_serve/rails/listener.rb",
|
|
30
32
|
"lib/quick_serve/rails/snapshot.rb",
|
|
31
33
|
"lib/quick_serve/server.rb",
|
|
32
|
-
"lib/quick_serve/snapshot/handler.rb",
|
|
33
34
|
"quick_serve.gemspec"
|
|
34
35
|
]
|
|
35
36
|
s.homepage = %q{http://github.com/marcinbunsch/quick_serve}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: marcinbunsch-quick_serve
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marcin Bunsch
|
|
@@ -31,16 +31,18 @@ files:
|
|
|
31
31
|
- bin/qs
|
|
32
32
|
- bin/quick_serve
|
|
33
33
|
- lib/quick_serve.rb
|
|
34
|
+
- lib/quick_serve/handlers/directory.rb
|
|
35
|
+
- lib/quick_serve/handlers/snapshot.rb
|
|
34
36
|
- lib/quick_serve/rails.rb
|
|
35
37
|
- lib/quick_serve/rails/ext/mongrel.rb
|
|
36
38
|
- lib/quick_serve/rails/ext/rails.rb
|
|
37
39
|
- lib/quick_serve/rails/listener.rb
|
|
38
40
|
- lib/quick_serve/rails/snapshot.rb
|
|
39
41
|
- lib/quick_serve/server.rb
|
|
40
|
-
- lib/quick_serve/snapshot/handler.rb
|
|
41
42
|
- quick_serve.gemspec
|
|
42
43
|
has_rdoc: false
|
|
43
44
|
homepage: http://github.com/marcinbunsch/quick_serve
|
|
45
|
+
licenses:
|
|
44
46
|
post_install_message:
|
|
45
47
|
rdoc_options:
|
|
46
48
|
- --charset=UTF-8
|
|
@@ -61,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
61
63
|
requirements: []
|
|
62
64
|
|
|
63
65
|
rubyforge_project:
|
|
64
|
-
rubygems_version: 1.
|
|
66
|
+
rubygems_version: 1.3.5
|
|
65
67
|
signing_key:
|
|
66
68
|
specification_version: 3
|
|
67
69
|
summary: Super simple web server mainly for javascript development
|