ramaze 2011.01.30 → 2011.07.25

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 (229) hide show
  1. data/.gitignore +2 -1
  2. data/.mailmap +2 -0
  3. data/.rvmrc +1 -0
  4. data/README.md +119 -197
  5. data/Rakefile +14 -97
  6. data/bin/ramaze +6 -14
  7. data/doc/AUTHORS +8 -4
  8. data/doc/CHANGELOG +3784 -3339
  9. data/examples/app/chat/start.rb +2 -2
  10. data/lib/proto/app.rb +2 -3
  11. data/lib/proto/config.ru +4 -5
  12. data/lib/proto/controller/init.rb +11 -4
  13. data/lib/proto/controller/main.rb +12 -7
  14. data/lib/proto/layout/default.xhtml +56 -23
  15. data/lib/proto/model/init.rb +3 -1
  16. data/lib/proto/public/css/grid.css +107 -0
  17. data/lib/proto/public/css/layout.css +81 -0
  18. data/lib/proto/public/css/reset.css +123 -0
  19. data/lib/proto/public/css/text.css +109 -0
  20. data/lib/proto/public/images/bg.png +0 -0
  21. data/lib/proto/spec/main.rb +2 -2
  22. data/lib/proto/start.rb +11 -1
  23. data/lib/proto/view/index.xhtml +27 -23
  24. data/lib/ramaze.rb +0 -1
  25. data/lib/ramaze/app.rb +85 -12
  26. data/lib/ramaze/app_graph.rb +107 -0
  27. data/lib/ramaze/bin/console.rb +87 -0
  28. data/lib/ramaze/bin/create.rb +94 -0
  29. data/lib/ramaze/bin/helper.rb +107 -0
  30. data/lib/ramaze/bin/restart.rb +95 -0
  31. data/lib/ramaze/bin/runner.rb +141 -0
  32. data/lib/ramaze/bin/start.rb +206 -0
  33. data/lib/ramaze/bin/status.rb +152 -0
  34. data/lib/ramaze/bin/stop.rb +112 -0
  35. data/lib/ramaze/cache.rb +9 -4
  36. data/lib/ramaze/cache/localmemcache.rb +10 -13
  37. data/lib/ramaze/cache/lru.rb +49 -7
  38. data/lib/ramaze/cache/memcache.rb +170 -92
  39. data/lib/ramaze/cache/sequel.rb +301 -118
  40. data/lib/ramaze/controller.rb +108 -9
  41. data/lib/ramaze/controller/default.rb +15 -2
  42. data/lib/ramaze/current.rb +14 -2
  43. data/lib/ramaze/dependencies.rb +46 -0
  44. data/lib/ramaze/files.rb +38 -3
  45. data/lib/ramaze/gestalt.rb +12 -12
  46. data/lib/ramaze/helper.rb +0 -2
  47. data/lib/ramaze/helper/auth.rb +30 -23
  48. data/lib/ramaze/helper/blue_form.rb +175 -126
  49. data/lib/ramaze/helper/csrf.rb +76 -91
  50. data/lib/ramaze/helper/email.rb +105 -0
  51. data/lib/ramaze/helper/erector.rb +16 -15
  52. data/lib/ramaze/helper/gestalt.rb +2 -2
  53. data/lib/ramaze/helper/layout.rb +89 -73
  54. data/lib/ramaze/helper/link.rb +7 -6
  55. data/lib/ramaze/helper/localize.rb +6 -5
  56. data/lib/ramaze/helper/markaby.rb +25 -23
  57. data/lib/ramaze/helper/maruku.rb +3 -3
  58. data/lib/ramaze/helper/paginate.rb +19 -27
  59. data/lib/ramaze/helper/remarkably.rb +3 -3
  60. data/lib/ramaze/helper/request_accessor.rb +3 -3
  61. data/lib/ramaze/helper/send_file.rb +12 -8
  62. data/lib/ramaze/helper/simple_captcha.rb +5 -6
  63. data/lib/ramaze/helper/stack.rb +7 -4
  64. data/lib/ramaze/helper/tagz.rb +10 -11
  65. data/lib/ramaze/helper/thread.rb +19 -16
  66. data/lib/ramaze/helper/ultraviolet.rb +7 -4
  67. data/lib/ramaze/helper/user.rb +40 -21
  68. data/lib/ramaze/helper/xhtml.rb +29 -20
  69. data/lib/ramaze/log.rb +3 -11
  70. data/lib/ramaze/log/analogger.rb +5 -4
  71. data/lib/ramaze/log/growl.rb +9 -7
  72. data/lib/ramaze/log/hub.rb +3 -5
  73. data/lib/ramaze/log/informer.rb +15 -12
  74. data/lib/ramaze/log/knotify.rb +3 -5
  75. data/lib/ramaze/log/logger.rb +3 -5
  76. data/lib/ramaze/log/logging.rb +6 -8
  77. data/lib/ramaze/log/rotatinginformer.rb +27 -17
  78. data/lib/ramaze/log/syslog.rb +7 -7
  79. data/lib/ramaze/log/xosd.rb +3 -5
  80. data/lib/ramaze/middleware_compiler.rb +27 -4
  81. data/lib/ramaze/reloader.rb +50 -12
  82. data/lib/ramaze/reloader/watch_inotify.rb +4 -5
  83. data/lib/ramaze/reloader/watch_stat.rb +3 -3
  84. data/lib/ramaze/request.rb +18 -8
  85. data/lib/ramaze/response.rb +38 -7
  86. data/lib/ramaze/rest.rb +36 -0
  87. data/lib/ramaze/setup.rb +101 -31
  88. data/lib/ramaze/spec.rb +1 -1
  89. data/lib/ramaze/spec/bacon.rb +6 -3
  90. data/lib/ramaze/spec/helper/bacon.rb +0 -1
  91. data/lib/ramaze/version.rb +1 -1
  92. data/lib/ramaze/view.rb +2 -11
  93. data/lib/ramaze/view/erector.rb +46 -31
  94. data/lib/ramaze/view/erubis.rb +7 -3
  95. data/lib/ramaze/view/ezamar.rb +7 -3
  96. data/lib/ramaze/view/gestalt.rb +9 -3
  97. data/lib/ramaze/view/haml.rb +7 -3
  98. data/lib/ramaze/view/liquid.rb +3 -3
  99. data/lib/ramaze/view/lokar.rb +7 -3
  100. data/lib/ramaze/view/mustache.rb +11 -5
  101. data/lib/ramaze/view/nagoro.rb +3 -3
  102. data/lib/ramaze/view/sass.rb +1 -1
  103. data/lib/ramaze/view/slippers.rb +40 -13
  104. data/lib/ramaze/view/tagz.rb +9 -5
  105. data/ramaze.gemspec +23 -128
  106. data/spec/helper.rb +5 -0
  107. data/spec/ramaze/bin/app/config.ru +11 -0
  108. data/spec/ramaze/bin/create.rb +28 -0
  109. data/spec/ramaze/bin/runner.rb +30 -0
  110. data/spec/ramaze/bin/start.rb +38 -0
  111. data/spec/ramaze/cache/memcache.rb +10 -3
  112. data/spec/ramaze/cache/sequel.rb +7 -0
  113. data/spec/ramaze/controller/provide_inheritance.rb +0 -10
  114. data/spec/ramaze/dispatcher/file.rb +19 -15
  115. data/spec/ramaze/helper/auth.rb +10 -9
  116. data/spec/ramaze/helper/blue_form.rb +121 -68
  117. data/spec/ramaze/helper/email.rb +69 -0
  118. data/spec/ramaze/helper/layout.rb +12 -15
  119. data/spec/ramaze/helper/layout/alternative.xhtml +5 -0
  120. data/spec/ramaze/helper/user.rb +2 -0
  121. data/spec/ramaze/log/growl.rb +14 -1
  122. data/spec/{contrib → ramaze}/rest.rb +1 -1
  123. data/spec/ramaze/session/memcache.rb +2 -2
  124. data/spec/ramaze/view/sass.rb +1 -1
  125. data/tasks/bacon.rake +3 -3
  126. data/tasks/gem.rake +17 -18
  127. data/tasks/rcov.rake +2 -3
  128. data/tasks/release.rake +8 -65
  129. data/tasks/setup.rake +10 -8
  130. data/tasks/todo.rake +9 -5
  131. data/tasks/yard.rake +3 -2
  132. metadata +105 -397
  133. data/MANIFEST +0 -532
  134. data/TODO.md +0 -19
  135. data/benchmark/bench_templates/bench.rb +0 -67
  136. data/benchmark/bench_templates/view/large.erb +0 -79
  137. data/benchmark/bench_templates/view/large.haml +0 -41
  138. data/benchmark/bench_templates/view/large.lok +0 -79
  139. data/benchmark/bench_templates/view/large.xhtml +0 -79
  140. data/benchmark/bench_templates/view/small.erb +0 -21
  141. data/benchmark/bench_templates/view/small.haml +0 -12
  142. data/benchmark/bench_templates/view/small.lok +0 -21
  143. data/benchmark/bench_templates/view/small.xhtml +0 -21
  144. data/benchmark/results.txt +0 -131
  145. data/benchmark/run.rb +0 -355
  146. data/benchmark/suite/minimal.rb +0 -11
  147. data/benchmark/suite/no_informer.rb +0 -7
  148. data/benchmark/suite/no_sessions.rb +0 -9
  149. data/benchmark/suite/no_template.rb +0 -7
  150. data/benchmark/suite/simple.rb +0 -5
  151. data/benchmark/suite/template_erubis.rb +0 -8
  152. data/benchmark/suite/template_etanni.rb +0 -8
  153. data/benchmark/suite/template_ezamar.rb +0 -8
  154. data/benchmark/suite/template_haml.rb +0 -13
  155. data/benchmark/suite/template_liquid.rb +0 -11
  156. data/benchmark/suite/template_markaby.rb +0 -9
  157. data/benchmark/suite/template_nagoro.rb +0 -8
  158. data/benchmark/suite/template_redcloth.rb +0 -13
  159. data/benchmark/suite/template_tenjin.rb +0 -8
  160. data/benchmark/test.rb +0 -35
  161. data/doc/FAQ +0 -92
  162. data/doc/INSTALL +0 -92
  163. data/doc/TODO +0 -29
  164. data/doc/meta/announcement.txt +0 -119
  165. data/doc/meta/configuration.txt +0 -163
  166. data/doc/meta/internals.txt +0 -278
  167. data/doc/meta/users.kml +0 -64
  168. data/doc/tutorial/todolist.html +0 -1512
  169. data/doc/tutorial/todolist.txt +0 -920
  170. data/examples/app/sourceview/public/coderay.css +0 -104
  171. data/examples/app/sourceview/public/images/file.gif +0 -0
  172. data/examples/app/sourceview/public/images/folder.gif +0 -0
  173. data/examples/app/sourceview/public/images/tv-collapsable-last.gif +0 -0
  174. data/examples/app/sourceview/public/images/tv-collapsable.gif +0 -0
  175. data/examples/app/sourceview/public/images/tv-expandable-last.gif +0 -0
  176. data/examples/app/sourceview/public/images/tv-expandable.gif +0 -0
  177. data/examples/app/sourceview/public/images/tv-item-last.gif +0 -0
  178. data/examples/app/sourceview/public/images/tv-item.gif +0 -0
  179. data/examples/app/sourceview/public/jquery.js +0 -11
  180. data/examples/app/sourceview/public/jquery.treeview.css +0 -48
  181. data/examples/app/sourceview/public/jquery.treeview.js +0 -223
  182. data/examples/app/sourceview/public/sourceview.js +0 -52
  183. data/examples/app/sourceview/start.rb +0 -79
  184. data/examples/app/sourceview/view/index.haml +0 -59
  185. data/examples/helpers/httpdigest.rb +0 -107
  186. data/lib/proto/public/css/screen.css +0 -30
  187. data/lib/proto/public/js/jquery.js +0 -7179
  188. data/lib/ramaze/contrib/addressable_route.rb +0 -56
  189. data/lib/ramaze/contrib/app_graph.rb +0 -64
  190. data/lib/ramaze/contrib/email.rb +0 -88
  191. data/lib/ramaze/contrib/facebook.rb +0 -23
  192. data/lib/ramaze/contrib/facebook/facebook.rb +0 -171
  193. data/lib/ramaze/contrib/gettext.rb +0 -113
  194. data/lib/ramaze/contrib/gettext/mo.rb +0 -155
  195. data/lib/ramaze/contrib/gettext/parser.rb +0 -46
  196. data/lib/ramaze/contrib/gettext/po.rb +0 -109
  197. data/lib/ramaze/contrib/gzip_filter.rb +0 -1
  198. data/lib/ramaze/contrib/maruku_uv.rb +0 -59
  199. data/lib/ramaze/contrib/profiling.rb +0 -36
  200. data/lib/ramaze/contrib/rest.rb +0 -23
  201. data/lib/ramaze/contrib/sequel/create_join.rb +0 -26
  202. data/lib/ramaze/contrib/sequel/form_field.rb +0 -129
  203. data/lib/ramaze/contrib/sequel/image.rb +0 -196
  204. data/lib/ramaze/contrib/sequel/relation.rb +0 -98
  205. data/lib/ramaze/helper/httpdigest.rb +0 -96
  206. data/lib/ramaze/tool/bin.rb +0 -340
  207. data/lib/ramaze/tool/create.rb +0 -48
  208. data/lib/ramaze/tool/project_creator.rb +0 -120
  209. data/lib/ramaze/view/less.rb +0 -12
  210. data/lib/ramaze/view/maruku.rb +0 -15
  211. data/lib/ramaze/view/redcloth.rb +0 -21
  212. data/spec/contrib/addressable_route.rb +0 -30
  213. data/spec/examples/helpers/httpdigest.rb +0 -64
  214. data/spec/examples/templates/template_redcloth.rb +0 -13
  215. data/spec/ramaze/bin/ramaze.rb +0 -96
  216. data/spec/ramaze/helper/httpdigest.rb +0 -176
  217. data/spec/ramaze/view/less.rb +0 -60
  218. data/spec/ramaze/view/less/file.css.less +0 -8
  219. data/spec/ramaze/view/redcloth.rb +0 -66
  220. data/spec/ramaze/view/redcloth/external.redcloth +0 -8
  221. data/tasks/copyright.rake +0 -21
  222. data/tasks/gem_setup.rake +0 -112
  223. data/tasks/git.rake +0 -46
  224. data/tasks/grancher.rake +0 -12
  225. data/tasks/jquery.rake +0 -15
  226. data/tasks/manifest.rake +0 -4
  227. data/tasks/metric_changes.rake +0 -24
  228. data/tasks/reversion.rake +0 -8
  229. data/tasks/traits.rake +0 -21
@@ -36,15 +36,14 @@ module Ramaze
36
36
  op = rand > 0.42 ? [ns[0], :+, ns[1]] : [ns[1], :-, ns[0]]
37
37
 
38
38
  question = op.join(' ')
39
- answer = op[0].send(op[1], op[2])
39
+ answer = op[0].send(op[1], op[2])
40
40
 
41
41
  [question, answer]
42
42
  }
43
43
 
44
44
  # Call the trait[:captcha] and store question/answer in session
45
45
  def simple_captcha
46
- question, answer = ancestral_trait[:captcha].call
47
-
46
+ question, answer = ancestral_trait[:captcha].call
48
47
  session[:CAPTCHA] = { :question => question, :answer => answer.to_s }
49
48
 
50
49
  question
@@ -56,6 +55,6 @@ module Ramaze
56
55
 
57
56
  answer.to_s.strip == captcha[:answer].to_s
58
57
  end
59
- end
60
- end
61
- end
58
+ end # SimpleCaptcha
59
+ end # Helper
60
+ end # Ramaze
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Ramaze
5
5
  module Helper
6
-
6
+ ##
7
7
  # provides an call/answer mechanism, this is useful for example in a
8
8
  # login-system.
9
9
  #
@@ -38,6 +38,7 @@ module Ramaze
38
38
  # "Agent X is assigned to fight the RubyNinjas"
39
39
  # end
40
40
  # end
41
+ #
41
42
  module Stack
42
43
  # redirect to another location and pushing the current location
43
44
  # on the session[:STACK]
@@ -50,11 +51,13 @@ module Ramaze
50
51
  redirect(this)
51
52
  end
52
53
 
54
+ ##
53
55
  # return to the last location on session[:STACK]
54
56
  # The optional alternative paramter will be used to redirect in case you
55
57
  # are not inside_stack?
56
58
  # If the session has no stack and no alternative is given this won't do
57
59
  # anything
60
+ #
58
61
  def answer(alternative = nil)
59
62
  if inside_stack?
60
63
  stack = session[:STACK]
@@ -70,6 +73,6 @@ module Ramaze
70
73
  def inside_stack?
71
74
  session[:STACK] and session[:STACK].any?
72
75
  end
73
- end
74
- end
75
- end
76
+ end # Stack
77
+ end # Helper
78
+ end # Ramaze
@@ -4,16 +4,15 @@
4
4
  require 'tagz'
5
5
 
6
6
  module Ramaze
7
-
8
- # Allows you to use some shortcuts for Tagz in your Controller.
9
-
10
- # use this inside your controller to directly build Tagz
11
- # Refer to the Tagz-documentation and testsuite for more examples.
12
- # Usage:
13
- # tagz { h1_{ "Apples & Oranges" } } #=> "<h1>Apples &amp; Oranges</h1>"
14
- # tagz { h1_(:class => 'fruits&floots'){ 'Apples' } } #=> "<h1 class=\"fruits&amp;floots\">Apples</h1>"
15
-
16
7
  module Helper
8
+ ##
9
+ # Allows you to use some shortcuts for Tagz in your Controller.
10
+ # use this inside your controller to directly build Tagz
11
+ # Refer to the Tagz-documentation and testsuite for more examples.
12
+ # Usage:
13
+ # tagz { h1_{ "Apples & Oranges" } } #=> "<h1>Apples &amp; Oranges</h1>"
14
+ # tagz { h1_(:class => 'fruits&floots'){ 'Apples' } }
15
+ #
17
16
  Tagz = ::Tagz
18
- end
19
- end
17
+ end # Helper
18
+ end # Ramaze
@@ -2,21 +2,24 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  module Ramaze
5
- module Helper::Thread
6
- ##
7
- # The thread method executes the specified block in a new thread.
8
- #
9
- # @param [Block] block The block that contains the code that will be executed in the new thread.
10
- #
11
- def thread &block
12
- parent_thread = Thread.current
13
- Thread.new do
14
- begin
15
- block.call
16
- rescue Exception => e
17
- parent_thread.raise(e)
5
+ module Helper
6
+ module Thread
7
+ ##
8
+ # The thread method executes the specified block in a new thread.
9
+ #
10
+ # @param [Block] block The block that contains the code that will be
11
+ # executed in the new thread.
12
+ #
13
+ def thread &block
14
+ parent_thread = Thread.current
15
+ Thread.new do
16
+ begin
17
+ block.call
18
+ rescue Exception => e
19
+ parent_thread.raise(e)
20
+ end
18
21
  end
19
22
  end
20
- end
21
- end
22
- end
23
+ end # Thread
24
+ end # Helper
25
+ end # Ramaze
@@ -11,9 +11,11 @@ module Ramaze
11
11
  :headers => false, # ouput document with all headers
12
12
  }
13
13
 
14
+ ##
14
15
  # Parse and output the file at the given path.
15
16
  # Please head over to the Ultraviolet documentation for more information
16
17
  # on possible options.
18
+ #
17
19
  def ultraviolet(path, options = {})
18
20
  o = ancestral_trait[:ultraviolet].merge(options)
19
21
  output, syntax, lines, style, headers =
@@ -26,6 +28,7 @@ module Ramaze
26
28
  Uv.parse(code, output, syntax, lines, style, headers)
27
29
  end
28
30
 
31
+ ##
29
32
  # Return absolute path to the css of given name.
30
33
  #
31
34
  # Usually this will point to somewhere in the gem tree.
@@ -33,7 +36,7 @@ module Ramaze
33
36
  # It seems like Uv will add support for user-defined PATH in the future,
34
37
  # so we will, to be future-proof, traverse the Uv.path even though it
35
38
  # currently will only have one directory.
36
-
39
+ #
37
40
  def ultraviolet_css(theme)
38
41
  Uv.path.each do |path|
39
42
  Dir[path/"render/xhtml/files/css/*.css"].each do |css|
@@ -41,6 +44,6 @@ module Ramaze
41
44
  end
42
45
  end
43
46
  end
44
- end
45
- end
46
- end
47
+ end # UltraViolet
48
+ end # Helper
49
+ end # Ramaze
@@ -4,8 +4,8 @@ module Ramaze
4
4
  # This helper provides a convenience wrapper for handling authentication
5
5
  # and persistence of users.
6
6
  #
7
- # On every request, when you use the {UserHelper#user} method for the first time,
8
- # we confirm the authentication and store the returned object in the
7
+ # On every request, when you use the {UserHelper#user} method for the first
8
+ # time, we confirm the authentication and store the returned object in the
9
9
  # request.env, usually this will involve a request to your database.
10
10
  #
11
11
  # @example Basic usage with User::authenticate
@@ -77,7 +77,7 @@ module Ramaze
77
77
  #
78
78
  # @example Using a lambda instead of User::authenticate
79
79
  #
80
- # # assumes all your controllers inhert from this one
80
+ # # assumes all your controllers inherit from this one
81
81
  #
82
82
  # class Controller < Ramaze::Controller
83
83
  # trait :user_callback => lambda{|creds|
@@ -87,7 +87,7 @@ module Ramaze
87
87
  #
88
88
  # @example Using a different model instead of User
89
89
  #
90
- # # assumes all your controllers inhert from this one
90
+ # # assumes all your controllers inherit from this one
91
91
  #
92
92
  # class Controller < Ramaze::Controller
93
93
  # trait :user_model => Account
@@ -99,36 +99,42 @@ module Ramaze
99
99
  # Using this as key in request.env
100
100
  RAMAZE_HELPER_USER = 'ramaze.helper.user'.freeze
101
101
 
102
+ ##
102
103
  # Use this method in your application, but do not use it in conditionals
103
104
  # as it will never be nil or false.
104
105
  #
105
- # @return [Ramaze::Helper::User::Wrapper] wrapped return value from model or callback
106
+ # @return [Ramaze::Helper::User::Wrapper] wrapped return value from
107
+ # model or callback
106
108
  #
107
109
  # @api external
108
110
  # @author manveru
111
+ #
109
112
  def user
110
113
  env = request.env
111
114
  found = env[RAMAZE_HELPER_USER]
112
115
  return found if found
113
116
 
114
117
  model, callback = ancestral_trait.values_at(:user_model, :user_callback)
115
- model ||= ::User
118
+ model ||= ::User unless callback
116
119
  env[RAMAZE_HELPER_USER] = Wrapper.new(model, callback)
117
120
  end
118
121
 
122
+ ##
119
123
  # shortcut for user._login but default argument are request.params
120
124
  #
121
- # @param [Hash] creds the credentials that will be passed to callback or model
122
- #
125
+ # @param [Hash] creds the credentials that will be passed to callback or
126
+ # model
123
127
  # @return [nil Hash] the given creds are returned on successful login
124
128
  #
125
129
  # @api external
126
130
  # @see Ramaze::Helper::User::Wrapper#_login
127
131
  # @author manveru
132
+ #
128
133
  def user_login(creds = request.params)
129
134
  user._login(creds)
130
135
  end
131
136
 
137
+ ##
132
138
  # shortcut for user._logout
133
139
  #
134
140
  # @return [nil]
@@ -136,19 +142,23 @@ module Ramaze
136
142
  # @api external
137
143
  # @see Ramaze::Helper::User::Wrapper#_logout
138
144
  # @author manveru
145
+ #
139
146
  def user_logout
140
147
  user._logout
141
148
  end
142
149
 
150
+ ##
143
151
  # @return [true false] whether the user is logged in already.
144
152
  #
145
153
  # @api external
146
154
  # @see Ramaze::Helper::User::Wrapper#_logged_in?
147
155
  # @author manveru
156
+ #
148
157
  def logged_in?
149
158
  user._logged_in?
150
159
  end
151
160
 
161
+ ##
152
162
  # Wrapper for the ever-present "user" in your application.
153
163
  # It wraps around an arbitrary instance and worries about authentication
154
164
  # and storing information about the user in the session.
@@ -157,6 +167,7 @@ module Ramaze
157
167
  # methods with an underscore.
158
168
  #
159
169
  # Patches and suggestions are highly appreciated.
170
+ #
160
171
  class Wrapper < BlankSlate
161
172
  attr_accessor :_model, :_callback, :_user
162
173
 
@@ -166,15 +177,21 @@ module Ramaze
166
177
  _login
167
178
  end
168
179
 
169
- # @param [Hash] creds this hash will be stored in the session on successful login
180
+ ##
181
+ # @param [Hash] creds this hash will be stored in the session on
182
+ # successful login
170
183
  # @return [Ramaze::Helper::User::Wrapper] wrapped return value from
171
- # model or callback
184
+ # model or callback
172
185
  # @see Ramaze::Helper::User#user_login
173
186
  # @author manveru
174
- def _login(creds = _persistence)
175
- if @_user = _would_login?(creds)
176
- Current.session.resid!
177
- self._persistence = creds
187
+ def _login(creds = nil)
188
+ if creds
189
+ if @_user = _would_login?(creds)
190
+ Current.session.resid!
191
+ self._persistence = {:credentials => creds}
192
+ end
193
+ elsif persistence = self._persistence
194
+ @_user = _would_login?(persistence[:credentials])
178
195
  end
179
196
  end
180
197
 
@@ -184,6 +201,8 @@ module Ramaze
184
201
  # This will not actually login, just check whether the credentials
185
202
  # would result in a user.
186
203
  def _would_login?(creds)
204
+ return unless creds
205
+
187
206
  if c = @_callback
188
207
  c.call(creds)
189
208
  elsif _model.respond_to?(:authenticate)
@@ -198,7 +217,7 @@ module Ramaze
198
217
  # @see Ramaze::Helper::User#user_logout
199
218
  # @author manveru
200
219
  def _logout
201
- _persistence.clear
220
+ (_persistence || {}).clear
202
221
  Current.request.env['ramaze.helper.user'] = nil
203
222
  end
204
223
 
@@ -210,12 +229,12 @@ module Ramaze
210
229
  !!_user
211
230
  end
212
231
 
213
- def _persistence=(creds)
214
- Current.session[:USER] = creds
232
+ def _persistence=(obj)
233
+ Current.session[:USER] = obj
215
234
  end
216
235
 
217
236
  def _persistence
218
- Current.session[:USER] || {}
237
+ Current.session[:USER]
219
238
  end
220
239
 
221
240
  # Refer everything not known
@@ -225,6 +244,6 @@ module Ramaze
225
244
  _user.send(meth, *args, &block)
226
245
  end
227
246
  end
228
- end
229
- end
230
- end
247
+ end # User
248
+ end # Helper
249
+ end # Ramaze
@@ -8,8 +8,8 @@ module Ramaze
8
8
  #
9
9
  # css 'reset', 'screen', :only => 'ie'
10
10
  #
11
- # This would result in a stylesheet named "reset.css" being loaded only when the user
12
- # is using Internet Explorer.
11
+ # This would result in a stylesheet named "reset.css" being loaded only when
12
+ # the user is using Internet Explorer.
13
13
  #
14
14
  module XHTML
15
15
  LINK_TAG = '<link href=%p media=%p rel="stylesheet" type="text/css" />'
@@ -17,12 +17,15 @@ module Ramaze
17
17
 
18
18
  ##
19
19
  # Generate a CSS tag based on the name, media type and a hash containing
20
- # additional options. For example, if we want to load the stylesheet only when the user
21
- # is using Internet Explorer we would have to add a key 'only' with a value of 'ie' to the hash.
20
+ # additional options. For example, if we want to load the stylesheet only
21
+ # when the user is using Internet Explorer we would have to add a key
22
+ # 'only' with a value of 'ie' to the hash.
22
23
  #
23
24
  # @param [String] name The name of the CSS file to load.
24
- # @param [String] media The media type for which the stylesheet should be loaded.
25
- # @param [Hash] options A hash containing additional options for the stylesheet tag.
25
+ # @param [String] media The media type for which the stylesheet should be
26
+ # loaded.
27
+ # @param [Hash] options A hash containing additional options for the
28
+ # stylesheet tag.
26
29
  # @example
27
30
  #
28
31
  # # A very basic example.
@@ -46,14 +49,18 @@ module Ramaze
46
49
  LINK_TAG % [name, media]
47
50
  else
48
51
  prefix = options[:prefix] || 'css'
49
- LINK_TAG % ["#{Ramaze.options.prefix.chomp("/")}/#{prefix}/#{name}.css", media]
52
+ LINK_TAG % [
53
+ "#{Ramaze.options.prefix.chomp("/")}/#{prefix}/#{name}.css",
54
+ media
55
+ ]
50
56
  end
51
57
  end
52
58
  end
53
59
 
54
60
  ##
55
- # The css_for method can be used when you want to load multiple stylesheets and don't
56
- # want to call the css() method over and over again.
61
+ # The css_for method can be used when you want to load multiple
62
+ # stylesheets and don't want to call the css() method over and over
63
+ # again.
57
64
  #
58
65
  # @example
59
66
  #
@@ -64,8 +71,9 @@ module Ramaze
64
71
  # css_for ['reset', 'print'], ['960', 'print']
65
72
  #
66
73
  # @see css()
67
- # @param [Array] args An array containing either the names of all stylesheets to load or a collection of arrays
68
- # of which each array defines the name, media and additional parameters.
74
+ # @param [Array] args An array containing either the names of all
75
+ # stylesheets to load or a collection of arrays of which each array
76
+ # defines the name, media and additional parameters.
69
77
  # @return [String]
70
78
  #
71
79
  def css_for(*args)
@@ -73,8 +81,8 @@ module Ramaze
73
81
  end
74
82
 
75
83
  ##
76
- # Generates a Javascript tag that loads an external Javascript file. This tag can't be used for loading inline
77
- # javascript files.
84
+ # Generates a Javascript tag that loads an external Javascript file. This
85
+ # tag can't be used for loading inline Javascript files.
78
86
  #
79
87
  # @example
80
88
  #
@@ -84,11 +92,12 @@ module Ramaze
84
92
  # # Let's change the directory to "some_other_directory"
85
93
  # js 'jquery', :prefix => 'some_other_directory'
86
94
  #
87
- # @param [String] name The name of the Javascript file that should be loaded.
88
- # @param [Hash] options Hash that can contain a :prefix key that defines the directory in which the JS file
89
- # is located. By default this key is set to "js".
95
+ # @param [String] name The name of the Javascript file that should be
96
+ # loaded.
97
+ # @param [Hash] options Hash that can contain a :prefix key that defines
98
+ # the directory in which the JS file is located. By default this key is
99
+ # set to "js".
90
100
  # @return [String]
91
- # TODO: The js() method 2nd argument is a hash but only supports the :prefix key. Perhaps changing this hash into a string would be better - Yorick
92
101
  #
93
102
  def js(name, options={})
94
103
  if name =~ /^http/ # consider it external full url
@@ -112,6 +121,6 @@ module Ramaze
112
121
  def js_for(*args)
113
122
  args.map{|arg| js(*arg) }.join("\n")
114
123
  end
115
- end
116
- end
117
- end
124
+ end # XHTML
125
+ end # Helper
126
+ end # Ramaze