merb 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/README +64 -80
  2. data/Rakefile +25 -12
  3. data/bin/merb +2 -223
  4. data/examples/README_EXAMPLES +10 -0
  5. data/examples/skeleton.tar +0 -0
  6. data/lib/merb.rb +48 -21
  7. data/lib/merb/core_ext.rb +12 -2
  8. data/lib/merb/core_ext/merb_class.rb +21 -21
  9. data/lib/merb/core_ext/merb_kernel.rb +60 -0
  10. data/lib/merb/core_ext/merb_object.rb +14 -0
  11. data/lib/merb/core_ext/merb_string.rb +3 -13
  12. data/lib/merb/generators/merb_app/merb_app.rb +33 -0
  13. data/lib/merb/merb_constants.rb +7 -0
  14. data/lib/merb/merb_controller.rb +31 -23
  15. data/lib/merb/merb_drb_server.rb +6 -60
  16. data/lib/merb/merb_exceptions.rb +162 -2
  17. data/lib/merb/merb_handler.rb +8 -19
  18. data/lib/merb/merb_mailer.rb +60 -0
  19. data/lib/merb/merb_router.rb +1 -1
  20. data/lib/merb/merb_server.rb +240 -0
  21. data/lib/merb/merb_upload_handler.rb +1 -1
  22. data/lib/merb/merb_view_context.rb +11 -6
  23. data/lib/merb/mixins/basic_authentication_mixin.rb +11 -13
  24. data/lib/merb/mixins/controller_mixin.rb +12 -6
  25. data/lib/merb/mixins/form_control_mixin.rb +94 -0
  26. data/lib/merb/mixins/render_mixin.rb +50 -24
  27. data/lib/merb/mixins/view_context_mixin.rb +122 -0
  28. data/lib/merb/session/merb_ar_session.rb +13 -14
  29. data/lib/merb/session/merb_memory_session.rb +105 -0
  30. metadata +13 -132
  31. data/examples/app_skeleton/Rakefile +0 -82
  32. data/examples/app_skeleton/dist/app/helpers/global_helper.rb +0 -6
  33. data/examples/app_skeleton/dist/conf/merb.yml +0 -11
  34. data/examples/app_skeleton/dist/conf/merb_init.rb +0 -16
  35. data/examples/app_skeleton/dist/conf/mup.conf +0 -5
  36. data/examples/app_skeleton/dist/conf/router.rb +0 -19
  37. data/examples/app_skeleton/scripts/merb_stop +0 -13
  38. data/examples/app_skeleton/scripts/new_migration +0 -21
  39. data/examples/app_skeleton/test/test_helper.rb +0 -1
  40. data/examples/sample_app/Rakefile +0 -82
  41. data/examples/sample_app/dist/app/controllers/files.rb +0 -31
  42. data/examples/sample_app/dist/app/controllers/posts.rb +0 -71
  43. data/examples/sample_app/dist/app/controllers/test.rb +0 -40
  44. data/examples/sample_app/dist/app/helpers/global_helper.rb +0 -7
  45. data/examples/sample_app/dist/app/helpers/posts_helper.rb +0 -4
  46. data/examples/sample_app/dist/app/models/comment.rb +0 -3
  47. data/examples/sample_app/dist/app/models/post.rb +0 -4
  48. data/examples/sample_app/dist/app/views/files/progress.jerb +0 -3
  49. data/examples/sample_app/dist/app/views/files/start.herb +0 -62
  50. data/examples/sample_app/dist/app/views/files/upload.herb +0 -6
  51. data/examples/sample_app/dist/app/views/layout/application.herb +0 -61
  52. data/examples/sample_app/dist/app/views/layout/foo.herb +0 -6
  53. data/examples/sample_app/dist/app/views/posts/_comments.herb +0 -11
  54. data/examples/sample_app/dist/app/views/posts/comment.jerb +0 -1
  55. data/examples/sample_app/dist/app/views/posts/list.herb +0 -5
  56. data/examples/sample_app/dist/app/views/posts/new.herb +0 -37
  57. data/examples/sample_app/dist/app/views/posts/show.herb +0 -37
  58. data/examples/sample_app/dist/app/views/posts/xml_test.xerb +0 -3
  59. data/examples/sample_app/dist/app/views/shared/_test.herb +0 -1
  60. data/examples/sample_app/dist/app/views/test/foo.herb +0 -2
  61. data/examples/sample_app/dist/app/views/test/hello.herb +0 -5
  62. data/examples/sample_app/dist/app/views/test/json.jerb +0 -1
  63. data/examples/sample_app/dist/conf/merb.yml +0 -11
  64. data/examples/sample_app/dist/conf/merb_init.rb +0 -24
  65. data/examples/sample_app/dist/conf/mup.conf +0 -5
  66. data/examples/sample_app/dist/conf/router.rb +0 -19
  67. data/examples/sample_app/dist/public/images/bg.jpg +0 -0
  68. data/examples/sample_app/dist/public/images/book.gif +0 -0
  69. data/examples/sample_app/dist/public/images/booksmall.gif +0 -0
  70. data/examples/sample_app/dist/public/images/greenright.jpg +0 -0
  71. data/examples/sample_app/dist/public/images/louiecon.gif +0 -0
  72. data/examples/sample_app/dist/public/images/menu.gif +0 -0
  73. data/examples/sample_app/dist/public/images/menuleft.gif +0 -0
  74. data/examples/sample_app/dist/public/images/menuright.gif +0 -0
  75. data/examples/sample_app/dist/public/images/mountain.jpg +0 -0
  76. data/examples/sample_app/dist/public/images/n3.jpg +0 -0
  77. data/examples/sample_app/dist/public/images/nautica.jpg +0 -0
  78. data/examples/sample_app/dist/public/javascripts/application.js +0 -0
  79. data/examples/sample_app/dist/public/javascripts/effects.js +0 -975
  80. data/examples/sample_app/dist/public/javascripts/mup.js +0 -113
  81. data/examples/sample_app/dist/public/javascripts/prototype.js +0 -2264
  82. data/examples/sample_app/dist/public/stylesheets/merb.css +0 -277
  83. data/examples/sample_app/dist/public/test.html +0 -5
  84. data/examples/sample_app/dist/schema/migrations/001_add_comments_to_posts.rb +0 -22
  85. data/examples/sample_app/dist/schema/migrations/002_add_sessions_table.rb +0 -14
  86. data/examples/sample_app/dist/schema/schema.rb +0 -28
  87. data/examples/sample_app/foo.txt +0 -0
  88. data/examples/sample_app/log/merb.4000.pid +0 -1
  89. data/examples/sample_app/script/merb_stop +0 -13
  90. data/examples/sample_app/script/new_migration +0 -21
  91. data/examples/sample_app/test/test_helper.rb +0 -1
  92. data/lib/merb/mixins/javascript_mixin.rb +0 -147
  93. data/lib/merb/session/merb_drb_session.rb +0 -65
  94. data/test/test_helper.rb +0 -1
  95. data/test/unit/route_matcher_test.rb +0 -46
@@ -1,277 +0,0 @@
1
-
2
- html{
3
- padding:0;
4
- margin:0;
5
- }
6
-
7
- body{
8
- background:#ffffff url('/images/bg.jpg') top center repeat-x;
9
- margin:0;
10
- padding:0;
11
- color:#999999;
12
- font-family:"Trebuchet MS",arial,sans-serif;
13
- font-size:62.5%;
14
- text-align:center;
15
- }
16
-
17
- h1{
18
- font-family:"Trebuchet MS",arial,sans-serif;
19
- font-size:2.6em;
20
- font-weight:normal;
21
- background:#fff url(/images/booksmall.gif) no-repeat bottom left;
22
- padding:0 0 10px 50px;
23
- margin:20px 5px 5px 5px;
24
- }
25
-
26
- h3{
27
- color:#9aba11;
28
- font-family:geneva,arial,sans-serif;
29
- font-weight:normal;
30
- text-transform:uppercase;
31
- word-spacing:4px;
32
- letter-spacing:3px;
33
- font-size:0.8em;
34
- font-weight:bold;
35
- padding:0 2px;
36
- margin:0;
37
- }
38
-
39
- h2{
40
- font-family:"Lucida Grande","Lucida Sans Unicode",arial,sans-serif;
41
- font-size:1.4em;
42
- margin:auto;
43
- text-transform:capitalize;
44
- }
45
-
46
- h2 span{
47
- background:#fff url(/images/booksmall.gif) no-repeat bottom right;
48
- padding:10px 50px 0px 0;
49
- margin:auto;
50
- line-height:2em;
51
- }
52
-
53
- p{
54
- line-height:1.8em;
55
- }
56
-
57
- a{
58
- text-decoration:none;
59
- color:#72a12d;
60
- border-bottom:1px solid #dbe6be;
61
- }
62
-
63
- a:hover{
64
- color:#999999;
65
- background-color:#fcfded;
66
- border-bottom:1px solid #aecb6e;
67
- }
68
-
69
- #border{
70
- width:700px;
71
- padding:0;
72
- margin:15px auto;
73
- background:#fff
74
-
75
- }
76
-
77
- #blogtitle{
78
- width:700px;
79
- margin:10px auto;
80
- padding:0 0 5px 0;
81
- text-align:left;
82
- padding-left: 20px;
83
- font-size:1.1em;
84
- line-height:1.2em;
85
-
86
- }
87
-
88
- #small{
89
- background: url(/images/nautica.jpg) no-repeat;
90
- padding-left: 20px;
91
- }
92
-
93
- #blogtitle a:link, a:visited{
94
- color:#b8ce83;
95
- }
96
-
97
- #blogtitle a:hover, a:active{
98
- color:#cccccc;
99
- }
100
-
101
- #container{
102
- font-size:1.2em;
103
- text-align:left;
104
- margin:0px 0 0px 0;
105
- padding:10px;
106
- border-color:#686923;
107
- border-style:solid;
108
- border-width:0 0px;
109
- }
110
-
111
- #introduction{
112
- float:right;
113
- width:170px;
114
- padding:10px 20px;
115
- margin:20px 0 20px 20px;
116
- background: url(/images/menu.gif) no-repeat;
117
- text-align:center;
118
- line-height:1.5em;
119
- color:#999999;
120
- font-size:1.0em;
121
- font-family:"Lucida Grande","Lucida Sans Unicode",arial,sans-serif;
122
- letter-spacing:0px;
123
- }
124
-
125
- #introduction ul, #introduction li {
126
- text-align:center;
127
- list-style: none;
128
- margin: 0;
129
- padding: 0;
130
- }
131
-
132
- #introduction a {
133
- border-bottom: none;
134
- color:#999999;
135
- }
136
-
137
- #introduction h3{
138
- text-align: center;
139
- position:static;
140
- }
141
-
142
- .splitright {
143
- background-color: #ffffff;
144
- margin:19px 0 0 0;
145
- width: 45%;
146
- float: right;
147
- overflow: hidden;
148
- }
149
-
150
- .splitleft {
151
- background-color: #ffffff;
152
- margin:19px 0 0 0;
153
- width: 45%;
154
- float: left;
155
- overflow: hidden;
156
- }
157
-
158
- .maintext {
159
- background-color: #ffffff;
160
- text-align:justify;
161
- margin:0px auto;
162
- padding-top:5px;
163
- width: 65%;
164
- float: left;
165
- overflow: hidden;
166
- }
167
-
168
- .maintext img{
169
- display:inline;
170
- color:#303030;
171
- border: 2px dashed #CCCCCC;
172
- background-color: #FFFFFF;
173
- top: 0px;
174
- clip: rect(0px,auto,auto,auto);
175
- padding: 2px;
176
- }
177
-
178
- .maintext2 {
179
- background-color: #ffffff;
180
- padding:5px;
181
- margin:0px auto;
182
- width: 75%;
183
- height:45px;
184
- float: left;
185
- overflow: hidden;
186
- }
187
-
188
- .maintext3 {
189
- background-color: #ffffff;
190
- margin:0px 0px 0px 0px;
191
- width: 100%;
192
- float: left;
193
-
194
- }
195
-
196
- #footer{
197
- background-color: #ffffff;
198
- border-top: 1px solid #86C32A;
199
- margin:80px 0 0 0;
200
- padding-top: 5px;
201
- width: 100%;
202
- float: left;
203
- overflow: hidden;
204
- }
205
-
206
-
207
- #footer a{
208
- background-color:#fff;
209
- border:0;
210
- }
211
- #footer a:link, a:visited{
212
- color:#b8ce83;
213
- }
214
-
215
- #footer a:hover, a:active{
216
- color:#999999;
217
- }
218
-
219
- /* ~~~~~~~~~ PROPS FOR THE MENU GO OUT TO EXPLODING-BOY.COM ~~~~~~~~~ */
220
-
221
- #topmenu {
222
- position: relative;
223
- top: 13px;
224
- left: 0px;
225
- width: 600px;
226
- font-size:93%;
227
- margin: 0;
228
- line-height:normal;
229
- height: 35px;
230
- }
231
- #topmenu ul {
232
- margin:0;
233
- padding:0px 0px 0 0px;
234
- list-style:none;
235
- }
236
- #topmenu li {
237
- display:inline;
238
- margin:0;
239
- padding:0;
240
- }
241
- #topmenu a {
242
- float:left;
243
- background:url(/images/menuleft.gif) no-repeat left top;
244
- margin:0;
245
- padding:0 0 0 4px;
246
- text-decoration:none;
247
- }
248
- #topmenu a span {
249
- float:left;
250
- display:block;
251
- background:url(/images/menuright.gif) no-repeat right top;
252
- padding:5px 15px 4px 6px;
253
- color:#669900;
254
- }
255
-
256
- /* Commented Backslash Hack hides rule from IE5-Mac \*/
257
- #topmenu a span {float:none;}
258
- /* End IE5-Mac hack */
259
- #topmenu a:hover span {
260
- color:#999999;
261
- }
262
- #topmenu a:hover {
263
- background-position:0% -42px;
264
- }
265
- #topmenu a:hover span {
266
- background-position:100% -42px;
267
- }
268
-
269
- .left{
270
- margin:10px 10px 5px 0;
271
- float:left;
272
- }
273
-
274
- .right{
275
- margin:2px 0 2px 2px;
276
- float:right;
277
- }
@@ -1,5 +0,0 @@
1
- <html>
2
- <body>
3
- <h1>Static cached page!</h1>
4
- </body>
5
- </html>
@@ -1,22 +0,0 @@
1
- class AddCommentsToPosts < ActiveRecord::Migration
2
- def self.up
3
- create_table "posts", :force => true do |t|
4
- t.column "title", :string
5
- t.column "body", :text
6
- t.column "created_at", :datetime
7
- t.column "updated_at", :datetime
8
- end
9
- create_table "comments" do |t|
10
- t.column "post_id", :integer
11
- t.column "name", :string
12
- t.column "body", :text
13
- t.column "created_at", :datetime
14
- t.column "updated_at", :datetime
15
- end
16
- end
17
-
18
- def self.down
19
- drop_table "comments"
20
- drop_table "posts"
21
- end
22
- end
@@ -1,14 +0,0 @@
1
- class AddSessionsTable < ActiveRecord::Migration
2
- def self.up
3
- create_table :sessions, :force => true do |t|
4
- t.column :id, :integer, :null => false
5
- t.column :session_id, :string, :limit => 32
6
- t.column :created_at, :datetime
7
- t.column :data, :text
8
- end
9
- end
10
-
11
- def self.down
12
- drop_table :sessions
13
- end
14
- end
@@ -1,28 +0,0 @@
1
- # This file is autogenerated. Instead of editing this file, please use the
2
- # migrations feature of ActiveRecord to incrementally modify your database, and
3
- # then regenerate this schema definition.
4
-
5
- ActiveRecord::Schema.define(:version => 2) do
6
-
7
- create_table "comments", :force => true do |t|
8
- t.column "post_id", :integer
9
- t.column "name", :string
10
- t.column "body", :text
11
- t.column "created_at", :datetime
12
- t.column "updated_at", :datetime
13
- end
14
-
15
- create_table "posts", :force => true do |t|
16
- t.column "title", :string
17
- t.column "body", :text
18
- t.column "created_at", :datetime
19
- t.column "updated_at", :datetime
20
- end
21
-
22
- create_table "sessions", :force => true do |t|
23
- t.column "session_id", :string, :limit => 32
24
- t.column "created_at", :datetime
25
- t.column "data", :text
26
- end
27
-
28
- end
File without changes
@@ -1 +0,0 @@
1
- 2006
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'fileutils'
3
-
4
- pids=[]
5
-
6
- port_or_star = ARGV[0] || '*'
7
-
8
- Dir[File.dirname(__FILE__)+"/../log/merb.#{port_or_star}.pid"].each do |f|
9
- pid = IO.read(f).chomp.to_i
10
- puts "killing PID: #{pid}"
11
- Process.kill(9, pid)
12
- FileUtils.rm f
13
- end
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require 'merb'
4
-
5
- TMPL = <<EOF
6
- class <%= class_name.snake_case.camel_case %> < ActiveRecord::Migration
7
- def self.up
8
- end
9
-
10
- def self.down
11
- end
12
- end
13
- EOF
14
-
15
- class_name = ARGV[0]
16
- highest_migration = Dir[Dir.pwd+'/dist/schema/migrations/*'].map{|f| File.basename(f) =~ /^(\d+)/; $1}.max
17
- filename = format("%03d_%s", (highest_migration.to_i+1), class_name.snake_case)
18
-
19
- File.open(Dir.pwd+"/dist/schema/migrations/#{filename}.rb", 'w+') do |file|
20
- file.write Erubis::Eruby.new(TMPL).result(binding)
21
- end
@@ -1 +0,0 @@
1
- require 'test/unit'
@@ -1,147 +0,0 @@
1
- module Merb
2
- module JavascriptMixin
3
-
4
- # escape text for javascript.
5
- def escape_js(javascript)
6
- (javascript || '').gsub('\\','\0\0').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
7
- end
8
-
9
- # creates an <a> tag with with an onclick containing
10
- # a js function
11
- # link_to_function('click me', "alert('hi!')")
12
- def link_to_function(name, function)
13
- %{<a href="#" onclick="#{function}; return false;">#{name}</a>}
14
- end
15
-
16
- # calls .to_json on data. This will use fjson if installed
17
- # so it can be faster than escape_js
18
- def js(data)
19
- if data.respond_to? :to_json
20
- data.to_json
21
- else
22
- data.inspect.to_json
23
- end
24
- end
25
-
26
- # Requiring javascripts and stylesheets:
27
- # you can use require_js(:prototype) or require_css(:shinystyles)
28
- # from any view or layout and the scripts will only be included once
29
- # in the head of the final page. In the head of your layout you will
30
- # need to add these two tags:
31
- #
32
- # <%= include_required_js %>
33
- # <%= include_required_css %>
34
- #
35
- # --app/views/layouts/application.rhtml
36
- #
37
- # <html>
38
- # <head>
39
- # <%= include_required_js %>
40
- # <%= include_required_css %>
41
- # </head>
42
- # <body>
43
- # <%= catch_content :layout %>
44
- # </body>
45
- # </html>
46
- #
47
- # --app/views/whatever/index.rhtml
48
- #
49
- # <%= partial(:part1) %>
50
- # <%= partial(:part2) %>
51
- #
52
- # --app/views/whatever/_part1.rhtml
53
- #
54
- # <% require_js 'this' -%>
55
- # <% require_css 'that', 'another_one' -%>
56
- #
57
- # --app/views/whatever/_part2.rhtml
58
- #
59
- # <% require_js 'this', 'something_else' -%>
60
- # <% require_css 'that' -%>
61
-
62
-
63
- # require_js(:myjs) can be used to require any javascript
64
- # file anywhere in your templates. It will only include the
65
- # javascript tag once in the header
66
- def require_js(*js)
67
- @required_js ||= []
68
- @required_js |= js
69
- end
70
-
71
- # require_css(:mystyles) can be used to require any javascript
72
- # file anywhere in your templates. It will only include the
73
- # javascript tag once in the header
74
- def require_css(*css)
75
- @required_css ||= []
76
- @required_css |= css
77
- end
78
-
79
- # this goes in the head of your layout if you will be using
80
- # require_js
81
- def include_required_js
82
- js_include_tag(*@required_js)
83
- end
84
-
85
- # this goes in the head of your layout if you will be using
86
- # require_css
87
- def include_required_css
88
- css_link_tag(*@required_js)
89
- end
90
-
91
- # js_include_tag(:foo, :bar, :baz) will create a javascript
92
- # include tag for each script in the arguments. It will append
93
- # '.js' if it is left out of the call.
94
- def js_include_tag(*scripts)
95
- return nil if scripts.empty?
96
- scripts.inject('') do |memo,script|
97
- script = script.to_s
98
- memo << %Q|<script src="/javascripts/#{script=~/\.js$/ ? script : script+'.js' }" type="text/javascript">//</script>\n|
99
- end
100
- end
101
-
102
- # css_include_tag(:foo, :bar, :baz) will create a stylesheet
103
- # link tag for each stylesheet in the arguments. It will append
104
- # '.css' if it is left out of the call.
105
- def css_include_tag(*scripts)
106
- return nil if scripts.empty?
107
- scripts.inject('') do |memo,script|
108
- script = script.to_s
109
- memo << %Q|<link href="/stylesheets/#{script=~/\.css$/ ? script : script+'.css' }" media="all" rel="Stylesheet" type="text/css"/>\n|
110
- end
111
- end
112
-
113
- ##
114
- # Prototype library helpers.
115
- ##
116
-
117
- # insert_html takes a position, a dom id and html to be inserted.
118
- # insert_html(:before, 'my_dom_id', partial(:foo) )
119
- def insert_html(position, id, html)
120
- position = options.fetch(:where, :before)
121
- "new Insertion.#{position.to_s.camel_case}('#{id}', '#{js html}');"
122
- end
123
-
124
- # replace_html takes a dom id and html to replace the contents with
125
- # replace_html('my_dom_id', partial(:foo))
126
- def replace_html(id, html)
127
- "Element.update('#{id}', '#{js html}');"
128
- end
129
-
130
- # takes a dom id and hides the corresponding element.
131
- def hide(id)
132
- "$('#{id}').style.display = 'none';"
133
- end
134
-
135
- # takes a dom id and shows the corresponding element.
136
- def show(id)
137
- "$('#{id}').style.display = 'block';"
138
- end
139
-
140
- # takes a dom id and toggles it to either on or off depending
141
- # on its current state.
142
- def toggle(id)
143
- "Element.toggle('#{id}');"
144
- end
145
-
146
- end
147
- end