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
@@ -24,7 +24,7 @@ module Ramaze
24
24
 
25
25
  # This module holds all classes and methods related to the adapters like
26
26
  # webrick or mongrel.
27
- # It's responsible to start and stop them.
27
+ # It's responsible for starting and stopping them.
28
28
 
29
29
  module Adapter
30
30
  class << self
@@ -13,9 +13,6 @@ module Ramaze::Adapter
13
13
  # to make it compatible with other adapters but have no influence and
14
14
  # can be omitted
15
15
  def start host = nil, ports = nil
16
- global = Ramaze::Global
17
- global.inform_to = :stderr if global.inform_to == $stdout
18
-
19
16
  Thread.new do
20
17
  Thread.current[:task] = :cgi
21
18
  Rack::Handler::CGI.run(self)
@@ -0,0 +1,7 @@
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
+ Ramaze::Inform.debug "Using Evented Mongrel"
5
+
6
+ require 'swiftcore/evented_mongrel'
7
+ require 'ramaze/adapter/mongrel'
@@ -1,20 +1,11 @@
1
1
  # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
- module Ramaze
5
- if ENV['SWIFT']
6
- require 'swiftcore/swiftiplied_mongrel'
7
- Inform.debug "Using Swiftiplied Mongrel"
8
- elsif ENV['EVENT']
9
- require 'swiftcore/evented_mongrel'
10
- Inform.debug "Using Evented Mongrel"
11
- else
12
- require 'mongrel'
13
- end
14
-
15
- require 'ramaze/adapter'
16
- require 'rack/handler/mongrel'
4
+ require 'mongrel'
5
+ require 'ramaze/adapter'
6
+ require 'rack/handler/mongrel'
17
7
 
8
+ module Ramaze
18
9
  module Adapter
19
10
 
20
11
  # Our Mongrel adapter acts as wrapper for the Rack::Handler::Mongrel.
@@ -0,0 +1,7 @@
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
+ Ramaze::Inform.debug "Using Swiftiplied Mongrel"
5
+
6
+ require 'swiftcore/swiftiplied_mongrel'
7
+ require 'ramaze/adapter/mongrel'
@@ -36,14 +36,19 @@ module Ramaze
36
36
  #+++
37
37
 
38
38
  def add *keys
39
- keys.each do |key|
40
- CACHES[key] = new
41
- CACHES[key].instance_variable_set("@cache_name", key)
42
- self.class.class_eval do
43
- define_method(key){ CACHES[key] }
44
- end
39
+ keys.each{|key|
40
+ klass = Global.cache_alternative.fetch(key, self)
41
+ add_on(key, klass)
42
+ }
43
+ Inform.dev("Added caches for: #{keys.join(', ')}")
44
+ end
45
+
46
+ def add_on(key, cache_class)
47
+ CACHES[key] = new(cache_class)
48
+ CACHES[key].instance_variable_set("@cache_name", key)
49
+ self.class.class_eval do
50
+ define_method(key){ CACHES[key] }
45
51
  end
46
- Inform.debug("Added caches for: #{keys.join(', ')}")
47
52
  end
48
53
 
49
54
  end
@@ -0,0 +1,22 @@
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
+ module Ramaze
5
+ def self.contrib(*args)
6
+ Ramaze::Contrib.load *args
7
+ end
8
+
9
+ module Contrib
10
+ class << self
11
+ def load(*contribs)
12
+ contribs.each do |name|
13
+ require 'ramaze/contrib'/name
14
+ const = Ramaze::Contrib.const_get(name.to_s.camel_case)
15
+ Ramaze::Global.contribs << const
16
+ const.startup if const.respond_to?(:startup)
17
+ Inform.dev "Loaded contrib: #{const}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,128 @@
1
+ # auto_params.rb
2
+ #
3
+ # AutoParams implements action parameterization ala merb 0.4 and Nitro
4
+ # using ruby2ruby and ParseTree
5
+ #
6
+ # Usage:
7
+ # require 'ramaze/contrib'
8
+ # Ramaze.contrib :auto_params
9
+ #
10
+ # For example,
11
+ #
12
+ # def search(query) end
13
+ #
14
+ # can be accessed via
15
+ #
16
+ # - /search?query=findthis, which calls search('findthis')
17
+ # - /search/findthis search('findthis')
18
+ # - /search/findthis?query=andthis search(['findthis', 'andthis'])
19
+ #
20
+ # For more examples, take a look at spec/contrib/auto_params.rb
21
+ #
22
+ # Note: A simpler alternative for similar functionality would be:
23
+ #
24
+ # def search(query = request['query']) end
25
+ #
26
+
27
+ require __DIR__/:auto_params/:get_args
28
+
29
+ module Ramaze
30
+
31
+ module Contrib
32
+ class AutoParams
33
+ def self.startup
34
+ Ramaze::Cache.add :args
35
+ end
36
+ end
37
+ end
38
+
39
+ class Action
40
+
41
+ # with parameterization, params may include
42
+ # arrays: /num?n=1&n=2 becomes [['1','2']] for def num(n) end
43
+ # nil: /calc?w=10&d=2 becomes ['10', nil, '2'] for def calc(w, h, d) end
44
+
45
+ def params=(*par)
46
+ par = *par
47
+ self[:params] = par.map{ |pa|
48
+ case pa
49
+ when Array
50
+ pa.map{|p| CGI.unescape(p.to_s)}
51
+ when nil
52
+ nil
53
+ else
54
+ CGI.unescape(pa.to_s)
55
+ end
56
+ } unless par.nil?
57
+ self[:params] ||= []
58
+ end
59
+
60
+ end
61
+
62
+ class Controller
63
+
64
+ # ignore cache when request.params is interesting
65
+
66
+ def self.cached(path)
67
+ if found = Cache.resolved[path]
68
+ if found.respond_to?(:relaxed_hash)
69
+
70
+ # don't use cache if we need to add request.params entries to the Action
71
+ if args = Cache.args[found.method]
72
+ param_keys = request.params.keys
73
+ return nil if args.find{|k,v| param_keys.include?(k.to_s) }
74
+ end
75
+
76
+ return found.dup
77
+ else
78
+ Inform.warn("Found faulty `#{path}' in Cache.resolved, deleting it for sanity.")
79
+ Cache.resolved.delete path
80
+ end
81
+ end
82
+
83
+ nil
84
+ end
85
+
86
+ # use Method#get_args to insert values from request.params into Action#params
87
+
88
+ def self.resolve_method(name, *params)
89
+ if method = action_methods.delete(name)
90
+ meth = instance_method(method)
91
+ arity = meth.arity
92
+
93
+ if meth.respond_to? :get_args
94
+ Cache.args[name] ||= meth.get_args.select{|e| e.to_s !~ /^\*/} || []
95
+ args = Cache.args[name]
96
+
97
+ param_keys = request.params.keys
98
+
99
+ # if there are missing args, or keys in request.params that match expected args
100
+ if args.size > params.size or args.find{|k,v| param_keys.include?(k.to_s) }
101
+ args.each_with_index do |(name, val), i|
102
+ r_params = request.params[name.to_s]
103
+ if params[i] and r_params.size > 0
104
+ params[i] = [params[i], r_params].flatten
105
+ else
106
+ params[i] ||= r_params
107
+ end
108
+ end
109
+
110
+ # strip trailing nils so default argument values are used
111
+ params.reverse.each{|e| if e.nil? then params.pop else break end }
112
+ end
113
+
114
+ argity = args.select{|e| e.size==1}.size..args.size
115
+ else
116
+ argity = arity..arity
117
+ end
118
+
119
+ if arity < 0 or argity.include? params.size
120
+ return method, params
121
+ end
122
+ end
123
+ return nil, []
124
+ end
125
+
126
+ end
127
+
128
+ end
@@ -0,0 +1,56 @@
1
+ # from merb/core_ext/get_args.rb
2
+ begin
3
+ require 'ruby2ruby'
4
+
5
+ class ParseTreeArray < Array
6
+ def self.translate(*args)
7
+ self.new(ParseTree.translate(*args))
8
+ end
9
+
10
+ def deep_array_node(type = nil)
11
+ each do |node|
12
+ return ParseTreeArray.new(node) if node.is_a?(Array) && (!type || node[0] == type)
13
+ next unless node.is_a?(Array)
14
+ return ParseTreeArray.new(node).deep_array_node(type)
15
+ end
16
+ nil
17
+ end
18
+
19
+ def arg_nodes
20
+ self[1..-1].inject([]) do |sum,item|
21
+ sum << [item] unless item.is_a?(Array)
22
+ sum
23
+ end
24
+ end
25
+
26
+ def get_args
27
+ arg_node = deep_array_node(:args)
28
+ args = arg_node.arg_nodes
29
+ default_node = arg_node.deep_array_node(:block)
30
+ return args unless default_node
31
+ lasgns = default_node[1..-1]
32
+ lasgns.each do |asgn|
33
+ args.assoc(asgn[1]) << eval(RubyToRuby.new.process(asgn[2]))
34
+ end
35
+ args
36
+ end
37
+
38
+ end
39
+
40
+ module GetArgs
41
+ def get_args
42
+ klass, meth = self.to_s.split(/ /).to_a[1][0..-2].split("#")
43
+ klass = $` if klass =~ /\(/
44
+ ParseTreeArray.translate(Object.const_get(klass), meth).get_args
45
+ end
46
+ end
47
+
48
+ class UnboundMethod
49
+ include GetArgs
50
+ end
51
+
52
+ class Method
53
+ include GetArgs
54
+ end
55
+ rescue LoadError
56
+ end
@@ -0,0 +1,57 @@
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
+ # gzip_filter.rb
5
+ #
6
+ # Use this to compress "large" pages with gzip. All major browsers support gzipped pages.
7
+ # This filter brought to you by your friends in #ramaze: Pistos, manveru, rikur and Kashia.
8
+ #
9
+ # Usage:
10
+ # in start.rb:
11
+ #
12
+ # require 'path/to/gzip-filter'
13
+ # Ramaze::Dispatcher::Action::FILTER << Ramaze::Filter::Gzip
14
+
15
+ require 'zlib'
16
+
17
+ module Ramaze
18
+ module Filter
19
+ class Gzip
20
+
21
+ trait :enabled => true
22
+ trait :threshold => 32768 # bytes
23
+
24
+ class << self
25
+
26
+ include Ramaze::Trinity
27
+
28
+ # Enables being plugged into Dispatcher::Action::FILTER
29
+
30
+ def call( response, options = {} )
31
+ return response if not trait[ :enabled ]
32
+ return response if response.body.nil?
33
+ return response if response.body.respond_to?( :read )
34
+
35
+ accepts = request.env[ 'HTTP_ACCEPT_ENCODING' ]
36
+ return response if accepts.nil? || ( accepts !~ /(x-gzip|gzip)/ )
37
+
38
+ if response.content_type == 'text/html' && response.body.size > trait[ :threshold ]
39
+ output = StringIO.new
40
+ def output.close
41
+ # Zlib closes the file handle, so we want to circumvent this
42
+ rewind
43
+ end
44
+ gz = Zlib::GzipWriter.new( output )
45
+ gz.write( response.body )
46
+ gz.close
47
+
48
+ response.body = output.string
49
+ response.header[ 'Content-encoding' ] = 'gzip'
50
+ end
51
+
52
+ response
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,40 @@
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
+ module Ramaze
5
+ module Contrib
6
+ class Route
7
+ class << self
8
+ def startup
9
+ trait :route => true
10
+ trait :routes => Dictionary.new
11
+ Ramaze::Controller::FILTER.put_before(:default, :routed)
12
+ end
13
+
14
+ def [](key)
15
+ trait[:routes][key]
16
+ end
17
+
18
+ def []=(key, value)
19
+ trait[:routes][key] = value
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ class Controller
26
+ class << self
27
+ def routed(path)
28
+ routes = Contrib::Route.trait[:routes]
29
+ routes.each do |regex, pattern|
30
+ if md = path.match(regex)
31
+ new_path = pattern % md.to_a[1..-1]
32
+ return resolve(new_path, :routed)
33
+ end
34
+ end
35
+
36
+ nil
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,12 @@
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
+ module Sequel
5
+ class Model
6
+ class << self
7
+ def fill request_object = Ramaze::Request.current
8
+ create(request_object.params)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -42,11 +42,11 @@ module Ramaze
42
42
  # Global.controllers and a new trait :actions_cached is set on it.
43
43
 
44
44
  def inherited controller
45
- controller.trait :actions_cached => Set.new
45
+ controller.trait :actions_cached => {}
46
46
  controller.trait :layout => {:all => nil, :deny => Set.new}
47
47
  Global.controllers << controller
48
48
  if map = controller.mapping
49
- Inform.debug("mapping #{map} => #{controller}")
49
+ Inform.dev("mapping #{map} => #{controller}")
50
50
  Global.mapping[map] ||= controller
51
51
  end
52
52
  end
@@ -56,7 +56,7 @@ module Ramaze
56
56
  # they are not assigned yet.
57
57
 
58
58
  def startup options = {}
59
- Inform.debug("found Controllers: #{Global.controllers.inspect}")
59
+ Inform.dev("found Controllers: #{Global.controllers.inspect}")
60
60
  tr, pr = Global.template_root, Global.public_root
61
61
  Inform.warn("Template root: #{tr} doesn't exist") unless File.directory?(tr)
62
62
  Inform.warn("Public root: #{pr} doesn't exist") unless File.directory?(pr)
@@ -118,15 +118,17 @@ module Ramaze
118
118
  # the layout-action where @content may or may not be used, returning
119
119
  # whatever the layout returns.
120
120
 
121
- def layout(meth_or_hash, &block)
121
+ def layout(meth_or_hash)
122
122
  if meth_or_hash.respond_to?(:to_hash)
123
123
  meth_or_hash.each do |layout_name, *actions|
124
+ layout_name = R(self, layout_name) if layout_name.to_s !~ /\A\//
124
125
  actions.flatten.each do |action|
125
- trait[:layout][action.to_s] = R(self, layout_name)
126
+ trait[:layout][action.to_s] = layout_name
126
127
  end
127
128
  end
128
129
  else
129
- trait[:layout][:all] = R(self, meth_or_hash)
130
+ layout_name = R(self, meth_or_hash) if meth_or_hash.to_s !~ /\A\//
131
+ trait[:layout][:all] = layout_name || meth_or_hash
130
132
  end
131
133
  end
132
134
 
@@ -172,6 +174,15 @@ module Ramaze
172
174
  trait "#{this}_template" => [from, that.to_s]
173
175
  end
174
176
 
177
+ def engine(name)
178
+ name = Ramaze::Template.const_get(name)
179
+ rescue NameError => ex
180
+ Inform.warn ex
181
+ Inform.warn "Try to use passed engine directly"
182
+ ensure
183
+ trait :engine => name
184
+ end
185
+
175
186
  # Return Controller of current Action
176
187
 
177
188
  def current