serve 1.5.1 → 1.5.2
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/Gemfile +18 -18
- data/Gemfile.lock +64 -61
- data/README.rdoc +14 -2
- data/VERSION +1 -1
- data/lib/serve.rb +2 -0
- data/lib/serve/application.rb +1 -1
- data/lib/serve/bootstrap/Gemfile +4 -1
- data/lib/serve/bootstrap/README.md +2 -7
- data/lib/serve/bootstrap/config.ru +6 -2
- data/lib/serve/handlers/coffee_handler.rb +18 -0
- data/lib/serve/handlers/dynamic_handler.rb +11 -65
- data/lib/serve/handlers/file_type_handler.rb +34 -14
- data/lib/serve/handlers/less_handler.rb +1 -1
- data/lib/serve/handlers/redirect_handler.rb +9 -5
- data/lib/serve/handlers/sass_handler.rb +6 -8
- data/lib/serve/pipeline.rb +119 -0
- data/lib/serve/rack.rb +3 -8
- data/lib/serve/router.rb +12 -8
- data/lib/serve/templates/default/views/view_helpers.rb +2 -2
- data/lib/serve/view_helpers.rb +14 -12
- data/spec/fixtures/directory/_layout.erb +3 -0
- data/spec/fixtures/directory/coffee.coffee +0 -0
- data/spec/fixtures/directory/markdown.html.markdown +0 -0
- data/spec/fixtures/directory/markdown.markdown +0 -0
- data/spec/fixtures/directory/markdown_erb.markdown.erb +0 -0
- data/spec/fixtures/directory/subdirectory/test.erb +1 -0
- data/spec/fixtures/file.erb +1 -0
- data/spec/pipeline_spec.rb +67 -0
- data/spec/router_spec.rb +4 -2
- data/spec/views/view_helpers.rb +7 -7
- metadata +259 -152
data/Gemfile
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gem 'rack', '~> 1.2'
|
4
|
-
gem 'rack-test', '~> 0.
|
5
|
-
gem 'tilt', '~> 1.3'
|
6
|
-
gem 'activesupport', '~> 3.
|
3
|
+
gem 'rack', '~> 1.5.2'
|
4
|
+
gem 'rack-test', '~> 0.6.2'
|
5
|
+
gem 'tilt', '~> 1.3.3'
|
6
|
+
gem 'activesupport', '~> 3.2.12'
|
7
7
|
gem 'tzinfo'
|
8
8
|
gem 'i18n'
|
9
9
|
|
10
10
|
group :development do
|
11
|
-
gem 'rake', '~> 0.
|
12
|
-
gem 'rdoc', '~> 3.
|
13
|
-
gem 'rspec', '~> 2.
|
11
|
+
gem 'rake', '~> 10.0.3'
|
12
|
+
gem 'rdoc', '~> 3.12.1'
|
13
|
+
gem 'rspec', '~> 2.12.0'
|
14
14
|
gem 'jeweler', '~> 1.6.4'
|
15
|
-
gem 'haml', '~> 3.1.
|
16
|
-
gem 'sass', '~> 3.
|
17
|
-
gem 'compass', '~> 0.
|
18
|
-
gem 'slim', '~>
|
19
|
-
gem 'rdiscount', '~>
|
20
|
-
gem 'RedCloth', '~> 4.2.
|
15
|
+
gem 'haml', '~> 3.1.7'
|
16
|
+
gem 'sass', '~> 3.2.5'
|
17
|
+
gem 'compass', '~> 0.12.2'
|
18
|
+
gem 'slim', '~> 1.3.6'
|
19
|
+
gem 'rdiscount', '~> 2.0.7'
|
20
|
+
gem 'RedCloth', '~> 4.2.9'
|
21
21
|
gem 'erubis', '~> 2.7.0'
|
22
|
-
gem 'less', '~>
|
23
|
-
gem 'radius', '~> 0.
|
22
|
+
gem 'less', '~> 2.2.2'
|
23
|
+
gem 'radius', '~> 0.7.3'
|
24
24
|
gem 'coffee-script', '~> 2.2.0'
|
25
25
|
end
|
26
26
|
|
27
27
|
group :website do
|
28
28
|
gem 'serve', :git => 'git://github.com/jlong/serve.git'
|
29
|
-
gem 'css_parser', '~> 1.
|
30
|
-
gem 'maruku', '~> 0.6.
|
29
|
+
gem 'css_parser', '~> 1.2.6'
|
30
|
+
gem 'maruku', '~> 0.6.1'
|
31
31
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/jlong/serve.git
|
3
|
-
revision:
|
3
|
+
revision: fa84a08fad9b5364f8b4d93fc5b69507a7bd0363
|
4
4
|
specs:
|
5
|
-
serve (1.5.
|
5
|
+
serve (1.5.1)
|
6
6
|
activesupport (~> 3.0)
|
7
7
|
i18n
|
8
8
|
rack (~> 1.2)
|
@@ -11,90 +11,93 @@ GIT
|
|
11
11
|
tzinfo
|
12
12
|
|
13
13
|
GEM
|
14
|
-
remote:
|
14
|
+
remote: https://rubygems.org/
|
15
15
|
specs:
|
16
|
-
RedCloth (4.2.
|
17
|
-
activesupport (3.
|
18
|
-
|
16
|
+
RedCloth (4.2.9)
|
17
|
+
activesupport (3.2.12)
|
18
|
+
i18n (~> 0.6)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
addressable (2.3.3)
|
21
|
+
chunky_png (1.2.7)
|
19
22
|
coffee-script (2.2.0)
|
20
23
|
coffee-script-source
|
21
24
|
execjs
|
22
|
-
coffee-script-source (1.
|
23
|
-
|
25
|
+
coffee-script-source (1.4.0)
|
26
|
+
commonjs (0.2.6)
|
27
|
+
compass (0.12.2)
|
24
28
|
chunky_png (~> 1.2)
|
25
29
|
fssm (>= 0.2.7)
|
26
30
|
sass (~> 3.1)
|
27
|
-
css_parser (1.
|
28
|
-
|
31
|
+
css_parser (1.2.6)
|
32
|
+
addressable
|
33
|
+
rdoc
|
34
|
+
diff-lcs (1.1.3)
|
29
35
|
erubis (2.7.0)
|
30
|
-
execjs (1.
|
36
|
+
execjs (1.4.0)
|
31
37
|
multi_json (~> 1.0)
|
32
|
-
fssm (0.2.
|
38
|
+
fssm (0.2.10)
|
33
39
|
git (1.2.5)
|
34
|
-
haml (3.1.
|
35
|
-
i18n (0.
|
40
|
+
haml (3.1.8)
|
41
|
+
i18n (0.6.1)
|
36
42
|
jeweler (1.6.4)
|
37
43
|
bundler (~> 1.0)
|
38
44
|
git (>= 1.2.5)
|
39
45
|
rake
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
maruku (0.6.
|
46
|
+
json (1.7.7)
|
47
|
+
less (2.2.2)
|
48
|
+
commonjs (~> 0.2.6)
|
49
|
+
maruku (0.6.1)
|
44
50
|
syntax (>= 1.0.0)
|
45
|
-
multi_json (1.
|
46
|
-
|
47
|
-
|
48
|
-
rack (1.2.3)
|
49
|
-
rack-test (0.5.7)
|
51
|
+
multi_json (1.6.1)
|
52
|
+
rack (1.5.2)
|
53
|
+
rack-test (0.6.2)
|
50
54
|
rack (>= 1.0)
|
51
|
-
radius (0.
|
52
|
-
rake (0.
|
53
|
-
rdiscount (
|
54
|
-
rdoc (3.
|
55
|
-
|
56
|
-
|
57
|
-
rspec-
|
58
|
-
rspec-
|
59
|
-
|
60
|
-
rspec-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
55
|
+
radius (0.7.3)
|
56
|
+
rake (10.0.3)
|
57
|
+
rdiscount (2.0.7)
|
58
|
+
rdoc (3.12.1)
|
59
|
+
json (~> 1.4)
|
60
|
+
rspec (2.12.0)
|
61
|
+
rspec-core (~> 2.12.0)
|
62
|
+
rspec-expectations (~> 2.12.0)
|
63
|
+
rspec-mocks (~> 2.12.0)
|
64
|
+
rspec-core (2.12.2)
|
65
|
+
rspec-expectations (2.12.1)
|
66
|
+
diff-lcs (~> 1.1.3)
|
67
|
+
rspec-mocks (2.12.2)
|
68
|
+
sass (3.2.6)
|
69
|
+
slim (1.3.6)
|
70
|
+
temple (~> 0.5.5)
|
71
|
+
tilt (~> 1.3.3)
|
67
72
|
syntax (1.0.0)
|
68
|
-
temple (0.
|
69
|
-
tilt (1.3.
|
70
|
-
|
71
|
-
polyglot (>= 0.3.1)
|
72
|
-
tzinfo (0.3.29)
|
73
|
+
temple (0.5.5)
|
74
|
+
tilt (1.3.3)
|
75
|
+
tzinfo (0.3.35)
|
73
76
|
|
74
77
|
PLATFORMS
|
75
78
|
ruby
|
76
79
|
|
77
80
|
DEPENDENCIES
|
78
|
-
RedCloth (~> 4.2.
|
79
|
-
activesupport (~> 3.
|
81
|
+
RedCloth (~> 4.2.9)
|
82
|
+
activesupport (~> 3.2.12)
|
80
83
|
coffee-script (~> 2.2.0)
|
81
|
-
compass (~> 0.
|
82
|
-
css_parser (~> 1.
|
84
|
+
compass (~> 0.12.2)
|
85
|
+
css_parser (~> 1.2.6)
|
83
86
|
erubis (~> 2.7.0)
|
84
|
-
haml (~> 3.1.
|
87
|
+
haml (~> 3.1.7)
|
85
88
|
i18n
|
86
89
|
jeweler (~> 1.6.4)
|
87
|
-
less (~>
|
88
|
-
maruku (~> 0.6.
|
89
|
-
rack (~> 1.2)
|
90
|
-
rack-test (~> 0.
|
91
|
-
radius (~> 0.
|
92
|
-
rake (~> 0.
|
93
|
-
rdiscount (~>
|
94
|
-
rdoc (~> 3.
|
95
|
-
rspec (~> 2.
|
96
|
-
sass (~> 3.
|
90
|
+
less (~> 2.2.2)
|
91
|
+
maruku (~> 0.6.1)
|
92
|
+
rack (~> 1.5.2)
|
93
|
+
rack-test (~> 0.6.2)
|
94
|
+
radius (~> 0.7.3)
|
95
|
+
rake (~> 10.0.3)
|
96
|
+
rdiscount (~> 2.0.7)
|
97
|
+
rdoc (~> 3.12.1)
|
98
|
+
rspec (~> 2.12.0)
|
99
|
+
sass (~> 3.2.5)
|
97
100
|
serve!
|
98
|
-
slim (~>
|
99
|
-
tilt (~> 1.3)
|
101
|
+
slim (~> 1.3.6)
|
102
|
+
tilt (~> 1.3.3)
|
100
103
|
tzinfo
|
data/README.rdoc
CHANGED
@@ -61,7 +61,7 @@ following on the command line:
|
|
61
61
|
|
62
62
|
serve create project # create a new project in the project directory
|
63
63
|
|
64
|
-
|
64
|
+
Learn more: http://get-serve.com/documentation/create
|
65
65
|
|
66
66
|
|
67
67
|
== Layouts & Partials
|
@@ -108,6 +108,17 @@ Serve also provides a number of stock helpers methods that are very similar to t
|
|
108
108
|
Learn more: http://get-serve.com/documentation/view-helpers
|
109
109
|
|
110
110
|
|
111
|
+
== Exporting
|
112
|
+
|
113
|
+
To export your project, use the new "export" command:
|
114
|
+
|
115
|
+
serve export project output
|
116
|
+
|
117
|
+
Where "project" is the path to the project and "output" is the path to the
|
118
|
+
directory where you would like your HTML and CSS generated.
|
119
|
+
|
120
|
+
Learn more: http://get-serve.com/documentation/export
|
121
|
+
|
111
122
|
== "Design First" Prototyping
|
112
123
|
|
113
124
|
If you use a "Design First" methodology, you may find Serve especially useful
|
@@ -124,6 +135,7 @@ also be estimated with a high degree of accuracy.
|
|
124
135
|
== Website & Documentation
|
125
136
|
|
126
137
|
Detailed documentation is available on the Serve website: http://get-serve.com
|
138
|
+
Build status: {<img src="https://secure.travis-ci.org/jlong/serve.png?branch=master" />}[http://travis-ci.org/jlong/serve]
|
127
139
|
|
128
140
|
|
129
141
|
== Mailing List
|
@@ -137,4 +149,4 @@ http://groups.google.com/group/serve-users
|
|
137
149
|
|
138
150
|
Serve is released under a MIT-style license and is copyright (c) 2007-2011
|
139
151
|
John W. Long and Adam I. Williams. Portions have been contributed by Robert
|
140
|
-
Evans and others. A copy of the license can be found in the LICENSE file.
|
152
|
+
Evans and others. A copy of the license can be found in the LICENSE file.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.2
|
data/lib/serve.rb
CHANGED
@@ -9,10 +9,12 @@ end
|
|
9
9
|
|
10
10
|
require 'serve/version'
|
11
11
|
require 'serve/router'
|
12
|
+
require 'serve/pipeline'
|
12
13
|
require 'serve/handlers/file_type_handler'
|
13
14
|
require 'serve/handlers/dynamic_handler'
|
14
15
|
require 'serve/handlers/sass_handler'
|
15
16
|
require 'serve/handlers/less_handler'
|
16
17
|
require 'serve/handlers/email_handler'
|
17
18
|
require 'serve/handlers/redirect_handler'
|
19
|
+
require 'serve/handlers/coffee_handler'
|
18
20
|
require 'serve/rack'
|
data/lib/serve/application.rb
CHANGED
@@ -160,7 +160,7 @@ module Serve
|
|
160
160
|
end
|
161
161
|
|
162
162
|
def extract_port(args)
|
163
|
-
(args.delete(args.find {|a| /^\d\d\d*$/.match(a) }) || ((rails_app? or rack_app?) ? 3000 : 4000)).to_i
|
163
|
+
(args.delete(args.find {|a| /^\d\d\d*$/.match(a) }) || ENV['PORT'] || ((rails_app? or rack_app?) ? 3000 : 4000)).to_i
|
164
164
|
end
|
165
165
|
|
166
166
|
def extract_address(args)
|
data/lib/serve/bootstrap/Gemfile
CHANGED
@@ -66,14 +66,9 @@ information about using Serve and Passenger see:
|
|
66
66
|
Exporting
|
67
67
|
---------
|
68
68
|
|
69
|
-
To export this project to pure HTML and CSS you will need the prerelease
|
70
|
-
version of Serve. To get started with the prerelease version:
|
71
|
-
|
72
|
-
gem install --pre serve
|
73
|
-
|
74
69
|
To export your project, use the new "export" command:
|
75
70
|
|
76
|
-
serve export
|
71
|
+
serve export project output
|
77
72
|
|
78
73
|
Where "project" is the path to the project and "output" is the path to the
|
79
74
|
directory where you would like your HTML and CSS generated.
|
@@ -84,4 +79,4 @@ Learning More
|
|
84
79
|
|
85
80
|
You can learn more about Serve on the GitHub project page:
|
86
81
|
|
87
|
-
<http://github.com/jlong/serve>
|
82
|
+
<http://github.com/jlong/serve>
|
@@ -36,12 +36,16 @@ use Rack::ShowExceptions # Nice looking errors
|
|
36
36
|
|
37
37
|
# Rack Application
|
38
38
|
if ENV['SERVER_SOFTWARE'] =~ /passenger/i
|
39
|
-
#
|
39
|
+
# Passenger only needs the adapter
|
40
40
|
run Serve::RackAdapter.new(root + '/views')
|
41
41
|
else
|
42
|
+
# Use Rack::TryStatic to attempt to load files from public first
|
43
|
+
require 'rack/contrib/try_static'
|
44
|
+
use Rack::TryStatic, :root => (root + '/public'), :urls => %w(/), :try => %w(.html index.html /index.html)
|
45
|
+
|
42
46
|
# Use Rack::Cascade and Rack::Directory on other platforms for static assets
|
43
47
|
run Rack::Cascade.new([
|
44
48
|
Serve::RackAdapter.new(root + '/views'),
|
45
49
|
Rack::Directory.new(root + '/public')
|
46
50
|
])
|
47
|
-
end
|
51
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Serve #:nodoc:
|
2
|
+
class CoffeeHandler < FileTypeHandler #:nodoc:
|
3
|
+
extension 'coffee'
|
4
|
+
|
5
|
+
def parse(input, context)
|
6
|
+
engine = Tilt::CoffeeScriptTemplate.new { input }
|
7
|
+
engine.render
|
8
|
+
end
|
9
|
+
|
10
|
+
def content_type
|
11
|
+
'text/javascript'
|
12
|
+
end
|
13
|
+
|
14
|
+
def layout?
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'serve/view_helpers'
|
2
1
|
require 'tilt'
|
3
2
|
|
4
3
|
module Serve #:nodoc:
|
@@ -13,64 +12,25 @@ module Serve #:nodoc:
|
|
13
12
|
self.class.extensions
|
14
13
|
end
|
15
14
|
|
16
|
-
extension
|
15
|
+
extension(*extensions)
|
17
16
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def parse(request, response)
|
24
|
-
context = Context.new(@root_path, request, response)
|
25
|
-
install_view_helpers(context)
|
26
|
-
parser = Parser.new(context)
|
27
|
-
context.content << parser.parse_file(@script_filename)
|
28
|
-
layout = find_layout_for(@script_filename)
|
29
|
-
if layout
|
30
|
-
parser.parse_file(layout)
|
31
|
-
else
|
32
|
-
context.content
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def find_layout_for(filename)
|
37
|
-
root = @root_path
|
38
|
-
path = filename[root.size..-1]
|
39
|
-
layout = nil
|
40
|
-
until layout or path == "/"
|
41
|
-
path = File.dirname(path)
|
42
|
-
possible_layouts = extensions.map do |ext|
|
43
|
-
l = "_layout.#{ext}"
|
44
|
-
possible_layout = File.join(root, path, l)
|
45
|
-
File.file?(possible_layout) ? possible_layout : false
|
46
|
-
end
|
47
|
-
layout = possible_layouts.detect { |o| o }
|
48
|
-
end
|
49
|
-
layout
|
50
|
-
end
|
51
|
-
|
52
|
-
def install_view_helpers(context)
|
53
|
-
view_helpers_file_path = @root_path + '/view_helpers.rb'
|
54
|
-
if File.file?(view_helpers_file_path)
|
55
|
-
context.singleton_class.module_eval(File.read(view_helpers_file_path) + "\ninclude ViewHelpers", view_helpers_file_path)
|
56
|
-
end
|
17
|
+
def parse(input, context)
|
18
|
+
parser = Parser.new(context, @template_path)
|
19
|
+
parser.parse(input, extension)
|
57
20
|
end
|
58
21
|
|
59
22
|
class Parser #:nodoc:
|
60
|
-
attr_accessor :context, :
|
23
|
+
attr_accessor :context, :script_extension, :engine, :template_path
|
61
24
|
|
62
|
-
def initialize(context)
|
25
|
+
def initialize(context, template_path)
|
63
26
|
@context = context
|
64
27
|
@context.parser = self
|
28
|
+
@template_path = template_path
|
65
29
|
end
|
66
30
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
@script_filename = filename
|
71
|
-
|
72
|
-
ext = File.extname(filename).sub(/^\.html\.|^\./, '').downcase
|
73
|
-
|
31
|
+
def parse(input, ext, locals={})
|
32
|
+
old_script_extension, old_engine = @script_extension, @engine
|
33
|
+
|
74
34
|
if ext == 'slim' # Ugly, but works
|
75
35
|
if Thread.list.size > 1
|
76
36
|
warn "WARN: serve autoloading 'slim' in a non thread-safe way; " +
|
@@ -81,7 +41,7 @@ module Serve #:nodoc:
|
|
81
41
|
|
82
42
|
@script_extension = ext
|
83
43
|
|
84
|
-
@engine = Tilt[ext].new(
|
44
|
+
@engine = Tilt[ext].new(nil, nil, {:outvar => '@_out_buf'}.merge(FileTypeHandler.options_for(ext))){input}
|
85
45
|
|
86
46
|
raise "#{ext} extension not supported" if @engine.nil?
|
87
47
|
|
@@ -89,23 +49,9 @@ module Serve #:nodoc:
|
|
89
49
|
context.get_content_for(*args)
|
90
50
|
end
|
91
51
|
ensure
|
92
|
-
@script_filename = old_script_filename
|
93
52
|
@script_extension = old_script_extension
|
94
53
|
@engine = old_engine
|
95
54
|
end
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
class Context #:nodoc:
|
100
|
-
attr_accessor :content, :parser
|
101
|
-
attr_reader :request, :response
|
102
|
-
|
103
|
-
def initialize(root_path, request, response)
|
104
|
-
@root_path, @request, @response = root_path, request, response
|
105
|
-
@content = ''
|
106
|
-
end
|
107
|
-
|
108
|
-
include Serve::ViewHelpers
|
109
55
|
end
|
110
56
|
end
|
111
57
|
end
|