ramaze 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +14 -259
- data/bin/ramaze +52 -25
- data/doc/AUTHORS +6 -0
- data/doc/CHANGELOG +1363 -42
- data/doc/INSTALL +1 -1
- data/doc/README +48 -35
- data/doc/README.html +637 -0
- data/doc/TODO +7 -16
- data/doc/allison/allison.css +6 -7
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/cache/STYLE +1 -2
- data/doc/changes.txt +3375 -0
- data/doc/changes.xml +3378 -0
- data/doc/meta/announcement.txt +47 -0
- data/doc/meta/configuration.txt +179 -0
- data/doc/meta/internals.txt +111 -0
- data/doc/readme_chunks/features.txt +8 -16
- data/doc/readme_chunks/installing.txt +7 -1
- data/doc/tutorial/todolist.txt +2 -3
- data/examples/blog/main.rb +9 -8
- data/examples/blog/public/styles/blog.css +132 -0
- data/examples/blog/src/controller.rb +14 -41
- data/examples/blog/src/model.rb +12 -13
- data/examples/blog/src/view.rb +16 -0
- data/examples/blog/template/edit.xhtml +19 -8
- data/examples/blog/template/index.xhtml +14 -22
- data/examples/blog/template/new.xhtml +18 -5
- data/examples/caching.rb +5 -8
- data/examples/element.rb +3 -3
- data/examples/hello.rb +3 -5
- data/examples/simple.rb +4 -7
- data/examples/templates/template/external.haml +8 -7
- data/examples/templates/template/external.mab +11 -8
- data/examples/templates/template_amrita2.rb +4 -4
- data/examples/templates/template_erubis.rb +3 -3
- data/examples/templates/template_ezamar.rb +1 -2
- data/examples/templates/template_haml.rb +24 -23
- data/examples/templates/template_liquid.rb +3 -1
- data/examples/templates/template_markaby.rb +15 -9
- data/examples/todolist/src/element/page.rb +1 -1
- data/lib/proto/conf/benchmark.yaml +6 -20
- data/lib/proto/conf/debug.yaml +6 -19
- data/lib/proto/conf/live.yaml +7 -19
- data/lib/proto/conf/silent.yaml +6 -16
- data/lib/proto/conf/stage.yaml +6 -18
- data/lib/proto/public/error.zmr +2 -2
- data/lib/ramaze.rb +34 -72
- data/lib/ramaze/adapter.rb +21 -18
- data/lib/ramaze/adapter/mongrel.rb +0 -3
- data/lib/ramaze/adapter/webrick.rb +6 -6
- data/lib/ramaze/cache/memcached.rb +3 -0
- data/lib/ramaze/controller.rb +227 -183
- data/lib/ramaze/dispatcher.rb +34 -129
- data/lib/ramaze/dispatcher/action.rb +28 -0
- data/lib/ramaze/dispatcher/error.rb +43 -0
- data/lib/ramaze/dispatcher/file.rb +34 -0
- data/lib/ramaze/global.rb +89 -48
- data/lib/ramaze/helper/aspect.rb +8 -6
- data/lib/ramaze/helper/auth.rb +3 -3
- data/lib/ramaze/helper/cache.rb +2 -2
- data/lib/ramaze/helper/file.rb +14 -0
- data/lib/ramaze/helper/inform.rb +36 -0
- data/lib/ramaze/helper/link.rb +7 -3
- data/lib/ramaze/helper/markaby.rb +30 -0
- data/lib/ramaze/helper/redirect.rb +2 -0
- data/lib/ramaze/inform.rb +8 -182
- data/lib/ramaze/inform/analogger.rb +19 -0
- data/lib/ramaze/inform/growl.rb +28 -0
- data/lib/ramaze/inform/hub.rb +26 -0
- data/lib/ramaze/inform/informer.rb +92 -0
- data/lib/ramaze/inform/informing.rb +44 -0
- data/lib/ramaze/inform/syslog.rb +27 -0
- data/lib/ramaze/inform/xosd.rb +42 -0
- data/lib/ramaze/snippets.rb +6 -2
- data/lib/ramaze/snippets/object/traits.rb +13 -1
- data/lib/ramaze/snippets/ramaze/autoreload.rb +58 -2
- data/lib/ramaze/snippets/string/color.rb +27 -0
- data/lib/ramaze/snippets/string/each.rb +6 -0
- data/lib/ramaze/snippets/struct/fill.rb +15 -0
- data/lib/ramaze/template/ezamar.rb +13 -22
- data/lib/ramaze/template/ezamar/element.rb +12 -12
- data/lib/ramaze/template/liquid.rb +19 -18
- data/lib/ramaze/template/markaby.rb +37 -58
- data/lib/ramaze/tool/localize.rb +128 -0
- data/lib/ramaze/tool/tidy.rb +51 -21
- data/lib/ramaze/trinity.rb +3 -3
- data/lib/ramaze/trinity/request.rb +41 -23
- data/lib/ramaze/trinity/response.rb +10 -5
- data/lib/ramaze/trinity/session.rb +17 -3
- data/lib/ramaze/version.rb +2 -2
- data/rake_tasks/conf.rake +56 -0
- data/rake_tasks/gem.rake +44 -0
- data/rake_tasks/maintaince.rake +187 -0
- data/spec/all.rb +32 -0
- data/spec/examples/caching.rb +19 -0
- data/spec/examples/element.rb +15 -0
- data/spec/examples/hello.rb +11 -0
- data/spec/examples/simple.rb +51 -0
- data/spec/examples/templates/template_amrita2.rb +14 -0
- data/spec/examples/templates/template_erubis.rb +21 -0
- data/spec/examples/templates/template_ezamar.rb +22 -0
- data/spec/examples/templates/template_haml.rb +23 -0
- data/spec/examples/templates/template_liquid.rb +24 -0
- data/spec/examples/templates/template_markaby.rb +21 -0
- data/spec/helper.rb +81 -0
- data/spec/{spec_helper_context.rb → helper/context.rb} +1 -1
- data/spec/helper/layout.rb +55 -0
- data/spec/helper/mock_http.rb +66 -0
- data/spec/{spec_helper_requester.rb → helper/requester.rb} +0 -6
- data/spec/{spec_helper_simple_http.rb → helper/simple_http.rb} +57 -57
- data/spec/helper/wrap.rb +193 -0
- data/spec/{adapter_spec.rb → ramaze/adapter.rb} +7 -5
- data/spec/{tc_adapter_mongrel.rb → ramaze/adapter/mongrel.rb} +2 -2
- data/spec/{tc_adapter_webrick.rb → ramaze/adapter/webrick.rb} +2 -2
- data/spec/{tc_cache.rb → ramaze/cache.rb} +16 -16
- data/spec/ramaze/conf/locale_de.yaml +6 -0
- data/spec/ramaze/conf/locale_en.yaml +6 -0
- data/spec/ramaze/controller.rb +184 -0
- data/spec/ramaze/controller/template/greet.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +54 -0
- data/spec/ramaze/dependencies.rb +16 -0
- data/spec/{tc_element.rb → ramaze/element.rb} +21 -19
- data/spec/ramaze/error.rb +64 -0
- data/spec/{tc_gestalt.rb → ramaze/gestalt.rb} +10 -10
- data/spec/{tc_global.rb → ramaze/global.rb} +7 -7
- data/spec/{tc_helper_aspect.rb → ramaze/helper/aspect.rb} +22 -14
- data/spec/{tc_helper_auth.rb → ramaze/helper/auth.rb} +9 -7
- data/spec/{tc_helper_cache.rb → ramaze/helper/cache.rb} +14 -24
- data/spec/{tc_helper_feed.rb → ramaze/helper/feed.rb} +12 -12
- data/spec/ramaze/helper/file.rb +17 -0
- data/spec/{tc_helper_flash.rb → ramaze/helper/flash.rb} +16 -17
- data/spec/{tc_helper_form.rb → ramaze/helper/form.rb} +25 -26
- data/spec/{tc_helper_link.rb → ramaze/helper/link.rb} +9 -9
- data/spec/{tc_helper_redirect.rb → ramaze/helper/redirect.rb} +11 -10
- data/spec/{tc_helper_stack.rb → ramaze/helper/stack.rb} +10 -11
- data/spec/ramaze/inform/informer.rb +40 -0
- data/spec/ramaze/inform/syslog.rb +10 -0
- data/spec/ramaze/localize.rb +40 -0
- data/spec/ramaze/morpher.rb +82 -0
- data/spec/ramaze/params.rb +124 -0
- data/spec/{public → ramaze/public}/error404.xhtml +0 -0
- data/spec/{public → ramaze/public}/favicon.ico +0 -0
- data/spec/{public → ramaze/public}/ramaze.png +0 -0
- data/spec/{public → ramaze/public}/test_download.css +0 -0
- data/spec/ramaze/request.rb +129 -0
- data/spec/{tc_request_mongrel.rb → ramaze/request/mongrel.rb} +2 -2
- data/spec/{tc_request_webrick.rb → ramaze/request/webrick.rb} +1 -1
- data/spec/{tc_session.rb → ramaze/session.rb} +18 -18
- data/spec/{tc_store.rb → ramaze/store/default.rb} +10 -10
- data/spec/{tc_store_yaml.rb → ramaze/store/yaml.rb} +9 -9
- data/spec/ramaze/template.rb +86 -0
- data/spec/{tc_template_amrita2.rb → ramaze/template/amrita2.rb} +5 -5
- data/spec/{template → ramaze/template}/amrita2/data.amrita +0 -0
- data/spec/{template → ramaze/template}/amrita2/index.amrita +0 -0
- data/spec/{template → ramaze/template}/amrita2/sum.amrita +0 -0
- data/spec/{tc_template_erubis.rb → ramaze/template/erubis.rb} +9 -9
- data/spec/{template → ramaze/template}/erubis/sum.rhtml +0 -0
- data/spec/ramaze/template/ezamar.rb +62 -0
- data/spec/{template → ramaze/template}/ezamar/another/long/action.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/combined.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/file_only.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/index.zmr +0 -0
- data/spec/ramaze/template/ezamar/nested.zmr +1 -0
- data/spec/{template → ramaze/template}/ezamar/some__long__action.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/sum.zmr +0 -0
- data/spec/{tc_template_haml.rb → ramaze/template/haml.rb} +7 -7
- data/spec/{template → ramaze/template}/haml/index.haml +0 -0
- data/spec/{template → ramaze/template}/haml/with_vars.haml +0 -0
- data/spec/{tc_template_liquid.rb → ramaze/template/liquid.rb} +7 -7
- data/spec/{template → ramaze/template}/liquid/index.liquid +0 -0
- data/spec/{template → ramaze/template}/liquid/products.liquid +0 -0
- data/spec/ramaze/template/markaby.rb +59 -0
- data/spec/{template → ramaze/template}/markaby/external.mab +0 -0
- data/spec/{template → ramaze/template}/markaby/sum.mab +0 -0
- data/spec/ramaze/template/ramaze/external.test +1 -0
- data/spec/{tc_tidy.rb → ramaze/tidy.rb} +3 -3
- metadata +145 -81
- data/examples/blog/public/screen.css +0 -106
- data/examples/blog/src/element.rb +0 -58
- data/examples/blog/template/view.xhtml +0 -15
- data/examples/blog/test/tc_entry.rb +0 -18
- data/lib/proto/public/404.jpg +0 -0
- data/spec/request_tc_helper.rb +0 -135
- data/spec/spec_all.rb +0 -118
- data/spec/spec_helper.rb +0 -66
- data/spec/tc_controller.rb +0 -49
- data/spec/tc_dependencies.rb +0 -13
- data/spec/tc_error.rb +0 -43
- data/spec/tc_morpher.rb +0 -88
- data/spec/tc_params.rb +0 -125
- data/spec/tc_template_ezamar.rb +0 -64
- data/spec/tc_template_markaby.rb +0 -72
- data/spec/template/ezamar/nested.zmr +0 -1
@@ -0,0 +1,47 @@
|
|
1
|
+
This is a one-time post to announce the creation of the Ramaze project, an open
|
2
|
+
source web framework with the aim to be light and modular.
|
3
|
+
Ramaze is already relatively stable and we decided that it is time to give it
|
4
|
+
broader exposure to find new users and contributors.
|
5
|
+
|
6
|
+
Home page: http://ramaze.rubyforge.org
|
7
|
+
IRC: #ramaze on irc.freenode.net
|
8
|
+
|
9
|
+
Features:
|
10
|
+
- Builds on top of the recently released Rack library, which provides easy use
|
11
|
+
of adapters like Mongrel, WEBrick, CGI or FCGI.
|
12
|
+
|
13
|
+
- Supports a wide range of templating-engines like:
|
14
|
+
Amrita2, Erubis, HAML, Liquid, Markaby and its own engine called Ezamar.
|
15
|
+
|
16
|
+
- Highly modular structure, you can just use the parts you like. This also
|
17
|
+
means that it's very simple to add your own customizations.
|
18
|
+
|
19
|
+
- A variety of helpers is already available, giving you things like advanced
|
20
|
+
caching, OpenID-authentication or aspect-oriented programming for your
|
21
|
+
controllers.
|
22
|
+
|
23
|
+
- It is possible to use the ORM you like, be it ActiveRecord, Og, Kansas or
|
24
|
+
something more simplistic like a wrapper around YAML::Store.
|
25
|
+
|
26
|
+
- Good documentation: although we don't have 100% documentation right now,
|
27
|
+
just about every part of Ramaze is covered with basic and advanced docs.
|
28
|
+
There are a variety of examples and a tutorial available.
|
29
|
+
|
30
|
+
- Friendly community: lastly, but still quite important, there are people from
|
31
|
+
all over the world using Ramaze, so you can get almost instant help and
|
32
|
+
info.
|
33
|
+
|
34
|
+
|
35
|
+
Features planned:
|
36
|
+
- Unified FormHelper for ORMs, making the framework mostly independent of the
|
37
|
+
underlying model.
|
38
|
+
|
39
|
+
- Improved configuration system, providing an way to totally change options
|
40
|
+
during runtime and link that with the CLI-parameter automatically.
|
41
|
+
|
42
|
+
|
43
|
+
For more information please come to http://ramaze.rubyforge.org or ask directly
|
44
|
+
on IRC (irc://irc.freenode.net/#ramaze)
|
45
|
+
|
46
|
+
Thank you,
|
47
|
+
Michael 'manveru' Fellinger and the Ramaze community
|
@@ -0,0 +1,179 @@
|
|
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 a subclass of OpenStruct and behaves mostly like it, so you can assign
|
10
|
+
your own key/value pairs to do your own configuration. Just ensure you don't
|
11
|
+
change key/value pairs by accident that Ramaze itself uses (doing it intentional
|
12
|
+
is OK of course).
|
13
|
+
|
14
|
+
Before covering some of the available options let us see how to actually use it.
|
15
|
+
|
16
|
+
For the examples shown here we will assume that you did include Ramaze
|
17
|
+
into your main into your main name space. If you don't do that, just prefix
|
18
|
+
Global with Ramaze so it is written Ramaze::Global.
|
19
|
+
|
20
|
+
|
21
|
+
#### Basic assignment:
|
22
|
+
|
23
|
+
Global.ports = (7000..7010)
|
24
|
+
|
25
|
+
if you do that before calling Ramaze::start Ramaze will spawn one server on each
|
26
|
+
port in that Range. The first value of this Range is also assigned to
|
27
|
+
Global.port during the startup procedure.
|
28
|
+
|
29
|
+
|
30
|
+
#### Multiple assignment:
|
31
|
+
|
32
|
+
Global.setup :adapter => :mongrel,
|
33
|
+
:cache => MemcachedCache
|
34
|
+
|
35
|
+
So you can pass a Hash of all the options you want to change.
|
36
|
+
In this case you would use Mongrel as the adapter and use memcached for your
|
37
|
+
sessions and general caching.
|
38
|
+
|
39
|
+
|
40
|
+
#### Block assignment:
|
41
|
+
|
42
|
+
Global.setup do |g|
|
43
|
+
g.error_page = false
|
44
|
+
g.host = '127.0.0.1'
|
45
|
+
g.port = 7070
|
46
|
+
end
|
47
|
+
|
48
|
+
This method is similar to the hash-assignment, but may be preferred for some
|
49
|
+
applications.
|
50
|
+
|
51
|
+
|
52
|
+
#### Pass on Ramaze.start
|
53
|
+
|
54
|
+
Ramaze.start :run_loose => true
|
55
|
+
|
56
|
+
This way you can save a line or two in a small script.
|
57
|
+
Please note that the values passed here have precedence over the ones directly
|
58
|
+
set on Global and will overwrite them if you set them before, that is mostly
|
59
|
+
useful to quickly test some configuration.
|
60
|
+
|
61
|
+
|
62
|
+
### Global options
|
63
|
+
|
64
|
+
Since this document is especially prone to be outdated at times make sure you
|
65
|
+
check lib/ramaze/global.rb in case you run into trouble, we will try to keep at
|
66
|
+
least the RDocs up to date. This update is from 2007/04/16.
|
67
|
+
|
68
|
+
This listing is here to provide you with descriptions of the most common
|
69
|
+
configurations in alphabetical order per section showing the default value next
|
70
|
+
to the key.
|
71
|
+
|
72
|
+
|
73
|
+
#### General Configuration:
|
74
|
+
|
75
|
+
:autoreload => 5
|
76
|
+
|
77
|
+
Autoreload is a nifty mechanism that takes advantage of the dynamics of Ruby,
|
78
|
+
it's basically a Thread that runs in the background and polls for files in the
|
79
|
+
application and framework that have changed (using mtime). The value specifies
|
80
|
+
roughly how fast your changes are going to be loaded and should be a usual
|
81
|
+
Fixnum.
|
82
|
+
|
83
|
+
|
84
|
+
:adapter => :webrick
|
85
|
+
|
86
|
+
The adapter is the server Ramaze runs to serve your application. This can be any
|
87
|
+
of mongrel/webrick/fcgi/cgi, please note that so far neither fcgi nor cgi have
|
88
|
+
received the necessary testing, but, as they are only wrappers around the
|
89
|
+
underlying Rack library, should work fine. Both fcgi and mongrel require
|
90
|
+
additional libraries to be installed, webrick and cgi run out of the box.
|
91
|
+
Generally the most supported and recommended for deployment is Mongrel.
|
92
|
+
|
93
|
+
|
94
|
+
:backtrace_size => 10
|
95
|
+
|
96
|
+
This option doesn't have a large impact and is most likely left on its default
|
97
|
+
value, it controls how long the backtrace shown in your log and on the error
|
98
|
+
page should be.
|
99
|
+
|
100
|
+
|
101
|
+
:cache => MemoryCache
|
102
|
+
|
103
|
+
The cache is one of the more important things for deployment, the default for
|
104
|
+
this is MemoryCache, a simple Hash.
|
105
|
+
The class you specify here is used throughout Ramaze to cache various things,
|
106
|
+
like sessions, page- and value-caching.
|
107
|
+
Included in Ramaze are the MemoryCache and YAMLStoreCache, after you install
|
108
|
+
'memcached' you can also use the much more performant MemcachedCache that also
|
109
|
+
makes it easy to use the same cache between different applications (sharing
|
110
|
+
sessions is one of the most obvious uses).
|
111
|
+
|
112
|
+
|
113
|
+
:cache_all => false
|
114
|
+
|
115
|
+
Setting this value to true would enable caching for all pages served from the
|
116
|
+
Controller (all actions).
|
117
|
+
This is a very powerful setting and you might want to enable it if all pages
|
118
|
+
you serve are only built once and have no further dynamics, the key for this
|
119
|
+
cache consists of the controller and parameters, when repeated requests are
|
120
|
+
made it will always serve the same (now static) page.
|
121
|
+
|
122
|
+
|
123
|
+
:cookies => true
|
124
|
+
|
125
|
+
Enables sending cookies by setting this to false.
|
126
|
+
Please note that many functionalities of Ramaze depend on an intact session and
|
127
|
+
you will have to be careful not to use these.
|
128
|
+
This is most likely useful in combination with `cache_all`
|
129
|
+
|
130
|
+
|
131
|
+
:error_page => true
|
132
|
+
|
133
|
+
Enables the default Error page of Ramaze which is mostly useful for manual
|
134
|
+
testing and faster debugging. In most deployment-scenarios you will however
|
135
|
+
want to use your own Error page and so you can safely disable this setting.
|
136
|
+
|
137
|
+
:host => '0.0.0.0'
|
138
|
+
|
139
|
+
Tell the adapter where it accepts requests from, 0.0.0.0 says that every
|
140
|
+
IP will be accepted, 127.0.0.1 would accept only requests from loopback.
|
141
|
+
|
142
|
+
|
143
|
+
:logger => Ramaze::Informer
|
144
|
+
|
145
|
+
The logger is used during startup to set Ramaze::Inform, you may set this
|
146
|
+
to Ramaze::Syslog or in case you have 'analogger' installed, you can use
|
147
|
+
Ramaze::Analogger.
|
148
|
+
|
149
|
+
|
150
|
+
:mapping => {}
|
151
|
+
|
152
|
+
This is a very central and special setting, it contains key/value pairs
|
153
|
+
that define routes to your controllers, the keys are simple strings and
|
154
|
+
start with '/', which means http://yourhost.com/ - '/foo/bar' would point
|
155
|
+
to http://yourhost.com/foo/bar.
|
156
|
+
The value is the class of your controller.
|
157
|
+
|
158
|
+
|
159
|
+
:port => 7000
|
160
|
+
|
161
|
+
The port Ramaze runs on, if you can think of more information about this feel
|
162
|
+
free to tell us.
|
163
|
+
|
164
|
+
|
165
|
+
:run_loose => false
|
166
|
+
|
167
|
+
This option is mostly used to run the specs, it means that Ramaze will not
|
168
|
+
join the adapter-threads and therefor you are free to run any code you want
|
169
|
+
afterwards. You won't have to use this in most cases, example usage is in
|
170
|
+
spec/spec_helper.
|
171
|
+
|
172
|
+
|
173
|
+
:template_root => 'template'
|
174
|
+
|
175
|
+
The template_root is the point your templates are located relative to the
|
176
|
+
location of the entry-file (usually main.rb)
|
177
|
+
It is also worth to mention that inside this directory the `mapping` is used
|
178
|
+
to locate templates for each controller, only the controller mapped to '/' uses
|
179
|
+
the templates directly from the `template_root`
|
@@ -0,0 +1,111 @@
|
|
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
|
+
#### The Ramaze module
|
17
|
+
|
18
|
+
Ramaze is also the main module or so-called namespace that the framework lives
|
19
|
+
in. It has
|
20
|
+
|
21
|
+
startup
|
22
|
+
shutdown
|
23
|
+
initial tasks
|
24
|
+
exiting tasks
|
25
|
+
|
26
|
+
|
27
|
+
#### Global configuration
|
28
|
+
|
29
|
+
Any serious application or framework needs to be configured.
|
30
|
+
Yes, I wished there was a silver bullet to serve all your needs as well, but at
|
31
|
+
the current stage of programming development there is no such thing.
|
32
|
+
So, since we need to configure, we should make it as simple and painless as
|
33
|
+
possible, and, thanks to Ruby, it is actually quite enjoyable to do that.
|
34
|
+
You can find a very detailed description about Global in the section about
|
35
|
+
Configuration, for now just the basics.
|
36
|
+
|
37
|
+
The basis of Ramaze::Global, the instance that is holding most part of your
|
38
|
+
configuration or at least links to the actual places, is the
|
39
|
+
Ramaze::GlobalStruct (ramaze/global.rb), which is a subclass of OpenStruct. If
|
40
|
+
you are not yet familiar with OpenStruct, I very much recommend to read its
|
41
|
+
documentation and play around a bit, it is basically just a wrapper around a
|
42
|
+
normal Hash where you can access the keys instead of ostruct[:foo] with
|
43
|
+
ostruct.foo.
|
44
|
+
It simply defines a new accessors on assignment by catching things in
|
45
|
+
method_missing. I won't go into more details here, I hope you got the principle.
|
46
|
+
|
47
|
+
Now, based on this technique, GlobalStruct adds things like defaults and a
|
48
|
+
couple of convenience methods like they are common in Ruby, giving you more
|
49
|
+
power by tapping to the internal Hash of the GlobalStruct and adding
|
50
|
+
update/setup methods so you can assign many key/value pairs at once.
|
51
|
+
The RDocs will give you a very good overview of what is available and how one is
|
52
|
+
supposed to work with it.
|
53
|
+
|
54
|
+
Now back to the big picture.
|
55
|
+
|
56
|
+
Ramaze accesses Global all over the place, there have been made several choices
|
57
|
+
as to why using something like Global is considered beneficial against choosing
|
58
|
+
for example global variables, which would be considered as a fatal choice by
|
59
|
+
any respected Rubyist anyway.
|
60
|
+
|
61
|
+
Now to something more subtle, which has to do with Global. I speak about traits,
|
62
|
+
which is a very different concept in most of its implementations, but it is
|
63
|
+
something that basically fits this name. It is configuration of single Objects
|
64
|
+
and whole ancestries.
|
65
|
+
You can give an object a trait, and most likely will use it along the lines of
|
66
|
+
something like MyController.trait(:map => '/'), which would be picked up on
|
67
|
+
startup and used to create Global.mapping - where we are at configuration again.
|
68
|
+
Choosing this style of configuration complementary to a central place to put all
|
69
|
+
your configuration was made very early in the development of Ramaze, and the
|
70
|
+
basic code of how traits are implemented and used has proven very efficient both
|
71
|
+
in understanding and using them.
|
72
|
+
|
73
|
+
There is a basic distinction when to use Global and when to use traits and when
|
74
|
+
to generate or assume one based on the other.
|
75
|
+
|
76
|
+
If something affects your whole application and is either used directly in the
|
77
|
+
Ramaze module or throughout the framework it is considered to be put into Global
|
78
|
+
to gain benefits of better documentation and accessibility.
|
79
|
+
|
80
|
+
On the other hand - if something is used in a configuring manner by a class that
|
81
|
+
is instantiated often (like Controller is for example), or a module that cannot
|
82
|
+
hold instance variables in a nice manner and is also not a constant - then it is
|
83
|
+
configured using traits.
|
84
|
+
|
85
|
+
|
86
|
+
Ramaze
|
87
|
+
Global
|
88
|
+
Adapter
|
89
|
+
Dispatcher
|
90
|
+
Controller
|
91
|
+
Action
|
92
|
+
|
93
|
+
Session
|
94
|
+
Helper
|
95
|
+
Tool
|
96
|
+
|
97
|
+
|
98
|
+
#### The Web
|
99
|
+
|
100
|
+
The so called web consists of a plethora of data, most of it is browsable
|
101
|
+
through a web browser that just about every toaster has installed these days.
|
102
|
+
The browser is the target of a web author, trying to utilize common standards
|
103
|
+
like HTML and CSS which are means for data and layout to be combined, giving the
|
104
|
+
browser a way to display the data.
|
105
|
+
Ramaze works on the URI-scale web, meaning that addresses like
|
106
|
+
http://someserver.com/blog/article/1 have a unique representation on your
|
107
|
+
server.
|
108
|
+
If we stay with this example, we see already everything Ramaze needs to see to
|
109
|
+
serve a page based on your instructions.
|
110
|
+
We assume that blog/article is a Controller named ArticleController in the blog
|
111
|
+
application.
|
@@ -7,16 +7,14 @@ Ramaze offers following features at the moment:
|
|
7
7
|
|
8
8
|
Rack supports at the moment:
|
9
9
|
|
10
|
-
* Mongrel
|
10
|
+
* [Mongrel](http://mongrel.rubyforge.org/)
|
11
11
|
|
12
|
-
http://mongrel.rubyforge.org/
|
13
12
|
Mongrel is a fast HTTP library and server for Ruby that is intended for
|
14
13
|
hosting Ruby web applications of any kind using plain HTTP rather than
|
15
14
|
FastCGI or SCGI.
|
16
15
|
|
17
|
-
* WEBrick
|
16
|
+
* [WEBrick](http://www.webrick.org/)
|
18
17
|
|
19
|
-
http://www.webrick.org/
|
20
18
|
WEBrick is a Ruby library program to build HTTP servers.
|
21
19
|
|
22
20
|
* CGI
|
@@ -26,37 +24,31 @@ Ramaze offers following features at the moment:
|
|
26
24
|
|
27
25
|
|
28
26
|
* Templates
|
29
|
-
* Amrita2
|
27
|
+
* [Amrita2](http://amrita2.rubyforge.org/)
|
30
28
|
|
31
|
-
http://amrita2.rubyforge.org/
|
32
29
|
Amrita2 is a xml/xhtml template library for Ruby. It makes html documents
|
33
30
|
from a template and a model data.
|
34
31
|
|
35
|
-
* Erubis
|
32
|
+
* [Erubis](http://rubyforge.org/projects/erubis)
|
36
33
|
|
37
|
-
http://rubyforge.org/projects/erubis
|
38
34
|
Erubis is a fast, secure, and very extensible implementation of eRuby.
|
39
35
|
|
40
|
-
* Haml
|
36
|
+
* [Haml](http://haml.hamptoncatlin.com/)
|
41
37
|
|
42
|
-
http://haml.hamptoncatlin.com/
|
43
38
|
Haml takes your gross, ugly templates and replaces them with veritable Haiku.
|
44
39
|
|
45
|
-
* Liquid
|
40
|
+
* [Liquid](http://home.leetsoft.com/liquid)
|
46
41
|
|
47
|
-
http://home.leetsoft.com/liquid
|
48
42
|
Liquid's syntax and parse model are inspired by Django templates, as well
|
49
43
|
as PHP's smarty.
|
50
44
|
|
51
|
-
* Markaby
|
45
|
+
* [Markaby](http://code.whytheluckystiff.net/markaby/)
|
52
46
|
|
53
|
-
http://code.whytheluckystiff.net/markaby/
|
54
47
|
Markaby means Markup as Ruby.
|
55
48
|
|
56
49
|
* Ezamar
|
57
50
|
|
58
|
-
A simple homage to
|
59
|
-
for more information.
|
51
|
+
A simple homage to [Nitro](http://nitroproject.org)s templating.
|
60
52
|
|
61
53
|
* Cache
|
62
54
|
* Hash
|
@@ -7,12 +7,13 @@
|
|
7
7
|
in case you have RubyGems installed.
|
8
8
|
(this will work as soon as I have registered on RubyForge ;)
|
9
9
|
|
10
|
+
|
10
11
|
* via darcs
|
11
12
|
|
12
13
|
To get the latest and sweetest, you can just pull from the repository and run
|
13
14
|
Ramaze that way.
|
14
15
|
|
15
|
-
$ darcs get http://manveru.mine.nu/ramaze
|
16
|
+
$ darcs get --partial http://manveru.mine.nu/ramaze
|
16
17
|
|
17
18
|
Please read the man page or `darcs help` for more information about updating
|
18
19
|
and creating your own patches.
|
@@ -39,3 +40,8 @@
|
|
39
40
|
|
40
41
|
$ darcs send -o ramaze_bundle
|
41
42
|
$ gzip -c ramaze_bundle > ramaze_bundle.gz
|
43
|
+
|
44
|
+
|
45
|
+
* via install.rb
|
46
|
+
|
47
|
+
Support for install.rb has been canceled and the file removed.
|
data/doc/tutorial/todolist.txt
CHANGED
@@ -453,7 +453,7 @@ so far:
|
|
453
453
|
<title>TodoList</title>
|
454
454
|
</head>
|
455
455
|
<body>
|
456
|
-
<h1>#{@
|
456
|
+
<h1>#{@title}</h1>
|
457
457
|
#{content}
|
458
458
|
</body>
|
459
459
|
</html>
|
@@ -461,8 +461,7 @@ so far:
|
|
461
461
|
end
|
462
462
|
end
|
463
463
|
|
464
|
-
Please note that
|
465
|
-
to tye Page-tag.
|
464
|
+
Please note that instance variables reflecting the parameters are set.
|
466
465
|
|
467
466
|
And let's change our templates as well.
|
468
467
|
|
data/examples/blog/main.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
-
#
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
1
|
+
$DBG = true # turn on debugging in Og
|
3
2
|
|
4
|
-
require 'yaml'
|
5
|
-
require 'bluecloth'
|
6
3
|
require 'ramaze'
|
7
|
-
|
8
|
-
require 'src/model'
|
4
|
+
require 'og'
|
9
5
|
|
10
6
|
include Ramaze
|
7
|
+
|
8
|
+
require 'src/model'
|
9
|
+
require 'src/view'
|
11
10
|
require 'src/controller'
|
12
|
-
require 'src/element'
|
13
11
|
|
14
|
-
|
12
|
+
Og.setup :evolve_schema => :full
|
13
|
+
|
14
|
+
Entry.create "Blog created", "Exciting news today, this blog was created!" if
|
15
|
+
Entry.count == 0
|
15
16
|
|
16
17
|
start
|