ramaze 0.3.0 → 0.3.5
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/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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
require 'bijou'
|
|
5
|
+
|
|
6
|
+
module Ramaze
|
|
7
|
+
module Template
|
|
8
|
+
|
|
9
|
+
# Is responsible for compiling a template using the Bijou templating engine.
|
|
10
|
+
# Can be found at: http://bijou.rubyforge.org/
|
|
11
|
+
|
|
12
|
+
class Bijou < Template
|
|
13
|
+
|
|
14
|
+
ENGINES[self] = %w[ bijou rbb ]
|
|
15
|
+
|
|
16
|
+
class << self
|
|
17
|
+
|
|
18
|
+
# Transform via Haml templating engine
|
|
19
|
+
|
|
20
|
+
def transform action
|
|
21
|
+
compiled = wrap_compile(action)
|
|
22
|
+
context = ::Bijou::Context.new(::Bijou::Config.new)
|
|
23
|
+
# context.container_callback = method(:container_callback)
|
|
24
|
+
# context.component_callback = method(:component_callback)
|
|
25
|
+
::Bijou::Processor.execute(context, compiled, 'GeneralView', {})
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Instantiates Haml::Engine with the template and haml_options trait from
|
|
29
|
+
# the controller.
|
|
30
|
+
|
|
31
|
+
def compile(action, template)
|
|
32
|
+
parser = ::Bijou::Parser.new
|
|
33
|
+
parser.parse('GeneralView', template)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'builder'
|
|
2
|
+
|
|
3
|
+
module Ramaze
|
|
4
|
+
module Template
|
|
5
|
+
|
|
6
|
+
class Builder < Template
|
|
7
|
+
ENGINES[self] = %w[ builder rxml ]
|
|
8
|
+
|
|
9
|
+
class << self
|
|
10
|
+
def transform action
|
|
11
|
+
if response = Response.current
|
|
12
|
+
response['Content-Type'] = "application/xml"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
template = wrap_compile(action)
|
|
16
|
+
action.instance.instance_eval(template, action.template || __FILE__)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def compile action, template
|
|
20
|
+
"xml = ::Builder::XmlMarkup.new(:indent => 2)\n" +
|
|
21
|
+
template +
|
|
22
|
+
"\nxml.target!\n"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'redcloth'
|
|
2
|
+
|
|
3
|
+
module Ramaze
|
|
4
|
+
module Template
|
|
5
|
+
|
|
6
|
+
# Is responsible for compiling a template using the RedCloth templating engine.
|
|
7
|
+
# Can be found at: http://whytheluckystiff.net/ruby/redcloth/
|
|
8
|
+
|
|
9
|
+
class RedCloth < Erubis
|
|
10
|
+
ENGINES[self] = %w[ redcloth ]
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
def transform(action)
|
|
14
|
+
restrictions = action.controller.trait[:redcloth_options] || []
|
|
15
|
+
rules = action.controller.trait[:redcloth_options] || []
|
|
16
|
+
|
|
17
|
+
# Erubis -> RedCloth -> HTML
|
|
18
|
+
redcloth = ::RedCloth.new(super, restrictions)
|
|
19
|
+
redcloth.to_html(*rules)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/ramaze/template/sass.rb
CHANGED
|
@@ -18,7 +18,9 @@ module Ramaze
|
|
|
18
18
|
# Transform via Sass templating engine
|
|
19
19
|
|
|
20
20
|
def transform action
|
|
21
|
-
Response.current
|
|
21
|
+
if response = Response.current
|
|
22
|
+
response['Content-Type'] = "text/css"
|
|
23
|
+
end
|
|
22
24
|
sass = wrap_compile(action)
|
|
23
25
|
sass.to_css()
|
|
24
26
|
end
|
data/lib/ramaze/tool/create.rb
CHANGED
|
@@ -43,7 +43,8 @@ module Ramaze
|
|
|
43
43
|
directories, files =
|
|
44
44
|
Dir[@basedir / '**' / '*'].partition{ |f| File.directory?(f) }
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
# gem packaging removes empty model directory, so add it in ourselves
|
|
47
|
+
create_dirs(*Array[ @basedir/'model', *directories ].uniq)
|
|
47
48
|
copy_files(*files)
|
|
48
49
|
|
|
49
50
|
puts "\nStart your new ramaze app: ruby #{project}/start.rb"
|
data/lib/ramaze/tool/localize.rb
CHANGED
|
@@ -59,7 +59,12 @@ class Ramaze::Tool::Localize
|
|
|
59
59
|
# `localize` for more information.
|
|
60
60
|
|
|
61
61
|
def localize_body(body, options)
|
|
62
|
-
locale =
|
|
62
|
+
locale =
|
|
63
|
+
if trait[:languages].include?(response["Content-Language"])
|
|
64
|
+
response["Content-Language"]
|
|
65
|
+
else
|
|
66
|
+
(session[:LOCALE] || set_session_locale).to_s
|
|
67
|
+
end
|
|
63
68
|
|
|
64
69
|
body.gsub!(trait[:regex]) do
|
|
65
70
|
localize($1, locale) unless $1.to_s.empty?
|
|
@@ -69,6 +69,14 @@ module Ramaze
|
|
|
69
69
|
Array[value, *params.values_at(*keys)]
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
def to_ivs(*args)
|
|
73
|
+
instance = Action.current.instance
|
|
74
|
+
args.each do |arg|
|
|
75
|
+
next unless value = self[arg]
|
|
76
|
+
instance.instance_variable_set("@#{arg}", value)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
72
80
|
unless method_defined?(:rack_params)
|
|
73
81
|
alias rack_params params
|
|
74
82
|
|
|
@@ -70,6 +70,10 @@ module Ramaze
|
|
|
70
70
|
|
|
71
71
|
IP_COUNT_LIMIT = 1000 unless defined?(IP_COUNT_LIMIT)
|
|
72
72
|
|
|
73
|
+
# Holds the default cookie used for sessions
|
|
74
|
+
|
|
75
|
+
COOKIE = { :path => '/' }
|
|
76
|
+
|
|
73
77
|
class << self
|
|
74
78
|
|
|
75
79
|
# called from Ramaze::startup and adds Cache.sessions if cookies are
|
|
@@ -95,11 +99,10 @@ module Ramaze
|
|
|
95
99
|
def initialize request
|
|
96
100
|
@session_id = (request.cookies[SESSION_KEY] || random_key)
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
sessions.delete(IP_COUNT[ip].shift)
|
|
102
|
+
unless IP_COUNT.nil?
|
|
103
|
+
ip = request.remote_addr
|
|
104
|
+
IP_COUNT[ip] << @session_id
|
|
105
|
+
sessions.delete(IP_COUNT[ip].shift) if IP_COUNT[ip].size > IP_COUNT_LIMIT
|
|
103
106
|
end
|
|
104
107
|
|
|
105
108
|
@flash = Ramaze::SessionFlash.new
|
data/lib/ramaze/version.rb
CHANGED
data/rake_tasks/gem.rake
CHANGED
data/rake_tasks/maintenance.rake
CHANGED
|
@@ -209,11 +209,14 @@ def authors
|
|
|
209
209
|
'clive@crous.co.za' => 'Clive Crous',
|
|
210
210
|
'comp.lang.zenix+ramaze@gmail.com' => 'zenix',
|
|
211
211
|
'jesuswasramazing.10.pistos@geoshell.com' => 'Pistos',
|
|
212
|
+
'jesusisramazing.10.pistos@geoshell.com' => 'Pistos',
|
|
212
213
|
'manveru@weez-int.com' => 'Michael Fellinger',
|
|
213
214
|
'm.fellinger@gmail.com' => 'Michael Fellinger',
|
|
214
|
-
'outtenr@gmail.com' => '
|
|
215
|
+
'outtenr@gmail.com' => 'Richard Outten',
|
|
215
216
|
'rff.rff@gmail.com' => 'Gabriele Renzi',
|
|
217
|
+
'skaar@waste.org' => 'skaar',
|
|
216
218
|
'stephan@spaceboyz.net' => 'Stephan Maka',
|
|
219
|
+
'keita.yamaguchi@gmail.com' => 'Keita Yamaguchi',
|
|
217
220
|
}
|
|
218
221
|
|
|
219
222
|
mapping = {}
|
data/spec/contrib/route.rb
CHANGED
|
@@ -3,20 +3,12 @@ require 'spec/helper'
|
|
|
3
3
|
Ramaze.contrib :route
|
|
4
4
|
|
|
5
5
|
class MainController < Ramaze::Controller
|
|
6
|
-
def
|
|
7
|
-
"
|
|
6
|
+
def text(num)
|
|
7
|
+
"text: #{num}"
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def
|
|
11
|
-
"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def price(p)
|
|
15
|
-
"Price: \$#{p}"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def sum(a, b)
|
|
19
|
-
a.to_i + b.to_i
|
|
10
|
+
def bar
|
|
11
|
+
"bar"
|
|
20
12
|
end
|
|
21
13
|
end
|
|
22
14
|
|
|
@@ -25,61 +17,20 @@ describe 'Route' do
|
|
|
25
17
|
ramaze
|
|
26
18
|
@route = Ramaze::Contrib::Route
|
|
27
19
|
|
|
28
|
-
it 'should
|
|
29
|
-
@route[
|
|
30
|
-
@route['
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if req[:do_calc]
|
|
34
|
-
lval, rval = req[:a, :b]
|
|
35
|
-
rval = rval.to_i * 10
|
|
36
|
-
"/sum/#{lval}/#{rval}"
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'should be possible to define routes' do
|
|
42
|
-
@route[%r!^/(\d+\.\d{2})$!] = "/price/%.2f"
|
|
43
|
-
@route[%r!^/(\d+\.\d{2})$!].should == "/price/%.2f"
|
|
44
|
-
|
|
45
|
-
@route[%r!^/(\d+\.\d+)!] = "/float/%.3f"
|
|
46
|
-
@route[%r!^/(\d+\.\d+)!].should == "/float/%.3f"
|
|
47
|
-
|
|
48
|
-
@route[%r!^/(\w+)!] = "/string/%s"
|
|
49
|
-
@route[%r!^/(\w+)!].should == "/string/%s"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it 'should be used - /float' do
|
|
53
|
-
r = get('/123.123')
|
|
54
|
-
r.status.should == 200
|
|
55
|
-
r.body.should == 'Float: 123.123'
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it 'should be used - /string' do
|
|
59
|
-
r = get('/foo')
|
|
60
|
-
r.status.should == 200
|
|
61
|
-
r.body.should == 'String: foo'
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it 'should use %.3f' do
|
|
65
|
-
r = get('/123.123456')
|
|
66
|
-
r.status.should == 200
|
|
67
|
-
r.body.should == 'Float: 123.123'
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it 'should resolve in the order added' do
|
|
71
|
-
r = get('/12.84')
|
|
72
|
-
r.status.should == 200
|
|
73
|
-
r.body.should == 'Price: $12.84'
|
|
20
|
+
it 'should provide backwards compat wrapper to Ramaze::Route' do
|
|
21
|
+
@route[ %r!^/(\d+)\.te?xt$! ] = "/text/%d"
|
|
22
|
+
@route[ 'foobar' ] = lambda{ |path, request|
|
|
23
|
+
'/bar' if path == '/foo' and request[:bar] == '1'
|
|
24
|
+
}
|
|
74
25
|
end
|
|
75
26
|
|
|
76
|
-
it 'should
|
|
77
|
-
r = get('/
|
|
27
|
+
it 'should work' do
|
|
28
|
+
r = get('/123.txt')
|
|
78
29
|
r.status.should == 200
|
|
79
|
-
r.body.should == '
|
|
30
|
+
r.body.should == 'text: 123'
|
|
80
31
|
|
|
81
|
-
r = get('/', '
|
|
32
|
+
r = get('/foo', 'bar=1')
|
|
82
33
|
r.status.should == 200
|
|
83
|
-
r.body.should == '
|
|
34
|
+
r.body.should == 'bar'
|
|
84
35
|
end
|
|
85
36
|
end
|
data/spec/examples/linking.rb
CHANGED
|
@@ -9,10 +9,10 @@ describe 'Linking' do
|
|
|
9
9
|
r = get('/').body
|
|
10
10
|
r.should.include('<a href="/help">Help?</a>')
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
it 'should provide a link to another controller' do
|
|
14
14
|
r = get('/help').body
|
|
15
15
|
r.should.include('<a href="/link_to/another">A Different Controller</a>')
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
spec_require 'redcloth'
|
|
4
|
+
require 'examples/templates/template_redcloth'
|
|
5
|
+
|
|
6
|
+
describe 'Template RedCloth' do
|
|
7
|
+
behaves_like 'http'
|
|
8
|
+
ramaze
|
|
9
|
+
|
|
10
|
+
it '/' do
|
|
11
|
+
html = get('/').body.strip
|
|
12
|
+
html.should =~ %r(<a href=\"/\">Home</a>)
|
|
13
|
+
html.should =~ %r(<a href=\"/internal\">internal</a>)
|
|
14
|
+
html.should =~ %r(<a href=\"/external\">external</a>)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
%w[/internal /external].each do |url|
|
|
18
|
+
it url do
|
|
19
|
+
name = url.gsub(/^\//, '')
|
|
20
|
+
response = get(url)
|
|
21
|
+
response.status.should == 200
|
|
22
|
+
html = response.body
|
|
23
|
+
html.should.not == nil
|
|
24
|
+
html.should =~ %r(<title>Template::RedCloth #{name}</title>)
|
|
25
|
+
html.should =~ %r(<h1>The #{name} Template for RedCloth</h1>)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
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 BaseController < Ramaze::Controller
|
|
7
|
+
def test() 'test' end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class MainController < BaseController
|
|
11
|
+
engine :None
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe 'Controller' do
|
|
15
|
+
behaves_like 'http'
|
|
16
|
+
ramaze
|
|
17
|
+
|
|
18
|
+
it 'should allow sub-classing MainController' do
|
|
19
|
+
get('/test').body.should == 'test'
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -21,4 +21,35 @@ describe 'Dispatcher::File' do
|
|
|
21
21
|
end
|
|
22
22
|
get('/favicon.ico').body.should == original
|
|
23
23
|
end
|
|
24
|
+
|
|
25
|
+
it 'should send ETag' do
|
|
26
|
+
res = get '/test_download.css'
|
|
27
|
+
res.headers['ETag'].should.not.be == nil
|
|
28
|
+
res.headers['ETag'].length.should == 34 # "32 hash"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should send Last-Modified' do
|
|
32
|
+
res = get '/test_download.css'
|
|
33
|
+
res.headers['Last-Modified'].should.not.be == nil
|
|
34
|
+
res.headers['Last-Modified'].should == File.stat(@public_root/'test_download.css').mtime.httpdate
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should respect ETag with IF_NONE_MATCHES' do
|
|
38
|
+
res = get '/test_download.css'
|
|
39
|
+
etag = res.headers['ETag']
|
|
40
|
+
etag.should.not.be == nil
|
|
41
|
+
res = get '/test_download.css', :if_none_match=>etag
|
|
42
|
+
res.status.should == 304
|
|
43
|
+
res.body.should == ''
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'should respect If-Modified' do
|
|
47
|
+
res = get '/test_download.css'
|
|
48
|
+
mtime = res.headers['Last-Modified']
|
|
49
|
+
mtime.should.not.be == nil
|
|
50
|
+
res = get '/test_download.css', :if_modified_since=>mtime
|
|
51
|
+
res.status.should == 304
|
|
52
|
+
res.body.should == ''
|
|
53
|
+
end
|
|
54
|
+
|
|
24
55
|
end
|
data/spec/ramaze/helper/link.rb
CHANGED
|
@@ -6,11 +6,24 @@ require 'ramaze/helper/link'
|
|
|
6
6
|
|
|
7
7
|
class TCLink < Ramaze::Controller
|
|
8
8
|
map '/'
|
|
9
|
+
def index; end
|
|
9
10
|
end
|
|
10
11
|
|
|
12
|
+
class TCLink2 < Ramaze::Controller
|
|
13
|
+
map '/2'
|
|
14
|
+
def index; end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
ramaze
|
|
18
|
+
|
|
11
19
|
describe "A" do
|
|
12
20
|
extend Ramaze::LinkHelper
|
|
13
21
|
|
|
22
|
+
before do
|
|
23
|
+
# initialize Ramaze::Controller.current for Rs()
|
|
24
|
+
Ramaze::Controller.handle('/')
|
|
25
|
+
end
|
|
26
|
+
|
|
14
27
|
it 'should build links' do
|
|
15
28
|
A('title', :href => '/').should == %(<a href="/">title</a>)
|
|
16
29
|
A('title', :href => '/foo').should == %(<a href="/foo">title</a>)
|
|
@@ -21,6 +34,10 @@ describe "A" do
|
|
|
21
34
|
a.should =~ /class="none"/
|
|
22
35
|
a.should =~ /href="\/foo"/
|
|
23
36
|
end
|
|
37
|
+
|
|
38
|
+
it 'should build position independend links' do
|
|
39
|
+
A(TCLink, :foo).should == %(<a href="/foo">foo</a>)
|
|
40
|
+
end
|
|
24
41
|
end
|
|
25
42
|
|
|
26
43
|
describe 'R' do
|
|
@@ -34,6 +51,24 @@ describe 'R' do
|
|
|
34
51
|
end
|
|
35
52
|
end
|
|
36
53
|
|
|
54
|
+
describe 'Rs' do
|
|
55
|
+
extend Ramaze::LinkHelper
|
|
56
|
+
|
|
57
|
+
it 'should build links for current controller' do
|
|
58
|
+
Ramaze::Controller.handle('/2')
|
|
59
|
+
Rs(:index).should == '/2/index'
|
|
60
|
+
|
|
61
|
+
Ramaze::Controller.handle('/')
|
|
62
|
+
Rs(:index).should == '/index'
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'should treat Rs() like R() when Controller given' do
|
|
66
|
+
Ramaze::Controller.handle('/2')
|
|
67
|
+
Rs(TCLink, :index).should == '/2/index'
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
37
72
|
describe 'breadcrumbs' do
|
|
38
73
|
extend Ramaze::LinkHelper
|
|
39
74
|
|
|
@@ -47,4 +82,15 @@ describe 'breadcrumbs' do
|
|
|
47
82
|
"<a href=\"/file/dir/listing/is/cool\">cool</a>"
|
|
48
83
|
].join('/')
|
|
49
84
|
end
|
|
85
|
+
|
|
86
|
+
it 'should lay out breadcrumbs with href prefix' do
|
|
87
|
+
breadcrumbs('/file/dir/listing/is/cool', '/', '/', '/prefix/path').
|
|
88
|
+
should == [
|
|
89
|
+
"<a href=\"/prefix/path/file\">file</a>",
|
|
90
|
+
"<a href=\"/prefix/path/file/dir\">dir</a>",
|
|
91
|
+
"<a href=\"/prefix/path/file/dir/listing\">listing</a>",
|
|
92
|
+
"<a href=\"/prefix/path/file/dir/listing/is\">is</a>",
|
|
93
|
+
"<a href=\"/prefix/path/file/dir/listing/is/cool\">cool</a>"
|
|
94
|
+
].join('/')
|
|
95
|
+
end
|
|
50
96
|
end
|