ramaze 0.1.4 → 0.2.0

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 (192) hide show
  1. data/Rakefile +26 -6
  2. data/bin/ramaze +8 -1
  3. data/doc/AUTHORS +13 -11
  4. data/doc/CHANGELOG +472 -13
  5. data/doc/LEGAL +22 -0
  6. data/doc/README +1 -4
  7. data/doc/TODO +7 -2
  8. data/doc/changes.txt +472 -13
  9. data/doc/changes.xml +472 -13
  10. data/doc/meta/announcement.txt +21 -23
  11. data/doc/readme_chunks/appendix.txt +0 -3
  12. data/doc/readme_chunks/features.txt +1 -1
  13. data/examples/auth/auth.rb +49 -0
  14. data/examples/auth/template/layout.haml +20 -0
  15. data/examples/auth/template/login.haml +16 -0
  16. data/examples/blog/spec/blog.rb +1 -0
  17. data/examples/caching.rb +5 -6
  18. data/examples/css.rb +37 -0
  19. data/examples/layout.rb +3 -17
  20. data/examples/simple_auth.rb +23 -0
  21. data/examples/sourceview/public/images/file.gif +0 -0
  22. data/examples/sourceview/public/images/folder.gif +0 -0
  23. data/examples/sourceview/public/images/tv-collapsable-last.gif +0 -0
  24. data/examples/sourceview/public/images/tv-collapsable.gif +0 -0
  25. data/examples/sourceview/public/images/tv-expandable-last.gif +0 -0
  26. data/examples/sourceview/public/images/tv-expandable.gif +0 -0
  27. data/examples/sourceview/public/images/tv-item-last.gif +0 -0
  28. data/examples/sourceview/public/images/tv-item.gif +0 -0
  29. data/examples/sourceview/public/jquery.js +11 -0
  30. data/examples/sourceview/public/jquery.treeview.css +47 -0
  31. data/examples/sourceview/public/jquery.treeview.js +223 -0
  32. data/examples/sourceview/public/sourceview.js +16 -0
  33. data/examples/sourceview/sourceview.rb +74 -0
  34. data/examples/sourceview/template/index.haml +43 -0
  35. data/examples/templates/template/external.nag +28 -0
  36. data/examples/templates/template/external.xsl +57 -0
  37. data/examples/templates/template_amrita2.rb +2 -4
  38. data/examples/templates/template_erubis.rb +1 -1
  39. data/examples/templates/template_haml.rb +1 -1
  40. data/examples/templates/template_liquid.rb +2 -4
  41. data/examples/templates/template_markaby.rb +2 -4
  42. data/examples/templates/template_nagoro.rb +53 -0
  43. data/examples/templates/template_remarkably.rb +2 -4
  44. data/examples/templates/template_xslt.rb +52 -0
  45. data/examples/whywiki/spec/whywiki.rb +63 -0
  46. data/examples/whywiki/start.rb +11 -13
  47. data/examples/whywiki/template/edit.xhtml +3 -3
  48. data/examples/whywiki/template/show.xhtml +5 -8
  49. data/examples/wikore/spec/wikore.rb +115 -0
  50. data/examples/wikore/src/controller.rb +81 -0
  51. data/examples/wikore/src/model.rb +51 -0
  52. data/examples/wikore/start.rb +6 -0
  53. data/examples/wikore/template/index.xhtml +8 -0
  54. data/examples/wiktacular/spec/wiktacular.rb +1 -0
  55. data/examples/wiktacular/src/controller.rb +1 -1
  56. data/lib/ramaze.rb +6 -3
  57. data/lib/ramaze/action.rb +2 -13
  58. data/lib/ramaze/action/render.rb +36 -18
  59. data/lib/ramaze/adapter.rb +1 -1
  60. data/lib/ramaze/adapter/cgi.rb +0 -3
  61. data/lib/ramaze/adapter/evented_mongrel.rb +7 -0
  62. data/lib/ramaze/adapter/mongrel.rb +4 -13
  63. data/lib/ramaze/adapter/swiftiplied_mongrel.rb +7 -0
  64. data/lib/ramaze/cache.rb +12 -7
  65. data/lib/ramaze/contrib.rb +22 -0
  66. data/lib/ramaze/contrib/auto_params.rb +128 -0
  67. data/lib/ramaze/contrib/auto_params/get_args.rb +56 -0
  68. data/lib/ramaze/contrib/gzip_filter.rb +57 -0
  69. data/lib/ramaze/contrib/route.rb +40 -0
  70. data/lib/ramaze/contrib/sequel/fill.rb +12 -0
  71. data/lib/ramaze/controller.rb +17 -6
  72. data/lib/ramaze/controller/resolve.rb +51 -14
  73. data/lib/ramaze/dispatcher.rb +15 -13
  74. data/lib/ramaze/dispatcher/action.rb +4 -3
  75. data/lib/ramaze/dispatcher/directory.rb +3 -3
  76. data/lib/ramaze/dispatcher/error.rb +1 -1
  77. data/lib/ramaze/dispatcher/file.rb +17 -6
  78. data/lib/ramaze/error.rb +3 -0
  79. data/lib/ramaze/gestalt.rb +28 -8
  80. data/lib/ramaze/global.rb +26 -6
  81. data/lib/ramaze/global/globalstruct.rb +31 -6
  82. data/lib/ramaze/helper.rb +2 -1
  83. data/lib/ramaze/helper/aspect.rb +2 -2
  84. data/lib/ramaze/helper/auth.rb +6 -9
  85. data/lib/ramaze/helper/cache.rb +89 -9
  86. data/lib/ramaze/helper/cgi.rb +2 -2
  87. data/lib/ramaze/helper/formatting.rb +44 -0
  88. data/lib/ramaze/helper/link.rb +7 -5
  89. data/lib/ramaze/helper/partial.rb +6 -4
  90. data/lib/ramaze/helper/redirect.rb +24 -9
  91. data/lib/ramaze/helper/stack.rb +6 -1
  92. data/lib/ramaze/inform/growl.rb +1 -1
  93. data/lib/ramaze/inform/informer.rb +2 -1
  94. data/lib/ramaze/inform/informing.rb +6 -0
  95. data/lib/ramaze/inform/syslog.rb +1 -0
  96. data/lib/ramaze/snippets/array/put_within.rb +24 -0
  97. data/lib/ramaze/snippets/dictionary.rb +499 -0
  98. data/lib/ramaze/snippets/numeric/filesize_format.rb +19 -0
  99. data/lib/ramaze/snippets/ordered_set.rb +31 -0
  100. data/lib/ramaze/snippets/string/DIVIDE.rb +1 -1
  101. data/lib/ramaze/snippets/string/snake_case.rb +1 -1
  102. data/lib/ramaze/snippets/struct/values_at.rb +5 -1
  103. data/lib/ramaze/snippets/thread/into.rb +25 -0
  104. data/lib/ramaze/sourcereload.rb +39 -19
  105. data/lib/ramaze/spec/helper.rb +4 -1
  106. data/lib/ramaze/spec/helper/{context.rb → browser.rb} +3 -0
  107. data/lib/ramaze/spec/helper/layout.rb +3 -0
  108. data/lib/ramaze/spec/helper/minimal.rb +3 -0
  109. data/lib/ramaze/spec/helper/mock_http.rb +8 -5
  110. data/lib/ramaze/spec/helper/requester.rb +4 -1
  111. data/lib/ramaze/spec/helper/wrap.rb +15 -7
  112. data/lib/ramaze/template.rb +5 -1
  113. data/lib/ramaze/template/ezamar/engine.rb +2 -3
  114. data/lib/ramaze/template/ezamar/morpher.rb +26 -45
  115. data/lib/ramaze/template/nagoro.rb +53 -0
  116. data/lib/ramaze/template/none.rb +14 -0
  117. data/lib/ramaze/template/xslt.rb +96 -0
  118. data/lib/ramaze/tool.rb +0 -1
  119. data/lib/ramaze/tool/localize.rb +7 -2
  120. data/lib/ramaze/trinity/request.rb +1 -0
  121. data/lib/ramaze/trinity/session.rb +3 -3
  122. data/lib/ramaze/version.rb +2 -2
  123. data/rake_tasks/conf.rake +1 -2
  124. data/rake_tasks/{maintaince.rake → maintenance.rake} +25 -17
  125. data/spec/contrib/auto_params.rb +97 -0
  126. data/spec/contrib/route.rb +60 -0
  127. data/spec/contrib/sequel/fill.rb +46 -0
  128. data/spec/examples/caching.rb +1 -2
  129. data/spec/examples/css.rb +12 -0
  130. data/spec/examples/element.rb +0 -1
  131. data/spec/examples/hello.rb +0 -1
  132. data/spec/examples/simple.rb +0 -1
  133. data/spec/helper.rb +3 -2
  134. data/spec/ramaze/action/cache.rb +24 -7
  135. data/spec/ramaze/action/layout.rb +19 -11
  136. data/spec/ramaze/action/template/sub/sub_wrapper.xhtml +1 -0
  137. data/spec/ramaze/controller.rb +11 -0
  138. data/spec/ramaze/controller/template_resolving.rb +28 -27
  139. data/spec/ramaze/dispatcher.rb +32 -0
  140. data/spec/ramaze/dispatcher/directory.rb +2 -1
  141. data/spec/ramaze/element.rb +1 -1
  142. data/spec/ramaze/gestalt.rb +28 -0
  143. data/spec/ramaze/helper/aspect.rb +14 -3
  144. data/spec/ramaze/helper/cache.rb +78 -13
  145. data/spec/ramaze/helper/formatting.rb +20 -0
  146. data/spec/ramaze/helper/link.rb +2 -0
  147. data/spec/ramaze/helper/partial.rb +12 -1
  148. data/spec/ramaze/helper/redirect.rb +44 -8
  149. data/spec/ramaze/helper/stack.rb +3 -3
  150. data/spec/ramaze/helper/template/loop.xhtml +3 -0
  151. data/spec/ramaze/helper/template/num.xhtml +1 -0
  152. data/spec/ramaze/helper/template/recursive.xhtml +8 -0
  153. data/spec/ramaze/morpher.rb +25 -6
  154. data/spec/ramaze/params.rb +6 -2
  155. data/spec/ramaze/request.rb +5 -2
  156. data/spec/ramaze/session.rb +19 -0
  157. data/spec/ramaze/template.rb +2 -2
  158. data/spec/ramaze/template/amrita2.rb +2 -2
  159. data/spec/ramaze/template/erubis.rb +2 -2
  160. data/spec/ramaze/template/ezamar.rb +6 -3
  161. data/spec/ramaze/template/haml.rb +3 -3
  162. data/spec/ramaze/template/liquid.rb +1 -1
  163. data/spec/ramaze/template/markaby.rb +1 -1
  164. data/spec/ramaze/template/nagoro.rb +65 -0
  165. data/spec/ramaze/template/nagoro/another/long/action.nag +1 -0
  166. data/spec/ramaze/template/nagoro/combined.nag +1 -0
  167. data/spec/ramaze/template/nagoro/file_only.nag +1 -0
  168. data/spec/ramaze/template/nagoro/index.nag +1 -0
  169. data/spec/ramaze/template/nagoro/nested.nag +1 -0
  170. data/spec/ramaze/template/nagoro/some__long__action.nag +1 -0
  171. data/spec/ramaze/template/nagoro/sum.nag +1 -0
  172. data/spec/ramaze/template/remarkably.rb +1 -1
  173. data/spec/ramaze/template/sass.rb +1 -1
  174. data/spec/ramaze/template/xslt.rb +93 -0
  175. data/spec/ramaze/template/xslt/concat_words.xsl +16 -0
  176. data/spec/ramaze/template/xslt/index.xsl +14 -0
  177. data/spec/ramaze/template/xslt/products.xsl +32 -0
  178. data/spec/ramaze/template/xslt/ruby_version.xsl +14 -0
  179. data/spec/snippets/array/put_within.rb +32 -0
  180. data/spec/snippets/numeric/filesize_format.rb +12 -0
  181. data/spec/snippets/ordered_set.rb +56 -0
  182. data/spec/snippets/ramaze/caller_lines.rb +6 -3
  183. data/spec/snippets/string/snake_case.rb +3 -0
  184. metadata +118 -22
  185. data/doc/README.html +0 -737
  186. data/examples/fcgi.rb +0 -13
  187. data/lib/ramaze/snippets/numeric/human_readable_filesize_format.rb +0 -33
  188. data/lib/ramaze/tool/tidy.rb +0 -104
  189. data/spec/ramaze/controller/template/edit.xhtml +0 -1
  190. data/spec/ramaze/controller/template/edit/content.xhtml +0 -1
  191. data/spec/ramaze/tidy.rb +0 -12
  192. 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
- # #ramaze - 9.5.2007
8
- #
9
- # manveru: if no possible controller is found, it's a NoController error
10
- # manveru: that would be a 404 then
11
- # Kashia: aye
12
- # manveru: if some controller are found but no actions on them, it's NoAction Error for the first controller found, again, 404
13
- # manveru: everything further down is considered 500
14
-
15
- def resolve(path)
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
- engine = trait[:engine]
153
- c_extensions = t_extensions.select{|k,v| k == engine}.map{|k,v| v}.flatten
154
- all_extensions = t_extensions.map{|k,v| v}.flatten
155
- (c_extensions + all_extensions).uniq
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
@@ -20,8 +20,7 @@ module Ramaze
20
20
  module Dispatcher
21
21
 
22
22
  # requests are passed to every
23
- FILTER = [ Dispatcher::File, Dispatcher::Directory,
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
- Inform.info("Request from #{request.remote_addr}: #{path}")
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) do
98
- redirection = catch(:redirect) do
99
- found = filter(path)
100
- throw(:respond, found)
101
- end
102
-
103
- body, status, head = redirection.values_at(:body, :status, :head)
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
- # Ramaze::Tool::Tidy
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).human_readable_filesize_format
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
- Response.current.build(file, Ramaze::STATUS_CODE['OK'])
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 = ::File.join(Global.public_root, path =~ /\/$/ ? path + 'index' : path)
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
- if ::File.file?(file)
28
- response = Response.current
29
- response['Content-Type'] = Tool::MIME.type_for(file)
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
@@ -9,6 +9,9 @@ module Ramaze
9
9
  # No action found on Controller
10
10
  class NoAction < Error; end
11
11
 
12
+ # No Controller found for request
13
+ class NoFilter < Error; end
14
+
12
15
  # No Controller found for request
13
16
  class NoController < Error; end
14
17
 
@@ -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
- _gestalt_build_tag meth, *args, &block
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
- _gestalt_build_tag :p, *args, &block
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, args = []
97
+ def _gestalt_build_tag name, attr={}, text=[]
88
98
  @out << "<#{name}"
89
- if block_given?
90
- @out << args.inject(''){ |s,v| s << %{ #{v[0]}="#{v[1]}"} }
99
+ @out << attr.inject(''){ |s,v| s << %{ #{v[0]}="#{_gestalt_escape_entities(v[1])}"} }
100
+ if text != [] or block_given?
91
101
  @out << ">"
92
- text = yield
93
- @out << text if text != @out and text.respond_to?(:to_str)
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(/&/, '&amp;').
115
+ gsub(/"/, '&quot;').
116
+ gsub(/'/, '&apos;').
117
+ gsub(/</, '&lt;').
118
+ gsub(/>/, '&gt;')
119
+ end
120
+
101
121
  # @out.to_s
102
122
 
103
123
  def to_s
@@ -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 => './public'
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 => :WEBrick,
16
- :mongrel => :Mongrel,
17
- :cgi => :CGI,
18
- :fcgi => :Fcgi,
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[internal.to_sym]
59
- require("ramaze/adapter/"/class_name.to_s.downcase)
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