rack-server-pages 0.0.2 → 0.0.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/Gemfile +5 -4
- data/README.md +8 -3
- data/config.ru +29 -1
- data/lib/rack/server_pages.rb +79 -111
- data/lib/rack/server_pages/sample_helper.rb +91 -0
- data/public/README.erb +1 -0
- data/public/_layout.html.erb +1 -1
- data/public/sample.erb +5 -0
- data/public/style.css.sass +99 -0
- data/spec/lib/rack/server_pages_spec.rb +13 -0
- data/spec/spec_helper.rb +1 -1
- metadata +6 -5
- data/public/style.css +0 -106
data/Gemfile
CHANGED
@@ -9,10 +9,11 @@ group :development do
|
|
9
9
|
gem 'guard'
|
10
10
|
gem 'guard-bundler'
|
11
11
|
gem 'guard-rspec'
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
gem 'rb-readline'
|
13
|
+
gem 'rb-inotify', :require => false
|
14
|
+
gem 'rb-fsevent', :require => false
|
15
|
+
gem 'rb-fchange', :require => false
|
16
|
+
gem 'ruby_gntp'
|
16
17
|
end
|
17
18
|
|
18
19
|
group :test do
|
data/README.md
CHANGED
@@ -7,6 +7,7 @@ There are no controllers or models, just only views like a jsp, asp and php!
|
|
7
7
|
<http://github.com/migrs/rack-server-pages>
|
8
8
|
|
9
9
|
[](http://travis-ci.org/migrs/rack-server-pages)
|
10
|
+
[](https://gemnasium.com/migrs/rack-server-pages)
|
10
11
|
|
11
12
|
## Features
|
12
13
|
|
@@ -16,12 +17,14 @@ There are no controllers or models, just only views like a jsp, asp and php!
|
|
16
17
|
- Tilt support (optional)
|
17
18
|
- Include a partial template
|
18
19
|
- Layout template
|
20
|
+
- Before/After filters
|
21
|
+
- Include helpers
|
19
22
|
- Integrate with any rack applications (Rails, Sinatra, etc...)
|
20
23
|
- Extremely simple and easy to use!
|
21
24
|
|
22
25
|
## Requirements
|
23
26
|
|
24
|
-
- [Ruby](http://ruby-lang.org/) 1.8.7
|
27
|
+
- [Ruby](http://ruby-lang.org/) 1.8.7, 1.9.x, jruby 1.6.x
|
25
28
|
- [Rack](http://github.com/rack/rack)
|
26
29
|
|
27
30
|
## Install
|
@@ -267,6 +270,7 @@ or put your `Gemfile`
|
|
267
270
|
### [CoffeeScript](http://jashkenas.github.com/coffee-script/)
|
268
271
|
|
269
272
|
`views/script.js.coffee`
|
273
|
+
|
270
274
|
number = 42
|
271
275
|
opposite = true
|
272
276
|
|
@@ -343,6 +347,8 @@ Create `sinatra_sample.rb`
|
|
343
347
|
require 'sinatra'
|
344
348
|
require 'rack-server-pages'
|
345
349
|
|
350
|
+
use Rack::ServerPages
|
351
|
+
|
346
352
|
get '/' do
|
347
353
|
'<p>Hello Sinatra!</p>'
|
348
354
|
end
|
@@ -382,8 +388,7 @@ And create `public/info.php` :)
|
|
382
388
|
## ToDo
|
383
389
|
|
384
390
|
### Implements
|
385
|
-
-
|
386
|
-
- Support Helpers
|
391
|
+
- Error handling
|
387
392
|
- Static file generator (for designer)
|
388
393
|
|
389
394
|
### Tasks
|
data/config.ru
CHANGED
@@ -10,4 +10,32 @@ require 'slim'
|
|
10
10
|
Rack::ServerPages::Template::ERBTemplate.extensions << 'php' # ERBTemplate
|
11
11
|
Tilt.register Tilt::ERBTemplate, 'php' # TiltTemplate
|
12
12
|
|
13
|
-
|
13
|
+
module SampleHelper
|
14
|
+
def before
|
15
|
+
@sample1 = 'sample1'
|
16
|
+
end
|
17
|
+
|
18
|
+
def sample5
|
19
|
+
'sample5'
|
20
|
+
end
|
21
|
+
|
22
|
+
def after
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
run Rack::ServerPages.new { |config|
|
27
|
+
config.helpers SampleHelper
|
28
|
+
config.helpers do
|
29
|
+
def sample4
|
30
|
+
'sample4'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
config.before do
|
35
|
+
@sample2 = 'sample2'
|
36
|
+
|
37
|
+
def sample3
|
38
|
+
'sample3'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
}
|
data/lib/rack/server_pages.rb
CHANGED
@@ -8,7 +8,7 @@ require 'forwardable'
|
|
8
8
|
|
9
9
|
module Rack
|
10
10
|
class ServerPages
|
11
|
-
VERSION = '0.0.
|
11
|
+
VERSION = '0.0.3'
|
12
12
|
|
13
13
|
def self.call(env)
|
14
14
|
new.call(env)
|
@@ -22,6 +22,12 @@ module Rack
|
|
22
22
|
@config = Config.new(*options)
|
23
23
|
yield @config if block_given?
|
24
24
|
@app = app || @config.failure_app || NotFound
|
25
|
+
@binding = Class.new(Binding)
|
26
|
+
|
27
|
+
require ::File.dirname(__FILE__) + "/server_pages/sample_helper"
|
28
|
+
@config.helpers Rack::ServerPages::SampleHelper
|
29
|
+
|
30
|
+
@binding.setup(@config.helpers, @config.filters)
|
25
31
|
end
|
26
32
|
|
27
33
|
def call(env)
|
@@ -37,15 +43,7 @@ module Rack
|
|
37
43
|
file = select_template_file(files)
|
38
44
|
|
39
45
|
if template = Template[file]
|
40
|
-
|
41
|
-
scope.response.tap do |res|
|
42
|
-
catch(:halt) do
|
43
|
-
res.write template.render_with_layout(scope)
|
44
|
-
res['Last-Modified'] ||= ::File.mtime(file).httpdate
|
45
|
-
res['Content-Type'] ||= template.mime_type_with_charset(@config.default_charset)
|
46
|
-
res['Cache-Control'] ||= @config.cache_control if @config.cache_control
|
47
|
-
end
|
48
|
-
end.finish
|
46
|
+
render(template, @binding.new(env))
|
49
47
|
else
|
50
48
|
StaticFile.new(file, @config.cache_control).call(env)
|
51
49
|
end
|
@@ -54,8 +52,27 @@ module Rack
|
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
55
|
+
def render(template, scope)
|
56
|
+
scope.response.tap do |res|
|
57
|
+
catch(:halt) do
|
58
|
+
invoke_filter(:before, scope)
|
59
|
+
res.write template.render_with_layout(scope)
|
60
|
+
res['Last-Modified'] ||= ::File.mtime(template.file).httpdate
|
61
|
+
res['Content-Type'] ||= template.mime_type_with_charset(@config.default_charset)
|
62
|
+
res['Cache-Control'] ||= @config.cache_control if @config.cache_control
|
63
|
+
invoke_filter(:after, scope)
|
64
|
+
end
|
65
|
+
end.finish
|
66
|
+
end
|
67
|
+
|
68
|
+
def invoke_filter(type, scope)
|
69
|
+
@config.filters[type].each do |filter|
|
70
|
+
filter.respond_to?(:bind) ? filter.bind(scope).call : scope.instance_exec(&filter)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
57
74
|
def evalute_path_info(path)
|
58
|
-
if m = path.match(%r!^#{@config.effective_path}/((?:[\w-]+/)+)?([
|
75
|
+
if m = path.match(%r!^#{@config.effective_path}/((?:[\w-]+/)+)?([A-z0-9]\w*)?(\.\w+)?(\.\w+)?$!)
|
59
76
|
m[1,3] # dir, file, ext
|
60
77
|
end
|
61
78
|
end
|
@@ -84,16 +101,38 @@ module Rack
|
|
84
101
|
end
|
85
102
|
|
86
103
|
hash_accessor :view_path, :effective_path, :cache_control, :default_charset, :failure_app
|
104
|
+
attr_reader :filters
|
87
105
|
|
88
106
|
def initialize
|
89
107
|
super
|
90
108
|
self[:default_charset] ||= 'utf-8'
|
91
109
|
self[:view_path] ||= %w(views public)
|
110
|
+
@helpers = []
|
111
|
+
@filters = { :before => [], :after => [] }
|
92
112
|
end
|
93
113
|
|
94
114
|
def view_paths
|
95
115
|
(v = self[:view_path]).kind_of?(Enumerable) ? v : [v.to_s]
|
96
116
|
end
|
117
|
+
|
118
|
+
def before(*fn, &block)
|
119
|
+
add_filter(:before, *fn, &block)
|
120
|
+
end
|
121
|
+
|
122
|
+
def after(*fn, &block)
|
123
|
+
add_filter(:after, *fn, &block)
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_filter(type, *args, &block)
|
127
|
+
@filters[type] << block if block_given?
|
128
|
+
@filters[type].concat args unless args.empty?
|
129
|
+
end
|
130
|
+
|
131
|
+
def helpers(*args, &block)
|
132
|
+
@helpers << block if block_given?
|
133
|
+
@helpers.concat args unless args.empty?
|
134
|
+
@helpers
|
135
|
+
end
|
97
136
|
end
|
98
137
|
|
99
138
|
class NotFound
|
@@ -103,18 +142,25 @@ module Rack
|
|
103
142
|
end
|
104
143
|
|
105
144
|
class Template
|
145
|
+
|
106
146
|
def self.[] file
|
107
147
|
engine.new(file).find_template
|
108
148
|
end
|
109
149
|
|
110
150
|
def self.engine
|
111
|
-
|
151
|
+
tilt? ? TiltTemplate : ERBTemplate
|
112
152
|
end
|
113
153
|
|
114
154
|
def self.tilt?
|
115
|
-
|
155
|
+
(@@use_tilt ||= defined?(Tilt)) and defined?(Tilt)
|
156
|
+
end
|
157
|
+
|
158
|
+
def self.tilt= bool
|
159
|
+
@@use_tilt = !!bool
|
116
160
|
end
|
117
161
|
|
162
|
+
attr_reader :file
|
163
|
+
|
118
164
|
def initialize(file)
|
119
165
|
@file = file
|
120
166
|
end
|
@@ -124,7 +170,7 @@ module Rack
|
|
124
170
|
Mime.mime_type(ext, default_mime_type)
|
125
171
|
end
|
126
172
|
|
127
|
-
def mime_type_with_charset(charset)
|
173
|
+
def mime_type_with_charset(charset = 'utf-8')
|
128
174
|
if (m = mime_type) =~ %r!^(text/\w+|application/(?:javascript|(xhtml\+)?xml|json))$!
|
129
175
|
"#{m}; charset=#{charset}"
|
130
176
|
else
|
@@ -195,9 +241,9 @@ module Rack
|
|
195
241
|
halt
|
196
242
|
end
|
197
243
|
|
198
|
-
def partial(file)
|
244
|
+
def partial(file, &block)
|
199
245
|
if tpl_file = Dir["#{file}{.*,}"].first and template = Template[tpl_file]
|
200
|
-
template.render(self)
|
246
|
+
template.render(self, &block)
|
201
247
|
else
|
202
248
|
IO.read(file)
|
203
249
|
end
|
@@ -226,7 +272,7 @@ module Rack
|
|
226
272
|
end
|
227
273
|
|
228
274
|
def url(path = "")
|
229
|
-
env['SCRIPT_NAME'] + (path.to_s[0,1]!='/'?'/':'') + path.to_s
|
275
|
+
env['SCRIPT_NAME'] + (path.to_s[0,1]!= '/' ? '/' : '') + path.to_s
|
230
276
|
end
|
231
277
|
end
|
232
278
|
|
@@ -240,6 +286,22 @@ module Rack
|
|
240
286
|
def_delegators :request, :env, :params, :session, :cookies, :logger
|
241
287
|
def_delegators :response, :headers, :set_cookies, :delete_cookie
|
242
288
|
|
289
|
+
def self.setup(helpers, filters)
|
290
|
+
helpers.each do |helper|
|
291
|
+
if helper.kind_of? Proc
|
292
|
+
class_eval(&helper)
|
293
|
+
else
|
294
|
+
class_eval { include helper }
|
295
|
+
[:before, :after].each do |type|
|
296
|
+
if helper.method_defined?(type)
|
297
|
+
filters[type] << helper.instance_method(type)
|
298
|
+
class_eval { undef :"#{type}" }
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
243
305
|
def initialize(env)
|
244
306
|
@request = Rack::Request.new(env)
|
245
307
|
@response = Rack::Response.new
|
@@ -250,99 +312,5 @@ module Rack
|
|
250
312
|
binding
|
251
313
|
end
|
252
314
|
end
|
253
|
-
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
module Rack::ServerPages::Binding::Extra
|
258
|
-
require 'erb'
|
259
|
-
def rubyinfo
|
260
|
-
ERB.new(<<-RUBYINFO).result(binding)
|
261
|
-
<html><head>
|
262
|
-
<style type="text/css"><!--
|
263
|
-
body {background-color: #ffffff; color: #000000;}
|
264
|
-
body, td, th, h1, h2 {font-family: sans-serif;}
|
265
|
-
pre {margin: 0px; font-family: monospace;}
|
266
|
-
a:link {color: #000099; text-decoration: none; background-color: #ffffff;}
|
267
|
-
a:hover {text-decoration: underline;}
|
268
|
-
table {border-collapse: collapse;}
|
269
|
-
.center {text-align: center;}
|
270
|
-
.center table { margin-left: auto; margin-right: auto; text-align: left;}
|
271
|
-
.center th { text-align: center !important; }
|
272
|
-
td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}
|
273
|
-
h1 {font-size: 150%;}
|
274
|
-
h2 {font-size: 125%;}
|
275
|
-
.p {text-align: left;}
|
276
|
-
.e {background-color: #ccccff; font-weight: bold; color: #000000;}
|
277
|
-
.h {background-color: #9999cc; font-weight: bold; color: #000000;}
|
278
|
-
.v {background-color: #cccccc; color: #000000;}
|
279
|
-
i {color: #666666; background-color: #cccccc;}
|
280
|
-
img {float: right; border: 0px;}
|
281
|
-
hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}
|
282
|
-
//--></style>
|
283
|
-
<title>rubyinfo()</title>
|
284
|
-
</head>
|
285
|
-
<body>
|
286
|
-
<div class="center">
|
287
|
-
<table border="0" cellpadding="3" width="600">
|
288
|
-
<tr class="h">
|
289
|
-
<td>
|
290
|
-
<h1 class="p">Rack Server Pages Version <%= Rack::ServerPages::VERSION%></h1>
|
291
|
-
</td>
|
292
|
-
</tr>
|
293
|
-
</table>
|
294
|
-
<br />
|
295
|
-
<h2>Rack Environment</h2>
|
296
|
-
<table border="0" cellpadding="3" width="600">
|
297
|
-
<tr class="h"><th>Variable</th><th>Value</th></tr>
|
298
|
-
<% for key, value in env do %>
|
299
|
-
<tr><td class="e"><%= key %></td><td class="v"><%= value %></td></tr>
|
300
|
-
<% end %>
|
301
|
-
</table>
|
302
|
-
<h2>Ruby</h2>
|
303
|
-
<table border="0" cellpadding="3" width="600">
|
304
|
-
<tr><td class="e">RUBY_VERSION</td><td class="v"><%= RUBY_VERSION %></td></tr>
|
305
|
-
<tr><td class="e">RUBY_PATCHLEVEL</td><td class="v"><%= RUBY_PATCHLEVEL %></td></tr>
|
306
|
-
<tr><td class="e">RUBY_RELEASE_DATE</td><td class="v"><%= RUBY_RELEASE_DATE %></td></tr>
|
307
|
-
<tr><td class="e">RUBY_PLATFORM</td><td class="v"><%= RUBY_PLATFORM %></td></tr>
|
308
|
-
</table>
|
309
|
-
<h2>Environment</h2>
|
310
|
-
<table border="0" cellpadding="3" width="600">
|
311
|
-
<tr class="h"><th>Variable</th><th>Value</th></tr>
|
312
|
-
<% for key, value in ENV do %>
|
313
|
-
<tr><td class="e"><%= key %></td><td class="v"><%= value %></td></tr>
|
314
|
-
<% end %>
|
315
|
-
</table>
|
316
|
-
<% if defined?(Tilt) %>
|
317
|
-
<h2>Tilt</h2>
|
318
|
-
<table border="0" cellpadding="3" width="600">
|
319
|
-
<% for key, value in Tilt.mappings do %>
|
320
|
-
<tr><td class="e"><%= key %></td><td class="v"><%= value %></td></tr>
|
321
|
-
<% end %>
|
322
|
-
</table>
|
323
|
-
<% else %>
|
324
|
-
<h2>ERB Template</h2>
|
325
|
-
<table border="0" cellpadding="3" width="600">
|
326
|
-
<tr><td class="e">extensions</td><td class="v"><%=Rack::ServerPages::Template::ERBTemplate.extensions.join(', ')%></td></tr>
|
327
|
-
</table>
|
328
|
-
<% end %>
|
329
|
-
<h2>Binding</h2>
|
330
|
-
<table border="0" cellpadding="3" width="600">
|
331
|
-
<tr><td class="e">methods</td><td class="v"><%= (methods - Object.methods).join(', ') %></td></tr>
|
332
|
-
</table>
|
333
|
-
<h2>License</h2>
|
334
|
-
<table border="0" cellpadding="3" width="600">
|
335
|
-
<tr class="v"><td>
|
336
|
-
<p>
|
337
|
-
MIT License
|
338
|
-
</p>
|
339
|
-
</td></tr>
|
340
|
-
</table><br />
|
341
|
-
</div>
|
342
|
-
</body>
|
343
|
-
</html>
|
344
|
-
RUBYINFO
|
345
315
|
end
|
346
|
-
alias phpinfo rubyinfo # just a joke :)
|
347
316
|
end
|
348
|
-
Rack::ServerPages::Binding.send(:include, Rack::ServerPages::Binding::Extra)
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Rack::ServerPages::SampleHelper
|
2
|
+
require 'erb'
|
3
|
+
def rubyinfo
|
4
|
+
ERB.new(<<-RUBYINFO).result(binding)
|
5
|
+
<html><head>
|
6
|
+
<style type="text/css"><!--
|
7
|
+
body {background-color: #ffffff; color: #000000;}
|
8
|
+
body, td, th, h1, h2 {font-family: sans-serif;}
|
9
|
+
pre {margin: 0px; font-family: monospace;}
|
10
|
+
a:link {color: #000099; text-decoration: none; background-color: #ffffff;}
|
11
|
+
a:hover {text-decoration: underline;}
|
12
|
+
table {border-collapse: collapse;}
|
13
|
+
.center {text-align: center;}
|
14
|
+
.center table { margin-left: auto; margin-right: auto; text-align: left;}
|
15
|
+
.center th { text-align: center !important; }
|
16
|
+
td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}
|
17
|
+
h1 {font-size: 150%;}
|
18
|
+
h2 {font-size: 125%;}
|
19
|
+
.p {text-align: left;}
|
20
|
+
.e {background-color: #ccccff; font-weight: bold; color: #000000;}
|
21
|
+
.h {background-color: #9999cc; font-weight: bold; color: #000000;}
|
22
|
+
.v {background-color: #cccccc; color: #000000;}
|
23
|
+
i {color: #666666; background-color: #cccccc;}
|
24
|
+
img {float: right; border: 0px;}
|
25
|
+
hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}
|
26
|
+
//--></style>
|
27
|
+
<title>rubyinfo()</title>
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="center">
|
31
|
+
<table border="0" cellpadding="3" width="600">
|
32
|
+
<tr class="h">
|
33
|
+
<td>
|
34
|
+
<h1 class="p">Rack Server Pages Version <%= Rack::ServerPages::VERSION%></h1>
|
35
|
+
</td>
|
36
|
+
</tr>
|
37
|
+
</table>
|
38
|
+
<br />
|
39
|
+
<h2>Rack Environment</h2>
|
40
|
+
<table border="0" cellpadding="3" width="600">
|
41
|
+
<tr class="h"><th>Variable</th><th>Value</th></tr>
|
42
|
+
<% for key, value in env do %>
|
43
|
+
<tr><td class="e"><%= key %></td><td class="v"><%= value %></td></tr>
|
44
|
+
<% end %>
|
45
|
+
</table>
|
46
|
+
<h2>Ruby</h2>
|
47
|
+
<table border="0" cellpadding="3" width="600">
|
48
|
+
<tr><td class="e">RUBY_VERSION</td><td class="v"><%= RUBY_VERSION %></td></tr>
|
49
|
+
<tr><td class="e">RUBY_PATCHLEVEL</td><td class="v"><%= RUBY_PATCHLEVEL %></td></tr>
|
50
|
+
<tr><td class="e">RUBY_RELEASE_DATE</td><td class="v"><%= RUBY_RELEASE_DATE %></td></tr>
|
51
|
+
<tr><td class="e">RUBY_PLATFORM</td><td class="v"><%= RUBY_PLATFORM %></td></tr>
|
52
|
+
</table>
|
53
|
+
<h2>Environment</h2>
|
54
|
+
<table border="0" cellpadding="3" width="600">
|
55
|
+
<tr class="h"><th>Variable</th><th>Value</th></tr>
|
56
|
+
<% for key, value in ENV do %>
|
57
|
+
<tr><td class="e"><%= key %></td><td class="v"><%= value %></td></tr>
|
58
|
+
<% end %>
|
59
|
+
</table>
|
60
|
+
<% if defined?(Tilt) %>
|
61
|
+
<h2>Tilt</h2>
|
62
|
+
<table border="0" cellpadding="3" width="600">
|
63
|
+
<% for key, value in Tilt.mappings do %>
|
64
|
+
<tr><td class="e"><%= key %></td><td class="v"><%= value %></td></tr>
|
65
|
+
<% end %>
|
66
|
+
</table>
|
67
|
+
<% else %>
|
68
|
+
<h2>ERB Template</h2>
|
69
|
+
<table border="0" cellpadding="3" width="600">
|
70
|
+
<tr><td class="e">extensions</td><td class="v"><%=Rack::ServerPages::Template::ERBTemplate.extensions.join(', ')%></td></tr>
|
71
|
+
</table>
|
72
|
+
<% end %>
|
73
|
+
<h2>Binding</h2>
|
74
|
+
<table border="0" cellpadding="3" width="600">
|
75
|
+
<tr><td class="e">methods</td><td class="v"><%= (methods - Object.methods).join(', ') %></td></tr>
|
76
|
+
</table>
|
77
|
+
<h2>License</h2>
|
78
|
+
<table border="0" cellpadding="3" width="600">
|
79
|
+
<tr class="v"><td>
|
80
|
+
<p>
|
81
|
+
MIT License
|
82
|
+
</p>
|
83
|
+
</td></tr>
|
84
|
+
</table><br />
|
85
|
+
</div>
|
86
|
+
</body>
|
87
|
+
</html>
|
88
|
+
RUBYINFO
|
89
|
+
end
|
90
|
+
alias phpinfo rubyinfo # just a joke :)
|
91
|
+
end
|
data/public/README.erb
CHANGED
data/public/_layout.html.erb
CHANGED
data/public/sample.erb
CHANGED
@@ -0,0 +1,99 @@
|
|
1
|
+
body
|
2
|
+
margin: 0 auto
|
3
|
+
font-family: Georgia, Palatino, serif
|
4
|
+
color: #444444
|
5
|
+
line-height: 1
|
6
|
+
max-width: 960px
|
7
|
+
padding: 30px
|
8
|
+
|
9
|
+
h1, h2, h3, h4
|
10
|
+
color: #111111
|
11
|
+
font-weight: 400
|
12
|
+
|
13
|
+
h1, h2, h3, h4, h5, p
|
14
|
+
margin-bottom: 24px
|
15
|
+
padding: 0
|
16
|
+
|
17
|
+
h1
|
18
|
+
font-size: 48px
|
19
|
+
|
20
|
+
h2
|
21
|
+
font-size: 36px
|
22
|
+
margin: 24px 0 6px
|
23
|
+
|
24
|
+
h3
|
25
|
+
font-size: 24px
|
26
|
+
|
27
|
+
h4
|
28
|
+
font-size: 21px
|
29
|
+
|
30
|
+
h5
|
31
|
+
font-size: 18px
|
32
|
+
|
33
|
+
a
|
34
|
+
color: #0099ff
|
35
|
+
margin: 0
|
36
|
+
padding: 0
|
37
|
+
vertical-align: baseline
|
38
|
+
&:hover
|
39
|
+
text-decoration: none
|
40
|
+
color: #ff6600
|
41
|
+
&:visited
|
42
|
+
color: purple
|
43
|
+
|
44
|
+
//ul, ol {
|
45
|
+
// padding: 0;
|
46
|
+
// margin: 0;
|
47
|
+
//}
|
48
|
+
|
49
|
+
li
|
50
|
+
line-height: 24px
|
51
|
+
ul
|
52
|
+
margin-left: 24px
|
53
|
+
|
54
|
+
p, ul, ol
|
55
|
+
font-size: 16px
|
56
|
+
line-height: 24px
|
57
|
+
//max-width: 540px;
|
58
|
+
|
59
|
+
pre
|
60
|
+
padding: 5px 10px
|
61
|
+
max-width: 800px
|
62
|
+
white-space: pre-wrap
|
63
|
+
background-color: #eee
|
64
|
+
|
65
|
+
code
|
66
|
+
font-family: Consolas, Monaco, Andale Mono, monospace
|
67
|
+
line-height: 1.5
|
68
|
+
font-size: 13px
|
69
|
+
background-color: #eee
|
70
|
+
|
71
|
+
p
|
72
|
+
padding: 2px
|
73
|
+
margin: 2px
|
74
|
+
|
75
|
+
aside
|
76
|
+
display: block
|
77
|
+
float: right
|
78
|
+
width: 390px
|
79
|
+
|
80
|
+
blockquote
|
81
|
+
border-left: .5em solid #eee
|
82
|
+
padding: 0 2em
|
83
|
+
margin-left: 0
|
84
|
+
max-width: 476px
|
85
|
+
cite
|
86
|
+
font-size: 14px
|
87
|
+
line-height: 20px
|
88
|
+
color: #bfbfbf
|
89
|
+
cite:before
|
90
|
+
content: '\2014 \00A0'
|
91
|
+
p
|
92
|
+
color: #666
|
93
|
+
max-width: 460px
|
94
|
+
|
95
|
+
hr
|
96
|
+
width: 540px
|
97
|
+
text-align: left
|
98
|
+
margin: 0 auto 0 0
|
99
|
+
color: #999
|
@@ -1,9 +1,15 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
begin
|
3
|
+
require 'ruby-debug'
|
4
|
+
require 'tapp'
|
5
|
+
rescue LoadError
|
6
|
+
end
|
2
7
|
|
3
8
|
describe 'Rack::ServerPages' do
|
4
9
|
describe 'Basic requests' do
|
5
10
|
before { get path_info }
|
6
11
|
subject { last_response }
|
12
|
+
let(:content_type) { 'text/html' }
|
7
13
|
|
8
14
|
should_be_ok '/'
|
9
15
|
should_be_not_found '/hoge'
|
@@ -24,6 +30,13 @@ describe 'Rack::ServerPages' do
|
|
24
30
|
should_be_ok '/examples/index.html'
|
25
31
|
should_be_not_found '/examples/index.htm'
|
26
32
|
should_be_not_found '/examples/.htaccess'
|
33
|
+
|
34
|
+
context 'content-type: text/css' do
|
35
|
+
let(:content_type) { 'text/css' }
|
36
|
+
should_be_ok '/betty'
|
37
|
+
should_be_ok '/betty.css'
|
38
|
+
should_be_ok '/betty.css.sass'
|
39
|
+
end
|
27
40
|
end
|
28
41
|
|
29
42
|
describe 'Rack::ServerPages private methods' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-server-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-06 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
16
|
-
requirement: &
|
16
|
+
requirement: &70252865364220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70252865364220
|
25
25
|
description: ! "Rack middleware and appilcation for serving dynamic pages in very
|
26
26
|
simple way.\n There are no controllers and no models, just only
|
27
27
|
views like a asp, jsp and php!"
|
@@ -41,12 +41,13 @@ files:
|
|
41
41
|
- config.ru
|
42
42
|
- lib/rack-server-pages.rb
|
43
43
|
- lib/rack/server_pages.rb
|
44
|
+
- lib/rack/server_pages/sample_helper.rb
|
44
45
|
- public/README.erb
|
45
46
|
- public/_layout.html.erb
|
46
47
|
- public/index.html
|
47
48
|
- public/info.php
|
48
49
|
- public/sample.erb
|
49
|
-
- public/style.css
|
50
|
+
- public/style.css.sass
|
50
51
|
- rack-server-pages.gemspec
|
51
52
|
- spec/lib/rack/server_pages_spec.rb
|
52
53
|
- spec/spec_helper.rb
|
data/public/style.css
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
body{
|
2
|
-
margin: 0 auto;
|
3
|
-
font-family: Georgia, Palatino, serif;
|
4
|
-
color: #444444;
|
5
|
-
line-height: 1;
|
6
|
-
max-width: 960px;
|
7
|
-
padding: 30px;
|
8
|
-
}
|
9
|
-
h1, h2, h3, h4 {
|
10
|
-
color: #111111;
|
11
|
-
font-weight: 400;
|
12
|
-
}
|
13
|
-
h1, h2, h3, h4, h5, p {
|
14
|
-
margin-bottom: 24px;
|
15
|
-
padding: 0;
|
16
|
-
}
|
17
|
-
h1 {
|
18
|
-
font-size: 48px;
|
19
|
-
}
|
20
|
-
h2 {
|
21
|
-
font-size: 36px;
|
22
|
-
margin: 24px 0 6px;
|
23
|
-
}
|
24
|
-
h3 {
|
25
|
-
font-size: 24px;
|
26
|
-
}
|
27
|
-
h4 {
|
28
|
-
font-size: 21px;
|
29
|
-
}
|
30
|
-
h5 {
|
31
|
-
font-size: 18px;
|
32
|
-
}
|
33
|
-
a {
|
34
|
-
color: #0099ff;
|
35
|
-
margin: 0;
|
36
|
-
padding: 0;
|
37
|
-
vertical-align: baseline;
|
38
|
-
}
|
39
|
-
a:hover {
|
40
|
-
text-decoration: none;
|
41
|
-
color: #ff6600;
|
42
|
-
}
|
43
|
-
a:visited {
|
44
|
-
color: purple;
|
45
|
-
}
|
46
|
-
/*ul, ol {
|
47
|
-
padding: 0;
|
48
|
-
margin: 0;
|
49
|
-
}*/
|
50
|
-
li {
|
51
|
-
line-height: 24px;
|
52
|
-
}
|
53
|
-
li ul, li ul {
|
54
|
-
margin-left: 24px;
|
55
|
-
}
|
56
|
-
p, ul, ol {
|
57
|
-
font-size: 16px;
|
58
|
-
line-height: 24px;
|
59
|
-
/*max-width: 540px;*/
|
60
|
-
}
|
61
|
-
pre {
|
62
|
-
padding: 5px 10px;
|
63
|
-
max-width: 800px;
|
64
|
-
white-space: pre-wrap;
|
65
|
-
background-color: #eee;
|
66
|
-
}
|
67
|
-
code {
|
68
|
-
font-family: Consolas, Monaco, Andale Mono, monospace;
|
69
|
-
line-height: 1.5;
|
70
|
-
font-size: 13px;
|
71
|
-
background-color: #eee;
|
72
|
-
}
|
73
|
-
p {
|
74
|
-
padding: 2px;
|
75
|
-
margin: 2px;
|
76
|
-
}
|
77
|
-
aside {
|
78
|
-
display: block;
|
79
|
-
float: right;
|
80
|
-
width: 390px;
|
81
|
-
}
|
82
|
-
blockquote {
|
83
|
-
border-left:.5em solid #eee;
|
84
|
-
padding: 0 2em;
|
85
|
-
margin-left:0;
|
86
|
-
max-width: 476px;
|
87
|
-
}
|
88
|
-
blockquote cite {
|
89
|
-
font-size:14px;
|
90
|
-
line-height:20px;
|
91
|
-
color:#bfbfbf;
|
92
|
-
}
|
93
|
-
blockquote cite:before {
|
94
|
-
content: '\2014 \00A0';
|
95
|
-
}
|
96
|
-
|
97
|
-
blockquote p {
|
98
|
-
color: #666;
|
99
|
-
max-width: 460px;
|
100
|
-
}
|
101
|
-
hr {
|
102
|
-
width: 540px;
|
103
|
-
text-align: left;
|
104
|
-
margin: 0 auto 0 0;
|
105
|
-
color: #999;
|
106
|
-
}
|