rack-server-pages 0.0.1

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.
Files changed (47) hide show
  1. data/.gitignore +11 -0
  2. data/.travis.yml +6 -0
  3. data/Gemfile +53 -0
  4. data/Gemfile.lock +127 -0
  5. data/Guardfile +16 -0
  6. data/README.md +401 -0
  7. data/Rakefile +11 -0
  8. data/config.ru +13 -0
  9. data/lib/rack-server-pages.rb +1 -0
  10. data/lib/rack/server_pages.rb +348 -0
  11. data/public/README.erb +3 -0
  12. data/public/_layout.html.erb +9 -0
  13. data/public/index.html +16 -0
  14. data/public/info.php +1 -0
  15. data/public/sample.erb +8 -0
  16. data/public/style.css +106 -0
  17. data/rack-server-pages.gemspec +22 -0
  18. data/spec/lib/rack/server_pages_spec.rb +69 -0
  19. data/spec/spec_helper.rb +40 -0
  20. data/views/about.html.slim +11 -0
  21. data/views/article.html.md +16 -0
  22. data/views/betty.css.sass +11 -0
  23. data/views/contact.xml.builder +5 -0
  24. data/views/examples/_layout.html.erb +14 -0
  25. data/views/examples/_time.html.erb +1 -0
  26. data/views/examples/builder.xml.builder +0 -0
  27. data/views/examples/coffee.js.coffee +0 -0
  28. data/views/examples/erb.html.erb +2 -0
  29. data/views/examples/haml.html.haml +6 -0
  30. data/views/examples/html.html +1 -0
  31. data/views/examples/index.html.erb +9 -0
  32. data/views/examples/less.css.less +0 -0
  33. data/views/examples/liquid.html.liquid +0 -0
  34. data/views/examples/markaby.html.mab +0 -0
  35. data/views/examples/markdown.html.markdown +6 -0
  36. data/views/examples/nokogiri.xml.nokogiri +0 -0
  37. data/views/examples/radius.html.radius +0 -0
  38. data/views/examples/rdoc.html.rdoc +0 -0
  39. data/views/examples/sass.css.sass +11 -0
  40. data/views/examples/scss.css.scss +0 -0
  41. data/views/examples/slim.html.slim +2 -0
  42. data/views/examples/source.html.slim +9 -0
  43. data/views/examples/textile.html.textile +0 -0
  44. data/views/examples/wiki.html.wiki +0 -0
  45. data/views/examples/yajl.json.yajl +0 -0
  46. data/views/script.js.coffee +13 -0
  47. metadata +106 -0
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rack-server-pages"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rack-server-pages"
7
+ s.version = Rack::ServerPages::VERSION
8
+ s.authors = ["Masato Igarashi"]
9
+ s.email = ["m@igrs.jp"]
10
+ s.homepage = "http://m.igrs.jp/"
11
+ s.summary = %q{Rack middleware and appilcation for serving dynamic pages in very simple way.}
12
+ s.description = %q{There are no controllers and no models, just only views like a asp, jsp and php!}
13
+
14
+ s.rubyforge_project = "rack-server-pages"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency 'rack'
22
+ end
@@ -0,0 +1,69 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'Rack::ServerPages' do
4
+ describe 'Basic requests' do
5
+ before { get path_info }
6
+ subject { last_response }
7
+
8
+ should_be_ok '/'
9
+ should_be_not_found '/hoge'
10
+
11
+ should_be_not_found '/inf'
12
+ should_be_ok '/info'
13
+ should_be_not_found '/info/'
14
+ should_be_ok '/info.php'
15
+ should_be_ok '/info.php?a=3'
16
+ should_be_not_found '/info.'
17
+ should_be_not_found '/info.p'
18
+ should_be_not_found '/info.php/'
19
+
20
+ should_be_not_found '/example'
21
+ should_be_not_found '/examples'
22
+ should_be_ok '/examples/'
23
+ should_be_ok '/examples/index'
24
+ should_be_ok '/examples/index.html'
25
+ should_be_not_found '/examples/index.htm'
26
+ should_be_not_found '/examples/.htaccess'
27
+ end
28
+
29
+ describe 'Rack::ServerPages private methods' do
30
+ describe '#evalute_path_info' do
31
+ subject { app.new.__send__(:evalute_path_info, path_info) }
32
+
33
+ context '/aaa/bbb.erb' do
34
+ let(:path_info) { '/aaa/bbb.erb' }
35
+ it { should eq %w(aaa/ bbb .erb) }
36
+ end
37
+
38
+ context '/aaa/bbb/ccc.erb' do
39
+ let(:path_info) { '/aaa/bbb/ccc.erb' }
40
+ it { should eq %w(aaa/bbb/ ccc .erb) }
41
+ end
42
+
43
+ context '/aaa/bbb/ccc.' do
44
+ let(:path_info) { '/aaa/bbb/ccc.' }
45
+ it { should be_nil }
46
+ end
47
+
48
+ context '/aaa/bbb/ccc' do
49
+ let(:path_info) { '/aaa/bbb/ccc' }
50
+ it { should eq ['aaa/bbb/', 'ccc', nil] }
51
+ end
52
+
53
+ context '/aaa-bbb/ccc' do
54
+ let(:path_info) { '/aaa-bbb/ccc' }
55
+ it { should eq ['aaa-bbb/', 'ccc', nil] }
56
+ end
57
+
58
+ context '/aaa/bbb/' do
59
+ let(:path_info) { '/aaa/bbb/' }
60
+ it { should eq ['aaa/bbb/', nil, nil] }
61
+ end
62
+
63
+ context '/' do
64
+ let(:path_info) { '/' }
65
+ it { should eq [nil, nil, nil] }
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rack/test'
3
+ require 'tapp'
4
+ require 'simplecov'
5
+ require File.dirname(__FILE__) + '/../lib/rack/server_pages'
6
+ SimpleCov.start
7
+
8
+ RSpec.configure do |conf|
9
+ conf.include Rack::Test::Methods
10
+ end
11
+
12
+ require 'tilt'
13
+ require 'slim'
14
+ Tilt.register Tilt::ERBTemplate, 'php'
15
+
16
+ def app
17
+ @app ||=Rack::Builder.app do
18
+ run Rack::ServerPages
19
+ end
20
+ end
21
+
22
+ def mock_app(&block)
23
+ @app = Rack::Builder.app(&block)
24
+ end
25
+
26
+ def should_be_ok(path)
27
+ context "GET #{path}" do
28
+ let(:path_info) { path }
29
+ it { should be_ok }
30
+ its(:content_type) { should match %r{\btext/html\b} }
31
+ end
32
+ end
33
+
34
+ def should_be_not_found(path)
35
+ context "GET #{path}" do
36
+ let(:path_info) { path }
37
+ it { should be_not_found }
38
+ #its(:content_type) { should eq 'text/plain' }
39
+ end
40
+ end
@@ -0,0 +1,11 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title Slim Core Example
5
+ meta name="keywords" content="template language"
6
+
7
+ body
8
+ h1 Markup examples
9
+
10
+ div id="content" class="example1"
11
+ p Nest by indentation
@@ -0,0 +1,16 @@
1
+ A First Level Header
2
+ ====================
3
+
4
+ A Second Level Header
5
+ ---------------------
6
+
7
+ Now is the time for all good men to come to
8
+ the aid of their country. This is just a
9
+ regular paragraph.
10
+
11
+ ### Header 3
12
+
13
+ > This is a blockquote.
14
+ > Thank you
15
+
16
+ [source](http://github.com/migrs/rack-server-pages)
@@ -0,0 +1,11 @@
1
+ $blue: #3bbfce
2
+ $margin: 16px
3
+
4
+ .content-navigation
5
+ border-color: $blue
6
+ color: darken($blue, 9%)
7
+
8
+ .border
9
+ padding: $margin / 2
10
+ margin: $margin / 2
11
+ border-color: $blue
@@ -0,0 +1,5 @@
1
+ xml.instruct!
2
+ xml.result do |result|
3
+ result.name "John"
4
+ result.phone "910-1974"
5
+ end
@@ -0,0 +1,14 @@
1
+ <html>
2
+ <head>
3
+ <title>rack-server-pages Tilt examples</title>
4
+ <link href="<%=url("/style.css")%>" media="screen" rel="stylesheet" type="text/css" />
5
+ </head>
6
+ <body>
7
+ <h1>rack-server-pages examples</h1>
8
+ <%= partial 'views/examples/_time.html' %>
9
+ <%= yield %>
10
+ <% unless request.path =~ %r!/examples/(index(\.html)?)?$! %>
11
+ <a href="<%=url('/examples/')%>">List examples</a>
12
+ <% end %>
13
+ </body>
14
+ </html>
@@ -0,0 +1 @@
1
+ <p><code>Time: <%= Time.now %></code></p>
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ <h1>Hello erb!</h1>
2
+ <p><%= Time.now %></p>
@@ -0,0 +1,6 @@
1
+ :ruby
2
+ layout 'views/examples/_layout.html'
3
+ %h1 Hello Haml!
4
+
5
+ %p
6
+ %a{:href => "/examples/source.html?src=haml.html"} source
@@ -0,0 +1 @@
1
+ <h1>Hello html!</h1>
@@ -0,0 +1,9 @@
1
+ <% layout 'views/examples/_layout.html' %>
2
+ <h2>Tilt examples</h2>
3
+ <ul>
4
+ <% for file in Dir["views/examples/*"] %>
5
+ <li>
6
+ <a href="./<%= file[%r!/examples/(\w+\.\w+)(?:\.\w+)?$!, 1]%>"><%=$1%></a>
7
+ </li>
8
+ <% end %>
9
+ </ul>
File without changes
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ Hello Markdown!
2
+ ===============
3
+
4
+ [source](/examples/source.html?src=markdown.html)
5
+
6
+ [List examples](/examples/)
File without changes
File without changes
File without changes
@@ -0,0 +1,11 @@
1
+ $blue: #3bbfce
2
+ $margin: 16px
3
+
4
+ .content-navigation
5
+ border-color: $blue
6
+ color: darken($blue, 9%)
7
+
8
+ .border
9
+ padding: $margin / 2
10
+ margin: $margin / 2
11
+ border-color: $blue
File without changes
@@ -0,0 +1,2 @@
1
+ h1 Hello slim!
2
+ p= Time.now
@@ -0,0 +1,9 @@
1
+ ruby:
2
+ layout 'views/examples/_layout.html'
3
+ src = params['src'][/(\w+\.)?(\w+)$/, 0]
4
+ h2 source
5
+ code = file = Dir["views/examples/#{src}.*"].first
6
+ pre style="background-color:#122831;color:#B3B3B3;padding:1em;" =IO.read(file)
7
+ a href=(u=url("/examples/#{src}")) = u
8
+ iframe src=u width="100%"
9
+
File without changes
File without changes
File without changes
@@ -0,0 +1,13 @@
1
+ number = 42
2
+ opposite = true
3
+
4
+ number = -42 if opposite
5
+
6
+ square = (x) -> x * x
7
+
8
+ list = [1, 2, 3, 4, 5]
9
+
10
+ math =
11
+ root: Math.sqrt
12
+ square: square
13
+ cube: (x) -> x * square x
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-server-pages
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Masato Igarashi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-31 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rack
16
+ requirement: &70308233311580 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70308233311580
25
+ description: There are no controllers and no models, just only views like a asp, jsp
26
+ and php!
27
+ email:
28
+ - m@igrs.jp
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - .travis.yml
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - Guardfile
38
+ - README.md
39
+ - Rakefile
40
+ - config.ru
41
+ - lib/rack-server-pages.rb
42
+ - lib/rack/server_pages.rb
43
+ - public/README.erb
44
+ - public/_layout.html.erb
45
+ - public/index.html
46
+ - public/info.php
47
+ - public/sample.erb
48
+ - public/style.css
49
+ - rack-server-pages.gemspec
50
+ - spec/lib/rack/server_pages_spec.rb
51
+ - spec/spec_helper.rb
52
+ - views/about.html.slim
53
+ - views/article.html.md
54
+ - views/betty.css.sass
55
+ - views/contact.xml.builder
56
+ - views/examples/_layout.html.erb
57
+ - views/examples/_time.html.erb
58
+ - views/examples/builder.xml.builder
59
+ - views/examples/coffee.js.coffee
60
+ - views/examples/erb.html.erb
61
+ - views/examples/haml.html.haml
62
+ - views/examples/html.html
63
+ - views/examples/index.html.erb
64
+ - views/examples/less.css.less
65
+ - views/examples/liquid.html.liquid
66
+ - views/examples/markaby.html.mab
67
+ - views/examples/markdown.html.markdown
68
+ - views/examples/nokogiri.xml.nokogiri
69
+ - views/examples/radius.html.radius
70
+ - views/examples/rdoc.html.rdoc
71
+ - views/examples/sass.css.sass
72
+ - views/examples/scss.css.scss
73
+ - views/examples/slim.html.slim
74
+ - views/examples/source.html.slim
75
+ - views/examples/textile.html.textile
76
+ - views/examples/wiki.html.wiki
77
+ - views/examples/yajl.json.yajl
78
+ - views/script.js.coffee
79
+ homepage: http://m.igrs.jp/
80
+ licenses: []
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project: rack-server-pages
99
+ rubygems_version: 1.8.10
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: Rack middleware and appilcation for serving dynamic pages in very simple
103
+ way.
104
+ test_files:
105
+ - spec/lib/rack/server_pages_spec.rb
106
+ - spec/spec_helper.rb