ramaze 2011.01.30 → 2011.07.25
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.mailmap +2 -0
- data/.rvmrc +1 -0
- data/README.md +119 -197
- data/Rakefile +14 -97
- data/bin/ramaze +6 -14
- data/doc/AUTHORS +8 -4
- data/doc/CHANGELOG +3784 -3339
- data/examples/app/chat/start.rb +2 -2
- data/lib/proto/app.rb +2 -3
- data/lib/proto/config.ru +4 -5
- data/lib/proto/controller/init.rb +11 -4
- data/lib/proto/controller/main.rb +12 -7
- data/lib/proto/layout/default.xhtml +56 -23
- data/lib/proto/model/init.rb +3 -1
- data/lib/proto/public/css/grid.css +107 -0
- data/lib/proto/public/css/layout.css +81 -0
- data/lib/proto/public/css/reset.css +123 -0
- data/lib/proto/public/css/text.css +109 -0
- data/lib/proto/public/images/bg.png +0 -0
- data/lib/proto/spec/main.rb +2 -2
- data/lib/proto/start.rb +11 -1
- data/lib/proto/view/index.xhtml +27 -23
- data/lib/ramaze.rb +0 -1
- data/lib/ramaze/app.rb +85 -12
- data/lib/ramaze/app_graph.rb +107 -0
- data/lib/ramaze/bin/console.rb +87 -0
- data/lib/ramaze/bin/create.rb +94 -0
- data/lib/ramaze/bin/helper.rb +107 -0
- data/lib/ramaze/bin/restart.rb +95 -0
- data/lib/ramaze/bin/runner.rb +141 -0
- data/lib/ramaze/bin/start.rb +206 -0
- data/lib/ramaze/bin/status.rb +152 -0
- data/lib/ramaze/bin/stop.rb +112 -0
- data/lib/ramaze/cache.rb +9 -4
- data/lib/ramaze/cache/localmemcache.rb +10 -13
- data/lib/ramaze/cache/lru.rb +49 -7
- data/lib/ramaze/cache/memcache.rb +170 -92
- data/lib/ramaze/cache/sequel.rb +301 -118
- data/lib/ramaze/controller.rb +108 -9
- data/lib/ramaze/controller/default.rb +15 -2
- data/lib/ramaze/current.rb +14 -2
- data/lib/ramaze/dependencies.rb +46 -0
- data/lib/ramaze/files.rb +38 -3
- data/lib/ramaze/gestalt.rb +12 -12
- data/lib/ramaze/helper.rb +0 -2
- data/lib/ramaze/helper/auth.rb +30 -23
- data/lib/ramaze/helper/blue_form.rb +175 -126
- data/lib/ramaze/helper/csrf.rb +76 -91
- data/lib/ramaze/helper/email.rb +105 -0
- data/lib/ramaze/helper/erector.rb +16 -15
- data/lib/ramaze/helper/gestalt.rb +2 -2
- data/lib/ramaze/helper/layout.rb +89 -73
- data/lib/ramaze/helper/link.rb +7 -6
- data/lib/ramaze/helper/localize.rb +6 -5
- data/lib/ramaze/helper/markaby.rb +25 -23
- data/lib/ramaze/helper/maruku.rb +3 -3
- data/lib/ramaze/helper/paginate.rb +19 -27
- data/lib/ramaze/helper/remarkably.rb +3 -3
- data/lib/ramaze/helper/request_accessor.rb +3 -3
- data/lib/ramaze/helper/send_file.rb +12 -8
- data/lib/ramaze/helper/simple_captcha.rb +5 -6
- data/lib/ramaze/helper/stack.rb +7 -4
- data/lib/ramaze/helper/tagz.rb +10 -11
- data/lib/ramaze/helper/thread.rb +19 -16
- data/lib/ramaze/helper/ultraviolet.rb +7 -4
- data/lib/ramaze/helper/user.rb +40 -21
- data/lib/ramaze/helper/xhtml.rb +29 -20
- data/lib/ramaze/log.rb +3 -11
- data/lib/ramaze/log/analogger.rb +5 -4
- data/lib/ramaze/log/growl.rb +9 -7
- data/lib/ramaze/log/hub.rb +3 -5
- data/lib/ramaze/log/informer.rb +15 -12
- data/lib/ramaze/log/knotify.rb +3 -5
- data/lib/ramaze/log/logger.rb +3 -5
- data/lib/ramaze/log/logging.rb +6 -8
- data/lib/ramaze/log/rotatinginformer.rb +27 -17
- data/lib/ramaze/log/syslog.rb +7 -7
- data/lib/ramaze/log/xosd.rb +3 -5
- data/lib/ramaze/middleware_compiler.rb +27 -4
- data/lib/ramaze/reloader.rb +50 -12
- data/lib/ramaze/reloader/watch_inotify.rb +4 -5
- data/lib/ramaze/reloader/watch_stat.rb +3 -3
- data/lib/ramaze/request.rb +18 -8
- data/lib/ramaze/response.rb +38 -7
- data/lib/ramaze/rest.rb +36 -0
- data/lib/ramaze/setup.rb +101 -31
- data/lib/ramaze/spec.rb +1 -1
- data/lib/ramaze/spec/bacon.rb +6 -3
- data/lib/ramaze/spec/helper/bacon.rb +0 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +2 -11
- data/lib/ramaze/view/erector.rb +46 -31
- data/lib/ramaze/view/erubis.rb +7 -3
- data/lib/ramaze/view/ezamar.rb +7 -3
- data/lib/ramaze/view/gestalt.rb +9 -3
- data/lib/ramaze/view/haml.rb +7 -3
- data/lib/ramaze/view/liquid.rb +3 -3
- data/lib/ramaze/view/lokar.rb +7 -3
- data/lib/ramaze/view/mustache.rb +11 -5
- data/lib/ramaze/view/nagoro.rb +3 -3
- data/lib/ramaze/view/sass.rb +1 -1
- data/lib/ramaze/view/slippers.rb +40 -13
- data/lib/ramaze/view/tagz.rb +9 -5
- data/ramaze.gemspec +23 -128
- data/spec/helper.rb +5 -0
- data/spec/ramaze/bin/app/config.ru +11 -0
- data/spec/ramaze/bin/create.rb +28 -0
- data/spec/ramaze/bin/runner.rb +30 -0
- data/spec/ramaze/bin/start.rb +38 -0
- data/spec/ramaze/cache/memcache.rb +10 -3
- data/spec/ramaze/cache/sequel.rb +7 -0
- data/spec/ramaze/controller/provide_inheritance.rb +0 -10
- data/spec/ramaze/dispatcher/file.rb +19 -15
- data/spec/ramaze/helper/auth.rb +10 -9
- data/spec/ramaze/helper/blue_form.rb +121 -68
- data/spec/ramaze/helper/email.rb +69 -0
- data/spec/ramaze/helper/layout.rb +12 -15
- data/spec/ramaze/helper/layout/alternative.xhtml +5 -0
- data/spec/ramaze/helper/user.rb +2 -0
- data/spec/ramaze/log/growl.rb +14 -1
- data/spec/{contrib → ramaze}/rest.rb +1 -1
- data/spec/ramaze/session/memcache.rb +2 -2
- data/spec/ramaze/view/sass.rb +1 -1
- data/tasks/bacon.rake +3 -3
- data/tasks/gem.rake +17 -18
- data/tasks/rcov.rake +2 -3
- data/tasks/release.rake +8 -65
- data/tasks/setup.rake +10 -8
- data/tasks/todo.rake +9 -5
- data/tasks/yard.rake +3 -2
- metadata +105 -397
- data/MANIFEST +0 -532
- data/TODO.md +0 -19
- data/benchmark/bench_templates/bench.rb +0 -67
- data/benchmark/bench_templates/view/large.erb +0 -79
- data/benchmark/bench_templates/view/large.haml +0 -41
- data/benchmark/bench_templates/view/large.lok +0 -79
- data/benchmark/bench_templates/view/large.xhtml +0 -79
- data/benchmark/bench_templates/view/small.erb +0 -21
- data/benchmark/bench_templates/view/small.haml +0 -12
- data/benchmark/bench_templates/view/small.lok +0 -21
- data/benchmark/bench_templates/view/small.xhtml +0 -21
- data/benchmark/results.txt +0 -131
- data/benchmark/run.rb +0 -355
- data/benchmark/suite/minimal.rb +0 -11
- data/benchmark/suite/no_informer.rb +0 -7
- data/benchmark/suite/no_sessions.rb +0 -9
- data/benchmark/suite/no_template.rb +0 -7
- data/benchmark/suite/simple.rb +0 -5
- data/benchmark/suite/template_erubis.rb +0 -8
- data/benchmark/suite/template_etanni.rb +0 -8
- data/benchmark/suite/template_ezamar.rb +0 -8
- data/benchmark/suite/template_haml.rb +0 -13
- data/benchmark/suite/template_liquid.rb +0 -11
- data/benchmark/suite/template_markaby.rb +0 -9
- data/benchmark/suite/template_nagoro.rb +0 -8
- data/benchmark/suite/template_redcloth.rb +0 -13
- data/benchmark/suite/template_tenjin.rb +0 -8
- data/benchmark/test.rb +0 -35
- data/doc/FAQ +0 -92
- data/doc/INSTALL +0 -92
- data/doc/TODO +0 -29
- data/doc/meta/announcement.txt +0 -119
- data/doc/meta/configuration.txt +0 -163
- data/doc/meta/internals.txt +0 -278
- data/doc/meta/users.kml +0 -64
- data/doc/tutorial/todolist.html +0 -1512
- data/doc/tutorial/todolist.txt +0 -920
- data/examples/app/sourceview/public/coderay.css +0 -104
- data/examples/app/sourceview/public/images/file.gif +0 -0
- data/examples/app/sourceview/public/images/folder.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item.gif +0 -0
- data/examples/app/sourceview/public/jquery.js +0 -11
- data/examples/app/sourceview/public/jquery.treeview.css +0 -48
- data/examples/app/sourceview/public/jquery.treeview.js +0 -223
- data/examples/app/sourceview/public/sourceview.js +0 -52
- data/examples/app/sourceview/start.rb +0 -79
- data/examples/app/sourceview/view/index.haml +0 -59
- data/examples/helpers/httpdigest.rb +0 -107
- data/lib/proto/public/css/screen.css +0 -30
- data/lib/proto/public/js/jquery.js +0 -7179
- data/lib/ramaze/contrib/addressable_route.rb +0 -56
- data/lib/ramaze/contrib/app_graph.rb +0 -64
- data/lib/ramaze/contrib/email.rb +0 -88
- data/lib/ramaze/contrib/facebook.rb +0 -23
- data/lib/ramaze/contrib/facebook/facebook.rb +0 -171
- data/lib/ramaze/contrib/gettext.rb +0 -113
- data/lib/ramaze/contrib/gettext/mo.rb +0 -155
- data/lib/ramaze/contrib/gettext/parser.rb +0 -46
- data/lib/ramaze/contrib/gettext/po.rb +0 -109
- data/lib/ramaze/contrib/gzip_filter.rb +0 -1
- data/lib/ramaze/contrib/maruku_uv.rb +0 -59
- data/lib/ramaze/contrib/profiling.rb +0 -36
- data/lib/ramaze/contrib/rest.rb +0 -23
- data/lib/ramaze/contrib/sequel/create_join.rb +0 -26
- data/lib/ramaze/contrib/sequel/form_field.rb +0 -129
- data/lib/ramaze/contrib/sequel/image.rb +0 -196
- data/lib/ramaze/contrib/sequel/relation.rb +0 -98
- data/lib/ramaze/helper/httpdigest.rb +0 -96
- data/lib/ramaze/tool/bin.rb +0 -340
- data/lib/ramaze/tool/create.rb +0 -48
- data/lib/ramaze/tool/project_creator.rb +0 -120
- data/lib/ramaze/view/less.rb +0 -12
- data/lib/ramaze/view/maruku.rb +0 -15
- data/lib/ramaze/view/redcloth.rb +0 -21
- data/spec/contrib/addressable_route.rb +0 -30
- data/spec/examples/helpers/httpdigest.rb +0 -64
- data/spec/examples/templates/template_redcloth.rb +0 -13
- data/spec/ramaze/bin/ramaze.rb +0 -96
- data/spec/ramaze/helper/httpdigest.rb +0 -176
- data/spec/ramaze/view/less.rb +0 -60
- data/spec/ramaze/view/less/file.css.less +0 -8
- data/spec/ramaze/view/redcloth.rb +0 -66
- data/spec/ramaze/view/redcloth/external.redcloth +0 -8
- data/tasks/copyright.rake +0 -21
- data/tasks/gem_setup.rake +0 -112
- data/tasks/git.rake +0 -46
- data/tasks/grancher.rake +0 -12
- data/tasks/jquery.rake +0 -15
- data/tasks/manifest.rake +0 -4
- data/tasks/metric_changes.rake +0 -24
- data/tasks/reversion.rake +0 -8
- data/tasks/traits.rake +0 -21
data/lib/ramaze/controller.rb
CHANGED
@@ -2,7 +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
|
-
|
5
|
+
##
|
6
|
+
# Ramaze::Controller is the base controller of all controllers when developing
|
7
|
+
# applications in Ramaze. It acts as a nice wrapper around Innate::Node and
|
8
|
+
# allows for a more traditional MVC approach.
|
9
|
+
#
|
10
|
+
# == Example
|
11
|
+
#
|
12
|
+
# class Posts < Ramaze::Controller
|
13
|
+
# map '/posts'
|
14
|
+
#
|
15
|
+
# def index
|
16
|
+
#
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# @author Michael Fellinger
|
21
|
+
# @since 04-01-2009
|
22
|
+
#
|
6
23
|
class Controller
|
7
24
|
include Innate::Traited
|
8
25
|
include Innate::Node
|
@@ -18,6 +35,27 @@ module Ramaze
|
|
18
35
|
trait :app => :pristine
|
19
36
|
trait :skip_controller_map => false
|
20
37
|
|
38
|
+
##
|
39
|
+
# Hash containing the names of two common controller names and the URIs they
|
40
|
+
# should be mapped to.
|
41
|
+
#
|
42
|
+
# @author Michael Fellinger
|
43
|
+
# @since 04-01-2009
|
44
|
+
#
|
45
|
+
IRREGULAR_MAPPING = {
|
46
|
+
'Controller' => nil,
|
47
|
+
'MainController' => '/'
|
48
|
+
}
|
49
|
+
|
50
|
+
##
|
51
|
+
# Modifies the extending class so that it's properly set up to be used as a
|
52
|
+
# controller.
|
53
|
+
#
|
54
|
+
# @author Michael Fellinger
|
55
|
+
# @since 04-01-2009
|
56
|
+
# @param [Class] into The class that extended Ramaze::Controller (or a sub
|
57
|
+
# class).
|
58
|
+
#
|
21
59
|
def self.inherited(into)
|
22
60
|
Innate::Node.included(into)
|
23
61
|
into.helper(:layout)
|
@@ -25,6 +63,13 @@ module Ramaze
|
|
25
63
|
into.trait :skip_node_map => true
|
26
64
|
end
|
27
65
|
|
66
|
+
##
|
67
|
+
# Sets all the controllers up and loads a default controller in case no
|
68
|
+
# custom ones have been specified.
|
69
|
+
#
|
70
|
+
# @author Michael Fellinger
|
71
|
+
# @since 04-01-2009
|
72
|
+
#
|
28
73
|
def self.setup
|
29
74
|
case CONTROLLER_LIST.size
|
30
75
|
when 0
|
@@ -46,28 +91,59 @@ module Ramaze
|
|
46
91
|
end
|
47
92
|
end
|
48
93
|
|
94
|
+
##
|
95
|
+
# Method that's used to setup each controller, called by
|
96
|
+
# Ramaze::Controller.setup.
|
97
|
+
#
|
98
|
+
# @author Michael Fellinger
|
99
|
+
# @since 04-01-2009
|
100
|
+
#
|
49
101
|
def self.setup_procedure
|
50
102
|
unless ancestral_trait[:provide_set]
|
51
|
-
engine(:
|
103
|
+
engine(:etanni)
|
52
104
|
trait(:provide_set => false)
|
53
105
|
end
|
54
106
|
|
55
107
|
map(generate_mapping(name)) unless trait[:skip_controller_map]
|
56
108
|
end
|
57
109
|
|
110
|
+
##
|
111
|
+
# Sets the view engine to use for pages with a content type of text/html.
|
112
|
+
#
|
113
|
+
# @example
|
114
|
+
# class Posts < Ramaze::Controller
|
115
|
+
# engine :etanni
|
116
|
+
# end
|
117
|
+
#
|
118
|
+
# @author Michael Fellinger
|
119
|
+
# @since 04-01-2009
|
120
|
+
# @param [#to_sym] name The name of the view engine to use.
|
121
|
+
#
|
58
122
|
def self.engine(name)
|
59
123
|
provide(:html, name.to_sym)
|
60
124
|
end
|
61
125
|
|
126
|
+
##
|
127
|
+
# Returns the URI a controller is mapped to.
|
128
|
+
#
|
129
|
+
# @author Michael Fellinger
|
130
|
+
# @since 04-01-2009
|
131
|
+
# @return [String]
|
132
|
+
#
|
62
133
|
def self.mapping
|
63
134
|
Ramaze.to(self)
|
64
135
|
end
|
65
136
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
137
|
+
##
|
138
|
+
# Generates a URI for the full namespace of a class. If a class is named
|
139
|
+
# A::B::C the URI would be /a/b/c.
|
140
|
+
#
|
141
|
+
# @author Michael Fellinger
|
142
|
+
# @since 04-01-2009
|
143
|
+
# @param [String] klass_name The name of the class for which to generate
|
144
|
+
# the mapping, defaults to the current class.
|
145
|
+
# @return [String]
|
146
|
+
#
|
71
147
|
def self.generate_mapping(klass_name = self.name)
|
72
148
|
chunks = klass_name.to_s.split(/::/)
|
73
149
|
return if chunks.empty?
|
@@ -79,6 +155,15 @@ module Ramaze
|
|
79
155
|
'/' << chunks.map{|chunk| chunk.snake_case }.join('/')
|
80
156
|
end
|
81
157
|
|
158
|
+
##
|
159
|
+
# Maps the current class to the specified location.
|
160
|
+
#
|
161
|
+
# @author Michael Fellinger
|
162
|
+
# @since 04-01-2009
|
163
|
+
# @param [String] location The URI to map the controller to.
|
164
|
+
# @param [String] app_name The name of the application the controller
|
165
|
+
# belongs to.
|
166
|
+
#
|
82
167
|
def self.map(location, app_name = nil)
|
83
168
|
if app_name
|
84
169
|
trait :app => app_name
|
@@ -91,13 +176,27 @@ module Ramaze
|
|
91
176
|
App.find_or_create(app_name).map(location, self)
|
92
177
|
end
|
93
178
|
|
179
|
+
##
|
180
|
+
# Returns the application to which the controller belongs to.
|
181
|
+
#
|
182
|
+
# @author Michael Fellinger
|
183
|
+
# @since 04-01-2009
|
184
|
+
# @return [Ramaze::App]
|
185
|
+
#
|
94
186
|
def self.app
|
95
187
|
App[ancestral_trait[:app]]
|
96
188
|
end
|
97
189
|
|
190
|
+
##
|
191
|
+
# Returns all the options for the application the controller belongs to.
|
192
|
+
#
|
193
|
+
# @author Michael Fellinger
|
194
|
+
# @since 04-01-2009
|
195
|
+
# @return [Innate::Options]
|
196
|
+
#
|
98
197
|
def self.options
|
99
198
|
return unless app = self.app
|
100
199
|
app.options
|
101
200
|
end
|
102
|
-
end
|
103
|
-
end
|
201
|
+
end # Controller
|
202
|
+
end # Ramaze
|
@@ -1,12 +1,25 @@
|
|
1
1
|
module Ramaze
|
2
2
|
Log.debug "Default controller invoked"
|
3
3
|
|
4
|
+
##
|
5
|
+
# The default controller that is loaded if no other controllers have been
|
6
|
+
# defined.
|
7
|
+
#
|
8
|
+
# @author Michael Fellinger
|
9
|
+
# @since 30-03-2009
|
10
|
+
#
|
4
11
|
class DefaultController < Ramaze::Controller
|
5
12
|
map '/'
|
6
13
|
|
14
|
+
##
|
15
|
+
# Shows an ASCII lobster using Rack::Lobster::LobsterString.
|
16
|
+
#
|
17
|
+
# @author Michael Fellinger
|
18
|
+
# @since 06-04-2009
|
19
|
+
#
|
7
20
|
def lobster
|
8
21
|
require 'rack/lobster'
|
9
22
|
respond Rack::Lobster::LobsterString
|
10
23
|
end
|
11
|
-
end
|
12
|
-
end
|
24
|
+
end # DefaultController
|
25
|
+
end # Ramaze
|
data/lib/ramaze/current.rb
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
module Ramaze
|
2
|
+
##
|
3
|
+
# Class that's used to point to the current action. This can be useful if you
|
4
|
+
# want to access data such as the session() method without having to include
|
5
|
+
# Innate::Trinity (which can pollute your namespace and/or cause collisions).
|
6
|
+
#
|
7
|
+
# @author Michael Fellinger
|
8
|
+
# @since 25-03-2009
|
9
|
+
#
|
2
10
|
class Current < Innate::Current
|
11
|
+
##
|
12
|
+
# @author Michael Fellinger
|
13
|
+
# @since 25-03-2009
|
14
|
+
# @see Innate::Current#setup
|
3
15
|
def setup(env, request = Request, response = Response, session = Session)
|
4
16
|
super
|
5
17
|
end
|
6
|
-
end
|
7
|
-
end
|
18
|
+
end # Current
|
19
|
+
end # Ramaze
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Ramaze
|
2
|
+
# Array containing the names and versions of all the gems required by Ramaze
|
3
|
+
# along with the name of how the gem should be required.
|
4
|
+
DEPENDENCIES = [
|
5
|
+
{:name => 'innate', :version => ['>= 2010.03']}
|
6
|
+
]
|
7
|
+
|
8
|
+
# Array containing all the development dependencies.
|
9
|
+
DEVELOPMENT_DEPENDENCIES = [
|
10
|
+
{:name => 'bacon' , :version => ['>= 1.1.0']},
|
11
|
+
{:name => 'dalli' , :version => ['>= 1.0.5']},
|
12
|
+
{:name => 'erector' , :version => ['>= 0.8.2']},
|
13
|
+
{:name => 'erubis' , :version => ['>= 2.7.0']},
|
14
|
+
{:name => 'ezamar' , :version => ['>= 2009.06']},
|
15
|
+
{:name => 'sass' , :version => ['>= 3.1.4']},
|
16
|
+
{:name => 'haml' , :version => ['>= 3.1.2']},
|
17
|
+
{:name => 'hpricot' , :version => ['>= 0.8.4']},
|
18
|
+
{:name => 'liquid' , :version => ['>= 2.2.2']},
|
19
|
+
{:name => 'locale' , :version => ['>= 2.0.5']},
|
20
|
+
{:name => 'lokar' , :version => ['>= 0.2.1']},
|
21
|
+
{:name => 'maruku' , :version => ['>= 0.6.0']},
|
22
|
+
{:name => 'mustache' , :version => ['>= 0.99.4']},
|
23
|
+
{:name => 'nagoro' , :version => ['>= 2009.05']},
|
24
|
+
{:name => 'rack-contrib', :version => ['>= 1.1.0'], :lib => 'rack/contrib'},
|
25
|
+
{:name => 'rack-test' , :version => ['>= 0.6.0'], :lib => 'rack/test'},
|
26
|
+
{:name => 'Remarkably' , :version => ['>= 0.6.1'], :lib => 'remarkably'},
|
27
|
+
{:name => 'sequel' , :version => ['>= 3.25.0']},
|
28
|
+
{:name => 'slippers' , :version => ['>= 0.0.14']},
|
29
|
+
{:name => 'sqlite3' , :version => ['>= 1.3.3']},
|
30
|
+
{:name => 'tagz' , :version => ['>= 9.0.0']},
|
31
|
+
{:name => 'tenjin' , :version => ['>= 0.6.1']},
|
32
|
+
{:name => 'yard' , :version => ['>= 0.7.2']},
|
33
|
+
]
|
34
|
+
|
35
|
+
if !RUBY_PLATFORM.include?('darwin')
|
36
|
+
DEVELOPMENT_DEPENDENCIES.push(
|
37
|
+
{:name => 'localmemcache', :version => ['>= 0.4.4']}
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
if RUBY_PLATFORM.include?('darwin')
|
42
|
+
DEVELOPMENT_DEPENDENCIES.push(
|
43
|
+
{:name => 'ruby-growl', :version => ['>= 3.0']}
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end # Ramaze
|
data/lib/ramaze/files.rb
CHANGED
@@ -1,24 +1,59 @@
|
|
1
1
|
module Ramaze
|
2
|
-
|
2
|
+
##
|
3
|
+
# Class that makes it possible to easily use multiple public directories in
|
4
|
+
# your Ramaze application.
|
5
|
+
#
|
6
|
+
# @author Michael Fellinger
|
7
|
+
# @since 14-03-2009
|
8
|
+
#
|
3
9
|
class Files
|
10
|
+
##
|
11
|
+
# Creates a new instance of the class, stores the given root directories and
|
12
|
+
# syncs the changes with Rack::Cascade.
|
13
|
+
#
|
14
|
+
# @author Michael Fellinger
|
15
|
+
# @since 14-03-2009
|
16
|
+
# @param [Array] *roots A set of root directories that contain a number of
|
17
|
+
# public directories.
|
18
|
+
#
|
4
19
|
def initialize(*roots)
|
5
20
|
@roots = roots.flatten.map{|root| File.expand_path(root.to_s) }
|
6
21
|
sync
|
7
22
|
end
|
8
23
|
|
24
|
+
##
|
25
|
+
# Allows this class to be called as a Rack middleware.
|
26
|
+
#
|
27
|
+
# @author Michael Fellinger
|
28
|
+
# @since 14-03-2009
|
29
|
+
# @param [Hash] env Hash containing all the environment details.
|
30
|
+
#
|
9
31
|
def call(env)
|
10
32
|
@cascade.call(env)
|
11
33
|
end
|
12
34
|
|
35
|
+
##
|
36
|
+
# Adds a new path to the list of root directories.
|
37
|
+
#
|
38
|
+
# @author Michael Fellinger
|
39
|
+
# @since 14-03-2009
|
40
|
+
# @param [String] path The path to add to the existing root directories.
|
41
|
+
#
|
13
42
|
def <<(path)
|
14
43
|
@roots << File.expand_path(path.to_s)
|
15
44
|
@roots.uniq!
|
16
45
|
sync
|
17
46
|
end
|
18
47
|
|
48
|
+
##
|
49
|
+
# Syncs the class with Rack::Cascade.
|
50
|
+
#
|
51
|
+
# @author Michael Fellinger
|
52
|
+
# @since 14-03-2009
|
53
|
+
#
|
19
54
|
def sync
|
20
55
|
file_apps = @roots.map{|root| Rack::File.new(root) }
|
21
56
|
@cascade = Rack::Cascade.new(file_apps)
|
22
57
|
end
|
23
|
-
end
|
24
|
-
end
|
58
|
+
end # Files
|
59
|
+
end # Ramaze
|
data/lib/ramaze/gestalt.rb
CHANGED
@@ -2,13 +2,11 @@
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
4
|
module Ramaze
|
5
|
-
|
6
5
|
##
|
7
6
|
# Gestalt is the custom HTML/XML builder for Ramaze, based on a very simple
|
8
7
|
# DSL it will build your markup.
|
9
8
|
#
|
10
9
|
# @example
|
11
|
-
#
|
12
10
|
# html =
|
13
11
|
# Gestalt.build do
|
14
12
|
# html do
|
@@ -28,7 +26,7 @@ module Ramaze
|
|
28
26
|
# The default way to start building your markup.
|
29
27
|
# Takes a block and returns the markup.
|
30
28
|
#
|
31
|
-
# @param [Block] block
|
29
|
+
# @param [Block] block
|
32
30
|
#
|
33
31
|
def self.build(&block)
|
34
32
|
self.new(&block).to_s
|
@@ -62,17 +60,19 @@ module Ramaze
|
|
62
60
|
##
|
63
61
|
# Workaround for Kernel#p to make <p /> tags possible.
|
64
62
|
#
|
65
|
-
# @param [Hash] args Extra arguments that should be processed before
|
63
|
+
# @param [Hash] args Extra arguments that should be processed before
|
64
|
+
# creating the paragraph tag.
|
66
65
|
# @param [Block] block
|
67
66
|
#
|
68
67
|
def p(*args, &block)
|
69
68
|
_gestalt_call_tag :p, args, &block
|
70
69
|
end
|
71
|
-
|
70
|
+
|
72
71
|
##
|
73
72
|
# Workaround for Kernel#select to make <select></select> work.
|
74
73
|
#
|
75
|
-
# @param [Hash] args Extra arguments that should be processed before
|
74
|
+
# @param [Hash] args Extra arguments that should be processed before
|
75
|
+
# creating the select tag.
|
76
76
|
# @param [Block] block
|
77
77
|
#
|
78
78
|
def select(*args, &block)
|
@@ -80,7 +80,7 @@ module Ramaze
|
|
80
80
|
end
|
81
81
|
|
82
82
|
##
|
83
|
-
#
|
83
|
+
# Calls a particular tag based on the specified parameters.
|
84
84
|
#
|
85
85
|
# @param [String] name
|
86
86
|
# @param [Hash] args
|
@@ -103,8 +103,6 @@ module Ramaze
|
|
103
103
|
# Build a tag for `name`, using `args` and an optional block that
|
104
104
|
# will be yielded.
|
105
105
|
#
|
106
|
-
# TODO: Describe this method since I'm not exactly sure what it does - Yorick
|
107
|
-
#
|
108
106
|
# @param [String] name
|
109
107
|
# @param [Hash] attr
|
110
108
|
# @param [Hash] text
|
@@ -139,7 +137,7 @@ module Ramaze
|
|
139
137
|
end
|
140
138
|
|
141
139
|
##
|
142
|
-
#
|
140
|
+
# Shortcut for building tags,
|
143
141
|
#
|
144
142
|
# @param [String] name
|
145
143
|
# @param [Hash] args
|
@@ -153,9 +151,11 @@ module Ramaze
|
|
153
151
|
# Convert the final output of Gestalt to a string.
|
154
152
|
# This method has the following alias: "to_str".
|
155
153
|
#
|
154
|
+
# @return [String]
|
155
|
+
#
|
156
156
|
def to_s
|
157
157
|
@out.join
|
158
158
|
end
|
159
159
|
alias to_str to_s
|
160
|
-
end
|
161
|
-
end
|
160
|
+
end # Gestalt
|
161
|
+
end # Ramaze
|
data/lib/ramaze/helper.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
3
|
require 'innate/helper'
|
5
4
|
|
6
|
-
# TODO: Describe what this module does besides loading a few default helper.
|
7
5
|
module Ramaze
|
8
6
|
Helper = Innate::Helper
|
9
7
|
Innate::HelpersHelper.options.paths << File.dirname(__FILE__)
|
data/lib/ramaze/helper/auth.rb
CHANGED
@@ -3,39 +3,42 @@
|
|
3
3
|
|
4
4
|
module Ramaze
|
5
5
|
module Helper
|
6
|
-
|
7
|
-
# A simple way to do authentication without a model.
|
8
|
-
# Please have a look at the docs of Auth#auth_login.
|
9
|
-
#
|
10
|
-
# If you want to do authentication with a model see Helper::User instead.
|
11
|
-
|
12
6
|
##
|
13
7
|
# The Auth helper can be used for authentication without using a model.
|
14
|
-
# This can be useful when working with very basic applications that don't
|
8
|
+
# This can be useful when working with very basic applications that don't
|
9
|
+
# require database access.
|
15
10
|
#
|
16
|
-
# If you're looking for a way to do authentication using a model you should
|
11
|
+
# If you're looking for a way to do authentication using a model you should
|
12
|
+
# take a look at Helper::User instead.
|
17
13
|
#
|
18
14
|
module Auth
|
19
15
|
Helper::LOOKUP << self
|
20
16
|
include Ramaze::Traited
|
21
17
|
|
22
|
-
trait :auth_table
|
23
|
-
trait :auth_hashify
|
18
|
+
trait :auth_table => {}
|
19
|
+
trait :auth_hashify => lambda { |pass| Digest::SHA1.hexdigest(pass) }
|
24
20
|
trait :auth_post_only => false
|
25
21
|
|
26
22
|
def self.included(into)
|
27
23
|
into.helper(:stack)
|
28
24
|
end
|
29
|
-
|
25
|
+
|
30
26
|
##
|
31
|
-
# Log a user in based on the :username and :password key in the request
|
27
|
+
# Log a user in based on the :username and :password key in the request
|
28
|
+
# hash.
|
32
29
|
#
|
33
|
-
# @return [String] The login template in case the user's login data was
|
30
|
+
# @return [String] The login template in case the user's login data was
|
31
|
+
# incorrect.
|
34
32
|
#
|
35
33
|
def login
|
36
|
-
|
34
|
+
if trait[:auth_post_only] and !request.post?
|
35
|
+
return auth_template
|
36
|
+
end
|
37
|
+
|
37
38
|
@username, password = request[:username, :password]
|
39
|
+
|
38
40
|
answer(request.referer) if auth_login(@username, password)
|
41
|
+
|
39
42
|
return auth_template
|
40
43
|
end
|
41
44
|
|
@@ -44,20 +47,22 @@ module Ramaze
|
|
44
47
|
#
|
45
48
|
def logout
|
46
49
|
auth_logout
|
47
|
-
|
50
|
+
redirect_referrer
|
48
51
|
end
|
49
52
|
|
50
53
|
private
|
51
54
|
|
52
55
|
##
|
53
|
-
# Validate the user's session and redirect him/her to the login page in
|
56
|
+
# Validate the user's session and redirect him/her to the login page in
|
57
|
+
# case the user isn't logged in.
|
54
58
|
#
|
55
59
|
def login_required
|
56
60
|
call(r(:login)) unless logged_in?
|
57
61
|
end
|
58
62
|
|
59
63
|
##
|
60
|
-
# Validate the user's session and return a boolean that indicates if the
|
64
|
+
# Validate the user's session and return a boolean that indicates if the
|
65
|
+
# user is logged in or not.
|
61
66
|
#
|
62
67
|
# @return [true false] Whether user is logged in right now
|
63
68
|
#
|
@@ -67,7 +72,8 @@ module Ramaze
|
|
67
72
|
|
68
73
|
##
|
69
74
|
# Try to log the user in based on the username and password.
|
70
|
-
# This method is called by the login() method and shouldn't be called
|
75
|
+
# This method is called by the login() method and shouldn't be called
|
76
|
+
# directly.
|
71
77
|
#
|
72
78
|
# @param [String] user The users's username.
|
73
79
|
# @param [String] pass The user's password.
|
@@ -75,7 +81,8 @@ module Ramaze
|
|
75
81
|
def auth_login(user, pass)
|
76
82
|
return unless user and pass
|
77
83
|
return if user.empty? or pass.empty?
|
78
|
-
|
84
|
+
|
85
|
+
return unless table = ancestral_trait[:auth_table]
|
79
86
|
return unless hashify = ancestral_trait[:auth_hashify]
|
80
87
|
|
81
88
|
if table.respond_to?(:to_sym) or table.respond_to?(:to_str)
|
@@ -87,7 +94,7 @@ module Ramaze
|
|
87
94
|
return unless table[user] == hashify.call(pass)
|
88
95
|
|
89
96
|
session[:logged_in] = true
|
90
|
-
session[:username]
|
97
|
+
session[:username] = user
|
91
98
|
end
|
92
99
|
|
93
100
|
##
|
@@ -113,6 +120,6 @@ module Ramaze
|
|
113
120
|
</form>
|
114
121
|
TEMPLATE
|
115
122
|
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
123
|
+
end # Auth
|
124
|
+
end # Helper
|
125
|
+
end # Ramaze
|