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.
Files changed (96) hide show
  1. data/Rakefile +1 -1
  2. data/doc/AUTHORS +2 -0
  3. data/doc/CHANGELOG +173 -0
  4. data/doc/changes.txt +4184 -0
  5. data/doc/changes.xml +4186 -0
  6. data/doc/meta/announcement.txt +22 -25
  7. data/doc/meta/internals.txt +146 -9
  8. data/examples/blog/template/index.xhtml +5 -2
  9. data/examples/fcgi.rb +13 -0
  10. data/examples/wiktacular/main.rb +8 -0
  11. data/examples/wiktacular/mkd/link/2007-07-20_19-45-51.mkd +1 -0
  12. data/examples/wiktacular/mkd/link/current.mkd +1 -0
  13. data/examples/wiktacular/mkd/main/2007-07-20_16-31-33.mkd +1 -0
  14. data/examples/wiktacular/mkd/main/2007-07-20_19-21-12.mkd +1 -0
  15. data/examples/wiktacular/mkd/main/2007-07-20_19-23-10.mkd +2 -0
  16. data/examples/wiktacular/mkd/main/2007-07-20_19-45-07.mkd +2 -0
  17. data/examples/wiktacular/mkd/main/current.mkd +2 -0
  18. data/examples/wiktacular/mkd/markdown/current.mkd +3 -0
  19. data/examples/wiktacular/mkd/testing/2007-07-20_16-43-46.mkd +2 -0
  20. data/examples/wiktacular/mkd/testing/2007-07-20_19-43-50.mkd +3 -0
  21. data/examples/wiktacular/mkd/testing/2007-07-21_18-46-01.mkd +11 -0
  22. data/examples/wiktacular/mkd/testing/2007-07-21_18-46-32.mkd +13 -0
  23. data/examples/wiktacular/mkd/testing/2007-07-21_18-47-08.mkd +17 -0
  24. data/examples/wiktacular/mkd/testing/2007-07-21_18-47-54.mkd +17 -0
  25. data/examples/wiktacular/mkd/testing/current.mkd +17 -0
  26. data/examples/wiktacular/public/favicon.ico +0 -0
  27. data/examples/wiktacular/public/screen.css +72 -0
  28. data/examples/wiktacular/src/controller.rb +44 -0
  29. data/examples/wiktacular/src/model.rb +92 -0
  30. data/examples/wiktacular/src/page.rb +66 -0
  31. data/examples/wiktacular/template/edit.xhtml +7 -0
  32. data/examples/wiktacular/template/index.xhtml +11 -0
  33. data/examples/wiktacular/template/new.xhtml +7 -0
  34. data/lib/proto/main.rb +2 -0
  35. data/lib/proto/public/error.zmr +3 -0
  36. data/lib/proto/public/js/jquery.js +1755 -1334
  37. data/lib/proto/template/index.xhtml +2 -2
  38. data/lib/ramaze.rb +8 -3
  39. data/lib/ramaze/action/render.rb +11 -0
  40. data/lib/ramaze/adapter/base.rb +11 -7
  41. data/lib/ramaze/cache.rb +25 -10
  42. data/lib/ramaze/cache/memcached.rb +16 -1
  43. data/lib/ramaze/cache/yaml_store.rb +10 -0
  44. data/lib/ramaze/controller.rb +12 -2
  45. data/lib/ramaze/controller/error.rb +9 -3
  46. data/lib/ramaze/controller/resolve.rb +20 -18
  47. data/lib/ramaze/dispatcher.rb +13 -4
  48. data/lib/ramaze/dispatcher/action.rb +7 -3
  49. data/lib/ramaze/dispatcher/error.rb +24 -2
  50. data/lib/ramaze/dispatcher/file.rb +12 -6
  51. data/lib/ramaze/global.rb +0 -3
  52. data/lib/ramaze/global/dsl.rb +9 -0
  53. data/lib/ramaze/global/globalstruct.rb +7 -1
  54. data/lib/ramaze/helper/aspect.rb +4 -2
  55. data/lib/ramaze/helper/cgi.rb +2 -2
  56. data/lib/ramaze/helper/file.rb +3 -0
  57. data/lib/ramaze/helper/link.rb +20 -0
  58. data/lib/ramaze/helper/markaby.rb +3 -0
  59. data/lib/ramaze/helper/pager.rb +10 -17
  60. data/lib/ramaze/helper/partial.rb +9 -3
  61. data/lib/ramaze/inform/analogger.rb +14 -0
  62. data/lib/ramaze/inform/growl.rb +7 -0
  63. data/lib/ramaze/inform/hub.rb +9 -0
  64. data/lib/ramaze/inform/informer.rb +9 -3
  65. data/lib/ramaze/inform/informing.rb +9 -3
  66. data/lib/ramaze/inform/knotify.rb +5 -1
  67. data/lib/ramaze/inform/syslog.rb +3 -0
  68. data/lib/ramaze/inform/xosd.rb +12 -0
  69. data/lib/ramaze/template.rb +3 -0
  70. data/lib/ramaze/template/amrita2.rb +2 -0
  71. data/lib/ramaze/template/erubis.rb +1 -0
  72. data/lib/ramaze/template/ezamar.rb +1 -0
  73. data/lib/ramaze/template/ezamar/element.rb +17 -11
  74. data/lib/ramaze/template/ezamar/engine.rb +5 -0
  75. data/lib/ramaze/template/ezamar/render_partial.rb +4 -2
  76. data/lib/ramaze/template/haml.rb +4 -0
  77. data/lib/ramaze/template/liquid.rb +4 -0
  78. data/lib/ramaze/template/markaby.rb +4 -0
  79. data/lib/ramaze/template/remarkably.rb +4 -0
  80. data/lib/ramaze/tool.rb +10 -0
  81. data/lib/ramaze/tool/localize.rb +1 -1
  82. data/lib/ramaze/trinity/session.rb +8 -1
  83. data/lib/ramaze/version.rb +1 -1
  84. data/rake_tasks/maintaince.rake +2 -2
  85. data/spec/ramaze/action/basics.rb +1 -1
  86. data/spec/ramaze/cache.rb +11 -0
  87. data/spec/ramaze/controller.rb +0 -14
  88. data/spec/ramaze/dispatcher/file.rb +5 -5
  89. data/spec/ramaze/dispatcher/public/favicon.ico +0 -0
  90. data/spec/ramaze/dispatcher/public/test_download.css +141 -0
  91. data/spec/ramaze/error.rb +21 -7
  92. data/spec/ramaze/helper/link.rb +15 -0
  93. data/spec/ramaze/helper/pager.rb +26 -3
  94. data/spec/ramaze/helper/partial.rb +2 -2
  95. metadata +43 -4
  96. data/doc/COPYING.ja +0 -51
@@ -1,45 +1,41 @@
1
- This time we are proud to announce Version 0.1.2 of the Ramaze framework, an
2
- open source web framework with the aim to be light and modular.
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 0.1.0 release we have made a lot of progress and the overall API has
5
- mostly settled down. An extensive set of tests is covering almost every detail
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
- It is developed by by several people and already in production-use at some
9
- companies.
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
- New Features in Version 0.1.2:
16
+ Short summary of changes from 0.1.2 to 0.1.3:
17
17
 
18
- - Restructuring of Ramaze internals, featuring a cleaner overall layout.
18
+ - Better error handling
19
19
 
20
- - Add Ramaze::Record to easily record requests fitting particular patterns.
20
+ - Many bugs fixed
21
21
 
22
- - Support for the Remarkably templating engine.
22
+ - Some speedup
23
23
 
24
- - Adapted for Rack 0.2
24
+ - Lots of docs added
25
25
 
26
- - Easier caching.
26
+ - Smoother sourcereload
27
27
 
28
- - replacing autoreload with a general SourceReload class.
28
+ - New Wiki example
29
29
 
30
- - tiny DSL for settings.
30
+ - jQuery 1.1.3.1
31
31
 
32
- - Reviewed and largely improved tutorial and tested examples.
33
32
 
34
- - Even less patches to the Ruby core, mostly for compatibility with the
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
- - Through some benchmarking and refactoring the overall speed has improved
40
- around the factor 2-3.
36
+ Known issues:
41
37
 
42
- A complete Changelog is available at http://manveru.mine.nu/ramaze/doc/CHANGELOG
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, HAML, Liquid, Markaby, Remarkably and its own engine
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% documentation right now,
64
- just about every part of Ramaze is covered with basic and advanced docs.
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
@@ -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.startup
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
- * Controller.startup
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
- * Adapter.startup
42
- * interpret Global.adapter
43
- * add every created adapter to Global.adapters
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.startup
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.shutdown (iterates Global.adapters)
53
- * Inform.shutdown (iterates all in LogHub)
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">#{link self, :new, :title => 'new entry'}</div>
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><li>#{link self, :edit, entry.oid, :title => 'edit'}</li><li>#{link self, :delete, entry.oid, :title => 'delete'}</li></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,13 @@
1
+ #!/usr/bin/ruby
2
+ require "rubygems"
3
+ require "rack"
4
+ require "ramaze"
5
+
6
+ class MainController < Ramaze::Controller
7
+ def index
8
+ "Hello, World!"
9
+ end
10
+ end
11
+
12
+ Ramaze::Global.adapter = :fcgi
13
+ Ramaze.start
@@ -0,0 +1,8 @@
1
+ require 'ramaze'
2
+ require 'bluecloth'
3
+
4
+ require 'src/page'
5
+ require 'src/model'
6
+ require 'src/controller'
7
+
8
+ Ramaze.start :adapter => :mongrel
@@ -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
@@ -0,0 +1,2 @@
1
+ # Hello, World
2
+ ## This is the first test of this most awesome wiki
@@ -0,0 +1,2 @@
1
+ # Hello, World
2
+ ## This is the first test of this most awesome [[rawiki]]
@@ -0,0 +1,2 @@
1
+ # Hello, World
2
+ This is the first test of this most awesome [[wiktaculous]]
@@ -0,0 +1,3 @@
1
+ # Markdown
2
+
3
+ Markdown is a engine for converting plain text to [[HTML]]. You can find more information at [markdown homepage](http://daringfireball.net/projects/markdown/)
@@ -0,0 +1,2 @@
1
+ # Just a test
2
+ ## nothing serious
@@ -0,0 +1,3 @@
1
+ # Just a test
2
+ ## nothing serious
3
+ ### Even less serious
@@ -0,0 +1,11 @@
1
+ # Just a test
2
+
3
+ Some more text
4
+
5
+ ## nothing serious
6
+
7
+ And some text
8
+
9
+ ### Even less serious
10
+
11
+ Here is a [[link]]
@@ -0,0 +1,13 @@
1
+ # Just a test
2
+
3
+ Some more text
4
+
5
+ ## nothing serious
6
+
7
+ And some text
8
+
9
+ ### Even less serious
10
+
11
+ Here is a [[link]]
12
+
13
+ <a href="foo">foo</a>
@@ -0,0 +1,17 @@
1
+ # Just a test
2
+
3
+ Some more text
4
+
5
+ ## nothing serious
6
+
7
+ And some text
8
+
9
+ ### Even less serious
10
+
11
+ Here is a [[link]]
12
+
13
+ <html>
14
+ <head>
15
+ <a href="foo">foo</a>
16
+ </head>
17
+ </html>
@@ -0,0 +1,17 @@
1
+ # Just a test
2
+
3
+ Some more text
4
+
5
+ ## nothing serious
6
+
7
+ And some text
8
+
9
+ ### Even less serious
10
+
11
+ Here is a [[link]]
12
+
13
+ <html>
14
+ <head>
15
+ <a href="foo">foo</a>
16
+ </head>
17
+ </html>
@@ -0,0 +1,17 @@
1
+ # Just a test
2
+
3
+ Some more text
4
+
5
+ ## nothing serious
6
+
7
+ And some text
8
+
9
+ ### Even less serious
10
+
11
+ Here is a [[link]]
12
+
13
+ <html>
14
+ <head>
15
+ <a href="foo">foo</a>
16
+ </head>
17
+ </html>
@@ -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
+ }