rack-server-pages 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ebf547288c35a2abec6e0bb9fddf1dfa094a6322
4
+ data.tar.gz: 85605af0f15440c8e6c8467def3304ddedcee9cf
5
+ SHA512:
6
+ metadata.gz: 3731a45b3094f36fbc7dc90527be0c197dda36f28e17d2392157f7e73a863c6a847e5ea92b8b454361b0d3733526399b94ec1c73cce71e639aeba1d7394832d5
7
+ data.tar.gz: 278a20953b594143592e2453cf8b048063b3a0c0f37311d6ac69e47090e79a1f8ffdc118732bdb69e0e29e273113151b8e393a0ebc94383d236375ef2b04ac33
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format=documentation
2
+ --color
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,96 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-10-25 11:22:12 -0400 using RuboCop version 0.44.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Lint/AmbiguousRegexpLiteral:
11
+ Exclude:
12
+ - 'spec/spec_helper.rb'
13
+
14
+ # Offense count: 1
15
+ # Configuration parameters: AllowSafeAssignment.
16
+ Lint/AssignmentInCondition:
17
+ Exclude:
18
+ - 'lib/rack/server_pages.rb'
19
+
20
+ # Offense count: 1
21
+ Lint/HandleExceptions:
22
+ Exclude:
23
+ - 'spec/lib/rack/server_pages_spec.rb'
24
+
25
+ # Offense count: 1
26
+ Lint/UselessAssignment:
27
+ Exclude:
28
+ - 'lib/rack/server_pages.rb'
29
+
30
+ # Offense count: 2
31
+ Metrics/AbcSize:
32
+ Max: 19
33
+
34
+ # Offense count: 1
35
+ # Configuration parameters: CountComments.
36
+ Metrics/BlockLength:
37
+ Max: 32
38
+
39
+ # Offense count: 20
40
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
41
+ # URISchemes: http, https
42
+ Metrics/LineLength:
43
+ Max: 113
44
+
45
+ # Offense count: 3
46
+ # Configuration parameters: CountComments.
47
+ Metrics/MethodLength:
48
+ Max: 85
49
+
50
+ # Offense count: 1
51
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
52
+ # SupportedStyles: nested, compact
53
+ Style/ClassAndModuleChildren:
54
+ Exclude:
55
+ - 'lib/rack/server_pages/php_helper.rb'
56
+
57
+ # Offense count: 12
58
+ Style/Documentation:
59
+ Exclude:
60
+ - 'spec/**/*'
61
+ - 'test/**/*'
62
+ - 'config.ru'
63
+ - 'lib/rack/server_pages.rb'
64
+ - 'lib/rack/server_pages/php_helper.rb'
65
+
66
+ # Offense count: 2
67
+ Style/DoubleNegation:
68
+ Exclude:
69
+ - 'lib/rack/server_pages.rb'
70
+
71
+ # Offense count: 1
72
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
73
+ Style/FileName:
74
+ Exclude:
75
+ - 'lib/rack-server-pages.rb'
76
+
77
+ # Offense count: 2
78
+ # Configuration parameters: MinBodyLength.
79
+ Style/GuardClause:
80
+ Exclude:
81
+ - 'lib/rack/server_pages.rb'
82
+
83
+ # Offense count: 1
84
+ # Cop supports --auto-correct.
85
+ # Configuration parameters: AllowAsExpressionSeparator.
86
+ Style/Semicolon:
87
+ Exclude:
88
+ - 'spec/lib/rack/server_pages_spec.rb'
89
+
90
+ # Offense count: 1
91
+ # Cop supports --auto-correct.
92
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
93
+ # SupportedStyles: use_perl_names, use_english_names
94
+ Style/SpecialGlobalVars:
95
+ Exclude:
96
+ - 'lib/rack/server_pages.rb'
@@ -1,6 +1,12 @@
1
1
  language: ruby
2
+
3
+ cache: bundler
4
+
2
5
  rvm:
3
- - 1.8.7
4
- - 1.9.2
5
- - 1.9.3
6
- - jruby
6
+ - 2.2.6
7
+ - 2.3.3
8
+ - 2.4.0
9
+
10
+ before_install:
11
+ - "export DISPLAY=:99.0"
12
+ - "sh -e /etc/init.d/xvfb start"
data/CHANGES.md CHANGED
@@ -1,6 +1,25 @@
1
1
  CHANGES
2
2
  =======
3
3
 
4
+ ### [Next](https://github.com/migrs/rack-server-pages/tree/master)
5
+
6
+ * [Changes](https://github.com/migrs/rack-server-pages/compare/v0.1.0...master)
7
+
8
+ ### [v0.1.0](https://github.com/migrs/rack-server-pages/tree/master)
9
+
10
+ * [Changes](https://github.com/migrs/rack-server-pages/compare/v0.0.6...v0.1.0)
11
+
12
+ * Bugfix
13
+ - Fix [#5](https://github.com/migrs/rack-server-pages/issues/5): compatibility with Rack 2.0 [@dblock](http://github.com/dblock)
14
+ - Fix [#4](https://github.com/migrs/rack-server-pages/issues/4): did not work redirect helper
15
+
16
+ * Misc
17
+ - No longer tested against Ruby < 2.2
18
+ - Added Rubocop, Ruby linter
19
+ - Upgraded to RSpec 3.x
20
+ - Added integration tests with Capybara
21
+ - Tested with Tilt 2.0
22
+
4
23
  ### [0.0.6](https://github.com/migrs/rack-server-pages/tree/v0.0.6) / 2012-05-16
5
24
 
6
25
  * [Changes](https://github.com/migrs/rack-server-pages/compare/v0.0.5...v0.0.6)
@@ -43,7 +62,7 @@ CHANGES
43
62
 
44
63
  * Documents
45
64
  - Filters and Helpers
46
- - Add [CHAMGES.md](https://github.com/migrs/rack-server-pages/blob/master/CHAMGES.md) (this document)
65
+ - Add [CHANGES.md](https://github.com/migrs/rack-server-pages/blob/master/CHANGES.md) (this document)
47
66
 
48
67
 
49
68
  ### [0.0.3](https://github.com/migrs/rack-server-pages/tree/v0.0.3) / 2012-01-06
data/Gemfile CHANGED
@@ -1,54 +1,40 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
2
4
 
3
- #gemspec
4
5
  gem 'rack'
5
6
 
6
- group :development do
7
+ group :development, :test do
7
8
  gem 'rake'
8
- gem 'thin'
9
- gem 'guard'
10
- gem 'guard-bundler'
11
- gem 'guard-rspec'
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'
17
- end
18
-
19
- group :test do
9
+ gem 'rubocop', '0.44.1'
20
10
  gem 'simplecov'
21
- gem 'rack-test', :require => 'rack/test'
11
+ gem 'rack-test', require: 'rack/test'
22
12
  gem 'rspec'
23
- end
24
-
25
- group :development, :test do
13
+ gem 'rspec-its'
14
+ gem 'slim'
15
+ gem 'sass'
26
16
  gem 'tapp'
27
- # gem 'ruby-debug', :platforms => :ruby_18
28
- # gem 'ruby-debug19', :require => 'ruby-debug', :platforms => :ruby_19
17
+ gem 'tilt', '>=2.0'
18
+ gem 'RedCloth'
19
+ gem 'bluecloth'
20
+ # gem 'builder'
21
+ gem 'coffee-script'
22
+ gem 'contest'
23
+ gem 'creole'
24
+ gem 'erubis'
25
+ gem 'haml'
26
+ gem 'kramdown'
27
+ # gem 'less'
28
+ gem 'liquid'
29
+ # gem 'markaby'
30
+ gem 'maruku'
31
+ gem 'nokogiri'
32
+ gem 'radius'
33
+ gem 'rdiscount'
34
+ gem 'rdoc'
35
+ # gem 'wikicloth'
36
+ gem 'yajl-ruby'
37
+ gem 'capybara'
38
+ gem 'selenium-webdriver', '~>2.5'
39
+ # gem 'therubyracer'
29
40
  end
30
-
31
- # Tilt
32
- gem 'tilt'
33
- gem 'RedCloth'
34
- gem 'bluecloth'
35
- gem 'builder'
36
- gem 'coffee-script'
37
- gem 'contest'
38
- gem 'creole'
39
- gem 'erubis'
40
- gem 'haml'
41
- gem 'kramdown'
42
- gem 'less', :platforms => [:ruby_18, :ruby_19]
43
- gem 'liquid'
44
- gem 'markaby'
45
- gem 'maruku'
46
- gem 'nokogiri'
47
- gem 'radius'
48
- gem 'rdiscount'
49
- gem 'rdoc'
50
- #gem 'redcarpet'
51
- gem 'sass'
52
- gem 'wikicloth'
53
- gem 'yajl-ruby'
54
- gem 'slim'
data/Guardfile CHANGED
@@ -6,11 +6,11 @@ group 'backend' do
6
6
  # Uncomment next line if Gemfile contain `gemspec' command
7
7
  # watch(/^.+\.gemspec/)
8
8
  end
9
- guard 'rspec', :cli => '--color --format nested', :bundler => true do
9
+ guard 'rspec', cli: '--color --format nested', bundler: true do
10
10
  watch(%r{^lib/([\w/]+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
11
11
 
12
12
  watch(%r{^spec/(.+)\_spec.rb}) { |m| "spec/#{m[1]}_spec.rb" }
13
13
 
14
- watch('spec/spec_helper.rb') { "bundle exec rake spec" }
14
+ watch('spec/spec_helper.rb') { 'bundle exec rake spec' }
15
15
  end
16
16
  end
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2012-2016 Masato Igarashi and Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,14 +1,13 @@
1
1
  Rack Server Pages
2
2
  =================
3
3
 
4
- Rack middleware and application for serving dynamic pages in very simple way.
4
+ Rack middleware and application for serving dynamic pages in very simple way.
5
5
  There are no controllers or models, just only views like a jsp, asp and php!
6
6
 
7
7
  <http://github.com/migrs/rack-server-pages>
8
8
 
9
- [![Build Status](https://secure.travis-ci.org/migrs/rack-server-pages.png)](http://travis-ci.org/migrs/rack-server-pages)
10
- [![Dependency Status](https://gemnasium.com/migrs/rack-server-pages.png?travis)](https://gemnasium.com/migrs/rack-server-pages)
11
- [![Still Maintained](http://stillmaintained.com/migrs/rack-server-pages.png)](http://stillmaintained.com/migrs/rack-server-pages)
9
+ [![Build Status](https://travis-ci.org/migrs/rack-server-pages.svg?branch=master)](https://travis-ci.org/migrs/rack-server-pages)
10
+ [![Gem Version](https://badge.fury.io/rb/rack-server-pages.svg)](http://badge.fury.io/rb/rack-server-pages)
12
11
 
13
12
  ## Features
14
13
 
@@ -26,14 +25,16 @@ There are no controllers or models, just only views like a jsp, asp and php!
26
25
 
27
26
  ## Requirements
28
27
 
29
- - [Ruby](http://ruby-lang.org/) 1.8.7, 1.9.x, jruby 1.6.x
28
+ - [Ruby](http://ruby-lang.org/) >= 2.2.2
30
29
  - [Rack](http://github.com/rack/rack)
31
30
 
32
31
  ## Install
33
32
 
34
33
  [RubyGems](http://rubygems.org/gems/rack-server-pages) available
35
34
 
36
- gem install rack-server-pages
35
+ ```
36
+ gem install rack-server-pages
37
+ ```
37
38
 
38
39
  ## Basic usage
39
40
 
@@ -41,17 +42,23 @@ There are no controllers or models, just only views like a jsp, asp and php!
41
42
 
42
43
  Create `config.ru`
43
44
 
44
- require 'rack-server-pages'
45
- run Rack::ServerPages
45
+ ```ruby
46
+ require 'rack-server-pages'
47
+ run Rack::ServerPages
48
+ ```
46
49
 
47
50
  Create `public/index.erb`
48
51
 
49
- <h1>Hello rack!</h1>
50
- <p><%= Time.now %></p>
52
+ ```html
53
+ <h1>Hello rack!</h1>
54
+ <p><%= Time.now %></p>
55
+ ```
51
56
 
52
57
  Finally running `rackup`
53
58
 
54
- rackup
59
+ ```
60
+ rackup
61
+ ```
55
62
 
56
63
  and visit <http://localhost:9292/>
57
64
 
@@ -66,9 +73,11 @@ Valid requests,
66
73
 
67
74
  Edit `config.ru`
68
75
 
69
- require 'rack-server-pages'
70
- use Rack::ServerPages
71
- run Rack::ServerPages::NotFound # or your MyApp
76
+ ```ruby
77
+ require 'rack-server-pages'
78
+ use Rack::ServerPages
79
+ run Rack::ServerPages::NotFound # or your MyApp
80
+ ```
72
81
 
73
82
  And same as above.
74
83
 
@@ -105,25 +114,33 @@ And same as above.
105
114
 
106
115
  with parameter
107
116
 
108
- use Rack::ServerPages, :view_path => 'public'
117
+ ```ruby
118
+ use Rack::ServerPages, :view_path => 'public'
119
+ ```
109
120
 
110
121
  with block
111
122
 
112
- use Rack::ServerPages do |config|
113
- config.view_path = 'public'
114
- end
123
+ ```ruby
124
+ use Rack::ServerPages do |config|
125
+ config.view_path = 'public'
126
+ end
127
+ ```
115
128
 
116
129
  ### Rack application
117
130
 
118
131
  with parameter
119
132
 
120
- run Rack::ServerPages[:view_path => 'public']
133
+ ```ruby
134
+ run Rack::ServerPages[:view_path => 'public']
135
+ ```
121
136
 
122
137
  with block
123
138
 
124
- run Rack::ServerPages.new { |config|
125
- config.view_path = 'public'
126
- }
139
+ ```ruby
140
+ run Rack::ServerPages.new { |config|
141
+ config.view_path = 'public'
142
+ }
143
+ ```
127
144
 
128
145
  ### Options
129
146
 
@@ -147,97 +164,115 @@ with block
147
164
 
148
165
  with helpers block
149
166
 
150
- use Rack::ServerPages do |config|
151
- config.helpers do
152
- def three_times(name)
153
- "#{([name.to_s]*3).join(' ')}!!"
154
- end
155
- end
167
+ ```ruby
168
+ use Rack::ServerPages do |config|
169
+ config.helpers do
170
+ def three_times(name)
171
+ "#{([name.to_s]*3).join(' ')}!!"
156
172
  end
173
+ end
174
+ end
175
+ ```
157
176
 
158
177
  in view file (erb)
159
178
 
160
- <%= three_times('blah') %>
179
+ ```erb
180
+ <%= three_times('blah') %>
181
+ ```
161
182
 
162
183
  with helper module
163
184
 
164
- module SampleHelper
165
- def three_times(name)
166
- "#{([name.to_s]*3).join(' ')}!!"
167
- end
168
- end
185
+ ```ruby
186
+ module SampleHelper
187
+ def three_times(name)
188
+ "#{([name.to_s]*3).join(' ')}!!"
189
+ end
190
+ end
169
191
 
170
- use Rack::ServerPages do |config|
171
- config.helpers SampleHelper
172
- end
192
+ use Rack::ServerPages do |config|
193
+ config.helpers SampleHelper
194
+ end
195
+ ```
173
196
 
174
197
  with procs
175
198
 
176
- help1 = proc do
177
- def three_times(name)
178
- "#{([name.to_s]*3).join(' ')}!!"
179
- end
180
- end
199
+ ```ruby
200
+ help1 = proc do
201
+ def three_times(name)
202
+ "#{([name.to_s]*3).join(' ')}!!"
203
+ end
204
+ end
181
205
 
182
- help2 = proc {...}
206
+ help2 = proc {...}
183
207
 
184
- use Rack::ServerPages do |config|
185
- config.helpers help1, help2
186
- end
208
+ use Rack::ServerPages do |config|
209
+ config.helpers help1, help2
210
+ end
211
+ ```
187
212
 
188
213
  ### Filters
189
214
 
190
215
  with before/after block
191
216
 
192
- use Rack::ServerPages do |config|
193
- config.before do
194
- @title = 'Hello!'
195
- end
217
+ ```ruby
218
+ use Rack::ServerPages do |config|
219
+ config.before do
220
+ @title = 'Hello!'
221
+ end
196
222
 
197
- config.after do
198
- logger.debug 'xxxx'
199
- end
200
- end
223
+ config.after do
224
+ logger.debug 'xxxx'
225
+ end
226
+ end
227
+ ```
201
228
 
202
229
  with procs
203
230
 
204
- proc1 = proc { @name = 'Jonny' }
205
- proc2 = proc { @age = 24 }
206
- proc3 = proc { logger.debug 'xxxx' }
231
+ ```ruby
232
+ proc1 = proc { @name = 'Jonny' }
233
+ proc2 = proc { @age = 24 }
234
+ proc3 = proc { logger.debug 'xxxx' }
207
235
 
208
- use Rack::ServerPages do |config|
209
- config.before proc1, proc2
210
- config.after proc3
211
- end
236
+ use Rack::ServerPages do |config|
237
+ config.before proc1, proc2
238
+ config.after proc3
239
+ end
240
+ ```
212
241
 
213
242
  if you define before/after method in helper module, it will be treated as filters
214
243
 
215
- module SampleHelper
216
- def before
217
- @title = 'Hello!'
218
- end
244
+ ```ruby
245
+ module SampleHelper
246
+ def before
247
+ @title = 'Hello!'
248
+ end
219
249
 
220
- def three_times(name)
221
- "#{([name.to_s]*3).join(' ')}!!"
222
- end
223
- end
250
+ def three_times(name)
251
+ "#{([name.to_s]*3).join(' ')}!!"
252
+ end
253
+ end
224
254
 
225
- use Rack::ServerPages do |config|
226
- config.helpers SampleHelper
227
- end
255
+ use Rack::ServerPages do |config|
256
+ config.helpers SampleHelper
257
+ end
258
+ ```
228
259
 
229
260
  in view file
230
261
 
231
- <%= three_times(@title) %>
262
+ ```erb
263
+ <%= three_times(@title) %>
264
+ ```
232
265
 
233
266
  ## Tilt support
234
- [Tilt](http://github.com/rtomayko/tilt) is generic interface to multiple Ruby template engines.
267
+ [Tilt](http://github.com/rtomayko/tilt) is generic interface to multiple Ruby template engines.
235
268
  If you want to use Tilt, just `require 'tilt'` and require template engine libraries that you want.
236
269
 
237
- require 'rack-server-pages'
238
- require 'tilt'
239
- require 'rdiscount' # markdown library
240
- run Rack::ServerPages
270
+ ```ruby
271
+ require 'rack-server-pages'
272
+ require 'tilt'
273
+ require 'rdiscount' # markdown library
274
+ run Rack::ServerPages
275
+ ```
241
276
 
242
277
  or put your `Gemfile`
243
278
 
@@ -245,161 +280,181 @@ or put your `Gemfile`
245
280
 
246
281
  `views/article.html.md`
247
282
 
248
- A First Level Header
249
- ====================
283
+ ```markdown
284
+ A First Level Header
285
+ ====================
250
286
 
251
- A Second Level Header
252
- ---------------------
287
+ A Second Level Header
288
+ ---------------------
253
289
 
254
- Now is the time for all good men to come to
255
- the aid of their country. This is just a
256
- regular paragraph.
290
+ Now is the time for all good men to come to
291
+ the aid of their country. This is just a
292
+ regular paragraph.
257
293
 
258
- ### Header 3
294
+ ### Header 3
259
295
 
260
- > This is a blockquote.
261
- > Thank you
296
+ > This is a blockquote.
297
+ > Thank you
262
298
 
263
- [source](http://github.com/migrs/rack-server-pages)
299
+ [source](http://github.com/migrs/rack-server-pages)
300
+ ```
264
301
 
265
302
  <http://localhost:9292/article.html>
266
303
 
267
- <h1>A First Level Header</h1>
304
+ ```html
305
+ <h1>A First Level Header</h1>
268
306
 
269
- <h2>A Second Level Header</h2>
307
+ <h2>A Second Level Header</h2>
270
308
 
271
- <p>Now is the time for all good men to come to
272
- the aid of their country. This is just a
273
- regular paragraph.</p>
309
+ <p>Now is the time for all good men to come to
310
+ the aid of their country. This is just a
311
+ regular paragraph.</p>
274
312
 
275
- <h3>Header 3</h3>
313
+ <h3>Header 3</h3>
276
314
 
277
- <blockquote><p>This is a blockquote.
278
- Thank you</p></blockquote>
315
+ <blockquote><p>This is a blockquote.
316
+ Thank you</p></blockquote>
279
317
 
280
- <p><a href="http://github.com/migrs/rack-server-pages">source</a></p>
318
+ <p><a href="http://github.com/migrs/rack-server-pages">source</a></p>
319
+ ```
281
320
 
282
321
 
283
322
  ### [Slim](http://slim-lang.com/)
284
323
 
285
324
  `views/about.html.slim`
286
325
 
287
- doctype html
288
- html
289
- head
290
- title Slim Core Example
291
- meta name="keywords" content="template language"
326
+ ```slim
327
+ doctype html
328
+ html
329
+ head
330
+ title Slim Core Example
331
+ meta name="keywords" content="template language"
292
332
 
293
- body
294
- h1 Markup examples
333
+ body
334
+ h1 Markup examples
295
335
 
296
- div id="content" class="example1"
297
- p Nest by indentation
336
+ div id="content" class="example1"
337
+ p Nest by indentation
338
+ ```
298
339
 
299
340
  <http://localhost:9292/about.html>
300
341
 
301
- <!DOCTYPE html>
302
- <html>
303
- <head>
304
- <title>Slim Core Example</title>
305
- <meta content="template language" name="keywords" />
306
- </head>
307
- <body>
308
- <h1>Markup examples</h1>
309
- <div class="example1" id="content">
310
- <p>Nest by indentation</p>
311
- </div>
312
- </body>
313
- </html>
342
+ ```html
343
+ <!DOCTYPE html>
344
+ <html>
345
+ <head>
346
+ <title>Slim Core Example</title>
347
+ <meta content="template language" name="keywords" />
348
+ </head>
349
+ <body>
350
+ <h1>Markup examples</h1>
351
+ <div class="example1" id="content">
352
+ <p>Nest by indentation</p>
353
+ </div>
354
+ </body>
355
+ </html>
356
+ ```
314
357
 
315
358
  ### [Sass](http://sass-lang.com/)
316
359
 
317
360
  `views/betty.css.sass`
318
361
 
319
- $blue: #3bbfce
320
- $margin: 16px
362
+ ```sass
363
+ $blue: #3bbfce
364
+ $margin: 16px
321
365
 
322
- .content-navigation
323
- border-color: $blue
324
- color: darken($blue, 9%)
366
+ .content-navigation
367
+ border-color: $blue
368
+ color: darken($blue, 9%)
325
369
 
326
- .border
327
- padding: $margin / 2
328
- margin: $margin / 2
329
- border-color: $blue
370
+ .border
371
+ padding: $margin / 2
372
+ margin: $margin / 2
373
+ border-color: $blue
374
+ ```
330
375
 
331
376
  <http://localhost:9292/betty.css>
332
377
 
333
- .content-navigation {
334
- border-color: #3bbfce;
335
- color: #2ca2af; }
378
+ ```css
379
+ .content-navigation {
380
+ border-color: #3bbfce;
381
+ color: #2ca2af; }
336
382
 
337
- .border {
338
- padding: 8px;
339
- margin: 8px;
340
- border-color: #3bbfce; }
383
+ .border {
384
+ padding: 8px;
385
+ margin: 8px;
386
+ border-color: #3bbfce; }
387
+ ```
341
388
 
342
389
  ### [Builder](http://builder.rubyforge.org/)
343
390
 
344
391
  `views/contact.xml.builder`
345
392
 
346
- xml.instruct!
347
- xml.result do |result|
348
- result.name "John"
349
- result.phone "910-1974"
350
- end
393
+ ```ruby
394
+ xml.instruct!
395
+ xml.result do |result|
396
+ result.name "John"
397
+ result.phone "910-1974"
398
+ end
399
+ ```
351
400
 
352
401
  <http://localhost:9292/contact.xml>
353
402
 
354
- <result>
355
- <name>John</name>
356
- <phone>910-1974</phone>
357
- </result>
403
+ ```xml
404
+ <result>
405
+ <name>John</name>
406
+ <phone>910-1974</phone>
407
+ </result>
408
+ ```
358
409
 
359
410
  ### [CoffeeScript](http://jashkenas.github.com/coffee-script/)
360
411
 
361
412
  `views/script.js.coffee`
362
413
 
363
- number = 42
364
- opposite = true
414
+ ```coffee
415
+ number = 42
416
+ opposite = true
365
417
 
366
- number = -42 if opposite
418
+ number = -42 if opposite
367
419
 
368
- square = (x) -> x * x
420
+ square = (x) -> x * x
369
421
 
370
- list = [1, 2, 3, 4, 5]
422
+ list = [1, 2, 3, 4, 5]
371
423
 
372
- math =
373
- root: Math.sqrt
374
- square: square
375
- cube: (x) -> x * square x
424
+ math =
425
+ root: Math.sqrt
426
+ square: square
427
+ cube: (x) -> x * square x
428
+ ```
376
429
 
377
430
  <http://localhost:9292/script.js>
378
431
 
379
- (function() {
380
- var list, math, number, opposite, square;
432
+ ```javascript
433
+ (function() {
434
+ var list, math, number, opposite, square;
381
435
 
382
- number = 42;
436
+ number = 42;
383
437
 
384
- opposite = true;
438
+ opposite = true;
385
439
 
386
- if (opposite) number = -42;
440
+ if (opposite) number = -42;
387
441
 
388
- square = function(x) {
389
- return x * x;
390
- };
442
+ square = function(x) {
443
+ return x * x;
444
+ };
391
445
 
392
- list = [1, 2, 3, 4, 5];
446
+ list = [1, 2, 3, 4, 5];
393
447
 
394
- math = {
395
- root: Math.sqrt,
396
- square: square,
397
- cube: function(x) {
398
- return x * square(x);
399
- }
400
- };
448
+ math = {
449
+ root: Math.sqrt,
450
+ square: square,
451
+ cube: function(x) {
452
+ return x * square(x);
453
+ }
454
+ };
401
455
 
402
- }).call(this);
456
+ }).call(this);
457
+ ```
403
458
 
404
459
  see more <http://localhost:9292/examples/>
405
460
 
@@ -407,24 +462,32 @@ see more <http://localhost:9292/examples/>
407
462
 
408
463
  At first, create sample file: `public/hello.erb` or `views/hello.html.erb`
409
464
 
410
- <p>Hello Rack Server Pages!</p>
411
- <p><%= Time.now %></p>
465
+ ```html
466
+ <p>Hello Rack Server Pages!</p>
467
+ <p><%= Time.now %></p>
468
+ ```
412
469
 
413
470
  ### Rails
414
471
 
415
472
  Add to `config/environment.rb` (Rails2) or `config/application.rb` (Rails3)
416
473
 
417
- config.middleware.use Rack::ServerPages
474
+ ```ruby
475
+ config.middleware.use Rack::ServerPages
476
+ ```
418
477
 
419
478
  And run
420
479
 
421
480
  Rails2
422
481
 
423
- script/server
482
+ ```
483
+ script/server
484
+ ```
424
485
 
425
486
  Rails3
426
487
 
427
- rails s
488
+ ```
489
+ rails s
490
+ ```
428
491
 
429
492
  - <http://localhost:3000/> is Rails response
430
493
  - <http://localhost:3000/hello> is Rack Server Pages response
@@ -433,19 +496,23 @@ Rails3
433
496
 
434
497
  Create `sinatra_sample.rb`
435
498
 
436
- require 'sinatra'
437
- require 'rack-server-pages'
499
+ ```ruby
500
+ require 'sinatra'
501
+ require 'rack-server-pages'
438
502
 
439
- use Rack::ServerPages
503
+ use Rack::ServerPages
440
504
 
441
- get '/' do
442
- '<p>Hello Sinatra!</p>'
443
- end
505
+ get '/' do
506
+ '<p>Hello Sinatra!</p>'
507
+ end
508
+ ```
444
509
 
445
510
 
446
511
  And run
447
512
 
448
- ruby sinatra_sample.rb`
513
+ ```
514
+ ruby sinatra_sample.rb
515
+ ```
449
516
 
450
517
  - <http://localhost:4567/> is Sinatra response
451
518
  - <http://localhost:4567/hello> is Rack Server Pages response
@@ -458,15 +525,21 @@ And run
458
525
 
459
526
  ERBTemplate (default)
460
527
 
461
- Rack::ServerPages::Template::ERBTemplate.extensions << 'php'
528
+ ```ruby
529
+ Rack::ServerPages::Template::ERBTemplate.extensions << 'php'
530
+ ```
462
531
 
463
532
  TiltTemplate (see. [Template Mappings](http://github.com/rtomayko/tilt))
464
533
 
465
- Tilt.register Tilt::ERBTemplate, 'php'
534
+ ```ruby
535
+ Tilt.register Tilt::ERBTemplate, 'php'
536
+ ```
466
537
 
467
538
  And create `public/info.php` :)
468
539
 
469
- <%= phpinfo(); %>
540
+ ```erb
541
+ <%= phpinfo(); %>
542
+ ```
470
543
 
471
544
  <http://localhost:9292/info.php>
472
545
 
@@ -491,4 +564,7 @@ And create `public/info.php` :)
491
564
  - Benchmark
492
565
 
493
566
  ## License
494
- [rack-server-pages](http://github.com/migrs/rack-server-pages) is Copyright (c) 2012 [Masato Igarashi](http://github.com/migrs)(@[migrs](http://twitter.com/migrs)) and distributed under the [MIT license](http://www.opensource.org/licenses/mit-license).
567
+
568
+ [rack-server-pages](http://github.com/migrs/rack-server-pages) is Copyright (c) 2012-2016 [Masato Igarashi](http://github.com/migrs)(@[migrs](http://twitter.com/migrs)) and Contributors.
569
+
570
+ Distributed under the [MIT license](LICENSE.md).