merb 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README +22 -4
- data/Rakefile +15 -3
- data/TODO +2 -3
- data/bin/merb +61 -36
- data/examples/sample_app/dist/app/controllers/files.rb +31 -0
- data/examples/sample_app/dist/app/controllers/posts.rb +26 -2
- data/examples/sample_app/dist/app/controllers/test.rb +7 -1
- data/examples/sample_app/dist/app/views/files/progress.jerb +3 -0
- data/examples/sample_app/dist/app/views/files/start.herb +62 -0
- data/examples/sample_app/dist/app/views/files/upload.herb +6 -0
- data/examples/sample_app/dist/app/views/layout/{application.rhtml → application.herb} +2 -3
- data/examples/sample_app/dist/app/views/layout/{foo.rhtml → foo.herb} +0 -0
- data/examples/sample_app/dist/app/views/posts/{_comments.rhtml → _comments.herb} +0 -0
- data/examples/sample_app/dist/app/views/posts/comment.jerb +1 -0
- data/examples/sample_app/dist/app/views/posts/{list.rhtml → list.herb} +0 -0
- data/examples/sample_app/dist/app/views/posts/{new.rhtml → new.herb} +0 -0
- data/examples/sample_app/dist/app/views/posts/{show.rhtml → show.herb} +0 -0
- data/examples/sample_app/dist/app/views/posts/xml_test.xerb +3 -0
- data/examples/sample_app/dist/app/views/test/{foo.rhtml → foo.herb} +0 -0
- data/examples/sample_app/dist/app/views/test/{hello.rhtml → hello.herb} +0 -0
- data/examples/sample_app/dist/app/views/test/json.jerb +1 -0
- data/examples/sample_app/dist/conf/merb.yml +11 -0
- data/examples/sample_app/dist/conf/merb_init.rb +1 -1
- data/examples/sample_app/dist/conf/mup.conf +11 -0
- data/examples/sample_app/dist/public/javascripts/mup.js +113 -0
- data/examples/sample_app/script/merb_stop +7 -3
- data/examples/sample_app/script/startdrb +8 -0
- data/lib/merb.rb +37 -2
- data/lib/merb/merb_class_extensions.rb +21 -22
- data/lib/merb/merb_controller.rb +101 -33
- data/lib/merb/merb_handler.rb +26 -25
- data/lib/merb/merb_router.rb +1 -1
- data/lib/merb/merb_utils.rb +35 -37
- data/lib/merb/mixins/basic_authentication_mixin.rb +39 -0
- data/lib/merb/mixins/controller_mixin.rb +119 -115
- data/lib/merb/mixins/javascript_mixin.rb +63 -0
- data/lib/merb/mixins/render_mixin.rb +85 -69
- data/lib/merb/mixins/responder_mixin.rb +38 -0
- data/lib/merb/session/merb_drb_server.rb +107 -0
- data/lib/merb/session/merb_drb_session.rb +71 -0
- data/lib/merb/session/merb_session.rb +1 -0
- data/lib/merb/vendor/paginator/README.txt +84 -0
- data/lib/merb/vendor/paginator/paginator.rb +121 -0
- data/lib/mutex_hotfix.rb +34 -0
- metadata +41 -63
- data/doc/rdoc/classes/ControllerMixin.html +0 -676
- data/doc/rdoc/classes/Hash.html +0 -148
- data/doc/rdoc/classes/Merb.html +0 -140
- data/doc/rdoc/classes/Merb/Controller.html +0 -338
- data/doc/rdoc/classes/Merb/RouteMatcher.html +0 -388
- data/doc/rdoc/classes/Merb/Server.html +0 -148
- data/doc/rdoc/classes/Merb/Session.html +0 -201
- data/doc/rdoc/classes/Merb/SessionMixin.html +0 -199
- data/doc/rdoc/classes/MerbControllerError.html +0 -111
- data/doc/rdoc/classes/MerbHandler.html +0 -430
- data/doc/rdoc/classes/MerbHash.html +0 -469
- data/doc/rdoc/classes/MerbHash/Mutex.html +0 -198
- data/doc/rdoc/classes/Noroutefound.html +0 -153
- data/doc/rdoc/classes/Object.html +0 -149
- data/doc/rdoc/classes/RenderMixin.html +0 -362
- data/doc/rdoc/classes/String.html +0 -212
- data/doc/rdoc/classes/Symbol.html +0 -179
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/LICENSE.html +0 -129
- data/doc/rdoc/files/README.html +0 -417
- data/doc/rdoc/files/TODO.html +0 -151
- data/doc/rdoc/files/lib/merb/merb_class_extensions_rb.html +0 -101
- data/doc/rdoc/files/lib/merb/merb_controller_rb.html +0 -101
- data/doc/rdoc/files/lib/merb/merb_handler_rb.html +0 -101
- data/doc/rdoc/files/lib/merb/merb_router_rb.html +0 -101
- data/doc/rdoc/files/lib/merb/merb_utils_rb.html +0 -108
- data/doc/rdoc/files/lib/merb/mixins/controller_mixin_rb.html +0 -101
- data/doc/rdoc/files/lib/merb/mixins/render_mixin_rb.html +0 -101
- data/doc/rdoc/files/lib/merb/session/merb_session_rb.html +0 -101
- data/doc/rdoc/files/lib/merb_rb.html +0 -140
- data/doc/rdoc/files/lib/merb_tasks_rb.html +0 -101
- data/doc/rdoc/fr_class_index.html +0 -43
- data/doc/rdoc/fr_file_index.html +0 -40
- data/doc/rdoc/fr_method_index.html +0 -104
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/examples/sample_app/dist/app/controllers/upload.rb +0 -29
- data/examples/sample_app/dist/app/views/posts/comment.merbjs +0 -1
- data/examples/sample_app/dist/app/views/upload/start.rhtml +0 -15
- data/examples/sample_app/dist/app/views/upload/upload.rhtml +0 -4
- data/examples/sample_app/dist/public/files/README +0 -35
- data/examples/sample_app/dist/public/files/setup.rb +0 -1346
- data/examples/sample_app/log/merb.log +0 -778
@@ -1,179 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: Symbol</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Symbol</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../files/lib/merb/merb_utils_rb.html">
|
59
|
-
lib/merb/merb_utils.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
<a href="Object.html">
|
69
|
-
Object
|
70
|
-
</a>
|
71
|
-
</td>
|
72
|
-
</tr>
|
73
|
-
</table>
|
74
|
-
</div>
|
75
|
-
<!-- banner header -->
|
76
|
-
|
77
|
-
<div id="bodyContent">
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<div id="contextContent">
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
</div>
|
86
|
-
|
87
|
-
<div id="method-list">
|
88
|
-
<h3 class="section-bar">Methods</h3>
|
89
|
-
|
90
|
-
<div class="name-list">
|
91
|
-
<a href="#M000002">to_proc</a>
|
92
|
-
<a href="#M000001">to_s</a>
|
93
|
-
</div>
|
94
|
-
</div>
|
95
|
-
|
96
|
-
</div>
|
97
|
-
|
98
|
-
|
99
|
-
<!-- if includes -->
|
100
|
-
|
101
|
-
<div id="section">
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
<!-- if method_list -->
|
111
|
-
<div id="methods">
|
112
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
113
|
-
|
114
|
-
<div id="method-M000002" class="method-detail">
|
115
|
-
<a name="M000002"></a>
|
116
|
-
|
117
|
-
<div class="method-heading">
|
118
|
-
<a href="#M000002" class="method-signature">
|
119
|
-
<span class="method-name">to_proc</span><span class="method-args">()</span>
|
120
|
-
</a>
|
121
|
-
</div>
|
122
|
-
|
123
|
-
<div class="method-description">
|
124
|
-
<p>
|
125
|
-
["foo", "bar"].map &:reverse #=>
|
126
|
-
[‘oof’, ‘rab’]
|
127
|
-
</p>
|
128
|
-
<p><a class="source-toggle" href="#"
|
129
|
-
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
130
|
-
<div class="method-source-code" id="M000002-source">
|
131
|
-
<pre>
|
132
|
-
<span class="ruby-comment cmt"># File lib/merb/merb_utils.rb, line 34</span>
|
133
|
-
34: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_proc</span>
|
134
|
-
35: <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span>{<span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">shift</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)}
|
135
|
-
36: <span class="ruby-keyword kw">end</span>
|
136
|
-
</pre>
|
137
|
-
</div>
|
138
|
-
</div>
|
139
|
-
</div>
|
140
|
-
|
141
|
-
<div id="method-M000001" class="method-detail">
|
142
|
-
<a name="M000001"></a>
|
143
|
-
|
144
|
-
<div class="method-heading">
|
145
|
-
<a href="#M000001" class="method-signature">
|
146
|
-
<span class="method-name">to_s</span><span class="method-args">()</span>
|
147
|
-
</a>
|
148
|
-
</div>
|
149
|
-
|
150
|
-
<div class="method-description">
|
151
|
-
<p>
|
152
|
-
faster <a href="Symbol.html#M000001">Symbol#to_s</a> to speed up routing.
|
153
|
-
</p>
|
154
|
-
<p><a class="source-toggle" href="#"
|
155
|
-
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
156
|
-
<div class="method-source-code" id="M000001-source">
|
157
|
-
<pre>
|
158
|
-
<span class="ruby-comment cmt"># File lib/merb/merb_utils.rb, line 29</span>
|
159
|
-
29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
160
|
-
30: <span class="ruby-ivar">@str_rep</span> <span class="ruby-operator">||</span> (<span class="ruby-ivar">@str_rep</span> = <span class="ruby-identifier">id2name</span>.<span class="ruby-identifier">freeze</span>)
|
161
|
-
31: <span class="ruby-keyword kw">end</span>
|
162
|
-
</pre>
|
163
|
-
</div>
|
164
|
-
</div>
|
165
|
-
</div>
|
166
|
-
|
167
|
-
|
168
|
-
</div>
|
169
|
-
|
170
|
-
|
171
|
-
</div>
|
172
|
-
|
173
|
-
|
174
|
-
<div id="validator-badges">
|
175
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
176
|
-
</div>
|
177
|
-
|
178
|
-
</body>
|
179
|
-
</html>
|
data/doc/rdoc/created.rid
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Thu Nov 09 19:39:10 -0800 2006
|
data/doc/rdoc/files/LICENSE.html
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: LICENSE</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>LICENSE</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>LICENSE
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Sat Oct 14 14:18:28 -0700 2006</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
<div id="description">
|
72
|
-
<p>
|
73
|
-
Copyright (c) 2006 Ezra Zygmuntowicz
|
74
|
-
</p>
|
75
|
-
<p>
|
76
|
-
Permission is hereby granted, free of charge, to any person obtaining a
|
77
|
-
copy of this software and associated documentation files (the
|
78
|
-
"Software"), to deal in the Software without restriction,
|
79
|
-
including without limitation the rights to use, copy, modify, merge,
|
80
|
-
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
81
|
-
permit persons to whom the Software is furnished to do so, subject to the
|
82
|
-
following conditions:
|
83
|
-
</p>
|
84
|
-
<p>
|
85
|
-
The above copyright notice and this permission notice shall be included in
|
86
|
-
all copies or substantial portions of the Software.
|
87
|
-
</p>
|
88
|
-
<p>
|
89
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
90
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
91
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
92
|
-
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
93
|
-
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
94
|
-
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
95
|
-
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
96
|
-
</p>
|
97
|
-
|
98
|
-
</div>
|
99
|
-
|
100
|
-
|
101
|
-
</div>
|
102
|
-
|
103
|
-
|
104
|
-
</div>
|
105
|
-
|
106
|
-
|
107
|
-
<!-- if includes -->
|
108
|
-
|
109
|
-
<div id="section">
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
<!-- if method_list -->
|
119
|
-
|
120
|
-
|
121
|
-
</div>
|
122
|
-
|
123
|
-
|
124
|
-
<div id="validator-badges">
|
125
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
126
|
-
</div>
|
127
|
-
|
128
|
-
</body>
|
129
|
-
</html>
|
data/doc/rdoc/files/README.html
DELETED
@@ -1,417 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: README</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>README</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>README
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Thu Nov 09 17:41:04 -0800 2006</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
<div id="description">
|
72
|
-
<p>
|
73
|
-
Copyright (c) 2006 Ezra Zygmuntowicz
|
74
|
-
</p>
|
75
|
-
<p>
|
76
|
-
<a href="../classes/Merb.html">Merb</a>. Mongrel+Erb
|
77
|
-
</p>
|
78
|
-
<p>
|
79
|
-
Little bitty lightweight ruby app server. For when you really need
|
80
|
-
performance for simple dynamic pages.
|
81
|
-
</p>
|
82
|
-
<p>
|
83
|
-
**Sample APP included**
|
84
|
-
</p>
|
85
|
-
<p>
|
86
|
-
Unpack the gem and grab the sample app
|
87
|
-
</p>
|
88
|
-
<p>
|
89
|
-
$ gem unpack merb
|
90
|
-
</p>
|
91
|
-
<p>
|
92
|
-
cd merb* cd examples/sample_app
|
93
|
-
</p>
|
94
|
-
<p>
|
95
|
-
$ merb
|
96
|
-
</p>
|
97
|
-
<p>
|
98
|
-
then the sample app will be running on port 4000 in the foreground. you can
|
99
|
-
go to a few urls:
|
100
|
-
</p>
|
101
|
-
<p>
|
102
|
-
<a
|
103
|
-
href="http://localhost:4000/upload/start">localhost:4000/upload/start</a>
|
104
|
-
</p>
|
105
|
-
<p>
|
106
|
-
<a
|
107
|
-
href="http://localhost:4000/foo/123/baz/12234345">localhost:4000/foo/123/baz/12234345</a>
|
108
|
-
</p>
|
109
|
-
<p>
|
110
|
-
*<b>FEATURES</b>* 1. Mongrel handler built in that parses incoming requests
|
111
|
-
including multipart uploads and post as well as ?query=strings. Puts the
|
112
|
-
params into params and the cookies into cookies when it instantiates your
|
113
|
-
controller class.
|
114
|
-
</p>
|
115
|
-
<ol>
|
116
|
-
<li>RouteMatcher and route compiler. Reads your route definition and compiles
|
117
|
-
|
118
|
-
</li>
|
119
|
-
</ol>
|
120
|
-
<p>
|
121
|
-
a method on the fly that will match the request path against each route and
|
122
|
-
do the right thing. So the following routes:
|
123
|
-
</p>
|
124
|
-
<p>
|
125
|
-
Merb::RouteMatcher.prepare do |r|
|
126
|
-
</p>
|
127
|
-
<pre>
|
128
|
-
r.add '/foo/:bar/baz/:id', :controller => 'Test', :action => 'foo'
|
129
|
-
r.add '/:controller/:action/:id'
|
130
|
-
r.add '/bar/:*rest', :controller => 'Test', :action => 'glob'
|
131
|
-
</pre>
|
132
|
-
<p>
|
133
|
-
end
|
134
|
-
</p>
|
135
|
-
<p>
|
136
|
-
Will be compiled and defined as a method with this lambda as the body:
|
137
|
-
</p>
|
138
|
-
<p>
|
139
|
-
lambda{|path|
|
140
|
-
</p>
|
141
|
-
<pre>
|
142
|
-
case path
|
143
|
-
when Regexp.new('/foo/([^/;.,?]+)/baz/([^/;.,?]+)')
|
144
|
-
@sections[:bar] = $1
|
145
|
-
@sections[:id] = $2
|
146
|
-
return {:controller=>"Test", :action=>"foo"}.merge(@sections)
|
147
|
-
when /\A\/([^\/;.,?]+)(?:\/?\Z|\/([^\/;.,?]+)\/?)(?:\/?\Z|\/([^\/;.,?]+)\/?)\Z/
|
148
|
-
@sections[:controller] = $1
|
149
|
-
@sections[:action] = $2 || 'index'
|
150
|
-
@sections[:id] = $3 || nil
|
151
|
-
return @sections
|
152
|
-
when Regexp.new('/bar/([^;.,?]+)')
|
153
|
-
@sections[:rest] = $1
|
154
|
-
return {:controller=>"Test", :action=>"glob"}.merge(@sections)
|
155
|
-
else
|
156
|
-
return {:controller=>'Noroutefound', :action=>'noroute'}
|
157
|
-
end
|
158
|
-
</pre>
|
159
|
-
<p>
|
160
|
-
}
|
161
|
-
</p>
|
162
|
-
<ol>
|
163
|
-
<li>Simple controller classes with built in render method and template handling
|
164
|
-
|
165
|
-
</li>
|
166
|
-
</ol>
|
167
|
-
<p>
|
168
|
-
with instance vars available in the views automatically. <a
|
169
|
-
href="../classes/Merb.html">Merb</a> also supports layouts. It will look
|
170
|
-
for a layout named after your controller class first and then fall back to
|
171
|
-
application.rhtml if no layout exists named after your controller. You can
|
172
|
-
use render_no_layout or do layout :none right before you render
|
173
|
-
</p>
|
174
|
-
<p>
|
175
|
-
class Test < <a
|
176
|
-
href="../classes/Merb/Controller.html">Merb::Controller</a>
|
177
|
-
</p>
|
178
|
-
<pre>
|
179
|
-
def hello
|
180
|
-
# params, headers and cookies are available here.
|
181
|
-
@name = params[:name]
|
182
|
-
render
|
183
|
-
end
|
184
|
-
</pre>
|
185
|
-
<p>
|
186
|
-
end
|
187
|
-
</p>
|
188
|
-
<p>
|
189
|
-
<html>
|
190
|
-
</p>
|
191
|
-
<pre>
|
192
|
-
<head>
|
193
|
-
<title>Hello, <%= @name %></title>
|
194
|
-
</head>
|
195
|
-
<body>
|
196
|
-
</pre>
|
197
|
-
<p>
|
198
|
-
<%= @layout_content %>
|
199
|
-
</p>
|
200
|
-
<pre>
|
201
|
-
</body>
|
202
|
-
</pre>
|
203
|
-
<p>
|
204
|
-
</html>
|
205
|
-
</p>
|
206
|
-
<p>
|
207
|
-
<h1><%= params.inspect %></h1> <h1><%=
|
208
|
-
cookies.inspect %></h1> <% 5.times do %>
|
209
|
-
</p>
|
210
|
-
<pre>
|
211
|
-
<h1>Hello, <%= @name %>!</h1>
|
212
|
-
</pre>
|
213
|
-
<p>
|
214
|
-
<% end %>
|
215
|
-
</p>
|
216
|
-
<p>
|
217
|
-
You can also render partials like so: <%= partial(:comments) %>
|
218
|
-
</p>
|
219
|
-
<p>
|
220
|
-
This assumes a _comments.rhtml file in the same view dir as the current
|
221
|
-
controller/view
|
222
|
-
</p>
|
223
|
-
<p>
|
224
|
-
<a href="../classes/Merb.html">Merb</a> also allows for returning
|
225
|
-
javascript instead of html for ajax actions You have to use the render_js
|
226
|
-
instead of normal render
|
227
|
-
</p>
|
228
|
-
<p>
|
229
|
-
def ajax_action
|
230
|
-
</p>
|
231
|
-
<pre>
|
232
|
-
@posts = Post.find :all
|
233
|
-
render_js
|
234
|
-
</pre>
|
235
|
-
<p>
|
236
|
-
end
|
237
|
-
</p>
|
238
|
-
<p>
|
239
|
-
# ajax_action.merbjs $(‘comments’).update(’<%=
|
240
|
-
escape_js(partial(:posts)) %>’);
|
241
|
-
</p>
|
242
|
-
<p>
|
243
|
-
# _posts.rhtml <ul>
|
244
|
-
</p>
|
245
|
-
<pre>
|
246
|
-
<% @posts.each do |p| %>
|
247
|
-
<li>
|
248
|
-
<%= p.title %><br />
|
249
|
-
<%= p.body %>
|
250
|
-
</li>
|
251
|
-
<% end %>
|
252
|
-
</pre>
|
253
|
-
<p>
|
254
|
-
</ul>
|
255
|
-
</p>
|
256
|
-
<p>
|
257
|
-
Controllers also now have before filters. Use the before method in your
|
258
|
-
controllers. before accepts either a symbol or a Proc/lambda object. If you
|
259
|
-
give it a symbol it will call a method with the same name as the symbol. If
|
260
|
-
you give it a proc that takes one argument it will call the proc with the
|
261
|
-
current controller as that argument.
|
262
|
-
</p>
|
263
|
-
<p>
|
264
|
-
class Foo < <a
|
265
|
-
href="../classes/Merb/Controller.html">Merb::Controller</a>
|
266
|
-
</p>
|
267
|
-
<pre>
|
268
|
-
before :setup_user
|
269
|
-
before lambda {|c| c.headers['X-Foo] = 'bar' }
|
270
|
-
|
271
|
-
def setup_user
|
272
|
-
# blah blah
|
273
|
-
end
|
274
|
-
|
275
|
-
def regular_action
|
276
|
-
# blah
|
277
|
-
end
|
278
|
-
</pre>
|
279
|
-
<p>
|
280
|
-
end
|
281
|
-
</p>
|
282
|
-
<p>
|
283
|
-
Sessions are available when you start merb with the -s flag. See sample app
|
284
|
-
for migration too add session table.
|
285
|
-
</p>
|
286
|
-
<ol>
|
287
|
-
<li>the server. right now you add your routes in
|
288
|
-
|
289
|
-
</li>
|
290
|
-
</ol>
|
291
|
-
<p>
|
292
|
-
the appdir/conf/router.rb file. So by default it runs on port 4000
|
293
|
-
</p>
|
294
|
-
<p>
|
295
|
-
$ cd /path/to/your/merb/app $ merb
|
296
|
-
</p>
|
297
|
-
<p>
|
298
|
-
Or to start merb on a different port: $ merb -p 3500
|
299
|
-
</p>
|
300
|
-
<p>
|
301
|
-
To start a cluster of merb servers you specify the first port and then how
|
302
|
-
many servers you want spawned. SO this command will start a merb instance
|
303
|
-
on ports 3000, 3001, 3002
|
304
|
-
</p>
|
305
|
-
<p>
|
306
|
-
$ merb -p 3000 -c 3
|
307
|
-
</p>
|
308
|
-
<p>
|
309
|
-
To start a <a href="../classes/Merb.html">Merb</a> IRB console where all
|
310
|
-
your models and other classes are pre loaded use the -i flag
|
311
|
-
</p>
|
312
|
-
<p>
|
313
|
-
$merb -i
|
314
|
-
</p>
|
315
|
-
<ol>
|
316
|
-
<li>File uploads. This is the thing that <a
|
317
|
-
href="../classes/Merb.html">Merb</a> was written for. Rails doesn‘t
|
318
|
-
allow
|
319
|
-
|
320
|
-
</li>
|
321
|
-
</ol>
|
322
|
-
<p>
|
323
|
-
multiple concurrent file uploads at once without blocking an entire rails
|
324
|
-
backend for each file upload. <a href="../classes/Merb.html">Merb</a>
|
325
|
-
allows multiple file uploads at once. Start the server and browse to <a
|
326
|
-
href="http://localhost:4000/upload/start">localhost:4000/upload/start</a>
|
327
|
-
and you will get a file upload form. There is a very simple upload
|
328
|
-
controller example that handles this upload. When a file is uploaded with
|
329
|
-
<a href="../classes/Merb.html">Merb</a>, it gets put in a Tempfile. So you
|
330
|
-
just want to copy it to the right place on the filesystem.
|
331
|
-
</p>
|
332
|
-
<p>
|
333
|
-
def upload
|
334
|
-
</p>
|
335
|
-
<pre>
|
336
|
-
puts params[:file].inspect
|
337
|
-
|
338
|
-
FileUtils.mv params[:file][:tempfile].path, MERB_ROOT+"/uploads/#{params[:file][:filename]}"
|
339
|
-
|
340
|
-
render
|
341
|
-
</pre>
|
342
|
-
<p>
|
343
|
-
end
|
344
|
-
</p>
|
345
|
-
<ol>
|
346
|
-
<li><a href="../classes/Merb.html">Merb</a> app layout. A <a
|
347
|
-
href="../classes/Merb.html">Merb</a> app contains everything it needs to
|
348
|
-
run in production in the
|
349
|
-
|
350
|
-
</li>
|
351
|
-
</ol>
|
352
|
-
<p>
|
353
|
-
MERB_ROOT/dist directory. So for deployment you only need to deploy the
|
354
|
-
dist dir. This keeps your test code and development plugins separate from
|
355
|
-
your main app and lets you not deploy them to the live server. You deal
|
356
|
-
with two things with this setup, MERB_ROOT and DIST_ROOT. MERB_ROOT is the
|
357
|
-
root of the whole tree. And DISTROOT is MERB_ROOT+/dist You will cd into
|
358
|
-
MERB_ROOT to run the merb command line. ANd when you deploy live you will
|
359
|
-
put the dist dir into another empty MERB_ROOT on the production server.
|
360
|
-
</p>
|
361
|
-
<p>
|
362
|
-
app_skeleton
|
363
|
-
</p>
|
364
|
-
<pre>
|
365
|
-
Rakefile
|
366
|
-
README
|
367
|
-
scripts
|
368
|
-
test
|
369
|
-
test_helper.rb
|
370
|
-
fixtures
|
371
|
-
spec
|
372
|
-
unit
|
373
|
-
plugins
|
374
|
-
dist
|
375
|
-
app
|
376
|
-
controllers
|
377
|
-
models
|
378
|
-
views
|
379
|
-
conf
|
380
|
-
lib
|
381
|
-
public
|
382
|
-
plugins
|
383
|
-
schema
|
384
|
-
</pre>
|
385
|
-
|
386
|
-
</div>
|
387
|
-
|
388
|
-
|
389
|
-
</div>
|
390
|
-
|
391
|
-
|
392
|
-
</div>
|
393
|
-
|
394
|
-
|
395
|
-
<!-- if includes -->
|
396
|
-
|
397
|
-
<div id="section">
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
<!-- if method_list -->
|
407
|
-
|
408
|
-
|
409
|
-
</div>
|
410
|
-
|
411
|
-
|
412
|
-
<div id="validator-badges">
|
413
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
414
|
-
</div>
|
415
|
-
|
416
|
-
</body>
|
417
|
-
</html>
|