ramaze 0.3.0 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -2
- data/bin/ramaze +9 -3
- data/doc/AUTHORS +6 -2
- data/doc/CHANGELOG +272 -66
- data/doc/GPL +12 -13
- data/doc/README.html +729 -0
- data/doc/changes.txt +5757 -0
- data/doc/changes.xml +5759 -0
- data/doc/meta/announcement.txt +48 -39
- data/doc/tutorial/todolist.mkd +10 -12
- data/examples/blog/start.rb +1 -0
- data/examples/caching.rb +1 -0
- data/examples/element.rb +3 -0
- data/examples/hello.rb +1 -3
- data/examples/identity.rb +5 -8
- data/examples/layout.rb +1 -0
- data/examples/linking.rb +1 -0
- data/examples/memleak_detector.rb +1 -0
- data/examples/nitro_form.rb +1 -0
- data/examples/rammit/start.rb +1 -0
- data/examples/rapaste/Rakefile +7 -0
- data/examples/rapaste/{src/controller.rb → controller/paste.rb} +28 -3
- data/examples/rapaste/{src/model.rb → model/paste.rb} +0 -4
- data/examples/rapaste/public/css/display.css +17 -0
- data/examples/rapaste/spec/rapaste.rb +2 -2
- data/examples/rapaste/start.rb +9 -4
- data/examples/rapaste/{template → view}/copy.xhtml +0 -0
- data/examples/rapaste/{template → view}/index.xhtml +0 -0
- data/examples/rapaste/{template → view}/layout.xhtml +3 -0
- data/examples/rapaste/{template → view}/list.xhtml +4 -3
- data/examples/rapaste/view/search.xhtml +41 -0
- data/examples/rapaste/{template → view}/view.xhtml +0 -0
- data/examples/simple.rb +3 -3
- data/examples/templates/template/external.amrita +9 -9
- data/examples/templates/template/external.redcloth +19 -0
- data/examples/templates/template_amrita2.rb +40 -7
- data/examples/templates/template_erubis.rb +3 -3
- data/examples/templates/template_ezamar.rb +1 -3
- data/examples/templates/template_haml.rb +1 -3
- data/examples/templates/template_liquid.rb +3 -3
- data/examples/templates/template_markaby.rb +1 -3
- data/examples/templates/template_nagoro.rb +1 -3
- data/examples/templates/template_redcloth.rb +59 -0
- data/examples/templates/template_remarkably.rb +1 -3
- data/examples/templates/template_xslt.rb +1 -4
- data/examples/todolist/src/controller/main.rb +1 -1
- data/examples/todolist/start.rb +1 -2
- data/examples/upload/start.rb +19 -0
- data/examples/upload/view/index.xhtml +25 -0
- data/examples/whywiki/start.rb +1 -3
- data/examples/wikore/start.rb +3 -0
- data/examples/wiktacular/mkd/newpagename/current.mkd +1 -0
- data/examples/wiktacular/mkd/newpagename/current.mkd.bak +1 -0
- data/examples/wiktacular/start.rb +1 -0
- data/lib/proto/controller/main.rb +0 -3
- data/lib/proto/public/js/jquery.js +106 -93
- data/lib/proto/spec/main.rb +2 -5
- data/lib/proto/start.rb +0 -3
- data/lib/ramaze.rb +3 -2
- data/lib/ramaze/action.rb +6 -10
- data/lib/ramaze/adapter/lsws.rb +19 -0
- data/lib/ramaze/contrib/email.rb +84 -0
- data/lib/ramaze/contrib/email.rb-darcs-backup0 +81 -0
- data/lib/ramaze/contrib/gettext.rb +1 -0
- data/lib/ramaze/contrib/gettext/parser.rb +46 -0
- data/lib/ramaze/contrib/route.rb +3 -36
- data/lib/ramaze/controller.rb +4 -6
- data/lib/ramaze/controller/resolve.rb +28 -1
- data/lib/ramaze/dispatcher.rb +1 -1
- data/lib/ramaze/dispatcher/file.rb +17 -0
- data/lib/ramaze/global/globalstruct.rb +7 -4
- data/lib/ramaze/helper/auth.rb +1 -1
- data/lib/ramaze/helper/identity.rb +25 -15
- data/lib/ramaze/helper/link.rb +29 -8
- data/lib/ramaze/helper/maruku.rb +7 -0
- data/lib/ramaze/helper/partial.rb +25 -10
- data/lib/ramaze/route.rb +56 -0
- data/lib/ramaze/snippets/metaid.rb +17 -0
- data/lib/ramaze/spec/helper.rb +0 -2
- data/lib/ramaze/spec/helper/mock_http.rb +6 -0
- data/lib/ramaze/spec/helper/pretty_output.rb +5 -1
- data/lib/ramaze/store/default.rb +3 -1
- data/lib/ramaze/template.rb +1 -1
- data/lib/ramaze/template/amrita2.rb +21 -15
- data/lib/ramaze/template/bijou.rb +39 -0
- data/lib/ramaze/template/builder.rb +28 -0
- data/lib/ramaze/template/redcloth.rb +24 -0
- data/lib/ramaze/template/sass.rb +3 -1
- data/lib/ramaze/tool/create.rb +2 -1
- data/lib/ramaze/tool/localize.rb +6 -1
- data/lib/ramaze/trinity/request.rb +8 -0
- data/lib/ramaze/trinity/session.rb +8 -5
- data/lib/ramaze/version.rb +1 -1
- data/rake_tasks/gem.rake +0 -1
- data/rake_tasks/maintenance.rake +4 -1
- data/spec/contrib/route.rb +14 -63
- data/spec/examples/linking.rb +2 -2
- data/spec/examples/templates/template_redcloth.rb +28 -0
- data/spec/ramaze/controller/subclass.rb +21 -0
- data/spec/ramaze/dispatcher/file.rb +31 -0
- data/spec/ramaze/helper/link.rb +46 -0
- data/spec/ramaze/helper/partial.rb +22 -1
- data/spec/ramaze/helper/template/locals.xhtml +1 -0
- data/spec/ramaze/helper/template/recursive_locals.xhtml +7 -0
- data/spec/ramaze/params.rb +8 -0
- data/spec/ramaze/request.rb +14 -0
- data/spec/ramaze/route.rb +107 -0
- data/spec/ramaze/session.rb +4 -2
- data/spec/ramaze/template/amrita2.rb +21 -7
- data/spec/ramaze/template/amrita2/external.amrita +6 -0
- data/spec/ramaze/template/amrita2/sum.amrita +1 -1
- data/spec/ramaze/template/bijou.rb +25 -0
- data/spec/ramaze/template/builder.rb +55 -0
- data/spec/ramaze/template/builder/external.rxml +3 -0
- data/spec/ramaze/template/haml.rb +15 -0
- data/spec/ramaze/template/haml/locals.haml +1 -0
- data/spec/ramaze/template/redcloth.rb +38 -0
- data/spec/ramaze/template/redcloth/external.redcloth +1 -0
- metadata +472 -442
- data/examples/rapaste/rapaste.sqlite +0 -0
- data/spec/ramaze/template/amrita2/data.amrita +0 -6
- data/spec/ramaze/template/amrita2/index.amrita +0 -1
@@ -21,9 +21,18 @@ class TCPartialHelperController < Ramaze::Controller
|
|
21
21
|
render_template("partial.xhtml")
|
22
22
|
end
|
23
23
|
|
24
|
-
def recursive
|
24
|
+
def recursive locals = false
|
25
|
+
respond render_template('recursive_locals.xhtml', :n => 1) if locals
|
25
26
|
@n = 1
|
26
27
|
end
|
28
|
+
|
29
|
+
def test_locals
|
30
|
+
render_template 'locals.xhtml', :say => 'Hello', :to => 'World'
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_without_ext
|
34
|
+
render_template :locals, :say => 'Hi', :to => 'World'
|
35
|
+
end
|
27
36
|
end
|
28
37
|
|
29
38
|
describe "PartialHelper" do
|
@@ -45,4 +54,16 @@ describe "PartialHelper" do
|
|
45
54
|
it 'should work recursively' do
|
46
55
|
get('/recursive').body.gsub(/\s/,'').should == '{1{2{3{44}4}3}2}'
|
47
56
|
end
|
57
|
+
|
58
|
+
it 'should support locals' do
|
59
|
+
get('/test_locals').body.should == 'Hello, World!'
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should work recursively with locals' do
|
63
|
+
get('/recursive/true').body.gsub(/\s/,'').should == '{1{2{3{44}3}2}1}'
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should not require file extension' do
|
67
|
+
get('/test_without_ext').body.should == 'Hi, World!'
|
68
|
+
end
|
48
69
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#{say}, #{to}!
|
data/spec/ramaze/params.rb
CHANGED
@@ -49,6 +49,10 @@ class TCParamsController2 < Ramaze::Controller
|
|
49
49
|
def add(one, two = nil, three = nil)
|
50
50
|
"#{one}:#{two}:#{three}"
|
51
51
|
end
|
52
|
+
|
53
|
+
def keys
|
54
|
+
request.params.keys.to_s.dump
|
55
|
+
end
|
52
56
|
end
|
53
57
|
|
54
58
|
class TCParamsController3 < Ramaze::Controller
|
@@ -146,4 +150,8 @@ describe "Simple Parameters" do
|
|
146
150
|
it 'should have a parameter via QUERY_PARAMS' do
|
147
151
|
get('/ma', 'foo' => 'bar').body.should == '"bar"'
|
148
152
|
end
|
153
|
+
|
154
|
+
it 'should handle valueless params' do
|
155
|
+
raw_mock_request(:get, '/jo/keys?foo').body.should == '"foo"'
|
156
|
+
end
|
149
157
|
end
|
data/spec/ramaze/request.rb
CHANGED
@@ -48,6 +48,13 @@ class TCRequestController < Ramaze::Controller
|
|
48
48
|
def my_ip
|
49
49
|
request.remote_addr
|
50
50
|
end
|
51
|
+
|
52
|
+
def to_ivs
|
53
|
+
request.to_ivs :foo, :bar
|
54
|
+
instance_variables.sort.map{|iv|
|
55
|
+
[ iv.to_s, instance_variable_get(iv) ].join(' => ')
|
56
|
+
}.join(', ')
|
57
|
+
end
|
51
58
|
end
|
52
59
|
|
53
60
|
options = ramaze_options rescue {}
|
@@ -56,6 +63,13 @@ ramaze options.merge(:public_root => 'spec/ramaze/public')
|
|
56
63
|
describe "Request" do
|
57
64
|
behaves_like 'http'
|
58
65
|
|
66
|
+
it 'to_ivs' do
|
67
|
+
got = get('/to_ivs', 'foo' => 'a')
|
68
|
+
got.body.should == '@foo => a'
|
69
|
+
got = get('/to_ivs', 'bar' => 'b', 'foo' => 'c')
|
70
|
+
got.body.should == '@bar => b, @foo => c'
|
71
|
+
end
|
72
|
+
|
59
73
|
describe "POST" do
|
60
74
|
behaves_like 'http'
|
61
75
|
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
class MainController < Ramaze::Controller
|
4
|
+
def float(flt)
|
5
|
+
"Float: #{flt}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def string(str)
|
9
|
+
"String: #{str}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def price(p)
|
13
|
+
"Price: \$#{p}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def sum(a, b)
|
17
|
+
a.to_i + b.to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
def bar
|
21
|
+
'this is bar'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'Route' do
|
26
|
+
behaves_like 'http'
|
27
|
+
ramaze
|
28
|
+
@route = Ramaze::Route
|
29
|
+
|
30
|
+
it 'should take custom lambda routers' do
|
31
|
+
@route['string'] = lambda {|path, req| path if path =~ %r!^/string! }
|
32
|
+
@route['string'].class.should == Proc
|
33
|
+
|
34
|
+
@route['calc sum'] = lambda do |path, req|
|
35
|
+
if req[:do_calc]
|
36
|
+
lval, rval = req[:a, :b]
|
37
|
+
rval = rval.to_i * 10
|
38
|
+
"/sum/#{lval}/#{rval}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Ramaze::Route('foo') do |path, req|
|
43
|
+
'/bar' if req[:bar]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should be possible to define simple string routes' do
|
48
|
+
@route['/foobar'] = '/bar'
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should be possible to define routes' do
|
52
|
+
@route[%r!^/(\d+\.\d{2})$!] = "/price/%.2f"
|
53
|
+
@route[%r!^/(\d+\.\d{2})$!].should == "/price/%.2f"
|
54
|
+
|
55
|
+
@route[%r!^/(\d+\.\d+)!] = "/float/%.3f"
|
56
|
+
@route[%r!^/(\d+\.\d+)!].should == "/float/%.3f"
|
57
|
+
|
58
|
+
@route[%r!^/(\w+)!] = "/string/%s"
|
59
|
+
@route[%r!^/(\w+)!].should == "/string/%s"
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should be used - /float' do
|
63
|
+
r = get('/123.123')
|
64
|
+
r.status.should == 200
|
65
|
+
r.body.should == 'Float: 123.123'
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should be used - /string' do
|
69
|
+
r = get('/foo')
|
70
|
+
r.status.should == 200
|
71
|
+
r.body.should == 'String: foo'
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should use %.3f' do
|
75
|
+
r = get('/123.123456')
|
76
|
+
r.status.should == 200
|
77
|
+
r.body.should == 'Float: 123.123'
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should resolve in the order added' do
|
81
|
+
r = get('/12.84')
|
82
|
+
r.status.should == 200
|
83
|
+
r.body.should == 'Price: $12.84'
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should use lambda routers' do
|
87
|
+
r = get('/string/abc')
|
88
|
+
r.status.should == 200
|
89
|
+
r.body.should == 'String: abc'
|
90
|
+
|
91
|
+
r = get('/', 'do_calc=1&a=2&b=6')
|
92
|
+
r.status.should == 200
|
93
|
+
r.body.should == '62'
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should support Route() with blocks' do
|
97
|
+
r = get('/foo', 'bar=1')
|
98
|
+
r.status.should == 200
|
99
|
+
r.body.should == 'this is bar'
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should support string route translations' do
|
103
|
+
r = get('/foobar')
|
104
|
+
r.status.should == 200
|
105
|
+
r.body.should == 'this is bar'
|
106
|
+
end
|
107
|
+
end
|
data/spec/ramaze/session.rb
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
require 'spec/helper'
|
5
5
|
|
6
6
|
class TCSessionController < Ramaze::Controller
|
7
|
+
map '/'
|
8
|
+
|
7
9
|
def index
|
8
10
|
session.inspect
|
9
11
|
end
|
@@ -29,7 +31,7 @@ end
|
|
29
31
|
|
30
32
|
describe "Session" do
|
31
33
|
behaves_like 'http', 'browser'
|
32
|
-
ramaze
|
34
|
+
ramaze :adapter => :webrick
|
33
35
|
|
34
36
|
{ :MemoryCache => :memory,
|
35
37
|
:YAMLStoreCache => :yaml_store,
|
@@ -42,7 +44,7 @@ describe "Session" do
|
|
42
44
|
next
|
43
45
|
end
|
44
46
|
|
45
|
-
describe cache
|
47
|
+
describe cache do
|
46
48
|
|
47
49
|
Ramaze::Global.cache = cache
|
48
50
|
Thread.main[:session_cache] = nil
|
@@ -9,14 +9,20 @@ class TCTemplateAmritaController < Ramaze::Controller
|
|
9
9
|
template_root __DIR__/:amrita2
|
10
10
|
engine :Amrita2
|
11
11
|
|
12
|
-
|
12
|
+
def internal
|
13
|
+
@data = { :hello => "hello world" }
|
14
|
+
"<h1 am:src='hello' />"
|
15
|
+
end
|
13
16
|
|
14
|
-
def
|
15
|
-
|
17
|
+
def external
|
18
|
+
@data = {
|
19
|
+
:title => "hello world",
|
20
|
+
:body => "Amrita2 is an HTML template library for Ruby"
|
21
|
+
}
|
16
22
|
end
|
17
23
|
|
18
|
-
def
|
19
|
-
|
24
|
+
def sum
|
25
|
+
@data = { :one => 1, :two => 2 }
|
20
26
|
end
|
21
27
|
end
|
22
28
|
|
@@ -24,8 +30,12 @@ describe "Simply calling" do
|
|
24
30
|
behaves_like 'http'
|
25
31
|
ramaze(:mapping => {'/' => TCTemplateAmritaController})
|
26
32
|
|
27
|
-
it "should respond to /
|
28
|
-
get('/
|
33
|
+
it "should respond to /internal" do
|
34
|
+
get('/internal').body.strip.should == "<h1>hello world</h1>"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should respond to /external" do
|
38
|
+
get('/external').body.strip.should ==
|
29
39
|
%{<html>
|
30
40
|
<body>
|
31
41
|
<h1>hello world</h1>
|
@@ -33,4 +43,8 @@ describe "Simply calling" do
|
|
33
43
|
</body>
|
34
44
|
</html>}
|
35
45
|
end
|
46
|
+
|
47
|
+
it "should respond to /sum" do
|
48
|
+
get('/sum').body.strip.should == "1 + 2 = 3"
|
49
|
+
end
|
36
50
|
end
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
<<:one>> + <<:two>> = <%= $_[:one] + $_[:two] %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'spec/helper'
|
5
|
+
|
6
|
+
class TCTemplateController < Ramaze::Controller
|
7
|
+
map :/
|
8
|
+
template_root __DIR__/:ezamar
|
9
|
+
engine :Bijou
|
10
|
+
|
11
|
+
def hello
|
12
|
+
"<% planet = 'World' %>
|
13
|
+
Hello, <%= planet %>!"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
describe "Bijou" do
|
19
|
+
behaves_like 'http'
|
20
|
+
ramaze
|
21
|
+
|
22
|
+
it "hello world" do
|
23
|
+
get('/hello').body.strip.should == 'Hello, World!'
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
spec_require 'builder'
|
4
|
+
|
5
|
+
class TCTemplateBuilder < Ramaze::Controller
|
6
|
+
template_root 'spec/ramaze/template/builder'
|
7
|
+
map '/'
|
8
|
+
engine :Builder
|
9
|
+
|
10
|
+
def external
|
11
|
+
@frameworks = { 'ramaze' => 'ruby',
|
12
|
+
'symfony' => 'php',
|
13
|
+
'django' => 'python' }
|
14
|
+
end
|
15
|
+
|
16
|
+
def internal
|
17
|
+
external
|
18
|
+
%q[
|
19
|
+
@frameworks.each do |name, lang|
|
20
|
+
xml.framework {|f| f.name(name); f.language(lang) }
|
21
|
+
end
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "Builder" do
|
27
|
+
behaves_like 'http'
|
28
|
+
ramaze
|
29
|
+
|
30
|
+
@xml = "<framework>
|
31
|
+
<name>symfony</name>
|
32
|
+
<language>php</language>
|
33
|
+
</framework>
|
34
|
+
<framework>
|
35
|
+
<name>ramaze</name>
|
36
|
+
<language>ruby</language>
|
37
|
+
</framework>
|
38
|
+
<framework>
|
39
|
+
<name>django</name>
|
40
|
+
<language>python</language>
|
41
|
+
</framework>"
|
42
|
+
|
43
|
+
@xml.gsub!(/\s/,'')
|
44
|
+
|
45
|
+
it "should render xml from files" do
|
46
|
+
r = get('/external')
|
47
|
+
r.status.should == 200
|
48
|
+
r.body.gsub(/\s/,'').should == @xml
|
49
|
+
r.headers['Content-Type'].should == 'application/xml'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should render internal templates' do
|
53
|
+
get('/internal').body.gsub(/\s/,'').should == @xml
|
54
|
+
end
|
55
|
+
end
|
@@ -20,6 +20,17 @@ class TCTemplateHamlController < Ramaze::Controller
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
class TCRamazeLocals < Ramaze::Controller
|
24
|
+
map '/test'
|
25
|
+
template_root __DIR__/:haml
|
26
|
+
|
27
|
+
helper :partial
|
28
|
+
|
29
|
+
def render_with_locals
|
30
|
+
render_template 'locals.haml', :abc => 'def'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
23
34
|
class TCTemplateHamlLocalsController < Ramaze::Controller
|
24
35
|
map '/locals'
|
25
36
|
engine :Haml
|
@@ -55,6 +66,10 @@ describe "Haml templates" do
|
|
55
66
|
</div>}
|
56
67
|
end
|
57
68
|
|
69
|
+
it 'should support locals via render_template' do
|
70
|
+
get('/test/render_with_locals').body.strip.should == 'def'
|
71
|
+
end
|
72
|
+
|
58
73
|
it "should have access to locals defined" do
|
59
74
|
get('/locals/test').body.strip.should == 'abcdefg'
|
60
75
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
= abc
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
spec_require 'erubis'
|
4
|
+
spec_require 'redcloth'
|
5
|
+
|
6
|
+
class TCTemplateRedClothController < Ramaze::Controller
|
7
|
+
template_root __DIR__/:redcloth
|
8
|
+
engine :RedCloth
|
9
|
+
|
10
|
+
def index
|
11
|
+
'RedCloth Index'
|
12
|
+
end
|
13
|
+
|
14
|
+
def external
|
15
|
+
@num = 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def internal
|
19
|
+
"h2. <%= 1 + 1 %>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "RedCloth templates" do
|
24
|
+
behaves_like 'http'
|
25
|
+
ramaze(:mapping => {'/' => TCTemplateRedClothController})
|
26
|
+
|
27
|
+
it "index" do
|
28
|
+
get('/').body.should == '<p>RedCloth Index</p>'
|
29
|
+
end
|
30
|
+
|
31
|
+
it "external" do
|
32
|
+
get('/external').body.should == '<h1>1</h1>'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "internal" do
|
36
|
+
get('/internal').body.should == "<h2>2</h2>"
|
37
|
+
end
|
38
|
+
end
|