strelka 0.0.1.pre.265 → 0.0.1.pre.279

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,5 +1,126 @@
1
+ 2012-07-06 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * .rvm.gems, Rakefile, lib/strelka/app/templating.rb:
4
+ Set encoding on loaded templates.
5
+
6
+ - bump Inversion dependency for encoding support
7
+ - Use the default_internal encoding or UTF-8 if that isn't set as the
8
+ encoding of templates loaded by the :templating plugin.
9
+ [4f7bb0f3a8f7] [tip]
10
+
11
+ * Manifest.txt:
12
+ Add multipart-form support files to the manifest
13
+ [b3367292cf3f]
14
+
15
+ * bin/strelka:
16
+ Fix the wording of the header from the "start" command in
17
+ bin/strelka
18
+ [5d677093466d]
19
+
20
+ 2012-07-03 Michael Granger <ged@FaerieMUD.org>
21
+
22
+ * lib/strelka/paramvalidator.rb, manual/src/starting.page,
23
+ manual/src/tutorial.page:
24
+ Documentation/manual updates
25
+ [75c75043ad29]
26
+
27
+ 2012-07-03 Mahlon E. Smith <mahlon@martini.nu>
28
+
29
+ * manual/src/plugins.page:
30
+ First round documentation for 'Writing Your Own Strelka Plugin'
31
+ manual page.
32
+ [e1c56057be7a]
33
+
34
+ * .rvm.gems, Rakefile, manual/src/starting.page:
35
+ Fix bootstrap missing quote. Update mongrel2 dependency to 0.27.
36
+ [6ea74939d550]
37
+
38
+ 2012-07-03 Michael Granger <ged@FaerieMUD.org>
39
+
40
+ * bin/strelka:
41
+ Make the default bin/strelka command "help"
42
+ [c82aa0ae98c9]
43
+
44
+ * README.rdoc:
45
+ Fix the command-line tool name
46
+ [b6ae193c24e9]
47
+
48
+ 2012-06-27 Mahlon E. Smith <mahlon@martini.nu>
49
+
50
+ * lib/strelka/mixins.rb, spec/strelka/mixins_spec.rb:
51
+ Don't deep copy modules/classes.
52
+ [d6cf8e4ac02f]
53
+
54
+ 2012-06-25 Michael Granger <ged@FaerieMUD.org>
55
+
56
+ * .hgignore, .rvm.gems, .tm_properties, Rakefile, examples/.env,
57
+ examples/Procfile, examples/apps/upload-demo, examples/config.yml,
58
+ examples/gen-config.rb, examples/static/examples.html,
59
+ examples/templates/upload-form.tmpl, examples/templates/upload-
60
+ success.tmpl, lib/strelka/app.rb, lib/strelka/exceptions.rb,
61
+ lib/strelka/httprequest.rb, lib/strelka/multipartparser.rb,
62
+ spec/data/forms/2_images.form, spec/data/forms/singleupload.form,
63
+ spec/data/forms/testform.form, spec/data/forms/testform_bad.form,
64
+ spec/data/forms/testform_badheaders.form,
65
+ spec/data/forms/testform_metadataonly.form,
66
+ spec/data/forms/testform_msie.form,
67
+ spec/data/forms/testform_multivalue.form,
68
+ spec/data/forms/testform_truncated_metadata.form,
69
+ spec/lib/helpers.rb, spec/strelka/app_spec.rb,
70
+ spec/strelka/multipartparser_spec.rb:
71
+ Added support for multipart/form-data entity bodies
72
+
73
+ - Add a multipart mime document parser, as well as support for
74
+ Mongrel2 asynchronous uploads.
75
+ - Hook up the multipart parser for form data of type 'multipart/form-
76
+ data'.
77
+ - Added an example of async upload and multipart/form-data to the
78
+ examples.
79
+ - Include the Ruby engine + version in the process name
80
+ [cfae502bcec1]
81
+
82
+ * spec/lib/helpers.rb:
83
+ Remove extra include from spec helpers
84
+ [abc12d87868e]
85
+
86
+ * .rvm.gems, Rakefile:
87
+ Bumping Loggability dependency
88
+ [6039fcf3a3e0]
89
+
90
+ 2012-06-22 Michael Granger <ged@FaerieMUD.org>
91
+
92
+ * lib/strelka/httpresponse/negotiation.rb,
93
+ spec/strelka/httpresponse/negotiation_spec.rb:
94
+ Fix the entity body for negotiated responses.
95
+ [d2c4f8ac4e07]
96
+
97
+ * lib/strelka/httpresponse.rb, spec/strelka/httpresponse_spec.rb:
98
+ Don't append a charset for non text/* content-type headers
99
+ [4ad96d45bcc2]
100
+
101
+ 2012-06-21 Michael Granger <ged@FaerieMUD.org>
102
+
103
+ * Rakefile:
104
+ Depend on mongrel2 0.25.0
105
+ [0f6b09255386]
106
+
107
+ * lib/strelka/app/negotiation.rb, lib/strelka/httprequest.rb,
108
+ lib/strelka/httpresponse.rb,
109
+ lib/strelka/httpresponse/negotiation.rb,
110
+ spec/strelka/app/errors_spec.rb,
111
+ spec/strelka/app/restresources_spec.rb,
112
+ spec/strelka/app/templating_spec.rb, spec/strelka/app_spec.rb,
113
+ spec/strelka/httpresponse/negotiation_spec.rb:
114
+ Mongrel2 stream API fixes
115
+ [6d267b848e8a]
116
+
1
117
  2012-06-20 Michael Granger <ged@FaerieMUD.org>
2
118
 
119
+ * lib/strelka/httprequest/session.rb,
120
+ lib/strelka/httpresponse/session.rb:
121
+ Remove the session from the request when it's destroyed, too.
122
+ [e0f2e2a0e4b8]
123
+
3
124
  * lib/strelka/httprequest/session.rb,
4
125
  lib/strelka/httpresponse/session.rb, lib/strelka/session.rb,
5
126
  lib/strelka/session/default.rb,
@@ -8,7 +129,7 @@
8
129
  spec/strelka/session/default_spec.rb:
9
130
  Fix session expiration for cookie-based persistance
10
131
  * * * Conversion to stream-based Mongrel2 API
11
- [7389c2f1e8e3] [tip]
132
+ [7389c2f1e8e3]
12
133
 
13
134
  2012-06-20 Mahlon E. Smith <mahlon@martini.nu>
14
135
 
data/Manifest.txt CHANGED
@@ -16,12 +16,12 @@ contrib/hoetemplate/data/project/templates/layout.tmpl.erb
16
16
  contrib/hoetemplate/data/project/templates/top.tmpl.erb
17
17
  contrib/hoetemplate/lib/file_name.rb.erb
18
18
  contrib/hoetemplate/spec/file_name_spec.rb.erb
19
- examples/.env
20
19
  examples/Procfile
21
20
  examples/apps/auth-demo
22
21
  examples/apps/auth-demo2
23
22
  examples/apps/hello-world
24
23
  examples/apps/sessions-demo
24
+ examples/apps/upload-demo
25
25
  examples/config.yml
26
26
  examples/gen-config.rb
27
27
  examples/static/examples.css
@@ -29,6 +29,8 @@ examples/static/examples.html
29
29
  examples/templates/auth-form.tmpl
30
30
  examples/templates/auth-success.tmpl
31
31
  examples/templates/layout.tmpl
32
+ examples/templates/upload-form.tmpl
33
+ examples/templates/upload-success.tmpl
32
34
  lib/strelka.rb
33
35
  lib/strelka/app.rb
34
36
  lib/strelka/app/auth.rb
@@ -57,6 +59,7 @@ lib/strelka/httpresponse.rb
57
59
  lib/strelka/httpresponse/negotiation.rb
58
60
  lib/strelka/httpresponse/session.rb
59
61
  lib/strelka/mixins.rb
62
+ lib/strelka/multipartparser.rb
60
63
  lib/strelka/paramvalidator.rb
61
64
  lib/strelka/plugins.rb
62
65
  lib/strelka/router.rb
@@ -66,6 +69,15 @@ lib/strelka/session.rb
66
69
  lib/strelka/session/db.rb
67
70
  lib/strelka/session/default.rb
68
71
  spec/data/error.tmpl
72
+ spec/data/forms/2_images.form
73
+ spec/data/forms/singleupload.form
74
+ spec/data/forms/testform.form
75
+ spec/data/forms/testform_bad.form
76
+ spec/data/forms/testform_badheaders.form
77
+ spec/data/forms/testform_metadataonly.form
78
+ spec/data/forms/testform_msie.form
79
+ spec/data/forms/testform_multivalue.form
80
+ spec/data/forms/testform_truncated_metadata.form
69
81
  spec/data/layout.tmpl
70
82
  spec/data/main.tmpl
71
83
  spec/lib/constants.rb
@@ -95,6 +107,7 @@ spec/strelka/httpresponse/negotiation_spec.rb
95
107
  spec/strelka/httpresponse/session_spec.rb
96
108
  spec/strelka/httpresponse_spec.rb
97
109
  spec/strelka/mixins_spec.rb
110
+ spec/strelka/multipartparser_spec.rb
98
111
  spec/strelka/paramvalidator_spec.rb
99
112
  spec/strelka/plugins_spec.rb
100
113
  spec/strelka/router/default_spec.rb
data/README.rdoc CHANGED
@@ -135,7 +135,7 @@ Here's a tentative list of what kinds of stuff we have planned:
135
135
 
136
136
  You'll be able to package up your applications as Rubygems for easy deployment.
137
137
  The Strelka::App class already supports application discovery, but we
138
- want to hook that up to the 'leash' command line tool so you can install
138
+ want to hook that up to the 'strelka' command line tool so you can install
139
139
  and run them with a minimum of manual monkeying around with directories,
140
140
  migrations, etc.
141
141
 
data/Rakefile CHANGED
@@ -22,17 +22,17 @@ hoespec = Hoe.spec 'strelka' do
22
22
 
23
23
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
24
24
 
25
- self.dependency 'trollop', '~> 1.16'
25
+ self.dependency 'configurability', '~> 1.2'
26
+ self.dependency 'foreman', '~> 0.47'
27
+ self.dependency 'formvalidator', '~> 0.1'
26
28
  self.dependency 'highline', '~> 1.6'
29
+ self.dependency 'inversion', '~> 0.11'
30
+ self.dependency 'loggability', '~> 0.4'
31
+ self.dependency 'mongrel2', '~> 0.28'
32
+ self.dependency 'pluginfactory', '~> 1.0'
27
33
  self.dependency 'sysexits', '~> 1.0'
28
- self.dependency 'formvalidator', '~> 0.1'
29
- self.dependency 'inversion', '~> 0.10'
30
- self.dependency 'mongrel2', '~> 0.25'
34
+ self.dependency 'trollop', '~> 1.16'
31
35
  self.dependency 'uuidtools', '~> 2.1'
32
- self.dependency 'configurability', '~> 1.0'
33
- self.dependency 'pluginfactory', '~> 1.0'
34
- self.dependency 'loggability', '~> 0.3'
35
- self.dependency 'foreman', '~> 0.47'
36
36
 
37
37
  self.dependency 'hoe-deveiate', '~> 0.1', :developer
38
38
  self.dependency 'hoe-manualgen', '~> 0.3', :developer
data/bin/strelka CHANGED
@@ -199,7 +199,7 @@ class Strelka::CLICommand
199
199
 
200
200
  ### Run the command with the specified +command+ and +args+.
201
201
  def run( command, *args )
202
- command ||= 'shell'
202
+ command ||= 'help'
203
203
  cmd_method = nil
204
204
 
205
205
  # Set the datadir override if it's given
@@ -291,7 +291,7 @@ class Strelka::CLICommand
291
291
 
292
292
  header "Starting the %s app%s" % [
293
293
  appname,
294
- gemname == '' ? '' : " the #{gemname} gem"
294
+ gemname == '' ? '' : " from the #{gemname} gem"
295
295
  ]
296
296
  fork do
297
297
  self.log.debug " in the child."
data/examples/Procfile CHANGED
@@ -4,5 +4,6 @@ helloworld: ../bin/strelka -D . -l warn -c config.yml start hello-world
4
4
  auth: ../bin/strelka -D . -l warn -c config.yml start auth-demo
5
5
  auth2: ../bin/strelka -D . -l warn -c config.yml start auth-demo2
6
6
  sessions: ../bin/strelka -D . -l debug -c config.yml start sessions-demo
7
+ upload: ../bin/strelka -D . -l debug -c config.yml start upload-demo
7
8
  # ws: ../bin/strelka -l info -c config.yml start ws-echo
8
9
 
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'strelka'
4
+
5
+ # An example of a file upload handler.
6
+ class UploadDemo < Strelka::App
7
+
8
+ # The route appid that will configure this app if no appid is specified
9
+ ID = 'upload-demo'
10
+
11
+
12
+ plugins :templating, :routing, :parameters
13
+
14
+ default_type 'text/html'
15
+
16
+ layout 'templates/layout.tmpl'
17
+ templates \
18
+ form: 'templates/upload-form.tmpl',
19
+ success: 'templates/upload-success.tmpl'
20
+
21
+
22
+ ### Show the form for any GET
23
+ get do |req|
24
+ return :form
25
+ end
26
+
27
+
28
+ ### Show the upload for POST requests
29
+ post do |req|
30
+ req.params.add( :description, :string )
31
+ req.params.add( :uploadfile ) do |input|
32
+ if input.respond_to?( :filename ) && input.respond_to?( :content_type )
33
+ input
34
+ else
35
+ nil
36
+ end
37
+ end
38
+
39
+ unless req.content_type.start_with?( 'multipart/form-data' )
40
+ self.log.error "Not a multipart/form-data request?!"
41
+ finish_with HTTP::BAD_REQUEST,
42
+ "Expecting a mutlipart/form-data request, got: %p" % [ req.content_type ]
43
+ end
44
+
45
+ unless req.params.okay?
46
+ self.log.error "Parameter validation error: %s" %
47
+ [ req.params.error_messages.join(', ') ]
48
+ finish_with HTTP::BAD_REQUEST,
49
+ "Form errors: %s" % [ req.params.error_messages.join(', ') ]
50
+ end
51
+
52
+ self.log.debug "Successful upload of file %s." % [ req.params[:uploadfile].filename ]
53
+
54
+ tmpl = template :success
55
+ tmpl.upload = req.params[:uploadfile]
56
+ tmpl.description = req.params[:description]
57
+
58
+ return tmpl
59
+ end
60
+
61
+
62
+ ### Override the upload-started notification to allow spooled (asynchronous)
63
+ ### uploads.
64
+ def handle_async_upload_start( request )
65
+ self.log.info "Asynchronous upload notice. Spooling entity body to %p" %
66
+ [ request.headers.x_mongrel_upload_start ]
67
+ return nil
68
+ end
69
+
70
+ end # class UploadDemo
71
+
72
+
73
+ # Run the app
74
+ UploadDemo.run if __FILE__ == $0
data/examples/config.yml CHANGED
@@ -21,7 +21,7 @@ defaultsession:
21
21
 
22
22
  templates:
23
23
  template_paths:
24
- - examples/templates
24
+ - templates
25
25
 
26
26
  logging:
27
27
  strelka: debug (color)
@@ -22,7 +22,7 @@ server 'examples' do
22
22
  chroot '/var/mongrel2'
23
23
  pid_file '/run/mongrel2.pid'
24
24
 
25
- bind_addr '127.0.0.1'
25
+ bind_addr '0.0.0.0'
26
26
  port 8113
27
27
 
28
28
  host 'localhost' do
@@ -34,6 +34,7 @@ server 'examples' do
34
34
  route '/sessions', handler( 'tcp://127.0.0.1:9905', 'sessions-demo' )
35
35
  route '/auth', handler( 'tcp://127.0.0.1:9910', 'auth-demo' )
36
36
  route '/formauth', handler( 'tcp://127.0.0.1:9915', 'auth-demo2' )
37
+ route '/upload', handler( 'tcp://127.0.0.1:9925', 'upload-demo' )
37
38
  route '/ws', handler( 'tcp://127.0.0.1:9920', 'ws-echo' )
38
39
 
39
40
  end
@@ -42,7 +43,10 @@ end
42
43
 
43
44
  setting "zeromq.threads", 1
44
45
 
45
- mkdir_p 'var'
46
+ setting 'limits.content_length', 8096
47
+ setting 'upload.temp_store', 'var/uploads/mongrel2.upload.XXXXXX'
48
+
49
+ mkdir_p 'var/uploads'
46
50
  mkdir_p 'run'
47
51
  mkdir_p 'logs'
48
52
 
@@ -25,6 +25,7 @@
25
25
  <li><a href="/sessions">Sessions Demo</a> - Demo of the <code>:sessions</code> plugin.</li>
26
26
  <li><a href="/auth">Auth Demo</a> - Demo of the <code>:auth</code> plugin.</li>
27
27
  <li><a href="/formauth">Form Auth Demo</a> - Demo of the <code>:auth</code> plugin with the :errors plugin for auth failure management.</li>
28
+ <li><a href="/upload">Upload Demo</a> - Demo of <tt>multipart/form-data</tt> support, Mongrel2 async upload support for larger files.</li>
28
29
  </ul>
29
30
 
30
31
  </body>
@@ -0,0 +1,17 @@
1
+ <?import request ?>
2
+
3
+ <?publish title ?>Upload/Multipart-FormData Demo<?end publish ?>
4
+
5
+ <form action="[?call request.uri ?]" method="post" accept-charset="utf-8" enctype="multipart/form-data">
6
+
7
+ <label for="uploadfile">Upload a file:</label>
8
+ <input type="file" name="uploadfile" value="" id="uploadfile-input">
9
+
10
+ <br />
11
+
12
+ <label for="description">Description</label>
13
+ <input type="text" name="description" value="" id="description-input">
14
+
15
+ <p><input type="submit" value="Upload &rarr;"></p>
16
+ </form>
17
+
@@ -0,0 +1,13 @@
1
+ <?import request ?>
2
+
3
+ <h2>Upload Successful</h2>
4
+
5
+ <p>You successfully uploaded a file: <tt><?call upload.filename ?></tt>
6
+ (<?call "%0.2fK" % upload.content_length / 1024.0 ?> of
7
+ '<?call upload.content_type ?>' data) with a description of
8
+ <tt><?escape description ?></tt></p>
9
+
10
+ <hr />
11
+
12
+ <?include upload-form.tmpl ?>
13
+
data/lib/strelka/app.rb CHANGED
@@ -246,7 +246,7 @@ class Strelka::App < Mongrel2::Handler
246
246
 
247
247
  ### Run the app -- overriden to set the process name to something interesting.
248
248
  def run
249
- procname = "%p %s" % [ self.class, self.conn ]
249
+ procname = "%s %s: %p %s" % [ RUBY_ENGINE, RUBY_VERSION, self.class, self.conn ]
250
250
  $0 = procname
251
251
 
252
252
  super
@@ -289,6 +289,28 @@ class Strelka::App < Mongrel2::Handler
289
289
  end
290
290
 
291
291
 
292
+ ### Handle uploads larger than the server's configured limit with a 413: Request Entity
293
+ ### Too Large before dropping the connection.
294
+ def handle_async_upload_start( request )
295
+ status_info = { :status => HTTP::REQUEST_ENTITY_TOO_LARGE, :message => 'Request too large.' }
296
+ response = self.prepare_status_response( request, status_info )
297
+ response.headers.connection = 'close'
298
+ self.conn.reply( response )
299
+
300
+ explanation = "If you wish to handle requests like this, either set your server's "
301
+ explanation << "'limits.content_length' setting to a higher value than %d, or override " %
302
+ [ request.content_length ]
303
+ explanation << "#handle_async_upload_start."
304
+
305
+ self.log.warn "Async upload from %s dropped." % [ request.remote_ip ]
306
+ self.log.info( explanation )
307
+
308
+ self.conn.reply_close( request )
309
+
310
+ return nil
311
+ end
312
+
313
+
292
314
  #########
293
315
  protected
294
316
  #########