ramaze 2011.12.28 → 2012.03.07
Sign up to get free protection for your applications and to get access to all the features.
- data/.gems +34 -0
- data/.travis.yml +0 -1
- data/.yardopts +3 -2
- data/README.md +8 -6
- data/examples/app/blog/controller/init.rb +0 -1
- data/examples/app/blog/controller/posts.rb +0 -9
- data/examples/app/blog/controller/users.rb +0 -8
- data/examples/app/blog/model/comment.rb +0 -3
- data/examples/app/blog/model/post.rb +0 -2
- data/examples/app/blog/model/user.rb +1 -6
- data/examples/app/wikore/spec/wikore.rb +2 -2
- data/examples/app/wikore/src/model.rb +2 -8
- data/examples/app/wikore/start.rb +2 -2
- data/examples/misc/memleak_detector.rb +1 -1
- data/guide/AUTHORS +5 -2
- data/guide/CHANGELOG +203 -0
- data/guide/LICENSE +19 -0
- data/guide/general/contributing.md +74 -1
- data/guide/general/helpers.md +14 -0
- data/guide/general/middlewares.md +35 -16
- data/guide/general/sessions.md +39 -13
- data/lib/proto/layout/default.xhtml +1 -1
- data/lib/ramaze.rb +1 -1
- data/lib/ramaze/cache.rb +1 -1
- data/lib/ramaze/cache/localmemcache.rb +1 -1
- data/lib/ramaze/cache/lru.rb +1 -1
- data/lib/ramaze/controller.rb +1 -1
- data/lib/ramaze/dependencies.rb +3 -2
- data/lib/ramaze/gestalt.rb +1 -1
- data/lib/ramaze/helper.rb +1 -1
- data/lib/ramaze/helper/auth.rb +1 -1
- data/lib/ramaze/helper/cache.rb +1 -1
- data/lib/ramaze/helper/csrf.rb +14 -21
- data/lib/ramaze/helper/erector.rb +1 -1
- data/lib/ramaze/helper/flash.rb +1 -1
- data/lib/ramaze/helper/formatting.rb +1 -1
- data/lib/ramaze/helper/identity.rb +1 -1
- data/lib/ramaze/helper/link.rb +1 -1
- data/lib/ramaze/helper/markaby.rb +1 -1
- data/lib/ramaze/helper/stack.rb +1 -1
- data/lib/ramaze/helper/tagz.rb +1 -1
- data/lib/ramaze/helper/thread.rb +1 -1
- data/lib/ramaze/helper/user.rb +68 -30
- data/lib/ramaze/log.rb +1 -1
- data/lib/ramaze/log/analogger.rb +1 -1
- data/lib/ramaze/log/growl.rb +1 -1
- data/lib/ramaze/log/hub.rb +1 -1
- data/lib/ramaze/log/informer.rb +1 -1
- data/lib/ramaze/log/knotify.rb +1 -1
- data/lib/ramaze/log/logger.rb +1 -1
- data/lib/ramaze/log/logging.rb +1 -1
- data/lib/ramaze/log/syslog.rb +1 -1
- data/lib/ramaze/log/xosd.rb +1 -1
- data/lib/ramaze/plugin.rb +1 -1
- data/lib/ramaze/reloader.rb +1 -1
- data/lib/ramaze/request.rb +1 -1
- data/lib/ramaze/response.rb +1 -1
- data/lib/ramaze/snippets.rb +1 -1
- data/lib/ramaze/snippets/array/put_within.rb +1 -1
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +1 -1
- data/lib/ramaze/snippets/numeric/filesize_format.rb +1 -1
- data/lib/ramaze/snippets/object/__dir__.rb +1 -1
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +1 -1
- data/lib/ramaze/snippets/ordered_set.rb +1 -1
- data/lib/ramaze/snippets/ramaze/acquire.rb +1 -1
- data/lib/ramaze/snippets/ramaze/struct.rb +1 -1
- data/lib/ramaze/snippets/string/camel_case.rb +1 -1
- data/lib/ramaze/snippets/string/color.rb +1 -1
- data/lib/ramaze/snippets/string/end_with.rb +1 -1
- data/lib/ramaze/snippets/string/ord.rb +1 -1
- data/lib/ramaze/snippets/string/snake_case.rb +1 -1
- data/lib/ramaze/snippets/thread/into.rb +1 -1
- data/lib/ramaze/spec/helper/template_examples.rb +1 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +3 -2
- data/lib/ramaze/view/erector.rb +16 -14
- data/lib/ramaze/view/erubis.rb +4 -3
- data/lib/ramaze/view/ezamar.rb +3 -1
- data/lib/ramaze/view/haml.rb +4 -0
- data/lib/ramaze/view/liquid.rb +4 -3
- data/lib/ramaze/view/lokar.rb +3 -1
- data/lib/ramaze/view/mustache.rb +3 -1
- data/lib/ramaze/view/nagoro.rb +4 -1
- data/lib/ramaze/view/remarkably.rb +4 -0
- data/lib/ramaze/view/sass.rb +5 -1
- data/lib/ramaze/view/slim.rb +45 -0
- data/lib/ramaze/view/slippers.rb +8 -6
- data/lib/ramaze/view/tagz.rb +3 -1
- data/lib/ramaze/view/tenjin.rb +3 -1
- data/ramaze.gemspec +1 -1
- data/spec/examples/templates/template_erubis.rb +1 -1
- data/spec/examples/templates/template_ezamar.rb +1 -1
- data/spec/examples/templates/template_haml.rb +1 -1
- data/spec/examples/templates/template_liquid.rb +1 -1
- data/spec/examples/templates/template_markaby.rb +1 -1
- data/spec/examples/templates/template_mustache.rb +1 -1
- data/spec/examples/templates/template_nagoro.rb +1 -1
- data/spec/examples/templates/template_remarkably.rb +1 -1
- data/spec/examples/templates/template_tenjin.rb +1 -1
- data/spec/ramaze/action/render.rb +1 -1
- data/spec/ramaze/app.rb +1 -1
- data/spec/ramaze/app/location.rb +1 -1
- data/spec/ramaze/cache/localmemcache.rb +1 -1
- data/spec/ramaze/cache/lru.rb +1 -1
- data/spec/ramaze/cache/memcache.rb +1 -1
- data/spec/ramaze/cache/redis.rb +1 -1
- data/spec/ramaze/cache/sequel.rb +1 -1
- data/spec/ramaze/controller/actionless_templates.rb +1 -1
- data/spec/ramaze/controller/lonely_mapping.rb +1 -1
- data/spec/ramaze/controller/mapping.rb +1 -1
- data/spec/ramaze/controller/provide_inheritance.rb +1 -1
- data/spec/ramaze/controller/resolve.rb +1 -1
- data/spec/ramaze/controller/subclass.rb +1 -1
- data/spec/ramaze/controller/template_resolving.rb +1 -1
- data/spec/ramaze/dispatcher/directory.rb +1 -1
- data/spec/ramaze/dispatcher/file.rb +1 -1
- data/spec/ramaze/error.rb +1 -1
- data/spec/ramaze/files.rb +1 -1
- data/spec/ramaze/gestalt.rb +1 -1
- data/spec/ramaze/helper/auth.rb +1 -1
- data/spec/ramaze/helper/bench.rb +1 -1
- data/spec/ramaze/helper/cache.rb +1 -1
- data/spec/ramaze/helper/csrf.rb +10 -19
- data/spec/ramaze/helper/flash.rb +1 -1
- data/spec/ramaze/helper/formatting.rb +1 -1
- data/spec/ramaze/helper/gestalt.rb +1 -1
- data/spec/ramaze/helper/gravatar.rb +1 -1
- data/spec/ramaze/helper/layout.rb +1 -1
- data/spec/ramaze/helper/link.rb +1 -1
- data/spec/ramaze/helper/localize.rb +1 -1
- data/spec/ramaze/helper/maruku.rb +1 -1
- data/spec/ramaze/helper/paginate.rb +1 -1
- data/spec/ramaze/helper/request_accessor.rb +1 -1
- data/spec/ramaze/helper/simple_captcha.rb +1 -1
- data/spec/ramaze/helper/stack.rb +1 -1
- data/spec/ramaze/helper/user.rb +1 -1
- data/spec/ramaze/helper/xhtml.rb +1 -1
- data/spec/ramaze/log/informer.rb +1 -1
- data/spec/ramaze/log/logging.rb +1 -1
- data/spec/ramaze/log/syslog.rb +1 -1
- data/spec/ramaze/params.rb +1 -1
- data/spec/ramaze/request.rb +1 -1
- data/spec/ramaze/session/memcache.rb +1 -1
- data/spec/ramaze/struct.rb +1 -1
- data/spec/ramaze/view.rb +1 -1
- data/spec/ramaze/view/erubis.rb +1 -1
- data/spec/ramaze/view/ezamar.rb +1 -1
- data/spec/ramaze/view/gestalt.rb +1 -1
- data/spec/ramaze/view/haml.rb +1 -1
- data/spec/ramaze/view/liquid.rb +1 -1
- data/spec/ramaze/view/lokar.rb +1 -1
- data/spec/ramaze/view/mustache.rb +1 -1
- data/spec/ramaze/view/nagoro.rb +1 -1
- data/spec/ramaze/view/remarkably.rb +1 -1
- data/spec/ramaze/view/sass.rb +1 -1
- data/spec/ramaze/view/slim.rb +49 -0
- data/spec/ramaze/view/slim/external.slim +5 -0
- data/spec/ramaze/view/slim/external_vars.slim +5 -0
- data/spec/ramaze/view/tagz.rb +1 -1
- data/spec/ramaze/view/tenjin.rb +1 -1
- data/spec/snippets/array/put_within.rb +1 -1
- data/spec/snippets/binding/locals.rb +1 -1
- data/spec/snippets/numeric/filesize_format.rb +1 -1
- data/spec/snippets/numeric/time.rb +1 -1
- data/spec/snippets/object/__dir__.rb +1 -1
- data/spec/snippets/ordered_set.rb +1 -1
- data/spec/snippets/ramaze/acquire.rb +1 -1
- data/spec/snippets/ramaze/dictionary.rb +1 -1
- data/spec/snippets/ramaze/lru_hash.rb +1 -1
- data/spec/snippets/ramaze/struct.rb +1 -1
- data/spec/snippets/string/camel_case.rb +1 -1
- data/spec/snippets/string/color.rb +1 -1
- data/spec/snippets/string/snake_case.rb +1 -1
- data/spec/snippets/string/unindent.rb +1 -1
- data/spec/snippets/thread/into.rb +1 -1
- metadata +75 -60
- data/guide/GPL_LICENSE +0 -339
- data/guide/RUBY_LICENSE +0 -53
data/lib/ramaze/helper/flash.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the
|
2
|
+
# All files in this distribution are subject to the terms of the MIT license.
|
3
3
|
|
4
4
|
require 'openid'
|
5
5
|
require 'openid/store/filesystem'
|
data/lib/ramaze/helper/link.rb
CHANGED
data/lib/ramaze/helper/stack.rb
CHANGED
data/lib/ramaze/helper/tagz.rb
CHANGED
data/lib/ramaze/helper/thread.rb
CHANGED
data/lib/ramaze/helper/user.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Ramaze
|
2
2
|
module Helper
|
3
|
-
|
3
|
+
##
|
4
4
|
# This helper provides a convenience wrapper for handling authentication
|
5
5
|
# and persistence of users.
|
6
6
|
#
|
@@ -99,12 +99,11 @@ module Ramaze
|
|
99
99
|
# Use this method in your application, but do not use it in conditionals
|
100
100
|
# as it will never be nil or false.
|
101
101
|
#
|
102
|
+
# @api external
|
103
|
+
# @author manveru
|
102
104
|
# @return [Ramaze::Helper::User::Wrapper] wrapped return value from
|
103
105
|
# model or callback
|
104
106
|
#
|
105
|
-
# @api external
|
106
|
-
# @author manveru
|
107
|
-
#
|
108
107
|
def user
|
109
108
|
env = request.env
|
110
109
|
found = env[RAMAZE_HELPER_USER]
|
@@ -116,48 +115,74 @@ module Ramaze
|
|
116
115
|
end
|
117
116
|
|
118
117
|
##
|
119
|
-
#
|
118
|
+
# This method is used to authenticate a user against the supplied
|
119
|
+
# credentials (which default to ``request.params``).
|
120
|
+
#
|
121
|
+
# This method is a proxy to user._login which returns the value as
|
122
|
+
# returned by ``Ramaze::Helper::User::Wrapper#_login``.
|
123
|
+
#
|
124
|
+
# The supplied argument should be a hash with the user's credentials. The
|
125
|
+
# credentials hash may use any naming for the hash keys as long as they
|
126
|
+
# are consistent with the model which authenticates them (through the
|
127
|
+
# ``authenticate()`` method) such as:
|
128
|
+
#
|
129
|
+
# {"username" =>"name", "password" => "the_passwd"}
|
120
130
|
#
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
131
|
+
# On success it returns a hash of the credentials embedded within a hash
|
132
|
+
# whose only key is ':credentials' such as the following:
|
133
|
+
#
|
134
|
+
# {:credentials=>{"username"=>"myuser", "password"=>"mypassword"}}
|
135
|
+
#
|
136
|
+
# On failure to authenticate this method returns nil.
|
137
|
+
#
|
138
|
+
# @example
|
139
|
+
# auth = {"username" => "my_username", "password" => "mypass"}
|
140
|
+
# creds = user_login(auth)
|
141
|
+
# if creds
|
142
|
+
# respond 'You have been logged in as #{creds[:credentials]["username"]}', 200
|
143
|
+
# else
|
144
|
+
# respond 'You could not be logged in', 401
|
145
|
+
# end
|
124
146
|
#
|
125
|
-
# @api external
|
126
|
-
# @see Ramaze::Helper::User::Wrapper#_login
|
127
147
|
# @author manveru
|
148
|
+
# @api external
|
149
|
+
# @see Ramaze::Helper::User::Wrapper#_login
|
150
|
+
# @param [Hash] creds the credentials that will be passed to the callback or model.
|
151
|
+
# @return [nil Hash[Hash]]
|
128
152
|
#
|
129
153
|
def user_login(creds = request.params)
|
130
154
|
user._login(creds)
|
131
155
|
end
|
132
156
|
|
133
157
|
##
|
134
|
-
#
|
158
|
+
# Shortcut for user._logout
|
135
159
|
#
|
136
|
-
# @return [nil]
|
137
|
-
#
|
138
|
-
# @api external
|
139
|
-
# @see Ramaze::Helper::User::Wrapper#_logout
|
140
160
|
# @author manveru
|
161
|
+
# @api external
|
162
|
+
# @see Ramaze::Helper::User::Wrapper#_logout
|
163
|
+
# @return [NilClass]
|
141
164
|
#
|
142
165
|
def user_logout
|
143
166
|
user._logout
|
144
167
|
end
|
145
168
|
|
146
169
|
##
|
147
|
-
#
|
170
|
+
# Checks if the user is logged in and returns true if this is the case and
|
171
|
+
# false otherwise.
|
148
172
|
#
|
149
|
-
# @api external
|
150
|
-
# @see Ramaze::Helper::User::Wrapper#_logged_in?
|
151
173
|
# @author manveru
|
174
|
+
# @api external
|
175
|
+
# @see Ramaze::Helper::User::Wrapper#_logged_in?
|
176
|
+
# @return [TrueClass|FalseClass] whether the user is logged in already.
|
152
177
|
#
|
153
178
|
def logged_in?
|
154
179
|
user._logged_in?
|
155
180
|
end
|
156
181
|
|
157
182
|
##
|
158
|
-
# Wrapper for the ever-present "user" in your application.
|
159
|
-
#
|
160
|
-
#
|
183
|
+
# Wrapper for the ever-present "user" in your application. It wraps
|
184
|
+
# around an arbitrary instance and worries about authentication and
|
185
|
+
# storing information about the user in the session.
|
161
186
|
#
|
162
187
|
# In order to not interfere with the wrapped instance/model we start our
|
163
188
|
# methods with an underscore.
|
@@ -174,12 +199,13 @@ module Ramaze
|
|
174
199
|
end
|
175
200
|
|
176
201
|
##
|
177
|
-
# @
|
202
|
+
# @author manveru
|
203
|
+
# @see Ramaze::Helper::User#user_login
|
204
|
+
# @param [Hash] creds this hash will be stored in the session on
|
178
205
|
# successful login
|
179
206
|
# @return [Ramaze::Helper::User::Wrapper] wrapped return value from
|
180
207
|
# model or callback
|
181
|
-
#
|
182
|
-
# @author manveru
|
208
|
+
#
|
183
209
|
def _login(creds = nil)
|
184
210
|
if creds
|
185
211
|
if @_user = _would_login?(creds)
|
@@ -191,11 +217,13 @@ module Ramaze
|
|
191
217
|
end
|
192
218
|
end
|
193
219
|
|
220
|
+
##
|
194
221
|
# The callback should return an instance of the user, otherwise it
|
195
222
|
# should answer with nil.
|
196
223
|
#
|
197
224
|
# This will not actually login, just check whether the credentials
|
198
225
|
# would result in a user.
|
226
|
+
#
|
199
227
|
def _would_login?(creds)
|
200
228
|
return unless creds
|
201
229
|
|
@@ -204,23 +232,31 @@ module Ramaze
|
|
204
232
|
elsif _model.respond_to?(:authenticate)
|
205
233
|
_model.authenticate(creds)
|
206
234
|
else
|
207
|
-
Log.warn(
|
235
|
+
Log.warn(
|
236
|
+
"Helper::User has no callback and there is no %p::authenticate" \
|
237
|
+
% _model
|
238
|
+
)
|
239
|
+
|
208
240
|
nil
|
209
241
|
end
|
210
242
|
end
|
211
243
|
|
212
|
-
|
213
|
-
# @see Ramaze::Helper::User#user_logout
|
244
|
+
##
|
214
245
|
# @author manveru
|
246
|
+
# @api internal
|
247
|
+
# @see Ramaze::Helper::User#user_logout
|
248
|
+
#
|
215
249
|
def _logout
|
216
250
|
(_persistence || {}).clear
|
217
251
|
Current.request.env['ramaze.helper.user'] = nil
|
218
252
|
end
|
219
253
|
|
220
|
-
|
221
|
-
# @api internal
|
222
|
-
# @see Ramaze::Helper::User#logged_in?
|
254
|
+
##
|
223
255
|
# @author manveru
|
256
|
+
# @api internal
|
257
|
+
# @see Ramaze::Helper::User#logged_in?
|
258
|
+
# @return [true false] whether the current user is logged in.
|
259
|
+
#
|
224
260
|
def _logged_in?
|
225
261
|
!!_user
|
226
262
|
end
|
@@ -233,8 +269,10 @@ module Ramaze
|
|
233
269
|
Current.session[:USER]
|
234
270
|
end
|
235
271
|
|
272
|
+
##
|
236
273
|
# Refer everything not known
|
237
274
|
# THINK: This might be quite confusing... should we raise instead?
|
275
|
+
#
|
238
276
|
def method_missing(meth, *args, &block)
|
239
277
|
return unless _user
|
240
278
|
_user.send(meth, *args, &block)
|
data/lib/ramaze/log.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the
|
2
|
+
# All files in this distribution are subject to the terms of the MIT license.
|
3
3
|
require 'ramaze/log/logging'
|
4
4
|
require 'ramaze/log/informer'
|
5
5
|
|
data/lib/ramaze/log/analogger.rb
CHANGED
data/lib/ramaze/log/growl.rb
CHANGED
data/lib/ramaze/log/hub.rb
CHANGED
data/lib/ramaze/log/informer.rb
CHANGED
data/lib/ramaze/log/knotify.rb
CHANGED
data/lib/ramaze/log/logger.rb
CHANGED
data/lib/ramaze/log/logging.rb
CHANGED
data/lib/ramaze/log/syslog.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# Copyright (c) 2008 rob@rebeltechnologies.nl
|
3
|
-
# All files in this distribution are subject to the terms of the
|
3
|
+
# All files in this distribution are subject to the terms of the MIT license.
|
4
4
|
|
5
5
|
require 'syslog'
|
6
6
|
|
data/lib/ramaze/log/xosd.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the
|
2
|
+
# All files in this distribution are subject to the terms of the MIT license.
|
3
3
|
|
4
4
|
Ramaze::Log.log( :warn, "Both xosd gems are currently known to be broken" )
|
5
5
|
require 'xosd'
|
data/lib/ramaze/plugin.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the
|
2
|
+
# All files in this distribution are subject to the terms of the MIT license.
|
3
3
|
|
4
4
|
module Ramaze
|
5
5
|
def self.plugin(name, options = {})
|
data/lib/ramaze/reloader.rb
CHANGED
data/lib/ramaze/request.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the
|
2
|
+
# All files in this distribution are subject to the terms of the MIT license.
|
3
3
|
module Ramaze
|
4
4
|
##
|
5
5
|
# The purpose of this class is to act as a simple wrapper for Rack::Request
|
data/lib/ramaze/response.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the
|
2
|
+
# All files in this distribution are subject to the terms of the MIT license.
|
3
3
|
module Ramaze
|
4
4
|
##
|
5
5
|
# Ramaze::Response is a small wrapper around Rack::Response that makes it
|
data/lib/ramaze/snippets.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the
|
2
|
+
# All files in this distribution are subject to the terms of the MIT license.
|
3
3
|
|
4
4
|
require 'ramaze/snippets/array/put_within'
|
5
5
|
require 'ramaze/snippets/binding/locals'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the
|
2
|
+
# All files in this distribution are subject to the terms of the MIT license.
|
3
3
|
|
4
4
|
require(File.join(File.dirname(__FILE__), 'blankslate'))
|
5
5
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the
|
2
|
+
# All files in this distribution are subject to the terms of the MIT license.
|
3
3
|
|
4
4
|
module Ramaze
|
5
5
|
# Require all .rb and .so files on the given globs, utilizes Dir::[].
|