rhr 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rhr (0.1.1)
4
+ rhr (0.1.2)
5
5
  rack
6
6
  tilt
7
7
 
data/Readme.md CHANGED
@@ -6,14 +6,20 @@ Install
6
6
 
7
7
  Usage
8
8
  =====
9
- echo 'Hello <%= "RHR" %>' > index.erb
9
+ echo 'Hello <%= params["name"] || "RHR" %>' > index.erb
10
10
  rhr server
11
11
  --> http://localhost:3000
12
- --> http://localhost:3000/index.erb
12
+ --> http://localhost:3000/index.erb?name=World
13
13
 
14
14
  - Supports [Erb, Haml, Liquid, ... everything](https://github.com/rtomayko/tilt)
15
15
  - Does not serve Rakefile / Gemfile / Gemfile.lock + everything starting with `_` or `.`
16
16
 
17
+ TODO (fork!)
18
+ ====
19
+ - use _layout.erb files as layout unless view does something like `no_layout`
20
+ - add helpers like link_to / tag / form
21
+ - escape html in params <-> xss
22
+
17
23
  Author
18
24
  ======
19
25
  Initial (crazy) idea by [Steffen Schröder](https://github.com/ChaosSteffen)
@@ -9,7 +9,9 @@ module RHR
9
9
  path = env['PATH_INFO']
10
10
  if template = find_template(path)
11
11
  if renderer = Tilt[template]
12
- body = renderer.new(template).render
12
+ request = Rack::Request.new(env)
13
+ params = request.GET.merge(request.POST)
14
+ body = renderer.new(template).render(nil, :request => request, :params => params)
13
15
  [200, {}, [body]]
14
16
  else
15
17
  Rack::File.new('.').call(env.merge('PATH_INFO' => template))
@@ -1,3 +1,3 @@
1
1
  module RHR
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -93,5 +93,20 @@ describe RHR do
93
93
  get "/xxx/.hidden.html"
94
94
  last_response.status.should == 404
95
95
  end
96
+
97
+ it "passes env" do
98
+ get "/xxx/env.erb"
99
+ last_response.body.should == "/xxx/env.erb"
100
+ end
101
+
102
+ it "passes get params" do
103
+ get "/xxx/params.erb?x=1&a%20b=b%20c"
104
+ last_response.body.should == "[[\"a b\", \"b c\"], [\"x\", \"1\"]]"
105
+ end
106
+
107
+ it "passes merged post and get params" do
108
+ post "/xxx/params.erb?a=1&b=2", {'b' => 3}
109
+ last_response.body.should == "[[\"a\", \"1\"], [\"b\", \"3\"]]"
110
+ end
96
111
  end
97
112
  end
@@ -0,0 +1 @@
1
+ <%= request.env["PATH_INFO"] %>
@@ -0,0 +1 @@
1
+ <%= params.sort.inspect %>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-04 00:00:00 +02:00
18
+ date: 2011-10-07 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -75,7 +75,9 @@ files:
75
75
  - spec/site/plain.html
76
76
  - spec/site/xxx/.hidden.html
77
77
  - spec/site/xxx/aaa.html
78
+ - spec/site/xxx/env.erb
78
79
  - spec/site/xxx/index.erb
80
+ - spec/site/xxx/params.erb
79
81
  - spec/site/yyy/index.html
80
82
  - spec/spec_helper.rb
81
83
  has_rdoc: true