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/doc/meta/configuration.txt
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
This chapter covers how to do configuration in Ramaze for your application.
|
2
|
-
|
3
|
-
|
4
|
-
### Global
|
5
|
-
|
6
|
-
The object holding most configuration is called Global. It resides in the Ramaze
|
7
|
-
module/name space.
|
8
|
-
|
9
|
-
Global is an instance of GlobalStruct, which itself is an instance of Struct.
|
10
|
-
There have been some changes to it to suit its purpose.
|
11
|
-
|
12
|
-
Before covering some of the available options let us see how to actually use it.
|
13
|
-
|
14
|
-
For the examples shown here we will assume that you did include Ramaze
|
15
|
-
into your main into your main name space. If you don't do that, just prefix
|
16
|
-
Global with Ramaze so it is written Ramaze::Global.
|
17
|
-
|
18
|
-
|
19
|
-
#### Basic assignment:
|
20
|
-
|
21
|
-
Global.port = 10
|
22
|
-
|
23
|
-
if you do that before calling Ramaze::start Ramaze will choose the given number
|
24
|
-
as port.
|
25
|
-
|
26
|
-
|
27
|
-
#### Multiple assignment:
|
28
|
-
|
29
|
-
Global.setup :adapter => :mongrel,
|
30
|
-
:cache => :memcached
|
31
|
-
|
32
|
-
So you can pass a Hash of all the options you want to change.
|
33
|
-
In this case you would use Mongrel as the adapter and use memcached for your
|
34
|
-
sessions and general caching.
|
35
|
-
|
36
|
-
|
37
|
-
#### Block assignment:
|
38
|
-
|
39
|
-
Global.setup do |g|
|
40
|
-
g.error_page = false
|
41
|
-
g.host = '127.0.0.1'
|
42
|
-
g.port = 7070
|
43
|
-
end
|
44
|
-
|
45
|
-
This method is similar to the hash-assignment, but may be preferred for some
|
46
|
-
applications.
|
47
|
-
|
48
|
-
|
49
|
-
#### Pass on Ramaze.start
|
50
|
-
|
51
|
-
Ramaze.start :run_loose => true
|
52
|
-
|
53
|
-
This way you can save a line or two in a small script.
|
54
|
-
Please note that the values passed here have precedence over the ones directly
|
55
|
-
set on Global and will overwrite them if you set them before, that is mostly
|
56
|
-
useful to quickly test some configuration.
|
57
|
-
|
58
|
-
|
59
|
-
### Global options
|
60
|
-
|
61
|
-
This listing is here to provide you with descriptions of the most common
|
62
|
-
configurations in alphabetical order per section showing the default value next
|
63
|
-
to the key.
|
64
|
-
|
65
|
-
This chapter has been shrunk a lot to cover only essentials, please look at
|
66
|
-
lib/ramaze/global.rb to see all available options.
|
67
|
-
|
68
|
-
Date of last update: 2007-05-20
|
69
|
-
|
70
|
-
#### General Configuration:
|
71
|
-
|
72
|
-
:sourcereload => 3
|
73
|
-
|
74
|
-
SourceReload is a nifty mechanism that takes advantage of the dynamics of Ruby,
|
75
|
-
it's basically a Thread that runs in the background and polls for files in the
|
76
|
-
application and framework that have changed (using mtime). The value specifies
|
77
|
-
roughly how fast your changes are going to be loaded and should be a number.
|
78
|
-
If you set this to false, it will not start.
|
79
|
-
|
80
|
-
|
81
|
-
:adapter => :webrick
|
82
|
-
|
83
|
-
The adapter is the server Ramaze runs to serve your application. This can be any
|
84
|
-
of mongrel/webrick/fcgi/cgi, please note that so far neither fcgi nor cgi have
|
85
|
-
received the necessary testing, but, as they are only wrappers around the
|
86
|
-
underlying Rack library, should work fine. Both fcgi and mongrel require
|
87
|
-
additional libraries to be installed, webrick and cgi run out of the box.
|
88
|
-
Generally the most supported and recommended for deployment is Mongrel.
|
89
|
-
|
90
|
-
|
91
|
-
:cache => :memory
|
92
|
-
|
93
|
-
Possible: :memory, :memcached, :yaml
|
94
|
-
The cache is one of the more important things for deployment, the default for
|
95
|
-
this is MemoryCache, a simple Hash.
|
96
|
-
What you specify here will be used by Ramaze::Cache and is used throughout
|
97
|
-
Ramaze to cache various things, like sessions, page- and value-caching.
|
98
|
-
Included in Ramaze are the MemoryCache and YAMLStoreCache, after you install
|
99
|
-
'memcached' you can also use the much more performant MemcachedCache that also
|
100
|
-
makes it easy to use the same cache between different applications (sharing
|
101
|
-
sessions is one of the most obvious uses).
|
102
|
-
|
103
|
-
|
104
|
-
:cache_all => false
|
105
|
-
|
106
|
-
Setting this value to true would enable caching for all pages served from the
|
107
|
-
Controller (all actions).
|
108
|
-
This is a very powerful setting and you might want to enable it if all pages
|
109
|
-
you serve are only built once and have no further dynamics, the key for this
|
110
|
-
cache consists of the controller and parameters, when repeated requests are
|
111
|
-
made it will always serve the same (now static) page.
|
112
|
-
|
113
|
-
|
114
|
-
:sessions => true
|
115
|
-
|
116
|
-
Enables creation of sessions and automatic creation/setting of cookies.
|
117
|
-
Please note that many functionalities of Ramaze depend on an intact session and
|
118
|
-
you will have to be careful not to use these.
|
119
|
-
This is most likely useful in combination with `cache_all`
|
120
|
-
|
121
|
-
|
122
|
-
:error_page => true
|
123
|
-
|
124
|
-
Enables the default Error page of Ramaze which is mostly useful for manual
|
125
|
-
testing and faster debugging. In most deployment-scenarios you will however
|
126
|
-
want to use your own Error page and so you can safely disable this setting.
|
127
|
-
|
128
|
-
:host => '0.0.0.0'
|
129
|
-
|
130
|
-
Tell the adapter where it accepts requests from, 0.0.0.0 says that every
|
131
|
-
IP will be accepted, 127.0.0.1 would accept only requests from loopback.
|
132
|
-
|
133
|
-
|
134
|
-
:mapping => {}
|
135
|
-
|
136
|
-
This is a very central and special setting, it contains key/value pairs
|
137
|
-
that define routes to your controllers, the keys are simple strings and
|
138
|
-
start with '/', which means http://yourhost.com/ - '/foo/bar' would point
|
139
|
-
to http://yourhost.com/foo/bar.
|
140
|
-
The value is the class of your controller.
|
141
|
-
|
142
|
-
|
143
|
-
:port => 7000
|
144
|
-
|
145
|
-
The port Ramaze runs on, if you can think of more information about this feel
|
146
|
-
free to tell us.
|
147
|
-
|
148
|
-
|
149
|
-
:run_loose => false
|
150
|
-
|
151
|
-
This option is mostly used to run the specs, it means that Ramaze will not
|
152
|
-
join the adapter-threads and therefor you are free to run any code you want
|
153
|
-
afterwards. You won't have to use this in most cases, example usage is in
|
154
|
-
spec/spec_helper.
|
155
|
-
|
156
|
-
|
157
|
-
:template_root => 'template'
|
158
|
-
|
159
|
-
The template_root is the point your templates are located relative to the
|
160
|
-
location of the entry-file (usually start.rb)
|
161
|
-
It is also worth to mention that inside this directory the `mapping` is used
|
162
|
-
to locate templates for each controller, only the controller mapped to '/' uses
|
163
|
-
the templates directly from the `template_root`
|
data/doc/meta/internals.txt
DELETED
@@ -1,278 +0,0 @@
|
|
1
|
-
This document is a humble attempt to explain the internal workings of Ramaze and
|
2
|
-
how the different parts fit into the big picture.
|
3
|
-
|
4
|
-
It does not try to describe every little detail, as you will be better off
|
5
|
-
reading the actual source instead. But you will at least get an idea of where to
|
6
|
-
look.
|
7
|
-
|
8
|
-
### Ramaze
|
9
|
-
|
10
|
-
Ramaze is a web framework and therefor tries to make it simple to deploy your
|
11
|
-
own applications on top of it.
|
12
|
-
Let's outline the realms that Ramaze works in as to show what the current
|
13
|
-
limitations and features are.
|
14
|
-
|
15
|
-
|
16
|
-
#### Life of a request/response cycle
|
17
|
-
|
18
|
-
This is a small summary of how a request creates a response in the
|
19
|
-
examples/hello.rb and webrick (to keep it simple and short).
|
20
|
-
All files referenced here are in lib/ramaze/ unless indicated otherwise.
|
21
|
-
We don't explain the startup/shutdown process, only what happens from request to
|
22
|
-
the eventual response.
|
23
|
-
|
24
|
-
Browser sends request, webrick receives it and hands the ENV over to our rack
|
25
|
-
handler (adapter/webrick.rb and adapter/base.rb).
|
26
|
-
There it gets converted into a Ramaze::Request (trinity/request.rb) and
|
27
|
-
a new blank Ramaze::Response (trinity/response.rb) is created.
|
28
|
-
These two objects are then sent to Dispatcher::handle (dispatcher.rb).
|
29
|
-
|
30
|
-
This all happens inside a new Thread, which is what Ramaze takes advantage of by
|
31
|
-
assigning Thread-variables. You can see this now in
|
32
|
-
Dispatcher::setup_environment which sets :request/:session/:response in
|
33
|
-
Thread.current.
|
34
|
-
|
35
|
-
After that, Dispatcher::dispatch is called with the path from request.path_info
|
36
|
-
which in turn takes every class/module set in Dispatcher::FILTER and calls
|
37
|
-
::process with the path.
|
38
|
-
|
39
|
-
|
40
|
-
##### First, `/favicon.ico` (for most browsers)
|
41
|
-
|
42
|
-
The first in FILTER is Dispatcher::File (dispatcher/file.rb) which searches
|
43
|
-
Global.public_root and afterwards Global.public_proto for a matching file on
|
44
|
-
this path. In our example the file found is a favicon.ico from
|
45
|
-
Global.public_proto.
|
46
|
-
|
47
|
-
The contents of FILTER have to return a Ramaze::Response, either the (possibly
|
48
|
-
modified) original (Response#build helps with that) or a totally new
|
49
|
-
one.
|
50
|
-
|
51
|
-
In our case, Dispatcher::File uses response#build with an opened filehandler as
|
52
|
-
body, '200 OK' as status and the Content-Type set to what Tool::MIME.type_for
|
53
|
-
tells it is the correct mimetype for this file.
|
54
|
-
|
55
|
-
|
56
|
-
##### Second, `/hello`
|
57
|
-
|
58
|
-
We start in the processing of FILTER, since the previous steps are the same for
|
59
|
-
every request.
|
60
|
-
|
61
|
-
Here we now get only a nil value back from Dispatcher::File since no file in our
|
62
|
-
two public directories exists for the given path.
|
63
|
-
|
64
|
-
So, this time, Dispatcher::Action is called via ::process and the first thing
|
65
|
-
this dispatcher does is trying to set the body of the request to the answer of
|
66
|
-
Controller.handle (controller.rb) for the given path.
|
67
|
-
|
68
|
-
Controller::handle doesn't do much either, but calls Controller::resolve
|
69
|
-
(controller/resolve.rb) for the path.
|
70
|
-
|
71
|
-
Here we get now into the guts of Ramaze, despite our efforts it's no easy
|
72
|
-
reading since the underlying theory is a bit complex and many edge-cases have to
|
73
|
-
be solved.
|
74
|
-
|
75
|
-
Let me try to quickly sketch what happens here, maybe we can add a chapter about
|
76
|
-
this aspect of Ramaze later.
|
77
|
-
|
78
|
-
First we generate a pattern of how the requested path could fit into our
|
79
|
-
controller and template structure. `/hello` only has 3 possible outcomes:
|
80
|
-
|
81
|
-
Controller on '/', template or method `hello`
|
82
|
-
Controller on '/', method `index` with parameter `hello`
|
83
|
-
Controller on '/hello', method or template `index`
|
84
|
-
|
85
|
-
After matching (in the order we wrote here) these possibilities against your
|
86
|
-
application we get only one possibility, MainController on '/' with method
|
87
|
-
`index`.
|
88
|
-
|
89
|
-
The result is stored into an instance of Action and cached for repeated lookups,
|
90
|
-
then passed back into Dispatcher::handle which subsequently calls Action#render
|
91
|
-
(action/render.rb) on it.
|
92
|
-
|
93
|
-
From here, Thread.current[:action] gets set and #uncached_render is called. This
|
94
|
-
calls #before_process which only has effects if you have the AspectHelper
|
95
|
-
activated and next on comes engine.transform with self as parameter.
|
96
|
-
#engine is a method that figures out which engine this Action has to be rendered
|
97
|
-
with, according to things like trait[:engine] in your controller and the
|
98
|
-
extension of a template. In this case we have neither and the default engine
|
99
|
-
Template::Ezamar (template/ezamar.rb) is used.
|
100
|
-
|
101
|
-
So off we go, to Template::Ezamar::transform with the current instance of Action
|
102
|
-
as parameter.
|
103
|
-
|
104
|
-
::transform first calls ::wrap_compile which is inherited from Template
|
105
|
-
(template.rb) and manages caching of compiled templates, calling ::compile with
|
106
|
-
the action and template.
|
107
|
-
|
108
|
-
The template again is retrieved through two attempts, firstly, we always call
|
109
|
-
the method (if specified from Controller::resolve) on the controller, we
|
110
|
-
temporarily store its result and replace it if a path for a template is set with
|
111
|
-
the contents of the file on this path. The result of this is the final template
|
112
|
-
that is ready for compilation.
|
113
|
-
|
114
|
-
In the case of Ezamar, we first walk the TRANSFORM_PIPELINE (only
|
115
|
-
Ezamar::Element (template/ezamar/element.rb) with ::transform and pass each the
|
116
|
-
template for manipulation. In the example we don't have any elements, so we get
|
117
|
-
back what we gave and generate a new instance of Ezamar::Template
|
118
|
-
(template/ezamar/engine.rb) with the template and a path that indicates eval
|
119
|
-
where we currently are supposed to be (templates path or the transformer).
|
120
|
-
|
121
|
-
This instance is passed back to Ezamar::transform and we call #result with the
|
122
|
-
actions binding (retrieved from earlier instantiation of the controller and
|
123
|
-
subsequently eval `binding` inside of it).
|
124
|
-
|
125
|
-
Now it's all done, we have got our body for the response which will be sent back
|
126
|
-
to our handler as body.
|
127
|
-
|
128
|
-
|
129
|
-
#### The Ramaze module
|
130
|
-
|
131
|
-
Ramaze is also the main module or so-called namespace that the framework lives
|
132
|
-
in. It has
|
133
|
-
|
134
|
-
Tasks on require
|
135
|
-
|
136
|
-
* Inform
|
137
|
-
* LogHub.new(Informer)
|
138
|
-
* Global
|
139
|
-
* GlobalStruct.new
|
140
|
-
|
141
|
-
|
142
|
-
Tasks on startup as defined in Ramaze.trait[:internals] in lib/ramaze.rb
|
143
|
-
|
144
|
-
* Global::startup
|
145
|
-
* passed options to Ramaze.start
|
146
|
-
* CLI options from bin/ramaze (treat as passed.merge)
|
147
|
-
* Global options set before startup (fake Global?)
|
148
|
-
|
149
|
-
* Cache::startup
|
150
|
-
* adds the following caches via Cache.add:
|
151
|
-
* compiled
|
152
|
-
If Global.compile is set true this cache is used to store the compiled
|
153
|
-
templates.
|
154
|
-
|
155
|
-
* actions
|
156
|
-
Caching compiled actions.
|
157
|
-
|
158
|
-
* patterns
|
159
|
-
This is used in Controller::resolve to cache the generated patterns for a
|
160
|
-
path.
|
161
|
-
|
162
|
-
* resolved
|
163
|
-
Caching the resolved but not yet compiled actions by their path.
|
164
|
-
|
165
|
-
* shield
|
166
|
-
Caching the generated errors for the path, so on repeated erronous
|
167
|
-
requests no new error-page has to be generated.
|
168
|
-
|
169
|
-
* Controller::startup
|
170
|
-
* mapping of all subclassed Controller
|
171
|
-
* validation of mapping
|
172
|
-
* validation of template_root
|
173
|
-
|
174
|
-
* Session::startup
|
175
|
-
* adds Cache.sessions if Global.sessions is true
|
176
|
-
This cache is used to store all sessions with their session-id as key.
|
177
|
-
|
178
|
-
* SourceReload::startup
|
179
|
-
* start with Global.reload_interval
|
180
|
-
* assign Global.sourcereload
|
181
|
-
|
182
|
-
* Adapter::startup
|
183
|
-
* interpret Global.adapter
|
184
|
-
* add every created adapter to Global.adapters
|
185
|
-
|
186
|
-
|
187
|
-
Tasks on shutdown
|
188
|
-
|
189
|
-
* Adapter::shutdown (iterates Global.adapters)
|
190
|
-
* Inform::shutdown (iterates all in LogHub)
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
#### Global configuration
|
195
|
-
|
196
|
-
Any serious application or framework needs to be configured.
|
197
|
-
Yes, I wished there was a silver bullet to serve all your needs as well, but at
|
198
|
-
the current stage of programming development there is no such thing.
|
199
|
-
So, since we need to configure, we should make it as simple and painless as
|
200
|
-
possible, and, thanks to Ruby, it is actually quite enjoyable to do that.
|
201
|
-
You can find a very detailed description about Global in the section about
|
202
|
-
Configuration, for now just the basics.
|
203
|
-
|
204
|
-
The basis of Ramaze::Global, the instance that is holding most part of your
|
205
|
-
configuration or at least links to the actual places, is the
|
206
|
-
Ramaze::GlobalStruct (ramaze/global.rb), which is a subclass of OpenStruct. If
|
207
|
-
you are not yet familiar with OpenStruct, I very much recommend to read its
|
208
|
-
documentation and play around a bit, it is basically just a wrapper around a
|
209
|
-
normal Hash where you can access the keys instead of ostruct[:foo] with
|
210
|
-
ostruct.foo.
|
211
|
-
It simply defines a new accessors on assignment by catching things in
|
212
|
-
method_missing. I won't go into more details here, I hope you got the principle.
|
213
|
-
|
214
|
-
Now, based on this technique, GlobalStruct adds things like defaults and a
|
215
|
-
couple of convenience methods like they are common in Ruby, giving you more
|
216
|
-
power by tapping to the internal Hash of the GlobalStruct and adding
|
217
|
-
update/setup methods so you can assign many key/value pairs at once.
|
218
|
-
The RDocs will give you a very good overview of what is available and how one is
|
219
|
-
supposed to work with it.
|
220
|
-
|
221
|
-
Now back to the big picture.
|
222
|
-
|
223
|
-
Ramaze accesses Global all over the place, there have been made several choices
|
224
|
-
as to why using something like Global is considered beneficial against choosing
|
225
|
-
for example global variables, which would be considered as a fatal choice by
|
226
|
-
any respected Rubyist anyway.
|
227
|
-
|
228
|
-
Now to something more subtle, which has to do with Global. I speak about traits,
|
229
|
-
which is a very different concept in most of its implementations, but it is
|
230
|
-
something that basically fits this name. It is configuration of single Objects
|
231
|
-
and whole ancestries.
|
232
|
-
You can give an object a trait, and most likely will use it along the lines of
|
233
|
-
something like MyController.trait(:map => '/'), which would be picked up on
|
234
|
-
startup and used to create Global.mapping - where we are at configuration again.
|
235
|
-
Choosing this style of configuration complementary to a central place to put all
|
236
|
-
your configuration was made very early in the development of Ramaze, and the
|
237
|
-
basic code of how traits are implemented and used has proven very efficient both
|
238
|
-
in understanding and using them.
|
239
|
-
|
240
|
-
There is a basic distinction when to use Global and when to use traits and when
|
241
|
-
to generate or assume one based on the other.
|
242
|
-
|
243
|
-
If something affects your whole application and is either used directly in the
|
244
|
-
Ramaze module or throughout the framework it is considered to be put into Global
|
245
|
-
to gain benefits of better documentation and accessibility.
|
246
|
-
|
247
|
-
On the other hand - if something is used in a configuring manner by a class that
|
248
|
-
is instantiated often (like Controller is for example), or a module that cannot
|
249
|
-
hold instance variables in a nice manner and is also not a constant - then it is
|
250
|
-
configured using traits.
|
251
|
-
|
252
|
-
|
253
|
-
Ramaze
|
254
|
-
Global
|
255
|
-
Adapter
|
256
|
-
Dispatcher
|
257
|
-
Controller
|
258
|
-
Action
|
259
|
-
|
260
|
-
Session
|
261
|
-
Helper
|
262
|
-
Tool
|
263
|
-
|
264
|
-
|
265
|
-
#### The Web
|
266
|
-
|
267
|
-
The so called web consists of a plethora of data, most of it is browsable
|
268
|
-
through a web browser that just about every toaster has installed these days.
|
269
|
-
The browser is the target of a web author, trying to utilize common standards
|
270
|
-
like HTML and CSS which are means for data and layout to be combined, giving the
|
271
|
-
browser a way to display the data.
|
272
|
-
Ramaze works on the URI-scale web, meaning that addresses like
|
273
|
-
http://someserver.com/blog/article/1 have a unique representation on your
|
274
|
-
server.
|
275
|
-
If we stay with this example, we see already everything Ramaze needs to see to
|
276
|
-
serve a page based on your instructions.
|
277
|
-
We assume that blog/article is a Controller named ArticleController in the blog
|
278
|
-
application.
|
data/doc/meta/users.kml
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<kml xmlns="http://earth.google.com/kml/2.2">
|
3
|
-
<Document>
|
4
|
-
<Placemark>
|
5
|
-
<name>manveru</name>
|
6
|
-
<description><![CDATA[ <img src="http://manveru.mine.nu/public/me.png" /><br />
|
7
|
-
Tokyo, Japan ]]>
|
8
|
-
</description>
|
9
|
-
<Point>
|
10
|
-
<coordinates>139.667846,35.614759</coordinates>
|
11
|
-
</Point>
|
12
|
-
</Placemark>
|
13
|
-
<Placemark>
|
14
|
-
<name>Pistos</name>
|
15
|
-
<description>
|
16
|
-
<![CDATA[
|
17
|
-
<img src="http://purepistos.net/favicon32.png" alt="Pistos" /><br />
|
18
|
-
Toronto, Canada<br />
|
19
|
-
<a href="http://blog.purepistos.net">blog.purepistos.net</a>
|
20
|
-
]]>
|
21
|
-
</description>
|
22
|
-
<Point>
|
23
|
-
<coordinates>-79.386985,43.642515,0</coordinates>
|
24
|
-
</Point>
|
25
|
-
</Placemark>
|
26
|
-
<Placemark>
|
27
|
-
<name>MonoDelDiablo</name>
|
28
|
-
<description><![CDATA[ Seattle, Washington, United States ]]></description>
|
29
|
-
<Point>
|
30
|
-
<coordinates>-122.266881,47.682765,0</coordinates>
|
31
|
-
</Point>
|
32
|
-
</Placemark>
|
33
|
-
<Placemark>
|
34
|
-
<name>Kashia</name>
|
35
|
-
<description><![CDATA[ Helsinki, Etela-Suomen Laani, Finland ]]></description>
|
36
|
-
<Point>
|
37
|
-
<coordinates>8.447204,49.028928,0</coordinates>
|
38
|
-
</Point>
|
39
|
-
</Placemark>
|
40
|
-
<Placemark>
|
41
|
-
<name>zenix</name>
|
42
|
-
<description><![CDATA[ Gaithersburg, Maryland, United States ]]></description>
|
43
|
-
<Point>
|
44
|
-
<coordinates>-77.183338,39.137049,0</coordinates>
|
45
|
-
</Point>
|
46
|
-
</Placemark>
|
47
|
-
<Placemark>
|
48
|
-
<name>tmm1</name>
|
49
|
-
<description><![CDATA[ <img src="http://tmm1.net/me.jpg" /><br />
|
50
|
-
Boston, Massachussetts ]]>
|
51
|
-
</description>
|
52
|
-
<Point>
|
53
|
-
<coordinates>-71.084371,42.365975,0</coordinates>
|
54
|
-
</Point>
|
55
|
-
</Placemark>
|
56
|
-
<Placemark>
|
57
|
-
<name>riffraff</name>
|
58
|
-
<description><![CDATA[ Rome, Italia ]]></description>
|
59
|
-
<Point>
|
60
|
-
<coordinates>41.993372,12.087193,0</coordinates>
|
61
|
-
</Point>
|
62
|
-
</Placemark>
|
63
|
-
</Document>
|
64
|
-
</kml>
|