ramaze 0.0.7 → 0.0.8

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 (193) hide show
  1. data/Rakefile +52 -19
  2. data/bin/ramaze +19 -6
  3. data/doc/CHANGELOG +33 -0
  4. data/doc/COPYING +1 -1
  5. data/doc/FAQ +92 -0
  6. data/doc/GPL +340 -0
  7. data/doc/INSTALL +34 -0
  8. data/doc/ProjectInfo +53 -0
  9. data/doc/README +187 -110
  10. data/doc/readme_chunks/appendix.txt +13 -0
  11. data/doc/readme_chunks/examples.txt +38 -0
  12. data/doc/readme_chunks/features.txt +82 -0
  13. data/doc/readme_chunks/getting_help.txt +5 -0
  14. data/doc/readme_chunks/getting_started.txt +18 -0
  15. data/doc/readme_chunks/installing.txt +41 -0
  16. data/doc/readme_chunks/introduction.txt +18 -0
  17. data/doc/readme_chunks/principles.txt +41 -0
  18. data/doc/readme_chunks/thanks.txt +59 -0
  19. data/doc/tutorial/todolist.txt +546 -0
  20. data/examples/blog/main.rb +1 -1
  21. data/examples/blog/src/controller.rb +13 -11
  22. data/examples/blog/src/element.rb +11 -6
  23. data/examples/blog/src/model.rb +8 -23
  24. data/examples/blog/template/edit.xhtml +3 -1
  25. data/examples/blog/template/index.xhtml +4 -4
  26. data/examples/caching.rb +4 -4
  27. data/examples/element.rb +10 -7
  28. data/examples/hello.rb +3 -4
  29. data/examples/simple.rb +5 -3
  30. data/examples/templates/template/external.amrita +19 -0
  31. data/examples/templates/template/{external.rmze → external.zmr} +2 -2
  32. data/examples/templates/template_amrita2.rb +48 -0
  33. data/examples/templates/template_erubis.rb +5 -2
  34. data/examples/templates/{template_ramaze.rb → template_ezamar.rb} +13 -7
  35. data/examples/templates/template_haml.rb +4 -1
  36. data/examples/templates/template_liquid.rb +2 -1
  37. data/examples/templates/template_markaby.rb +2 -1
  38. data/examples/todolist/conf/benchmark.yaml +35 -0
  39. data/examples/todolist/conf/debug.yaml +34 -0
  40. data/examples/todolist/conf/live.yaml +33 -0
  41. data/examples/todolist/conf/silent.yaml +31 -0
  42. data/examples/todolist/conf/stage.yaml +33 -0
  43. data/examples/todolist/main.rb +18 -0
  44. data/examples/todolist/public/404.jpg +0 -0
  45. data/examples/todolist/public/css/coderay.css +105 -0
  46. data/examples/todolist/public/css/ramaze_error.css +42 -0
  47. data/{lib/proto → examples/todolist}/public/error.xhtml +0 -0
  48. data/examples/todolist/public/favicon.ico +0 -0
  49. data/examples/todolist/public/js/jquery.js +1923 -0
  50. data/examples/todolist/public/ramaze.png +0 -0
  51. data/examples/todolist/src/controller/main.rb +56 -0
  52. data/examples/todolist/src/element/page.rb +26 -0
  53. data/examples/todolist/src/model.rb +14 -0
  54. data/examples/todolist/template/index.xhtml +17 -0
  55. data/examples/todolist/template/new.xhtml +7 -0
  56. data/examples/todolist/todolist.db +9 -0
  57. data/examples/whywiki/main.rb +3 -8
  58. data/examples/whywiki/template/show.xhtml +4 -0
  59. data/lib/proto/public/error.zmr +77 -0
  60. data/lib/proto/src/controller/main.rb +2 -1
  61. data/lib/proto/src/element/page.rb +2 -1
  62. data/lib/proto/src/model.rb +3 -2
  63. data/lib/ramaze.rb +7 -9
  64. data/lib/ramaze/adapter.rb +51 -0
  65. data/lib/ramaze/adapter/cgi.rb +23 -0
  66. data/lib/ramaze/adapter/fcgi.rb +22 -0
  67. data/lib/ramaze/adapter/mongrel.rb +7 -86
  68. data/lib/ramaze/adapter/webrick.rb +14 -133
  69. data/lib/ramaze/cache/memcached.rb +6 -0
  70. data/lib/ramaze/cache/yaml_store.rb +3 -1
  71. data/lib/ramaze/controller.rb +292 -2
  72. data/lib/ramaze/dispatcher.rb +85 -213
  73. data/lib/ramaze/error.rb +10 -0
  74. data/lib/ramaze/global.rb +8 -0
  75. data/lib/ramaze/helper/aspect.rb +30 -7
  76. data/lib/ramaze/helper/auth.rb +16 -9
  77. data/lib/ramaze/helper/cache.rb +40 -35
  78. data/lib/ramaze/helper/feed.rb +1 -1
  79. data/lib/ramaze/helper/flash.rb +34 -0
  80. data/lib/ramaze/helper/link.rb +8 -2
  81. data/lib/ramaze/helper/openid.rb +63 -0
  82. data/lib/ramaze/helper/redirect.rb +12 -11
  83. data/lib/ramaze/helper/stack.rb +5 -7
  84. data/lib/ramaze/inform.rb +12 -1
  85. data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
  86. data/lib/ramaze/snippets/kernel/{self_method.rb → method.rb} +3 -18
  87. data/lib/ramaze/snippets/kernel/{rescue_require.rb → pretty_inspect.rb} +7 -6
  88. data/lib/ramaze/snippets/method/name.rb +22 -0
  89. data/lib/ramaze/snippets/{kernel → ramaze}/autoreload.rb +0 -0
  90. data/lib/ramaze/snippets/ramaze/caller_info.rb +14 -0
  91. data/lib/ramaze/snippets/{kernel → ramaze}/caller_lines.rb +3 -10
  92. data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +49 -23
  93. data/lib/ramaze/snippets/string/DIVIDE.rb +0 -1
  94. data/lib/ramaze/store/default.rb +58 -2
  95. data/lib/ramaze/store/yaml.rb +161 -0
  96. data/lib/ramaze/template.rb +27 -86
  97. data/lib/ramaze/template/amrita2.rb +14 -19
  98. data/lib/ramaze/template/erubis.rb +15 -38
  99. data/lib/ramaze/template/ezamar.rb +100 -0
  100. data/lib/ramaze/template/ezamar/element.rb +166 -0
  101. data/lib/ramaze/template/ezamar/engine.rb +124 -0
  102. data/lib/ramaze/template/ezamar/morpher.rb +155 -0
  103. data/lib/ramaze/template/haml.rb +16 -43
  104. data/lib/ramaze/template/liquid.rb +11 -51
  105. data/lib/ramaze/template/markaby.rb +44 -42
  106. data/lib/ramaze/tool/mime.rb +18 -0
  107. data/lib/ramaze/tool/mime_types.yaml +615 -0
  108. data/lib/ramaze/trinity/request.rb +20 -196
  109. data/lib/ramaze/trinity/response.rb +4 -33
  110. data/lib/ramaze/trinity/session.rb +150 -72
  111. data/lib/ramaze/version.rb +1 -1
  112. data/spec/adapter_spec.rb +20 -0
  113. data/spec/public/favicon.ico +0 -0
  114. data/spec/public/ramaze.png +0 -0
  115. data/spec/public/test_download.css +141 -0
  116. data/spec/{tc_request.rb → request_tc_helper.rb} +45 -21
  117. data/spec/spec_all.rb +77 -34
  118. data/spec/spec_helper.rb +8 -157
  119. data/spec/spec_helper_context.rb +72 -0
  120. data/spec/spec_helper_requester.rb +52 -0
  121. data/spec/spec_helper_simple_http.rb +433 -0
  122. data/spec/tc_adapter_mongrel.rb +3 -15
  123. data/spec/tc_adapter_webrick.rb +4 -14
  124. data/spec/tc_cache.rb +3 -5
  125. data/spec/tc_controller.rb +22 -12
  126. data/spec/tc_dependencies.rb +13 -0
  127. data/spec/tc_element.rb +8 -7
  128. data/spec/tc_error.rb +13 -7
  129. data/spec/tc_global.rb +16 -18
  130. data/spec/tc_helper_aspect.rb +2 -4
  131. data/spec/tc_helper_auth.rb +15 -14
  132. data/spec/tc_helper_cache.rb +5 -7
  133. data/spec/tc_helper_feed.rb +0 -2
  134. data/spec/tc_helper_flash.rb +103 -0
  135. data/spec/tc_helper_form.rb +4 -6
  136. data/spec/tc_helper_link.rb +1 -3
  137. data/spec/tc_helper_redirect.rb +23 -8
  138. data/spec/tc_helper_stack.rb +31 -15
  139. data/spec/tc_morpher.rb +1 -3
  140. data/spec/tc_params.rb +48 -7
  141. data/spec/tc_request_mongrel.rb +9 -0
  142. data/spec/tc_request_webrick.rb +5 -0
  143. data/spec/tc_session.rb +41 -25
  144. data/spec/tc_store.rb +55 -6
  145. data/spec/tc_store_yaml.rb +71 -0
  146. data/spec/tc_template_amrita2.rb +3 -3
  147. data/spec/tc_template_erubis.rb +2 -3
  148. data/spec/{tc_template_ramaze.rb → tc_template_ezamar.rb} +15 -5
  149. data/spec/tc_template_haml.rb +4 -3
  150. data/spec/tc_template_liquid.rb +3 -4
  151. data/spec/tc_template_markaby.rb +4 -6
  152. data/spec/tc_tidy.rb +1 -3
  153. data/spec/template/amrita2/{data.html → data.amrita} +0 -0
  154. data/spec/template/amrita2/{index.html → index.amrita} +0 -0
  155. data/spec/template/amrita2/{sum.html → sum.amrita} +0 -0
  156. data/spec/template/ezamar/another/long/action.zmr +1 -0
  157. data/spec/template/ezamar/combined.zmr +1 -0
  158. data/spec/template/{ramaze/file_only.rmze → ezamar/file_only.zmr} +0 -0
  159. data/spec/template/{ramaze/index.rmze → ezamar/index.zmr} +0 -0
  160. data/spec/template/{ramaze/nested.rmze → ezamar/nested.zmr} +0 -0
  161. data/spec/template/ezamar/some__long__action.zmr +1 -0
  162. data/spec/template/{ramaze/sum.rmze → ezamar/sum.zmr} +0 -0
  163. metadata +181 -123
  164. data/doc/allison/LICENSE +0 -184
  165. data/doc/allison/README +0 -37
  166. data/doc/allison/allison.css +0 -300
  167. data/doc/allison/allison.gif +0 -0
  168. data/doc/allison/allison.js +0 -307
  169. data/doc/allison/allison.rb +0 -287
  170. data/doc/allison/cache/BODY +0 -588
  171. data/doc/allison/cache/CLASS_INDEX +0 -4
  172. data/doc/allison/cache/CLASS_PAGE +0 -1
  173. data/doc/allison/cache/FILE_INDEX +0 -4
  174. data/doc/allison/cache/FILE_PAGE +0 -1
  175. data/doc/allison/cache/FONTS +0 -1
  176. data/doc/allison/cache/FR_INDEX_BODY +0 -1
  177. data/doc/allison/cache/IMGPATH +0 -1
  178. data/doc/allison/cache/INDEX +0 -1
  179. data/doc/allison/cache/JAVASCRIPT +0 -307
  180. data/doc/allison/cache/METHOD_INDEX +0 -4
  181. data/doc/allison/cache/METHOD_LIST +0 -1
  182. data/doc/allison/cache/SRC_PAGE +0 -1
  183. data/doc/allison/cache/STYLE +0 -322
  184. data/doc/allison/cache/URL +0 -1
  185. data/doc/changes.txt +0 -2021
  186. data/doc/changes.xml +0 -2024
  187. data/lib/ramaze/snippets/kernel/silently.rb +0 -13
  188. data/lib/ramaze/snippets/thread/deadQUESTIONMARK.rb +0 -11
  189. data/lib/ramaze/template/haml/actionview_stub.rb +0 -20
  190. data/lib/ramaze/template/ramaze.rb +0 -177
  191. data/lib/ramaze/template/ramaze/element.rb +0 -166
  192. data/lib/ramaze/template/ramaze/morpher.rb +0 -156
  193. data/spec/tc_test.rb +0 -17
@@ -13,10 +13,11 @@ module Ramaze
13
13
  # implement your own authentication.
14
14
 
15
15
  module AuthHelper
16
+
17
+ # add AspectHelper and StackHelper on inclusion of AuthHelper
18
+
16
19
  def self.included(klass)
17
- klass.class_eval do
18
- helper :aspect, :stack
19
- end
20
+ klass.send(:helper, :aspect, :stack)
20
21
  end
21
22
 
22
23
  # The default Element to use (if any)
@@ -28,12 +29,17 @@ module Ramaze
28
29
  # if no password given, shows a simple form to input it.
29
30
 
30
31
  def login
31
- if check_auth(request['username'], request['password'])
32
+ username, password = request.params.values_at('username', 'password')
33
+ if check_auth(username, password)
32
34
  session[:logged_in] = true
33
35
  inside_stack? ? answer : redirect( R(self) )
34
36
  else
37
+ if AUTH_ELEMENT and AUTH_ELEMENT.to_s.split.any?
38
+ open_element = "<#{AUTH_ELEMENT}>"
39
+ close_element = "</#{AUTH_ELEMENT}>"
40
+ end
35
41
  %{
36
- <#{AUTH_ELEMENT}>
42
+ #{open_element}
37
43
  <form method="POST" action="#{R(self, :login)}"
38
44
  <ul style="list-style:none;">
39
45
  <li>Username: <input type="text" name="username" /></li>
@@ -41,7 +47,7 @@ module Ramaze
41
47
  <li><input type="submit" /></li>
42
48
  </ul>
43
49
  </form>
44
- </#{AUTH_ELEMENT}>
50
+ #{close_element}
45
51
  }
46
52
  end
47
53
  end
@@ -75,7 +81,7 @@ module Ramaze
75
81
  # Hash.
76
82
  # If it is neither of the above it has at least to respond to #[]
77
83
  # which will pass it the username as key and it should answer with the
78
- # password as a SHA1.hexdigest.
84
+ # password as a Digest::SHA1.hexdigest.
79
85
  #
80
86
  # The method and Proc are both called on demand.
81
87
  #
@@ -97,12 +103,13 @@ module Ramaze
97
103
  # trait :auth_tagle => 'auth_table'
98
104
  #
99
105
  # # Lambda that will be called upon demand
100
- # trait :auth_table => lambda{ {'manveru' => SHA1.hexdigest 'password'} }
106
+ # trait :auth_table => lambda{ {'manveru' => Digest::SHA1.hexdigest 'password'} }
101
107
  #
102
108
  # # Hash holding the data.
103
- # trait :auth_table => {'manveru' => SHA1.hexdigest('password')}
109
+ # trait :auth_table => {'manveru' => Digest::SHA1.hexdigest('password')}
104
110
 
105
111
  def check_auth user, pass
112
+ return false if (not user or user.empty?) and (not pass or pass.empty?)
106
113
  auth_table = ancestral_trait[:auth_table] ||= {}
107
114
 
108
115
  auth_table = method(auth_table) if auth_table.is_a?(Symbol)
@@ -1,52 +1,57 @@
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
4
5
  module CacheHelper
5
- private
6
6
 
7
- # a simple cache for values based on Global.cache
7
+ # Cache for single key/value pairs
8
8
 
9
- def value_cache
10
- @@cache ||= Global.cache.new
11
- end
9
+ trait :value_cache => Global.cache.new
12
10
 
13
- # forget about one cached action
11
+ # Cache for values returned from actions
14
12
 
15
- def uncache action
16
- Global.cached_actions[self.class].each do |e|
17
- e.include?(action.to_s)
18
- end
19
- end
20
-
21
- # uncache all actions
13
+ trait :action_cache => Global.cache.new
22
14
 
23
- def uncache_all
24
- Global.cached_actions.delete(self.class)
25
- end
26
- alias uncache_all_actions uncache_all
15
+ private
27
16
 
28
- # cache all given methods
17
+ # use this to cache values in your controller and templates,
18
+ # for example heavy calculations or time-consuming queries.
29
19
 
30
- def cache(*actions)
31
- self.class.cache(*actions)
20
+ def value_cache
21
+ ancestral_trait[:value_cache]
32
22
  end
33
- alias cache_actions cache
34
-
35
- # define the cache class-method on inclusion
36
23
 
37
- def self.included(klass)
38
- klass.class_eval do
39
- class << self
40
-
41
- # mark actions for caching
42
-
43
- def cache(*actions)
44
- Global.cache_actions[self].merge(*actions.flatten.map{|a| a.to_s })
45
- end
46
- alias cache_actions cache
24
+ # holds the values returned on the first call to a cached action.
25
+ # To uncache, simply delete.
26
+ #
27
+ # Please note that the action is cached by a combination of
28
+ # [action, parameter].inspect - so it is a bit awkward to use.
29
+ #
30
+ # Suggestions welcome.
31
+ #
32
+ # Example:
33
+ #
34
+ # action_cache.delete '["index", []]'
35
+ #
36
+ # or by delete_if
37
+ #
38
+ # action_cache.delete_if{|key, value| key =~ /"index",/}
39
+
40
+ def action_cache
41
+ ancestral_trait[:action_cache]
42
+ end
47
43
 
48
- end
49
- end
44
+ # This refers to the class-trait of cached actions, you can
45
+ # add/remove actions to be cached.
46
+ #
47
+ # Example:
48
+ #
49
+ # class FooController < Ramaze::Controller
50
+ # trait :actions_cached => [:index, :map_of_the_internet]
51
+ # end
52
+
53
+ def actions_cached
54
+ ancestral_trait[:actions_cached]
50
55
  end
51
56
  end
52
57
  end
@@ -129,7 +129,7 @@ module ReFeed
129
129
  unless attributes or attributes.empty?
130
130
  "<#{name}>#{xml}</#{name}>"
131
131
  else
132
- "<#{name} #{attributes.join(' ')}><#{xml}></#{name}>"
132
+ "<#{name} #{attributes.join(' ')}>#{xml}</#{name}>"
133
133
  end
134
134
  end
135
135
  end
@@ -0,0 +1,34 @@
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
+
6
+ # The purpose of this class is to provide an easy way of setting/retrieving
7
+ # from the current flash.
8
+ #
9
+ # Flash is a way to keep a temporary pairs of keys and values for the duration
10
+ # of two requests, the current and following.
11
+ #
12
+ # Very vague Example:
13
+ #
14
+ # On the first request, for example on registering:
15
+ #
16
+ # flash[:error] = "You should reconsider your username, it's taken already"
17
+ # redirect R(self, :register)
18
+ #
19
+ # This is the request from the redirect:
20
+ #
21
+ # do_stuff if flash[:error]
22
+ #
23
+ # On the request after this, flash[:error] is gone.
24
+
25
+ module FlashHelper
26
+ private
27
+
28
+ # answers with Session.current.flash
29
+
30
+ def flash
31
+ Session.current.flash
32
+ end
33
+ end
34
+ end
@@ -2,7 +2,7 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  module Ramaze
5
- # LinkHelper is included into the Template::Ramaze by default
5
+ # LinkHelper is included into the Controller by default
6
6
  #
7
7
  # this helper tries to get along without any major magic, the only 'magic'
8
8
  # thing is that it looks up controller-paths if you pass it a controller
@@ -51,6 +51,7 @@ module Ramaze
51
51
  end
52
52
 
53
53
  raw, title = hash.delete(:raw), hash.delete(:title)
54
+ params = {:class => hash.delete(:class), :id => hash.delete(:id)}
54
55
  opts = hash.inject('?'){|s,(k,v)| s << "#{k}=#{v};"}[0..-2]
55
56
  link = to.join('/').squeeze('/') << (opts.empty? ? '' : opts)
56
57
 
@@ -58,7 +59,8 @@ module Ramaze
58
59
  link
59
60
  else
60
61
  title ||= link.split('/').last.to_s.split('?').first || 'index'
61
- %{<a href="#{link}">#{title}</a>}
62
+ params = params.inject(''){|s,(k,v)| s + (k and v ? %{ #{k}="#{v}"} : '')}
63
+ l = %{<a href="#{link}"#{params}>#{title}</a>}
62
64
  end
63
65
  end
64
66
 
@@ -76,5 +78,9 @@ module Ramaze
76
78
 
77
79
  link(*to)
78
80
  end
81
+
82
+ def Rs(*to)
83
+ R(self, *to)
84
+ end
79
85
  end
80
86
  end
@@ -0,0 +1,63 @@
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 'tmpdir'
5
+
6
+ require 'openid'
7
+
8
+ module Ramaze
9
+ module OpenidHelper
10
+ def openid_login_form
11
+ %{
12
+ <form method="GET" action="#{R(self, :openid_begin)}">
13
+ Identity URL: <input type="text" name="url" />
14
+ <input type="submit" />
15
+ </form>
16
+ }
17
+ end
18
+
19
+ def openid_begin
20
+ url = request['url']
21
+ redirect_referrer if url.nil? or url.empty?
22
+ session[:openid_entry] = referrer
23
+
24
+ openid_request = openid_consumer.begin(url)
25
+ case openid_request.status
26
+ when OpenID::FAILURE
27
+ flash[:error] = "OpenID - Unable to find openid server for `#{url}'"
28
+
29
+ redirect_referrer
30
+ when OpenID::SUCCESS
31
+ host, port = Ramaze::Global.host, Ramaze::Global.port
32
+ root = "http://#{host}:#{port}/"
33
+ return_to = root[0..-2] + R(self, :openid_complete)
34
+ redirect_url = openid_request.redirect_url(root, return_to)
35
+
36
+ redirect(redirect_url)
37
+ end
38
+ end
39
+
40
+ def openid_complete
41
+ openid_response = openid_consumer.complete(request.params)
42
+
43
+ case openid_response.status
44
+ when OpenID::FAILURE
45
+ flash[:error] = 'OpenID - Verification failed.'
46
+ when OpenID::SUCCESS
47
+ flash[:success] = 'OpenID - Verification done.'
48
+ end
49
+
50
+ redirect session[:openid_entry]
51
+ end
52
+
53
+ private
54
+
55
+ def openid_consumer
56
+ OpenID::Consumer.new(session, Ramaze::Global.openid_store)
57
+ end
58
+ end
59
+ end
60
+
61
+ openid_store_file = File.join(Dir.tmpdir, 'openid-store')
62
+
63
+ Global.openid_store ||= OpenID::FilesystemStore.new(openid_store_file)
@@ -6,37 +6,38 @@ module Ramaze
6
6
  # RedirectHelper actually takes advantage of LinkHelper.link_raw to build the links
7
7
  # it redirects to.
8
8
  # It doesn't do much else than this:
9
- # setting a status-code of 303 and a head['Location'] = link
9
+ # setting a status-code of 303 and a response['Location'] = link
10
10
  # returning some nice text for visitors who insist on ignoring those hints :P
11
11
  #
12
12
  # example of usage:
13
13
  # redirect MainController
14
14
  # redirect MainController, :foo
15
15
  # redirect 'foo/bar'
16
+ # redirect :index, :status => 309
16
17
  #
17
18
  # TODO:
18
- # - setting custom status-code, it ignores any preset ones at the moment
19
19
  # - maybe some more options, like a delay
20
20
  #
21
21
 
22
22
  module RedirectHelper
23
23
 
24
24
  # Usage:
25
- # redirect MainController
26
- # redirect MainController, :foo
25
+ # redirect R(MainController)
26
+ # redirect R(MainController, :foo)
27
27
  # redirect 'foo/bar'
28
28
 
29
- def redirect *target
30
- target = target.join('/')
29
+ def redirect target, opts = {}
30
+ target = target.to_s
31
+ head = {
32
+ 'Location' => target
33
+ }.merge(response.header)
31
34
 
32
- response.head['Location'] = target
35
+ status = opts[:status] || STATUS_CODE[:see_other]
33
36
 
34
- hash = target.find{|h| h.is_a?(Hash)} and status = hash.delete(:status) rescue nil
37
+ body = %{Please follow <a href="#{target}">#{target}</a>!}
35
38
 
36
- response.code = status || STATUS_CODE[:see_other]
37
- response.out = %{Please follow <a href="#{target}">#{target}</a>!}
38
39
 
39
- throw :respond
40
+ throw(:redirect, :body => body, :status => status, :head => head)
40
41
  end
41
42
 
42
43
  # redirect to the location the browser says it's coming from.
@@ -12,7 +12,7 @@ module Ramaze
12
12
  #
13
13
  # Example:
14
14
  #
15
- # class AuthController < Template::Ramaze
15
+ # class AuthController < Controller
16
16
  # helper :stack
17
17
  #
18
18
  # def login pass
@@ -30,7 +30,7 @@ module Ramaze
30
30
  # end
31
31
  # end
32
32
  #
33
- # class ImportantController < Template::Ramaze
33
+ # class ImportantController < Controller
34
34
  # helper :stack
35
35
  #
36
36
  # def secret_information
@@ -47,21 +47,19 @@ module Ramaze
47
47
 
48
48
  def call this
49
49
  (session[:STACK] ||= []) << request.request_uri
50
- redirect(this)
50
+ redirect(R(this))
51
51
  end
52
52
 
53
53
  # return to the last location on session[:STACK]
54
54
 
55
55
  def answer
56
- redirect session[:STACK].pop if inside_stack?
56
+ redirect R(session[:STACK].pop) if inside_stack?
57
57
  end
58
58
 
59
59
  # check if the stack has something inside.
60
60
 
61
61
  def inside_stack?
62
- not session[:STACK].empty?
63
- rescue
64
- false
62
+ session[:STACK] and session[:STACK].any?
65
63
  end
66
64
  end
67
65
  end
@@ -39,6 +39,8 @@ module Ramaze
39
39
 
40
40
  alias D debug
41
41
 
42
+ def debug?() inform_tag?(:debug) end
43
+
42
44
  # A little but powerful method to debug calls to methods.
43
45
  #
44
46
  # def foo(*args)
@@ -73,6 +75,8 @@ module Ramaze
73
75
  log(Global.inform_prefix_info, message)
74
76
  end
75
77
 
78
+ def info?() inform_tag?(:info) end
79
+
76
80
  # Informing yourself about errors, you can pass it instances of Error
77
81
  # but also simple Strings.
78
82
  # (all that responds to :message/:backtrace or to_s)
@@ -103,6 +107,8 @@ module Ramaze
103
107
  end
104
108
  end
105
109
 
110
+ def error?() inform_tag?(:error) end
111
+
106
112
  # This uses Global.inform_timestamp or a date in the format of
107
113
  # %Y-%m-%d %H:%M:%S
108
114
  # # => "2007-01-19 21:09:32"
@@ -148,10 +154,13 @@ module Ramaze
148
154
  extend self
149
155
  end
150
156
 
157
+ # This class acts as a object you can pass to any other logger, it's basically
158
+ # just including Inform and making its methods public
159
+
151
160
  class GlobalInformer
152
161
  include Inform
153
162
 
154
- public :error, :info, :meth_debug, :debug
163
+ public :error, :error?, :info, :info?, :meth_debug, :debug, :debug?
155
164
 
156
165
  # this simply sends the parameters to #debug
157
166
 
@@ -160,6 +169,8 @@ module Ramaze
160
169
  end
161
170
  end
162
171
 
172
+ # The usual instance of GlobalInformer, for example used for WEBrick
173
+
163
174
  Informer = GlobalInformer.new
164
175
 
165
176
  include Inform