ramaze 0.1.2 → 0.1.3
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 +1 -1
- data/doc/AUTHORS +2 -0
- data/doc/CHANGELOG +173 -0
- data/doc/changes.txt +4184 -0
- data/doc/changes.xml +4186 -0
- data/doc/meta/announcement.txt +22 -25
- data/doc/meta/internals.txt +146 -9
- data/examples/blog/template/index.xhtml +5 -2
- data/examples/fcgi.rb +13 -0
- data/examples/wiktacular/main.rb +8 -0
- data/examples/wiktacular/mkd/link/2007-07-20_19-45-51.mkd +1 -0
- data/examples/wiktacular/mkd/link/current.mkd +1 -0
- data/examples/wiktacular/mkd/main/2007-07-20_16-31-33.mkd +1 -0
- data/examples/wiktacular/mkd/main/2007-07-20_19-21-12.mkd +1 -0
- data/examples/wiktacular/mkd/main/2007-07-20_19-23-10.mkd +2 -0
- data/examples/wiktacular/mkd/main/2007-07-20_19-45-07.mkd +2 -0
- data/examples/wiktacular/mkd/main/current.mkd +2 -0
- data/examples/wiktacular/mkd/markdown/current.mkd +3 -0
- data/examples/wiktacular/mkd/testing/2007-07-20_16-43-46.mkd +2 -0
- data/examples/wiktacular/mkd/testing/2007-07-20_19-43-50.mkd +3 -0
- data/examples/wiktacular/mkd/testing/2007-07-21_18-46-01.mkd +11 -0
- data/examples/wiktacular/mkd/testing/2007-07-21_18-46-32.mkd +13 -0
- data/examples/wiktacular/mkd/testing/2007-07-21_18-47-08.mkd +17 -0
- data/examples/wiktacular/mkd/testing/2007-07-21_18-47-54.mkd +17 -0
- data/examples/wiktacular/mkd/testing/current.mkd +17 -0
- data/examples/wiktacular/public/favicon.ico +0 -0
- data/examples/wiktacular/public/screen.css +72 -0
- data/examples/wiktacular/src/controller.rb +44 -0
- data/examples/wiktacular/src/model.rb +92 -0
- data/examples/wiktacular/src/page.rb +66 -0
- data/examples/wiktacular/template/edit.xhtml +7 -0
- data/examples/wiktacular/template/index.xhtml +11 -0
- data/examples/wiktacular/template/new.xhtml +7 -0
- data/lib/proto/main.rb +2 -0
- data/lib/proto/public/error.zmr +3 -0
- data/lib/proto/public/js/jquery.js +1755 -1334
- data/lib/proto/template/index.xhtml +2 -2
- data/lib/ramaze.rb +8 -3
- data/lib/ramaze/action/render.rb +11 -0
- data/lib/ramaze/adapter/base.rb +11 -7
- data/lib/ramaze/cache.rb +25 -10
- data/lib/ramaze/cache/memcached.rb +16 -1
- data/lib/ramaze/cache/yaml_store.rb +10 -0
- data/lib/ramaze/controller.rb +12 -2
- data/lib/ramaze/controller/error.rb +9 -3
- data/lib/ramaze/controller/resolve.rb +20 -18
- data/lib/ramaze/dispatcher.rb +13 -4
- data/lib/ramaze/dispatcher/action.rb +7 -3
- data/lib/ramaze/dispatcher/error.rb +24 -2
- data/lib/ramaze/dispatcher/file.rb +12 -6
- data/lib/ramaze/global.rb +0 -3
- data/lib/ramaze/global/dsl.rb +9 -0
- data/lib/ramaze/global/globalstruct.rb +7 -1
- data/lib/ramaze/helper/aspect.rb +4 -2
- data/lib/ramaze/helper/cgi.rb +2 -2
- data/lib/ramaze/helper/file.rb +3 -0
- data/lib/ramaze/helper/link.rb +20 -0
- data/lib/ramaze/helper/markaby.rb +3 -0
- data/lib/ramaze/helper/pager.rb +10 -17
- data/lib/ramaze/helper/partial.rb +9 -3
- data/lib/ramaze/inform/analogger.rb +14 -0
- data/lib/ramaze/inform/growl.rb +7 -0
- data/lib/ramaze/inform/hub.rb +9 -0
- data/lib/ramaze/inform/informer.rb +9 -3
- data/lib/ramaze/inform/informing.rb +9 -3
- data/lib/ramaze/inform/knotify.rb +5 -1
- data/lib/ramaze/inform/syslog.rb +3 -0
- data/lib/ramaze/inform/xosd.rb +12 -0
- data/lib/ramaze/template.rb +3 -0
- data/lib/ramaze/template/amrita2.rb +2 -0
- data/lib/ramaze/template/erubis.rb +1 -0
- data/lib/ramaze/template/ezamar.rb +1 -0
- data/lib/ramaze/template/ezamar/element.rb +17 -11
- data/lib/ramaze/template/ezamar/engine.rb +5 -0
- data/lib/ramaze/template/ezamar/render_partial.rb +4 -2
- data/lib/ramaze/template/haml.rb +4 -0
- data/lib/ramaze/template/liquid.rb +4 -0
- data/lib/ramaze/template/markaby.rb +4 -0
- data/lib/ramaze/template/remarkably.rb +4 -0
- data/lib/ramaze/tool.rb +10 -0
- data/lib/ramaze/tool/localize.rb +1 -1
- data/lib/ramaze/trinity/session.rb +8 -1
- data/lib/ramaze/version.rb +1 -1
- data/rake_tasks/maintaince.rake +2 -2
- data/spec/ramaze/action/basics.rb +1 -1
- data/spec/ramaze/cache.rb +11 -0
- data/spec/ramaze/controller.rb +0 -14
- data/spec/ramaze/dispatcher/file.rb +5 -5
- data/spec/ramaze/dispatcher/public/favicon.ico +0 -0
- data/spec/ramaze/dispatcher/public/test_download.css +141 -0
- data/spec/ramaze/error.rb +21 -7
- data/spec/ramaze/helper/link.rb +15 -0
- data/spec/ramaze/helper/pager.rb +26 -3
- data/spec/ramaze/helper/partial.rb +2 -2
- metadata +43 -4
- data/doc/COPYING.ja +0 -51
data/doc/meta/announcement.txt
CHANGED
|
@@ -1,45 +1,41 @@
|
|
|
1
|
-
This time we are proud to announce Version 0.1.
|
|
2
|
-
open source web framework
|
|
1
|
+
This time we are proud to announce Version 0.1.3 of the Ramaze framework, a
|
|
2
|
+
light and modular open source web framework.
|
|
3
3
|
|
|
4
|
-
Since the
|
|
5
|
-
|
|
6
|
-
of the implementation and usage.
|
|
4
|
+
Since the last release some polishing and improvments have been made, it seems
|
|
5
|
+
like Ramaze is now mostly feature-complete.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
An extensive set of specs is covering almost every detail of the implementation
|
|
8
|
+
and usage. It is developed by several people and already in production-use at
|
|
9
|
+
some companies.
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
Home page: http://ramaze.rubyforge.org
|
|
13
13
|
IRC: #ramaze on irc.freenode.net
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Short summary of changes from 0.1.2 to 0.1.3:
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
- Better error handling
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
- Many bugs fixed
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
- Some speedup
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
- Lots of docs added
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
- Smoother sourcereload
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
- New Wiki example
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
- jQuery 1.1.3.1
|
|
31
31
|
|
|
32
|
-
- Reviewed and largely improved tutorial and tested examples.
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
upcoming Ruby 1.9 and tested with older versions down to 1.8.2.
|
|
33
|
+
A complete Changelog is available at http://manveru.mine.nu/ramaze/doc/CHANGELOG
|
|
36
34
|
|
|
37
|
-
- Largely improved Spec-framework for any kind of web-application.
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
around the factor 2-3.
|
|
36
|
+
Known issues:
|
|
41
37
|
|
|
42
|
-
|
|
38
|
+
- Haml: either use Haml version 1.5.2 or require ActionPack.
|
|
43
39
|
|
|
44
40
|
|
|
45
41
|
Features:
|
|
@@ -47,7 +43,7 @@ Features:
|
|
|
47
43
|
of adapters like Mongrel, WEBrick, CGI or FCGI.
|
|
48
44
|
|
|
49
45
|
- Supports a wide range of templating-engines like:
|
|
50
|
-
Amrita2, Erubis,
|
|
46
|
+
Amrita2, Erubis, Haml, Liquid, Markaby, Remarkably and its own engine
|
|
51
47
|
called Ezamar.
|
|
52
48
|
|
|
53
49
|
- Highly modular structure, you can just use the parts you like. This also
|
|
@@ -60,8 +56,9 @@ Features:
|
|
|
60
56
|
- It is possible to use the ORM you like, be it ActiveRecord, Og, Kansas or
|
|
61
57
|
something more simplistic like a wrapper around YAML::Store.
|
|
62
58
|
|
|
63
|
-
- Good documentation: although we don't have 100%
|
|
64
|
-
just about every part of Ramaze is covered with
|
|
59
|
+
- Good documentation: although we don't have 100% (dcov says around 75%)
|
|
60
|
+
documentation right now, just about every part of Ramaze is covered with
|
|
61
|
+
basic and advanced docs.
|
|
65
62
|
There are a variety of examples and a tutorial available.
|
|
66
63
|
|
|
67
64
|
- Friendly community: lastly, but still quite important, there are people from
|
data/doc/meta/internals.txt
CHANGED
|
@@ -13,6 +13,119 @@ Let's outline the realms that Ramaze works in as to show what the current
|
|
|
13
13
|
limitations and features are.
|
|
14
14
|
|
|
15
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 (Dispatcher::build_response helps with that) or a totally new
|
|
49
|
+
one.
|
|
50
|
+
|
|
51
|
+
In our case, Dispatcher::File uses build_response 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
|
+
|
|
16
129
|
#### The Ramaze module
|
|
17
130
|
|
|
18
131
|
Ramaze is also the main module or so-called namespace that the framework lives
|
|
@@ -26,31 +139,55 @@ Tasks on require
|
|
|
26
139
|
* GlobalStruct.new
|
|
27
140
|
|
|
28
141
|
|
|
29
|
-
Tasks on startup
|
|
142
|
+
Tasks on startup as defined in Ramaze.trait[:internals] in lib/ramaze.rb
|
|
30
143
|
|
|
31
|
-
* Global
|
|
144
|
+
* Global::startup
|
|
32
145
|
* passed options to Ramaze.start
|
|
33
146
|
* CLI options from bin/ramaze (treat as passed.merge)
|
|
34
147
|
* Global options set before startup (fake Global?)
|
|
35
148
|
|
|
36
|
-
*
|
|
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
|
|
37
170
|
* mapping of all subclassed Controller
|
|
38
171
|
* validation of mapping
|
|
39
172
|
* validation of template_root
|
|
40
173
|
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
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.
|
|
44
177
|
|
|
45
|
-
* SourceReload
|
|
178
|
+
* SourceReload::startup
|
|
46
179
|
* start with Global.reload_interval
|
|
47
180
|
* assign Global.sourcereload
|
|
48
181
|
|
|
182
|
+
* Adapter::startup
|
|
183
|
+
* interpret Global.adapter
|
|
184
|
+
* add every created adapter to Global.adapters
|
|
185
|
+
|
|
49
186
|
|
|
50
187
|
Tasks on shutdown
|
|
51
188
|
|
|
52
|
-
* Adapter
|
|
53
|
-
* Inform
|
|
189
|
+
* Adapter::shutdown (iterates Global.adapters)
|
|
190
|
+
* Inform::shutdown (iterates all in LogHub)
|
|
54
191
|
|
|
55
192
|
|
|
56
193
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<Blog title="bl_Og">
|
|
2
|
-
<div id="actions">#{
|
|
2
|
+
<div id="actions">#{A 'new entry', :href => Rs(:new)}</div>
|
|
3
3
|
<div id="entries">
|
|
4
4
|
<?r @entries.each do |entry| ?>
|
|
5
5
|
<div class="entry">
|
|
6
6
|
<div class="header">
|
|
7
7
|
<div class="title">#{entry.title}</div>
|
|
8
8
|
<div class="created">Created: #{entry.created}</div>
|
|
9
|
-
<ul
|
|
9
|
+
<ul>
|
|
10
|
+
<li>#{A 'edit', :href => Rs(:edit, entry.oid)}</li>
|
|
11
|
+
<li>#{A 'delete', :href => Rs(:delete, entry.oid)}</li>
|
|
12
|
+
</ul>
|
|
10
13
|
</div>
|
|
11
14
|
<div class="content">#{entry.content}</div>
|
|
12
15
|
<div class="updated">Last updated: #{entry.updated}</div>
|
data/examples/fcgi.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Links are basically files, far down under
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Links are basically [[markdown]] files, far down under
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Hello, World
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Hello, World
|
|
Binary file
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
body {
|
|
2
|
+
background: #dff;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
a {
|
|
6
|
+
text-decoration: none;
|
|
7
|
+
color: #224;
|
|
8
|
+
}
|
|
9
|
+
a:hover {
|
|
10
|
+
text-decoration: underline overline;
|
|
11
|
+
color: #335;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
a:before { content:"[ "; }
|
|
15
|
+
a:after { content:" ]"; }
|
|
16
|
+
|
|
17
|
+
h1 { font-size: 1.5em; }
|
|
18
|
+
h2 { font-size: 1.4em; }
|
|
19
|
+
h3 { font-size: 1.3em; }
|
|
20
|
+
h4 { font-size: 1.2em; }
|
|
21
|
+
h5 { font-size: 1.1em; }
|
|
22
|
+
|
|
23
|
+
div#manipulate {
|
|
24
|
+
text-align: right;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
div#navigation {
|
|
28
|
+
background: #fff;
|
|
29
|
+
padding: 0.5em;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
div#text {
|
|
33
|
+
border: 1px black dashed;
|
|
34
|
+
padding: 1em;
|
|
35
|
+
margin: 1em;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
div#menu {
|
|
39
|
+
height: 2em;
|
|
40
|
+
font-size: 1.1em;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
form {
|
|
44
|
+
background: #cee;
|
|
45
|
+
padding: 2em;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
input {
|
|
49
|
+
border: 1px solid #699;
|
|
50
|
+
background: #eee;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
input:focus {
|
|
54
|
+
border: 1px solid green;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
textarea {
|
|
58
|
+
width: 100%;
|
|
59
|
+
height: 35em;
|
|
60
|
+
border: 1px solid #699;
|
|
61
|
+
background: #eee;
|
|
62
|
+
padding: 5px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
textarea:focus {
|
|
66
|
+
border: 1px solid green;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#copyright {
|
|
70
|
+
text-align: center;
|
|
71
|
+
font-size: 0.9em;
|
|
72
|
+
}
|