ramaze 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +26 -6
- data/bin/ramaze +8 -1
- data/doc/AUTHORS +13 -11
- data/doc/CHANGELOG +472 -13
- data/doc/LEGAL +22 -0
- data/doc/README +1 -4
- data/doc/TODO +7 -2
- data/doc/changes.txt +472 -13
- data/doc/changes.xml +472 -13
- data/doc/meta/announcement.txt +21 -23
- data/doc/readme_chunks/appendix.txt +0 -3
- data/doc/readme_chunks/features.txt +1 -1
- data/examples/auth/auth.rb +49 -0
- data/examples/auth/template/layout.haml +20 -0
- data/examples/auth/template/login.haml +16 -0
- data/examples/blog/spec/blog.rb +1 -0
- data/examples/caching.rb +5 -6
- data/examples/css.rb +37 -0
- data/examples/layout.rb +3 -17
- data/examples/simple_auth.rb +23 -0
- data/examples/sourceview/public/images/file.gif +0 -0
- data/examples/sourceview/public/images/folder.gif +0 -0
- data/examples/sourceview/public/images/tv-collapsable-last.gif +0 -0
- data/examples/sourceview/public/images/tv-collapsable.gif +0 -0
- data/examples/sourceview/public/images/tv-expandable-last.gif +0 -0
- data/examples/sourceview/public/images/tv-expandable.gif +0 -0
- data/examples/sourceview/public/images/tv-item-last.gif +0 -0
- data/examples/sourceview/public/images/tv-item.gif +0 -0
- data/examples/sourceview/public/jquery.js +11 -0
- data/examples/sourceview/public/jquery.treeview.css +47 -0
- data/examples/sourceview/public/jquery.treeview.js +223 -0
- data/examples/sourceview/public/sourceview.js +16 -0
- data/examples/sourceview/sourceview.rb +74 -0
- data/examples/sourceview/template/index.haml +43 -0
- data/examples/templates/template/external.nag +28 -0
- data/examples/templates/template/external.xsl +57 -0
- data/examples/templates/template_amrita2.rb +2 -4
- data/examples/templates/template_erubis.rb +1 -1
- data/examples/templates/template_haml.rb +1 -1
- data/examples/templates/template_liquid.rb +2 -4
- data/examples/templates/template_markaby.rb +2 -4
- data/examples/templates/template_nagoro.rb +53 -0
- data/examples/templates/template_remarkably.rb +2 -4
- data/examples/templates/template_xslt.rb +52 -0
- data/examples/whywiki/spec/whywiki.rb +63 -0
- data/examples/whywiki/start.rb +11 -13
- data/examples/whywiki/template/edit.xhtml +3 -3
- data/examples/whywiki/template/show.xhtml +5 -8
- data/examples/wikore/spec/wikore.rb +115 -0
- data/examples/wikore/src/controller.rb +81 -0
- data/examples/wikore/src/model.rb +51 -0
- data/examples/wikore/start.rb +6 -0
- data/examples/wikore/template/index.xhtml +8 -0
- data/examples/wiktacular/spec/wiktacular.rb +1 -0
- data/examples/wiktacular/src/controller.rb +1 -1
- data/lib/ramaze.rb +6 -3
- data/lib/ramaze/action.rb +2 -13
- data/lib/ramaze/action/render.rb +36 -18
- data/lib/ramaze/adapter.rb +1 -1
- data/lib/ramaze/adapter/cgi.rb +0 -3
- data/lib/ramaze/adapter/evented_mongrel.rb +7 -0
- data/lib/ramaze/adapter/mongrel.rb +4 -13
- data/lib/ramaze/adapter/swiftiplied_mongrel.rb +7 -0
- data/lib/ramaze/cache.rb +12 -7
- data/lib/ramaze/contrib.rb +22 -0
- data/lib/ramaze/contrib/auto_params.rb +128 -0
- data/lib/ramaze/contrib/auto_params/get_args.rb +56 -0
- data/lib/ramaze/contrib/gzip_filter.rb +57 -0
- data/lib/ramaze/contrib/route.rb +40 -0
- data/lib/ramaze/contrib/sequel/fill.rb +12 -0
- data/lib/ramaze/controller.rb +17 -6
- data/lib/ramaze/controller/resolve.rb +51 -14
- data/lib/ramaze/dispatcher.rb +15 -13
- data/lib/ramaze/dispatcher/action.rb +4 -3
- data/lib/ramaze/dispatcher/directory.rb +3 -3
- data/lib/ramaze/dispatcher/error.rb +1 -1
- data/lib/ramaze/dispatcher/file.rb +17 -6
- data/lib/ramaze/error.rb +3 -0
- data/lib/ramaze/gestalt.rb +28 -8
- data/lib/ramaze/global.rb +26 -6
- data/lib/ramaze/global/globalstruct.rb +31 -6
- data/lib/ramaze/helper.rb +2 -1
- data/lib/ramaze/helper/aspect.rb +2 -2
- data/lib/ramaze/helper/auth.rb +6 -9
- data/lib/ramaze/helper/cache.rb +89 -9
- data/lib/ramaze/helper/cgi.rb +2 -2
- data/lib/ramaze/helper/formatting.rb +44 -0
- data/lib/ramaze/helper/link.rb +7 -5
- data/lib/ramaze/helper/partial.rb +6 -4
- data/lib/ramaze/helper/redirect.rb +24 -9
- data/lib/ramaze/helper/stack.rb +6 -1
- data/lib/ramaze/inform/growl.rb +1 -1
- data/lib/ramaze/inform/informer.rb +2 -1
- data/lib/ramaze/inform/informing.rb +6 -0
- data/lib/ramaze/inform/syslog.rb +1 -0
- data/lib/ramaze/snippets/array/put_within.rb +24 -0
- data/lib/ramaze/snippets/dictionary.rb +499 -0
- data/lib/ramaze/snippets/numeric/filesize_format.rb +19 -0
- data/lib/ramaze/snippets/ordered_set.rb +31 -0
- data/lib/ramaze/snippets/string/DIVIDE.rb +1 -1
- data/lib/ramaze/snippets/string/snake_case.rb +1 -1
- data/lib/ramaze/snippets/struct/values_at.rb +5 -1
- data/lib/ramaze/snippets/thread/into.rb +25 -0
- data/lib/ramaze/sourcereload.rb +39 -19
- data/lib/ramaze/spec/helper.rb +4 -1
- data/lib/ramaze/spec/helper/{context.rb → browser.rb} +3 -0
- data/lib/ramaze/spec/helper/layout.rb +3 -0
- data/lib/ramaze/spec/helper/minimal.rb +3 -0
- data/lib/ramaze/spec/helper/mock_http.rb +8 -5
- data/lib/ramaze/spec/helper/requester.rb +4 -1
- data/lib/ramaze/spec/helper/wrap.rb +15 -7
- data/lib/ramaze/template.rb +5 -1
- data/lib/ramaze/template/ezamar/engine.rb +2 -3
- data/lib/ramaze/template/ezamar/morpher.rb +26 -45
- data/lib/ramaze/template/nagoro.rb +53 -0
- data/lib/ramaze/template/none.rb +14 -0
- data/lib/ramaze/template/xslt.rb +96 -0
- data/lib/ramaze/tool.rb +0 -1
- data/lib/ramaze/tool/localize.rb +7 -2
- data/lib/ramaze/trinity/request.rb +1 -0
- data/lib/ramaze/trinity/session.rb +3 -3
- data/lib/ramaze/version.rb +2 -2
- data/rake_tasks/conf.rake +1 -2
- data/rake_tasks/{maintaince.rake → maintenance.rake} +25 -17
- data/spec/contrib/auto_params.rb +97 -0
- data/spec/contrib/route.rb +60 -0
- data/spec/contrib/sequel/fill.rb +46 -0
- data/spec/examples/caching.rb +1 -2
- data/spec/examples/css.rb +12 -0
- data/spec/examples/element.rb +0 -1
- data/spec/examples/hello.rb +0 -1
- data/spec/examples/simple.rb +0 -1
- data/spec/helper.rb +3 -2
- data/spec/ramaze/action/cache.rb +24 -7
- data/spec/ramaze/action/layout.rb +19 -11
- data/spec/ramaze/action/template/sub/sub_wrapper.xhtml +1 -0
- data/spec/ramaze/controller.rb +11 -0
- data/spec/ramaze/controller/template_resolving.rb +28 -27
- data/spec/ramaze/dispatcher.rb +32 -0
- data/spec/ramaze/dispatcher/directory.rb +2 -1
- data/spec/ramaze/element.rb +1 -1
- data/spec/ramaze/gestalt.rb +28 -0
- data/spec/ramaze/helper/aspect.rb +14 -3
- data/spec/ramaze/helper/cache.rb +78 -13
- data/spec/ramaze/helper/formatting.rb +20 -0
- data/spec/ramaze/helper/link.rb +2 -0
- data/spec/ramaze/helper/partial.rb +12 -1
- data/spec/ramaze/helper/redirect.rb +44 -8
- data/spec/ramaze/helper/stack.rb +3 -3
- data/spec/ramaze/helper/template/loop.xhtml +3 -0
- data/spec/ramaze/helper/template/num.xhtml +1 -0
- data/spec/ramaze/helper/template/recursive.xhtml +8 -0
- data/spec/ramaze/morpher.rb +25 -6
- data/spec/ramaze/params.rb +6 -2
- data/spec/ramaze/request.rb +5 -2
- data/spec/ramaze/session.rb +19 -0
- data/spec/ramaze/template.rb +2 -2
- data/spec/ramaze/template/amrita2.rb +2 -2
- data/spec/ramaze/template/erubis.rb +2 -2
- data/spec/ramaze/template/ezamar.rb +6 -3
- data/spec/ramaze/template/haml.rb +3 -3
- data/spec/ramaze/template/liquid.rb +1 -1
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/nagoro.rb +65 -0
- data/spec/ramaze/template/nagoro/another/long/action.nag +1 -0
- data/spec/ramaze/template/nagoro/combined.nag +1 -0
- data/spec/ramaze/template/nagoro/file_only.nag +1 -0
- data/spec/ramaze/template/nagoro/index.nag +1 -0
- data/spec/ramaze/template/nagoro/nested.nag +1 -0
- data/spec/ramaze/template/nagoro/some__long__action.nag +1 -0
- data/spec/ramaze/template/nagoro/sum.nag +1 -0
- data/spec/ramaze/template/remarkably.rb +1 -1
- data/spec/ramaze/template/sass.rb +1 -1
- data/spec/ramaze/template/xslt.rb +93 -0
- data/spec/ramaze/template/xslt/concat_words.xsl +16 -0
- data/spec/ramaze/template/xslt/index.xsl +14 -0
- data/spec/ramaze/template/xslt/products.xsl +32 -0
- data/spec/ramaze/template/xslt/ruby_version.xsl +14 -0
- data/spec/snippets/array/put_within.rb +32 -0
- data/spec/snippets/numeric/filesize_format.rb +12 -0
- data/spec/snippets/ordered_set.rb +56 -0
- data/spec/snippets/ramaze/caller_lines.rb +6 -3
- data/spec/snippets/string/snake_case.rb +3 -0
- metadata +118 -22
- data/doc/README.html +0 -737
- data/examples/fcgi.rb +0 -13
- data/lib/ramaze/snippets/numeric/human_readable_filesize_format.rb +0 -33
- data/lib/ramaze/tool/tidy.rb +0 -104
- data/spec/ramaze/controller/template/edit.xhtml +0 -1
- data/spec/ramaze/controller/template/edit/content.xhtml +0 -1
- data/spec/ramaze/tidy.rb +0 -12
- data/spec/snippets/numeric/human_readable_filesize_format.rb +0 -11
@@ -3,16 +3,34 @@
|
|
3
3
|
|
4
4
|
module Ramaze
|
5
5
|
class Controller
|
6
|
+
FILTER = [ :cached, :default ] unless defined?(FILTER)
|
7
|
+
|
6
8
|
class << self
|
7
|
-
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
|
10
|
+
# Resolve an absolute path in the application by passing it to each
|
11
|
+
# element of Ramaze::Controller::FILTER.
|
12
|
+
# Elements in exclude_filter are excluded from handling.
|
13
|
+
# If an element does not respond to call it will be sent to self
|
14
|
+
# instead, in either case with path as argument.
|
15
|
+
|
16
|
+
def resolve(path, *exclude_filter)
|
17
|
+
(FILTER - exclude_filter.flatten).each do |filter|
|
18
|
+
answer =
|
19
|
+
if filter.respond_to?(:call)
|
20
|
+
filter.call(path)
|
21
|
+
else
|
22
|
+
send(filter.to_s, path)
|
23
|
+
end
|
24
|
+
return answer if answer
|
25
|
+
end
|
26
|
+
|
27
|
+
raise_no_filter(path)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Default element of FILTER.
|
31
|
+
# Looks up the path in Cache.resolved and returns it if found.
|
32
|
+
|
33
|
+
def cached(path)
|
16
34
|
if found = Cache.resolved[path]
|
17
35
|
if found.respond_to?(:relaxed_hash)
|
18
36
|
return found.dup
|
@@ -22,6 +40,15 @@ module Ramaze
|
|
22
40
|
end
|
23
41
|
end
|
24
42
|
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
# Default element of FILTER.
|
47
|
+
# The default handler that tries to find the best match for the given
|
48
|
+
# path in terms of Controller/method/template and given arguments.
|
49
|
+
# If a match is found it will be cached for further use.
|
50
|
+
|
51
|
+
def default(path)
|
25
52
|
mapping = Global.mapping
|
26
53
|
controllers = Global.controllers
|
27
54
|
|
@@ -52,6 +79,7 @@ module Ramaze
|
|
52
79
|
|
53
80
|
# Try to produce an Action from the given path and paremters with the
|
54
81
|
# appropiate template if one exists.
|
82
|
+
|
55
83
|
def resolve_action(path, *parameter)
|
56
84
|
path, parameter = path.to_s, parameter.map(&:to_s)
|
57
85
|
if alternate_template = trait["#{path}_template"]
|
@@ -74,6 +102,7 @@ module Ramaze
|
|
74
102
|
|
75
103
|
# Search the #template_paths for a fitting template for path.
|
76
104
|
# Only the first found possibility for the generated glob is returned.
|
105
|
+
|
77
106
|
def resolve_template(path)
|
78
107
|
path = path.to_s
|
79
108
|
path_converted = path.split('__').inject{|s,v| s/v}
|
@@ -118,7 +147,7 @@ module Ramaze
|
|
118
147
|
|
119
148
|
# Generate all possible permutations for given path.
|
120
149
|
def pattern_for(path)
|
121
|
-
atoms = path.split('/').grep(/\S/)
|
150
|
+
atoms = path.to_s.split('/').grep(/\S/)
|
122
151
|
atoms.unshift('')
|
123
152
|
patterns, joiner = [], '/'
|
124
153
|
|
@@ -149,10 +178,18 @@ module Ramaze
|
|
149
178
|
# templating-engine to use ordered by priority and likelyhood.
|
150
179
|
def extension_order
|
151
180
|
t_extensions = Template::ENGINES
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
181
|
+
all_extensions = t_extensions.values.flatten
|
182
|
+
|
183
|
+
if engine = trait[:engine]
|
184
|
+
c_extensions = t_extensions.select{|k,v| k == engine}.map{|k,v| v}.flatten
|
185
|
+
return (c_extensions + all_extensions).uniq
|
186
|
+
end
|
187
|
+
|
188
|
+
all_extensions
|
189
|
+
end
|
190
|
+
|
191
|
+
def raise_no_filter(path)
|
192
|
+
raise Ramaze::Error::NoFilter, "No Filter found for `#{path}'"
|
156
193
|
end
|
157
194
|
|
158
195
|
# Raises Ramaze::Error::NoController
|
data/lib/ramaze/dispatcher.rb
CHANGED
@@ -20,8 +20,7 @@ module Ramaze
|
|
20
20
|
module Dispatcher
|
21
21
|
|
22
22
|
# requests are passed to every
|
23
|
-
FILTER = [ Dispatcher::File, Dispatcher::
|
24
|
-
Dispatcher::Action ] unless defined?(FILTER)
|
23
|
+
FILTER = [ Dispatcher::File, Dispatcher::Action ] unless defined?(FILTER)
|
25
24
|
|
26
25
|
# Response codes to cache the output of for repeated requests.
|
27
26
|
trait :shielded => [ STATUS_CODE["Not Found"] ]
|
@@ -36,7 +35,13 @@ module Ramaze
|
|
36
35
|
setup_environment(rack_request, rack_response)
|
37
36
|
|
38
37
|
path = request.path_info.squeeze('/')
|
39
|
-
|
38
|
+
|
39
|
+
case path
|
40
|
+
when *Global.ignore
|
41
|
+
unless ::File.exist?(Dispatcher::File.resolve_path(path))
|
42
|
+
return response.build(Global.ignore_body, Global.ignore_status)
|
43
|
+
end
|
44
|
+
end
|
40
45
|
|
41
46
|
general_dispatch path
|
42
47
|
rescue Object => error
|
@@ -94,16 +99,13 @@ module Ramaze
|
|
94
99
|
# filters the path until a response or redirect is thrown or a filter is
|
95
100
|
# successful, builds a response from the returned hash in case of throws.
|
96
101
|
def dispatch(path)
|
97
|
-
catch(:respond)
|
98
|
-
|
99
|
-
|
100
|
-
throw(:respond
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
Inform.info("Redirect to `#{head['Location']}'")
|
105
|
-
throw(:respond, response.build(body, status, head))
|
106
|
-
end
|
102
|
+
catch(:respond){
|
103
|
+
redirected = catch(:redirect){
|
104
|
+
filter(path)
|
105
|
+
throw(:respond)
|
106
|
+
}
|
107
|
+
response.build(*redirected)
|
108
|
+
}
|
107
109
|
end
|
108
110
|
|
109
111
|
# Calls .process(path) on every class in Dispatcher::FILTER until one
|
@@ -11,18 +11,19 @@ module Ramaze
|
|
11
11
|
|
12
12
|
# The response is passed to each filter by sending .call(response) to it.
|
13
13
|
|
14
|
-
FILTER =
|
14
|
+
FILTER = OrderedSet.new(
|
15
15
|
# Ramaze::Tool::Localize,
|
16
|
-
|
17
|
-
]
|
16
|
+
) unless defined?(FILTER)
|
18
17
|
|
19
18
|
class << self
|
19
|
+
include Trinity
|
20
20
|
|
21
21
|
# Takes path, asks Controller to handle it and builds a response on
|
22
22
|
# success. The response is then passed to each member of FILTER for
|
23
23
|
# post-processing.
|
24
24
|
|
25
25
|
def process(path)
|
26
|
+
Inform.info("Dynamic request from #{request.remote_addr}: #{path}")
|
26
27
|
body = Controller.handle(path)
|
27
28
|
response = Response.current.build(body)
|
28
29
|
FILTER.inject(response){|r,f| f.call(r) }
|
@@ -78,7 +78,7 @@ module Ramaze
|
|
78
78
|
dirs, files = Dir[path/'*'].partition{|file| ::File.directory?(file) }
|
79
79
|
dir_body, file_body = [], []
|
80
80
|
|
81
|
-
dirs.each do |dir|
|
81
|
+
dirs.sort.each do |dir|
|
82
82
|
basename = ::File.basename(dir)
|
83
83
|
dir_body << %[<tr>
|
84
84
|
<td class="n"><a href="#{display/basename}">#{basename}/</a></td>
|
@@ -89,10 +89,10 @@ module Ramaze
|
|
89
89
|
end
|
90
90
|
|
91
91
|
time_format = "%Y-%b-%d %H:%M:%S"
|
92
|
-
files.each do |file|
|
92
|
+
files.sort.each do |file|
|
93
93
|
basename = ::File.basename(file)
|
94
94
|
time = ::File.mtime(file).strftime(time_format)
|
95
|
-
size = ::File.size(file).
|
95
|
+
size = ::File.size(file).filesize_format
|
96
96
|
mime = Tool::MIME.type_for(file)
|
97
97
|
file_body << %[<tr>
|
98
98
|
<td class="n"><a href="#{display/basename}">#{basename}</a></td>
|
@@ -64,7 +64,7 @@ module Ramaze
|
|
64
64
|
def log_error error
|
65
65
|
error_message = error.message
|
66
66
|
|
67
|
-
if trait[:last_error] == error_message
|
67
|
+
if trait[:last_error] == error_message or error.is_a? Ramaze::Error::NoAction
|
68
68
|
Inform.error(error_message)
|
69
69
|
else
|
70
70
|
trait[:last_error] = error_message
|
@@ -9,26 +9,37 @@ module Ramaze
|
|
9
9
|
|
10
10
|
class File
|
11
11
|
class << self
|
12
|
+
include Trinity
|
12
13
|
|
13
14
|
# Entry point from Dispatcher::filter.
|
14
15
|
# searches for the file and builds a response with status 200 if found.
|
15
16
|
|
16
17
|
def process(path)
|
17
18
|
return unless file = open_file(path)
|
18
|
-
|
19
|
+
response.build(file, STATUS_CODE['OK'])
|
19
20
|
end
|
20
21
|
|
21
22
|
# returns file-handle with the open file on success, setting the
|
22
23
|
# Content-Type as found in Tool::MIME
|
23
24
|
|
24
25
|
def open_file(path)
|
25
|
-
file =
|
26
|
+
file = resolve_path(path)
|
27
|
+
if ::File.file?(file) or ::File.file?(file=file/'index')
|
28
|
+
response['Content-Type'] = Tool::MIME.type_for(file) unless ::File.extname(file).empty?
|
29
|
+
log(file)
|
30
|
+
::File.open(file, 'rb')
|
31
|
+
end
|
32
|
+
end
|
26
33
|
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
def resolve_path(path)
|
35
|
+
::File.join(Global.public_root, path)
|
36
|
+
end
|
37
|
+
|
38
|
+
def log(file)
|
39
|
+
case file
|
40
|
+
when *Global.boring
|
41
|
+
else
|
30
42
|
Inform.debug("Serving static: #{file}")
|
31
|
-
::File.open(file, 'rb')
|
32
43
|
end
|
33
44
|
end
|
34
45
|
end
|
data/lib/ramaze/error.rb
CHANGED
data/lib/ramaze/gestalt.rb
CHANGED
@@ -72,32 +72,52 @@ module Ramaze
|
|
72
72
|
# catching all the tags. passing it to _gestalt_build_tag
|
73
73
|
|
74
74
|
def method_missing meth, *args, &block
|
75
|
-
|
75
|
+
_gestalt_call_tag meth, args, &block
|
76
76
|
end
|
77
77
|
|
78
78
|
# workaround for Kernel#p to make <p /> tags possible.
|
79
79
|
|
80
80
|
def p *args, &block
|
81
|
-
|
81
|
+
_gestalt_call_tag :p, args, &block
|
82
|
+
end
|
83
|
+
|
84
|
+
def _gestalt_call_tag name, args, &block
|
85
|
+
if args.size == 1 and args[0].kind_of? Hash
|
86
|
+
# args are just attributes, children in block...
|
87
|
+
_gestalt_build_tag name, args[0], &block
|
88
|
+
else
|
89
|
+
# no attributes, but text
|
90
|
+
_gestalt_build_tag name, {}, args, &block
|
91
|
+
end
|
82
92
|
end
|
83
93
|
|
84
94
|
# build a tag for `name`, using `args` and an optional block that
|
85
95
|
# will be yielded
|
86
96
|
|
87
|
-
def _gestalt_build_tag name,
|
97
|
+
def _gestalt_build_tag name, attr={}, text=[]
|
88
98
|
@out << "<#{name}"
|
89
|
-
|
90
|
-
|
99
|
+
@out << attr.inject(''){ |s,v| s << %{ #{v[0]}="#{_gestalt_escape_entities(v[1])}"} }
|
100
|
+
if text != [] or block_given?
|
91
101
|
@out << ">"
|
92
|
-
|
93
|
-
|
102
|
+
@out << _gestalt_escape_entities(text.to_s)
|
103
|
+
if block_given?
|
104
|
+
text = yield
|
105
|
+
@out << text.to_str if text != @out and text.respond_to?(:to_str)
|
106
|
+
end
|
94
107
|
@out << "</#{name}>"
|
95
108
|
else
|
96
|
-
@out << args.inject(''){ |s,v| s << %{ #{v[0]}="#{v[1]}"} }
|
97
109
|
@out << ' />'
|
98
110
|
end
|
99
111
|
end
|
100
112
|
|
113
|
+
def _gestalt_escape_entities(s)
|
114
|
+
s.to_s.gsub(/&/, '&').
|
115
|
+
gsub(/"/, '"').
|
116
|
+
gsub(/'/, ''').
|
117
|
+
gsub(/</, '<').
|
118
|
+
gsub(/>/, '>')
|
119
|
+
end
|
120
|
+
|
101
121
|
# @out.to_s
|
102
122
|
|
103
123
|
def to_s
|
data/lib/ramaze/global.rb
CHANGED
@@ -20,15 +20,25 @@ module Ramaze
|
|
20
20
|
o "Turn benchmarking every request on.",
|
21
21
|
:benchmarking => false, :cli => false, :short => :b
|
22
22
|
|
23
|
+
o "Do not log about these requests to static files, values as in Global.ignore",
|
24
|
+
# Example: [/\.(ico|gif|jpg|png)$/, '/robots.txt']
|
25
|
+
:boring => [ '/favicon.ico' ]
|
26
|
+
|
23
27
|
o "Use this for general caching and as base for Cache.new.",
|
24
28
|
:cache => :memory, :cli => [:memory, :memcached, :yaml]
|
25
29
|
|
30
|
+
o "Alternative caches",
|
31
|
+
:cache_alternative => {}
|
32
|
+
|
26
33
|
o "Turn on naive caching of all requests.",
|
27
34
|
:cache_all => false, :cli => false
|
28
35
|
|
29
36
|
o "Compile Templates",
|
30
37
|
:compile => false, :cli => false
|
31
38
|
|
39
|
+
o "Active contribs ",
|
40
|
+
:contribs => Set.new
|
41
|
+
|
32
42
|
o "All subclasses of Controller are collected here.",
|
33
43
|
:controllers => Set.new
|
34
44
|
|
@@ -41,12 +51,22 @@ module Ramaze
|
|
41
51
|
o "Caching actions to the filesystem in Global.public_root",
|
42
52
|
:file_cache => false, :cli => false
|
43
53
|
|
44
|
-
o "Base directory for meta information of file-caching",
|
45
|
-
:file_cache_meta_dir => "cache_meta", :cli => "cache_meta"
|
46
|
-
|
47
54
|
o "Specify what IP Ramaze will respond to - 0.0.0.0 for all",
|
48
55
|
:host => "0.0.0.0", :cli => '0.0.0.0'
|
49
56
|
|
57
|
+
o "Ignore requests to these paths if no file in public_root exists, absolute path or regex",
|
58
|
+
# Example: [/\.(ico|gif|jpg|png)$/, '/robots.txt']
|
59
|
+
:ignore => [ '/favicon.ico' ]
|
60
|
+
|
61
|
+
o "Body set on ignored paths",
|
62
|
+
:ignore_body => "File not found"
|
63
|
+
|
64
|
+
o "Status set on ignored paths",
|
65
|
+
:ignore_status => 404
|
66
|
+
|
67
|
+
o "Templating engines to load on startup",
|
68
|
+
:load_engines => []
|
69
|
+
|
50
70
|
o "All paths to controllers are mapped here.",
|
51
71
|
:mapping => {}
|
52
72
|
|
@@ -57,7 +77,7 @@ module Ramaze
|
|
57
77
|
:port => 7000, :cli => 7000, :short => :p
|
58
78
|
|
59
79
|
o "Specify directory to serve static files",
|
60
|
-
:public_root => './public', :cli => './
|
80
|
+
:public_root => APPDIR/'./public', :cli => './template'
|
61
81
|
|
62
82
|
o "Record all Request objects by assigning a filtering Proc to me.",
|
63
83
|
:record => false
|
@@ -84,7 +104,7 @@ module Ramaze
|
|
84
104
|
:test_connections => true, :cli => true
|
85
105
|
|
86
106
|
o "Specify directory to serve dynamic files",
|
87
|
-
:template_root => './template', :cli => './template'
|
107
|
+
:template_root => APPDIR/'./template', :cli => './template'
|
88
108
|
|
89
109
|
o "Enable directory listing",
|
90
110
|
:list_directories => false, :cli => false
|
@@ -92,5 +112,5 @@ module Ramaze
|
|
92
112
|
|
93
113
|
require 'ramaze/global/globalstruct'
|
94
114
|
|
95
|
-
Global = GlobalStruct.setup(OPTIONS)
|
115
|
+
Global = GlobalStruct.setup(OPTIONS) unless defined?(Global)
|
96
116
|
end
|
@@ -10,12 +10,19 @@ module Ramaze
|
|
10
10
|
# Class for Ramaze::Global instance.
|
11
11
|
class GlobalStruct
|
12
12
|
|
13
|
+
ENV_TRIGGER = {
|
14
|
+
'EVENT' => lambda{ require 'ramaze/adapter/evented_mongrel' },
|
15
|
+
'SWIFT' => lambda{ require 'ramaze/adapter/swiftiplied_mongrel' }
|
16
|
+
}
|
17
|
+
|
13
18
|
# mapping of :adapter => to the right class-name.
|
14
19
|
ADAPTER_ALIAS = {
|
15
|
-
:webrick
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
20
|
+
:webrick => :WEBrick,
|
21
|
+
:cgi => :Cgi,
|
22
|
+
:fcgi => :Fcgi,
|
23
|
+
:mongrel => :Mongrel,
|
24
|
+
:evented_mongrel => :Mongrel,
|
25
|
+
:swiftiplied_mongrel => :Mongrel,
|
19
26
|
}
|
20
27
|
|
21
28
|
# mapping of :cache => to the right class-name.
|
@@ -38,6 +45,13 @@ module Ramaze
|
|
38
45
|
create_member(key, value)
|
39
46
|
end
|
40
47
|
end
|
48
|
+
|
49
|
+
ENV_TRIGGER.values_at(*ENV.keys).compact.each{|l| l.call}
|
50
|
+
|
51
|
+
engines = self[:load_engines]
|
52
|
+
(Symbol === engines ? [engines] : engines).each do |engine|
|
53
|
+
Ramaze::Template.const_get(engine)
|
54
|
+
end
|
41
55
|
end
|
42
56
|
|
43
57
|
# batch-assignment of key/value from hash, yields self if a block is given.
|
@@ -55,8 +69,8 @@ module Ramaze
|
|
55
69
|
# the actual class.
|
56
70
|
def adapter
|
57
71
|
if internal = self[:adapter]
|
58
|
-
class_name = ADAPTER_ALIAS
|
59
|
-
require("ramaze/adapter
|
72
|
+
class_name = ADAPTER_ALIAS.fetch(internal.to_sym, internal)
|
73
|
+
require("ramaze/adapter"/internal.to_s.downcase)
|
60
74
|
adapter = Ramaze::Adapter.const_get(class_name)
|
61
75
|
end
|
62
76
|
end
|
@@ -90,6 +104,17 @@ module Ramaze
|
|
90
104
|
self[:public_root] = File.expand_path(pr)
|
91
105
|
end
|
92
106
|
|
107
|
+
def list_directories=(active)
|
108
|
+
require 'ramaze/dispatcher'
|
109
|
+
d = Ramaze::Dispatcher
|
110
|
+
self[:list_directories] = active
|
111
|
+
if active
|
112
|
+
d::FILTER.put_within(d::Directory, :after => d::File, :before => d::Action)
|
113
|
+
else
|
114
|
+
d::FILTER.delete(d::Directory)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
93
118
|
|
94
119
|
# External helpers
|
95
120
|
|