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.
- data/Rakefile +52 -19
- data/bin/ramaze +19 -6
- data/doc/CHANGELOG +33 -0
- data/doc/COPYING +1 -1
- data/doc/FAQ +92 -0
- data/doc/GPL +340 -0
- data/doc/INSTALL +34 -0
- data/doc/ProjectInfo +53 -0
- data/doc/README +187 -110
- data/doc/readme_chunks/appendix.txt +13 -0
- data/doc/readme_chunks/examples.txt +38 -0
- data/doc/readme_chunks/features.txt +82 -0
- data/doc/readme_chunks/getting_help.txt +5 -0
- data/doc/readme_chunks/getting_started.txt +18 -0
- data/doc/readme_chunks/installing.txt +41 -0
- data/doc/readme_chunks/introduction.txt +18 -0
- data/doc/readme_chunks/principles.txt +41 -0
- data/doc/readme_chunks/thanks.txt +59 -0
- data/doc/tutorial/todolist.txt +546 -0
- data/examples/blog/main.rb +1 -1
- data/examples/blog/src/controller.rb +13 -11
- data/examples/blog/src/element.rb +11 -6
- data/examples/blog/src/model.rb +8 -23
- data/examples/blog/template/edit.xhtml +3 -1
- data/examples/blog/template/index.xhtml +4 -4
- data/examples/caching.rb +4 -4
- data/examples/element.rb +10 -7
- data/examples/hello.rb +3 -4
- data/examples/simple.rb +5 -3
- data/examples/templates/template/external.amrita +19 -0
- data/examples/templates/template/{external.rmze → external.zmr} +2 -2
- data/examples/templates/template_amrita2.rb +48 -0
- data/examples/templates/template_erubis.rb +5 -2
- data/examples/templates/{template_ramaze.rb → template_ezamar.rb} +13 -7
- data/examples/templates/template_haml.rb +4 -1
- data/examples/templates/template_liquid.rb +2 -1
- data/examples/templates/template_markaby.rb +2 -1
- data/examples/todolist/conf/benchmark.yaml +35 -0
- data/examples/todolist/conf/debug.yaml +34 -0
- data/examples/todolist/conf/live.yaml +33 -0
- data/examples/todolist/conf/silent.yaml +31 -0
- data/examples/todolist/conf/stage.yaml +33 -0
- data/examples/todolist/main.rb +18 -0
- data/examples/todolist/public/404.jpg +0 -0
- data/examples/todolist/public/css/coderay.css +105 -0
- data/examples/todolist/public/css/ramaze_error.css +42 -0
- data/{lib/proto → examples/todolist}/public/error.xhtml +0 -0
- data/examples/todolist/public/favicon.ico +0 -0
- data/examples/todolist/public/js/jquery.js +1923 -0
- data/examples/todolist/public/ramaze.png +0 -0
- data/examples/todolist/src/controller/main.rb +56 -0
- data/examples/todolist/src/element/page.rb +26 -0
- data/examples/todolist/src/model.rb +14 -0
- data/examples/todolist/template/index.xhtml +17 -0
- data/examples/todolist/template/new.xhtml +7 -0
- data/examples/todolist/todolist.db +9 -0
- data/examples/whywiki/main.rb +3 -8
- data/examples/whywiki/template/show.xhtml +4 -0
- data/lib/proto/public/error.zmr +77 -0
- data/lib/proto/src/controller/main.rb +2 -1
- data/lib/proto/src/element/page.rb +2 -1
- data/lib/proto/src/model.rb +3 -2
- data/lib/ramaze.rb +7 -9
- data/lib/ramaze/adapter.rb +51 -0
- data/lib/ramaze/adapter/cgi.rb +23 -0
- data/lib/ramaze/adapter/fcgi.rb +22 -0
- data/lib/ramaze/adapter/mongrel.rb +7 -86
- data/lib/ramaze/adapter/webrick.rb +14 -133
- data/lib/ramaze/cache/memcached.rb +6 -0
- data/lib/ramaze/cache/yaml_store.rb +3 -1
- data/lib/ramaze/controller.rb +292 -2
- data/lib/ramaze/dispatcher.rb +85 -213
- data/lib/ramaze/error.rb +10 -0
- data/lib/ramaze/global.rb +8 -0
- data/lib/ramaze/helper/aspect.rb +30 -7
- data/lib/ramaze/helper/auth.rb +16 -9
- data/lib/ramaze/helper/cache.rb +40 -35
- data/lib/ramaze/helper/feed.rb +1 -1
- data/lib/ramaze/helper/flash.rb +34 -0
- data/lib/ramaze/helper/link.rb +8 -2
- data/lib/ramaze/helper/openid.rb +63 -0
- data/lib/ramaze/helper/redirect.rb +12 -11
- data/lib/ramaze/helper/stack.rb +5 -7
- data/lib/ramaze/inform.rb +12 -1
- data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
- data/lib/ramaze/snippets/kernel/{self_method.rb → method.rb} +3 -18
- data/lib/ramaze/snippets/kernel/{rescue_require.rb → pretty_inspect.rb} +7 -6
- data/lib/ramaze/snippets/method/name.rb +22 -0
- data/lib/ramaze/snippets/{kernel → ramaze}/autoreload.rb +0 -0
- data/lib/ramaze/snippets/ramaze/caller_info.rb +14 -0
- data/lib/ramaze/snippets/{kernel → ramaze}/caller_lines.rb +3 -10
- data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +49 -23
- data/lib/ramaze/snippets/string/DIVIDE.rb +0 -1
- data/lib/ramaze/store/default.rb +58 -2
- data/lib/ramaze/store/yaml.rb +161 -0
- data/lib/ramaze/template.rb +27 -86
- data/lib/ramaze/template/amrita2.rb +14 -19
- data/lib/ramaze/template/erubis.rb +15 -38
- data/lib/ramaze/template/ezamar.rb +100 -0
- data/lib/ramaze/template/ezamar/element.rb +166 -0
- data/lib/ramaze/template/ezamar/engine.rb +124 -0
- data/lib/ramaze/template/ezamar/morpher.rb +155 -0
- data/lib/ramaze/template/haml.rb +16 -43
- data/lib/ramaze/template/liquid.rb +11 -51
- data/lib/ramaze/template/markaby.rb +44 -42
- data/lib/ramaze/tool/mime.rb +18 -0
- data/lib/ramaze/tool/mime_types.yaml +615 -0
- data/lib/ramaze/trinity/request.rb +20 -196
- data/lib/ramaze/trinity/response.rb +4 -33
- data/lib/ramaze/trinity/session.rb +150 -72
- data/lib/ramaze/version.rb +1 -1
- data/spec/adapter_spec.rb +20 -0
- data/spec/public/favicon.ico +0 -0
- data/spec/public/ramaze.png +0 -0
- data/spec/public/test_download.css +141 -0
- data/spec/{tc_request.rb → request_tc_helper.rb} +45 -21
- data/spec/spec_all.rb +77 -34
- data/spec/spec_helper.rb +8 -157
- data/spec/spec_helper_context.rb +72 -0
- data/spec/spec_helper_requester.rb +52 -0
- data/spec/spec_helper_simple_http.rb +433 -0
- data/spec/tc_adapter_mongrel.rb +3 -15
- data/spec/tc_adapter_webrick.rb +4 -14
- data/spec/tc_cache.rb +3 -5
- data/spec/tc_controller.rb +22 -12
- data/spec/tc_dependencies.rb +13 -0
- data/spec/tc_element.rb +8 -7
- data/spec/tc_error.rb +13 -7
- data/spec/tc_global.rb +16 -18
- data/spec/tc_helper_aspect.rb +2 -4
- data/spec/tc_helper_auth.rb +15 -14
- data/spec/tc_helper_cache.rb +5 -7
- data/spec/tc_helper_feed.rb +0 -2
- data/spec/tc_helper_flash.rb +103 -0
- data/spec/tc_helper_form.rb +4 -6
- data/spec/tc_helper_link.rb +1 -3
- data/spec/tc_helper_redirect.rb +23 -8
- data/spec/tc_helper_stack.rb +31 -15
- data/spec/tc_morpher.rb +1 -3
- data/spec/tc_params.rb +48 -7
- data/spec/tc_request_mongrel.rb +9 -0
- data/spec/tc_request_webrick.rb +5 -0
- data/spec/tc_session.rb +41 -25
- data/spec/tc_store.rb +55 -6
- data/spec/tc_store_yaml.rb +71 -0
- data/spec/tc_template_amrita2.rb +3 -3
- data/spec/tc_template_erubis.rb +2 -3
- data/spec/{tc_template_ramaze.rb → tc_template_ezamar.rb} +15 -5
- data/spec/tc_template_haml.rb +4 -3
- data/spec/tc_template_liquid.rb +3 -4
- data/spec/tc_template_markaby.rb +4 -6
- data/spec/tc_tidy.rb +1 -3
- data/spec/template/amrita2/{data.html → data.amrita} +0 -0
- data/spec/template/amrita2/{index.html → index.amrita} +0 -0
- data/spec/template/amrita2/{sum.html → sum.amrita} +0 -0
- data/spec/template/ezamar/another/long/action.zmr +1 -0
- data/spec/template/ezamar/combined.zmr +1 -0
- data/spec/template/{ramaze/file_only.rmze → ezamar/file_only.zmr} +0 -0
- data/spec/template/{ramaze/index.rmze → ezamar/index.zmr} +0 -0
- data/spec/template/{ramaze/nested.rmze → ezamar/nested.zmr} +0 -0
- data/spec/template/ezamar/some__long__action.zmr +1 -0
- data/spec/template/{ramaze/sum.rmze → ezamar/sum.zmr} +0 -0
- metadata +181 -123
- data/doc/allison/LICENSE +0 -184
- data/doc/allison/README +0 -37
- data/doc/allison/allison.css +0 -300
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/allison.js +0 -307
- data/doc/allison/allison.rb +0 -287
- data/doc/allison/cache/BODY +0 -588
- data/doc/allison/cache/CLASS_INDEX +0 -4
- data/doc/allison/cache/CLASS_PAGE +0 -1
- data/doc/allison/cache/FILE_INDEX +0 -4
- data/doc/allison/cache/FILE_PAGE +0 -1
- data/doc/allison/cache/FONTS +0 -1
- data/doc/allison/cache/FR_INDEX_BODY +0 -1
- data/doc/allison/cache/IMGPATH +0 -1
- data/doc/allison/cache/INDEX +0 -1
- data/doc/allison/cache/JAVASCRIPT +0 -307
- data/doc/allison/cache/METHOD_INDEX +0 -4
- data/doc/allison/cache/METHOD_LIST +0 -1
- data/doc/allison/cache/SRC_PAGE +0 -1
- data/doc/allison/cache/STYLE +0 -322
- data/doc/allison/cache/URL +0 -1
- data/doc/changes.txt +0 -2021
- data/doc/changes.xml +0 -2024
- data/lib/ramaze/snippets/kernel/silently.rb +0 -13
- data/lib/ramaze/snippets/thread/deadQUESTIONMARK.rb +0 -11
- data/lib/ramaze/template/haml/actionview_stub.rb +0 -20
- data/lib/ramaze/template/ramaze.rb +0 -177
- data/lib/ramaze/template/ramaze/element.rb +0 -166
- data/lib/ramaze/template/ramaze/morpher.rb +0 -156
- data/spec/tc_test.rb +0 -17
data/lib/ramaze/helper/auth.rb
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
data/lib/ramaze/helper/cache.rb
CHANGED
|
@@ -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
|
-
#
|
|
7
|
+
# Cache for single key/value pairs
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
@@cache ||= Global.cache.new
|
|
11
|
-
end
|
|
9
|
+
trait :value_cache => Global.cache.new
|
|
12
10
|
|
|
13
|
-
#
|
|
11
|
+
# Cache for values returned from actions
|
|
14
12
|
|
|
15
|
-
|
|
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
|
-
|
|
24
|
-
Global.cached_actions.delete(self.class)
|
|
25
|
-
end
|
|
26
|
-
alias uncache_all_actions uncache_all
|
|
15
|
+
private
|
|
27
16
|
|
|
28
|
-
# cache
|
|
17
|
+
# use this to cache values in your controller and templates,
|
|
18
|
+
# for example heavy calculations or time-consuming queries.
|
|
29
19
|
|
|
30
|
-
def
|
|
31
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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
|
data/lib/ramaze/helper/feed.rb
CHANGED
|
@@ -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
|
data/lib/ramaze/helper/link.rb
CHANGED
|
@@ -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
|
|
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
|
-
%{
|
|
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
|
|
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
|
|
30
|
-
target = target.
|
|
29
|
+
def redirect target, opts = {}
|
|
30
|
+
target = target.to_s
|
|
31
|
+
head = {
|
|
32
|
+
'Location' => target
|
|
33
|
+
}.merge(response.header)
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
status = opts[:status] || STATUS_CODE[:see_other]
|
|
33
36
|
|
|
34
|
-
|
|
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 :
|
|
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.
|
data/lib/ramaze/helper/stack.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Ramaze
|
|
|
12
12
|
#
|
|
13
13
|
# Example:
|
|
14
14
|
#
|
|
15
|
-
# class AuthController <
|
|
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 <
|
|
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
|
-
|
|
63
|
-
rescue
|
|
64
|
-
false
|
|
62
|
+
session[:STACK] and session[:STACK].any?
|
|
65
63
|
end
|
|
66
64
|
end
|
|
67
65
|
end
|
data/lib/ramaze/inform.rb
CHANGED
|
@@ -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
|