merb 0.0.6 → 0.0.7
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/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
data/README
CHANGED
|
@@ -7,6 +7,15 @@ for simple dynamic pages.
|
|
|
7
7
|
|
|
8
8
|
**Sample APP included**
|
|
9
9
|
|
|
10
|
+
**Important**
|
|
11
|
+
The new default filename extensions for templates are as follows:
|
|
12
|
+
html -> .herb
|
|
13
|
+
js -> .jerb
|
|
14
|
+
xml -> .xerb
|
|
15
|
+
|
|
16
|
+
You can change the extensions to anything you want in your config file in
|
|
17
|
+
yourapp/dist/conf/merb.yml. See the default settings in the sample app.
|
|
18
|
+
|
|
10
19
|
Unpack the gem and grab the sample app
|
|
11
20
|
|
|
12
21
|
$ gem unpack merb
|
|
@@ -19,10 +28,19 @@ $ merb
|
|
|
19
28
|
then the sample app will be running on port 4000 in the foreground.
|
|
20
29
|
you can go to a few urls:
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
You will need the mongrel_upload_progress gem installed to go to /files
|
|
32
|
+
|
|
33
|
+
http://localhost:4000/files/start
|
|
23
34
|
|
|
24
35
|
http://localhost:4000/foo/123/baz/12234345
|
|
25
36
|
|
|
37
|
+
If you have checked out merb trunk from svn you will want to build and install
|
|
38
|
+
the gem to use merb. Run this command from the root of the merb svn checkout
|
|
39
|
+
to do that:
|
|
40
|
+
|
|
41
|
+
$ sudo rake install
|
|
42
|
+
|
|
43
|
+
*note* you may have to run this comand twice if it fails the first time.
|
|
26
44
|
|
|
27
45
|
**FEATURES** 1. Mongrel handler built in that parses incoming requests
|
|
28
46
|
including multipart uploads and post as well as ?query=strings. Puts the
|
|
@@ -63,7 +81,7 @@ lambda{|path|
|
|
|
63
81
|
3. Simple controller classes with built in render method and template handling
|
|
64
82
|
with instance vars available in the views automatically. Merb also supports
|
|
65
83
|
layouts. It will look for a layout named after your controller class first and
|
|
66
|
-
then fall back to application.
|
|
84
|
+
then fall back to application.herb if no layout exists named after your controller.
|
|
67
85
|
You can use render_no_layout or do layout :none right before you render
|
|
68
86
|
|
|
69
87
|
|
|
@@ -105,10 +123,10 @@ def ajax_action
|
|
|
105
123
|
render_js
|
|
106
124
|
end
|
|
107
125
|
|
|
108
|
-
# ajax_action.
|
|
126
|
+
# ajax_action.jerb
|
|
109
127
|
$('comments').update('<%= escape_js(partial(:posts)) %>');
|
|
110
128
|
|
|
111
|
-
# _posts.
|
|
129
|
+
# _posts.herb
|
|
112
130
|
<ul>
|
|
113
131
|
<% @posts.each do |p| %>
|
|
114
132
|
<li>
|
data/Rakefile
CHANGED
|
@@ -6,10 +6,11 @@ require 'rake/testtask'
|
|
|
6
6
|
require 'spec/rake/spectask'
|
|
7
7
|
require 'code_statistics'
|
|
8
8
|
require 'fileutils'
|
|
9
|
+
require File.dirname(__FILE__)+'/tools/rakehelp'
|
|
9
10
|
include FileUtils
|
|
10
11
|
|
|
11
12
|
NAME = "merb"
|
|
12
|
-
VERS = "0.0.
|
|
13
|
+
VERS = "0.0.7"
|
|
13
14
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
|
14
15
|
RDOC_OPTS = ['--quiet', '--title', "Merb Documentation",
|
|
15
16
|
"--opname", "index.html",
|
|
@@ -17,12 +18,21 @@ RDOC_OPTS = ['--quiet', '--title', "Merb Documentation",
|
|
|
17
18
|
"--main", "README",
|
|
18
19
|
"--inline-source"]
|
|
19
20
|
|
|
21
|
+
setup_clean [ "pkg", "lib/*.bundle", "*.gem",
|
|
22
|
+
"doc", ".config", "examples/sample_app/dist/public/files/**/*"]
|
|
23
|
+
|
|
24
|
+
|
|
20
25
|
desc "Packages up Merb."
|
|
21
26
|
task :default => [:package]
|
|
22
|
-
task :package => [:clean]
|
|
27
|
+
task :package => [:really_clean, :clean, :rdoc]
|
|
23
28
|
|
|
24
29
|
task :doc => [:rdoc]
|
|
25
30
|
|
|
31
|
+
task :really_clean do
|
|
32
|
+
rm_rf 'examples/sample_app/log/*'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
26
36
|
Rake::RDocTask.new do |rdoc|
|
|
27
37
|
rdoc.rdoc_dir = 'doc/rdoc'
|
|
28
38
|
rdoc.options += RDOC_OPTS
|
|
@@ -48,9 +58,10 @@ spec = Gem::Specification.new do |s|
|
|
|
48
58
|
|
|
49
59
|
s.add_dependency('mongrel')
|
|
50
60
|
s.add_dependency('erubis')
|
|
61
|
+
s.add_dependency('json')
|
|
51
62
|
s.required_ruby_version = '>= 1.8.4'
|
|
52
63
|
|
|
53
|
-
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{app,bin,
|
|
64
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{app,bin,test,lib,examples}/**/*")
|
|
54
65
|
|
|
55
66
|
s.require_path = "lib"
|
|
56
67
|
s.bindir = "bin"
|
|
@@ -62,6 +73,7 @@ Rake::GemPackageTask.new(spec) do |p|
|
|
|
62
73
|
end
|
|
63
74
|
|
|
64
75
|
task :install do
|
|
76
|
+
sh %{rake clean}
|
|
65
77
|
sh %{rake package}
|
|
66
78
|
sh %{sudo gem install pkg/#{NAME}-#{VERS}}
|
|
67
79
|
end
|
data/TODO
CHANGED
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
* Helpers
|
|
5
5
|
* config file **DONE**
|
|
6
6
|
* session
|
|
7
|
-
** AR
|
|
7
|
+
** AR ** DONE **
|
|
8
8
|
** DRb
|
|
9
9
|
* Rails integration
|
|
10
|
-
* Mongoose ?
|
|
11
10
|
* Text backend?
|
|
12
11
|
* plugins support(rails plugins too?)
|
|
13
12
|
* Layouts **DONE**
|
|
14
13
|
* auto template_dir **DONE**
|
|
15
|
-
* before/after filters
|
|
14
|
+
* before/after filters **DONE**
|
|
16
15
|
* merbjs **DONE**
|
|
17
16
|
* testing
|
data/bin/merb
CHANGED
|
@@ -4,6 +4,8 @@ require 'optparse'
|
|
|
4
4
|
require 'ostruct'
|
|
5
5
|
require 'fileutils'
|
|
6
6
|
require 'yaml'
|
|
7
|
+
require 'erubis'
|
|
8
|
+
|
|
7
9
|
module Merb
|
|
8
10
|
end
|
|
9
11
|
|
|
@@ -13,11 +15,11 @@ class Merb::Config
|
|
|
13
15
|
:host => "0.0.0.0",
|
|
14
16
|
:port => "4000",
|
|
15
17
|
:allow_reloading => true,
|
|
16
|
-
:merb_root => Dir.pwd
|
|
18
|
+
:merb_root => Dir.pwd,
|
|
19
|
+
:template_ext => {:html => :herb, :js => :jerb, :xml => :xerb}
|
|
17
20
|
}
|
|
18
|
-
|
|
19
21
|
begin
|
|
20
|
-
options = defaults.merge(YAML.load(
|
|
22
|
+
options = defaults.merge(YAML.load(Erubis::Eruby.new(IO.read("#{defaults[:merb_root]}/dist/conf/merb.yml")).result))
|
|
21
23
|
rescue
|
|
22
24
|
options = defaults
|
|
23
25
|
end
|
|
@@ -47,10 +49,6 @@ class Merb::Server
|
|
|
47
49
|
opts.on("-p", "--port [Integer]") do |port|
|
|
48
50
|
options[:port] = port
|
|
49
51
|
end
|
|
50
|
-
|
|
51
|
-
opts.on("-n", "--num-procs [Integer]") do |numprocs|
|
|
52
|
-
options[:numprocs] = numprocs
|
|
53
|
-
end
|
|
54
52
|
|
|
55
53
|
opts.on("-h", "--host [String]") do |host|
|
|
56
54
|
options[:host] = host
|
|
@@ -64,9 +62,12 @@ class Merb::Server
|
|
|
64
62
|
options[:console] = true
|
|
65
63
|
end
|
|
66
64
|
|
|
67
|
-
opts.on("-s", "--session-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
opts.on("-s", "--session-drb-port [Integer]") do |drb_port|
|
|
66
|
+
options[:session] = drb_port
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
opts.on("-l", "--log-level [String]") do |loglevel|
|
|
70
|
+
options[:log_level] = loglevel
|
|
70
71
|
end
|
|
71
72
|
|
|
72
73
|
end
|
|
@@ -79,19 +80,23 @@ class Merb::Server
|
|
|
79
80
|
puts @@merb_opts.to_yaml; puts
|
|
80
81
|
end
|
|
81
82
|
|
|
83
|
+
def self.initialize_merb
|
|
84
|
+
require 'merb'
|
|
85
|
+
require @@merb_opts[:merb_root]+'/dist/conf/router.rb'
|
|
86
|
+
require @@merb_opts[:merb_root]+'/dist/conf/merb_init.rb'
|
|
87
|
+
end
|
|
88
|
+
|
|
82
89
|
def self.run
|
|
83
90
|
@@merb_raw_opts = ARGV
|
|
84
91
|
merb_config
|
|
85
92
|
|
|
86
93
|
@@merb_opts[:dist_root] = @@merb_opts[:merb_root]+'/dist'
|
|
94
|
+
$LOAD_PATH.unshift( File.join(@@merb_opts[:dist_root] , '/app/controllers') )
|
|
95
|
+
$LOAD_PATH.unshift( File.join(@@merb_opts[:dist_root] , '/app/models') )
|
|
96
|
+
$LOAD_PATH.unshift( File.join(@@merb_opts[:dist_root] , '/lib') )
|
|
87
97
|
|
|
88
|
-
$LOAD_PATH.unshift( File.join(@@merb_opts[:merb_root] , '/dist/app/controllers') )
|
|
89
|
-
$LOAD_PATH.unshift( File.join(@@merb_opts[:merb_root] , '/dist/lib') )
|
|
90
|
-
require 'merb'
|
|
91
|
-
require @@merb_opts[:merb_root]+'/dist/conf/router.rb'
|
|
92
|
-
require @@merb_opts[:merb_root]+'/dist/conf/merb_init.rb'
|
|
93
|
-
|
|
94
98
|
if @@merb_opts[:console]
|
|
99
|
+
initialize_merb
|
|
95
100
|
ARGV.clear # Avoid passing args to IRB
|
|
96
101
|
require 'irb'
|
|
97
102
|
require 'irb/completion'
|
|
@@ -105,57 +110,77 @@ class Merb::Server
|
|
|
105
110
|
exit!
|
|
106
111
|
end
|
|
107
112
|
|
|
113
|
+
if @@merb_opts[:session]
|
|
114
|
+
start(@@merb_opts[:session], :drbserver_start)
|
|
115
|
+
end
|
|
116
|
+
|
|
108
117
|
if @@merb_opts[:cluster]
|
|
109
|
-
|
|
118
|
+
delete_pidfiles
|
|
110
119
|
@@merb_opts[:port].to_i.upto(@@merb_opts[:port].to_i+@@merb_opts[:cluster].to_i-1) do |port|
|
|
111
120
|
puts "Starting merb server on port: #{port}"
|
|
112
121
|
start(port)
|
|
113
122
|
end
|
|
114
123
|
elsif @@merb_opts[:daemonize]
|
|
115
|
-
|
|
124
|
+
delete_pidfiles(@@merb_opts[:port])
|
|
116
125
|
start(@@merb_opts[:port])
|
|
117
126
|
else
|
|
118
|
-
|
|
127
|
+
initialize_merb
|
|
128
|
+
trap('TERM') { exit }
|
|
119
129
|
mongrel_start(@@merb_opts[:port])
|
|
120
130
|
end
|
|
121
131
|
|
|
122
132
|
end
|
|
123
133
|
|
|
124
|
-
def self.store_pid(pid)
|
|
125
|
-
File.open("#{@@merb_opts[:merb_root]}/log/merb.pid", '
|
|
134
|
+
def self.store_pid(pid,port)
|
|
135
|
+
File.open("#{@@merb_opts[:merb_root]}/log/merb.#{port}.pid", 'w'){|f| f.write("#{Process.pid}\n")}
|
|
126
136
|
end
|
|
127
137
|
|
|
128
|
-
def self.start(port)
|
|
138
|
+
def self.start(port,what=:mongrel_start)
|
|
129
139
|
fork do
|
|
130
140
|
Process.setsid
|
|
131
141
|
exit if fork
|
|
132
|
-
|
|
142
|
+
if what == :mongrel_start
|
|
143
|
+
store_pid(Process.pid, port)
|
|
144
|
+
else
|
|
145
|
+
store_pid(Process.pid, "drb.#{port}")
|
|
146
|
+
end
|
|
133
147
|
Dir.chdir @@merb_opts[:merb_root]
|
|
134
148
|
File.umask 0000
|
|
135
149
|
STDIN.reopen "/dev/null"
|
|
136
150
|
STDOUT.reopen "/dev/null", "a"
|
|
137
151
|
STDERR.reopen STDOUT
|
|
138
152
|
trap("TERM") { exit }
|
|
139
|
-
|
|
153
|
+
send(what, port)
|
|
140
154
|
end
|
|
141
155
|
end
|
|
142
156
|
|
|
143
|
-
def self.
|
|
144
|
-
|
|
157
|
+
def self.delete_pidfiles(portor_star='*')
|
|
158
|
+
Dir["#{@@merb_opts[:merb_root]}/log/merb.#{portor_star}.pid"].each do |pid|
|
|
159
|
+
FileUtils.rm(pid) rescue nil
|
|
160
|
+
end
|
|
145
161
|
end
|
|
146
162
|
|
|
147
|
-
def self.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
end
|
|
163
|
+
def self.drbserver_start(port)
|
|
164
|
+
require 'merb/session/merb_drb_server'
|
|
165
|
+
DRb.start_service("druby://#{@@merb_opts[:host]}:#{port}", Merb::DRbSession.setup)
|
|
166
|
+
DRb.thread.join
|
|
167
|
+
end
|
|
153
168
|
|
|
154
169
|
def self.mongrel_start(port)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
170
|
+
initialize_merb
|
|
171
|
+
|
|
172
|
+
config = Mongrel::Configurator.new :host => (@@merb_opts[:host]||"0.0.0.0"), :port => (port ||4000) do
|
|
173
|
+
load_plugins( :includes => ["mongrel"], :excludes => ["rails"] ) if @@merb_opts[:config]
|
|
174
|
+
listener do
|
|
175
|
+
run_config(@@merb_opts[:config]) if @@merb_opts[:config]
|
|
176
|
+
uri "/", :handler => MerbHandler.new(@@merb_opts[:dist_root]+'/public')
|
|
177
|
+
uri "/favicon.ico", :handler => Mongrel::Error404Handler.new("")
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
trap("INT") { stop }
|
|
181
|
+
run
|
|
182
|
+
end
|
|
183
|
+
config.join
|
|
159
184
|
end
|
|
160
185
|
|
|
161
186
|
def self.config
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class Files < Merb::Controller
|
|
2
|
+
|
|
3
|
+
def start
|
|
4
|
+
render_no_layout
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def index
|
|
8
|
+
@args = params
|
|
9
|
+
render 'start'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def upload
|
|
13
|
+
puts params.inspect
|
|
14
|
+
|
|
15
|
+
FileUtils.mv params[:data][:tempfile].path,
|
|
16
|
+
Merb::Server.config[:dist_root]+"/public/files/#{params[:data][:filename]}"
|
|
17
|
+
render_no_layout
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def progress
|
|
21
|
+
puts params.inspect
|
|
22
|
+
Mongrel::Uploads.debug = true
|
|
23
|
+
@upstatus = Mongrel::Uploads.check(params[:upload_id])
|
|
24
|
+
render_js 'progress'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def file
|
|
28
|
+
send_file DIST_ROOT+'/public/files/'+params[:file]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
class Posts < Merb::Controller
|
|
3
3
|
|
|
4
4
|
def new
|
|
5
|
-
|
|
5
|
+
session[:foo] = 'bar'
|
|
6
|
+
puts session.sess_id
|
|
6
7
|
render
|
|
7
8
|
end
|
|
8
9
|
|
|
@@ -12,12 +13,35 @@ class Posts < Merb::Controller
|
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def show
|
|
15
|
-
|
|
16
|
+
puts session[:foo]
|
|
17
|
+
session[:foo] = 'changed'
|
|
16
18
|
@post = Post.find params[:id]
|
|
17
19
|
@comments = @post.comments
|
|
18
20
|
render
|
|
19
21
|
end
|
|
20
22
|
|
|
23
|
+
def test
|
|
24
|
+
puts "protocol: #{protocol}"
|
|
25
|
+
puts "ssl?: #{ssl?}"
|
|
26
|
+
puts "uri: #{uri}"
|
|
27
|
+
puts "path: #{path}"
|
|
28
|
+
puts "path_info: #{path_info}"
|
|
29
|
+
puts "port: #{port}"
|
|
30
|
+
puts "host: #{host}"
|
|
31
|
+
puts "domain: #{domain}"
|
|
32
|
+
puts "get?: #{get?}"
|
|
33
|
+
puts "post?: #{post?}"
|
|
34
|
+
puts "put?: #{put?}"
|
|
35
|
+
puts "delete?: #{delete?}"
|
|
36
|
+
puts "head?: #{head?}"
|
|
37
|
+
puts "xhr?: #{xhr?}"
|
|
38
|
+
puts @env.inspect
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def xml_test
|
|
42
|
+
render_xml
|
|
43
|
+
end
|
|
44
|
+
|
|
21
45
|
def list
|
|
22
46
|
@posts = Post.find :all, :limit => 4
|
|
23
47
|
render
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
class Test < Merb::Controller
|
|
3
3
|
|
|
4
|
-
before :
|
|
4
|
+
before :authenticate
|
|
5
5
|
before lambda{|c| puts 'lambda filter called'}
|
|
6
6
|
|
|
7
7
|
def bfilter
|
|
8
8
|
puts "Filter Called!"
|
|
9
|
+
#throw :halt
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def hello
|
|
@@ -18,6 +19,11 @@ class Test < Merb::Controller
|
|
|
18
19
|
"<html><body><h2>#{params[:rest]}</h2></body></html>"
|
|
19
20
|
end
|
|
20
21
|
|
|
22
|
+
def json
|
|
23
|
+
@post = Post.find :first
|
|
24
|
+
render_js
|
|
25
|
+
end
|
|
26
|
+
|
|
21
27
|
def foo
|
|
22
28
|
@args = params
|
|
23
29
|
render
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
|
4
|
+
<title>mongrel test</title>
|
|
5
|
+
<script src="/javascripts/prototype.js" type="text/javascript"></script>
|
|
6
|
+
<script src="/javascripts/effects.js" type="text/javascript"></script>
|
|
7
|
+
<script src="/javascripts/mup.js" type="text/javascript"></script>
|
|
8
|
+
|
|
9
|
+
<style type="text/css">
|
|
10
|
+
#progress-bar {
|
|
11
|
+
width:500px;
|
|
12
|
+
height:25px;
|
|
13
|
+
margin:15px;
|
|
14
|
+
border:solid 1px #000;
|
|
15
|
+
position:relative;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#progress-bar #status-bar {
|
|
19
|
+
display:block;
|
|
20
|
+
height:25px;
|
|
21
|
+
width:0;
|
|
22
|
+
background-color:#00f;
|
|
23
|
+
border-right:solid 1px #000;
|
|
24
|
+
position:absolute;
|
|
25
|
+
top:0; left:0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#progress-bar #status-text {
|
|
29
|
+
display:block;
|
|
30
|
+
padding: 0 15px;
|
|
31
|
+
line-height:25px;
|
|
32
|
+
position:absolute;
|
|
33
|
+
top:0; left:0;
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
36
|
+
</head>
|
|
37
|
+
<body>
|
|
38
|
+
|
|
39
|
+
<h2>Test file uploading.</h2>
|
|
40
|
+
<%= @upid = Time.now.to_i.to_s %>
|
|
41
|
+
<form action="/files/upload?upload_id=<%= @upid %>"
|
|
42
|
+
enctype="multipart/form-data" target='upload' method="post"
|
|
43
|
+
onsubmit="UploadProgress.monitor('<%= escape_js @upid %>')">
|
|
44
|
+
|
|
45
|
+
<dl>
|
|
46
|
+
<dt><label>Select a file</label></dt>
|
|
47
|
+
<dd><input name="data" type="file" /></dd>
|
|
48
|
+
</dl>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<p>
|
|
52
|
+
<input name="commit" type="submit" value="Upload" />
|
|
53
|
+
</p>
|
|
54
|
+
</form>
|
|
55
|
+
|
|
56
|
+
<div id="results"></div>
|
|
57
|
+
<div id="progress-bar"></div>
|
|
58
|
+
|
|
59
|
+
<iframe id="upload" name="upload" src="about:blank"></iframe>
|
|
60
|
+
|
|
61
|
+
</body>
|
|
62
|
+
</html>
|