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,11 +0,0 @@
1
- ---
2
- :host: 0.0.0.0
3
- :port: "4000"
4
- :allow_reloading: true
5
- #:sql_session: true
6
- #:basic_auth:
7
- # :username: ezra
8
- # :password: test
9
- # :domain: localhost
10
- #:daemonize: true
11
- #:cluster: 3
@@ -1,16 +0,0 @@
1
- puts "merb init called"
2
-
3
- # add your own ruby code here for app initialization and load path stuff
4
-
5
- require 'active_record'
6
-
7
- ActiveRecord::Base.logger = MERB_LOGGER
8
- ActiveRecord::Base.establish_connection(
9
- :adapter => 'mysql',
10
- :username => 'root',
11
- :password => 'xxx',
12
- :database => 'merb'
13
- )
14
- ActiveRecord::Base.verification_timeout = 14400
15
-
16
- Dir[DIST_ROOT+"/app/models/*.rb"].each { |m| require m }
@@ -1,5 +0,0 @@
1
- # upload progress conf
2
- ---
3
- :drb: true
4
- :path_info: /files/upload
5
- :frequency: 2
@@ -1,19 +0,0 @@
1
- # Merb::RouteMatcher is the request routing mapper for the merb framework.
2
- # You can define placeholder parts of the url with the :smbol notation.
3
- # so r.add '/foo/:bar/baz/:id', :class => 'Bar', :method => 'foo'
4
- # will match against a request to /foo/123/baz/456. It will then
5
- # use the class Bar as your merb controller and call the foo method on it.
6
- # the foo method will recieve a hash with {:bar => '123', :id => '456'}
7
- # as the content. So the :placeholders sections of your routes become
8
- # a hash of arguments to your controller methods.
9
- # The default route is installed
10
-
11
-
12
- puts "Compiling routes: \n"
13
- Merb::RouteMatcher.prepare do |r|
14
- r.add '/:controller/:action/:id'
15
- #r.add '', :controller => 'SomeController', :action =>'foo'
16
- end
17
-
18
- m = Merb::RouteMatcher.new
19
- puts m.compiled_statement
@@ -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,82 +0,0 @@
1
- require 'rake'
2
- require 'rake/rdoctask'
3
- require 'rake/testtask'
4
- require 'code_statistics'
5
- require 'fileutils'
6
- require 'rubygems'
7
- require 'merb'
8
- require MERB_FRAMEWORK_ROOT+'/merb_tasks'
9
- MERB_ROOT = File.dirname(__FILE__)
10
- include FileUtils
11
-
12
-
13
- #desc "Packages up Merb."
14
- #task :default => [:package]
15
-
16
- desc "load merb_init.rb"
17
- task :merb_init do
18
- require 'merb'
19
- require File.dirname(__FILE__)+'/dist/conf/merb_init.rb'
20
- end
21
-
22
- desc "Load db schema"
23
- task :load_schema => [:merb_init] do
24
- require File.dirname(__FILE__)+'/dist/schema/schema.rb'
25
- end
26
-
27
- task :uninstall => [:clean] do
28
- sh %{sudo gem uninstall #{NAME}}
29
- end
30
-
31
- desc 'Run unit tests'
32
- Rake::TestTask.new('test_unit') do |t|
33
- t.libs << 'test'
34
- t.pattern = 'test/unit/*_test.rb'
35
- t.verbose = true
36
- end
37
-
38
- desc 'Run functional tests'
39
- Rake::TestTask.new('test_functional') do |t|
40
- t.libs << 'test'
41
- t.pattern = 'test/functional/*_test.rb'
42
- t.verbose = true
43
- end
44
-
45
- desc 'Run all tests'
46
- Rake::TestTask.new('test') do |t|
47
- t.libs << 'test'
48
- t.pattern = 'test/**/*_test.rb'
49
- t.verbose = true
50
- end
51
-
52
- desc 'Run all tests, specs and finish with rcov'
53
- task :aok do
54
- sh %{rake rcov}
55
- sh %{rake spec}
56
- end
57
-
58
- ##############################################################################
59
- # Statistics
60
- ##############################################################################
61
-
62
- STATS_DIRECTORIES = [
63
- %w(Code lib/),
64
- %w(Unit\ tests test/unit),
65
- %w(Functional\ tests test/functional)
66
- ].collect { |name, dir| [ name, "./#{dir}" ] }.select { |name, dir| File.directory?(dir) }
67
-
68
- desc "Report code statistics (KLOCs, etc) from the application"
69
- task :stats do
70
- #require 'extra/stats'
71
- verbose = true
72
- CodeStatistics.new(*STATS_DIRECTORIES).to_s
73
- end
74
-
75
- ##############################################################################
76
- # SVN
77
- ##############################################################################
78
-
79
- desc "Add new files to subversion"
80
- task :svn_add do
81
- system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
82
- end
@@ -1,31 +0,0 @@
1
- class Files < Merb::Controller
2
-
3
- def start
4
- render :layout => :none
5
- end
6
-
7
- def index
8
- @args = params
9
- render :action => '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 params[:file]
29
- end
30
-
31
- end
@@ -1,71 +0,0 @@
1
-
2
- class Posts < Merb::Controller
3
-
4
- def access_denied
5
- render
6
- end
7
-
8
- def new
9
- #session[:foo] = 'foo'
10
- #puts session.session_id
11
- render
12
- end
13
-
14
- def create
15
- @post = Post.create( :title => params[:title], :body => params[:body])
16
- redirect "/posts/show/#{@post.id}"
17
- end
18
-
19
- def show
20
- #puts session[:foo]
21
- #session[:foo] = 'changed'
22
- @post = Post.find params[:id]
23
- @comments = @post.comments
24
- render
25
- end
26
-
27
- def test
28
- puts "request.protocol: #{request.protocol}"
29
- puts "request.ssl?: #{request.ssl?}"
30
- puts "request.uri: #{request.uri}"
31
- puts "request.path: #{request.path}"
32
- puts "request.path_info: #{request.path_info}"
33
- puts "request.port: #{request.port}"
34
- puts "request.host: #{request.host}"
35
- puts "request.domain: #{request.domain}"
36
- puts "request.get?: #{request.get?}"
37
- puts "request.post?: #{request.post?}"
38
- puts "request.put?: #{request.put?}"
39
- puts "request.delete?: #{request.delete?}"
40
- puts "request.head?: #{request.head?}"
41
- puts "request.xhr?: #{request.xhr?}"
42
- puts request.inspect
43
- end
44
-
45
- def xml_test
46
- render_xml
47
- end
48
-
49
- def list
50
- #session[:foo] = 'hi'
51
- @posts = Post.find :all, :limit => 4
52
- render
53
- end
54
-
55
- def add_comment
56
- puts params.inspect
57
- @post = Post.find params[:post_id]
58
- @post.comments.create :name => params[:comment_name],
59
- :body => params[:comment_body]
60
- @comments = @post.comments.reload
61
- render_js 'comment'
62
- end
63
-
64
- def delete_comment
65
- @post = Post.find params[:post_id]
66
- @post.comments.destroy params[:id]
67
- @comments = @post.comments.reload
68
- render_js 'comment'
69
- end
70
-
71
- end
@@ -1,40 +0,0 @@
1
- class Test < Merb::Controller
2
-
3
- #before :authenticate
4
- #before lambda{|c| puts 'lambda filter called'}
5
-
6
- def bfilter
7
- puts "Filter Called!"
8
- #throw :halt
9
- end
10
-
11
- def hello
12
- # Assign the parameter to an instance variable
13
- @name = params[:id]
14
- render
15
- end
16
-
17
- def glob
18
- "<html><body><h2>#{params[:rest]}</h2></body></html>"
19
- end
20
-
21
- def json
22
- @post = Post.find :first
23
- render_js
24
- end
25
-
26
- def rails
27
- puts session.inspect
28
- session[:foo]
29
- end
30
-
31
- def foo
32
- @args = params
33
- render
34
- end
35
-
36
- def to_s
37
- "<html><body>Test controller, no mathing action</body></html>"
38
- end
39
- end
40
-
@@ -1,7 +0,0 @@
1
- module Merb
2
- module GlobalHelper
3
- end
4
- end
5
-
6
-
7
-
@@ -1,4 +0,0 @@
1
- module Merb
2
- module PostsHelper
3
- end
4
- end
@@ -1,3 +0,0 @@
1
- class Comment < ActiveRecord::Base
2
- belongs_to :post
3
- end
@@ -1,4 +0,0 @@
1
- class Post < ActiveRecord::Base
2
- has_many :comments
3
-
4
- end
@@ -1,3 +0,0 @@
1
- <% if @upstatus %>
2
- UploadProgress.update(<%= @upstatus[:size] %>, <%= @upstatus[:received] %>);
3
- <% end %>
@@ -1,62 +0,0 @@
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>
@@ -1,6 +0,0 @@
1
- <h2>File uploaded successfully</h2>
2
-
3
- "UPLOADED: <%= params.inspect %><script type='text/javascript'>window.parent.UploadProgress.finish();</script>"
4
-
5
-
6
-
@@ -1,61 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
-
4
- <head>
5
- <title>Merb: Mongrel + Erb</title>
6
- <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
7
- <%= css_include_tag :merb %>
8
- <%= js_include_tag :prototype, :effects %>
9
- </head>
10
-
11
- <body>
12
-
13
- <div id="blogtitle">
14
- <div id="small">Welcome to the land of Merb | <a href="http://svn.devjavu.com/merb">SVN</a> | <a href="http://svn.devjavu.com/merb/README">README</a> | <a href="http://merb.devjavu.com/">Trac</a></div>
15
- </div>
16
-
17
- <div id="border">
18
-
19
- <div id="container">
20
-
21
- <div id="content">
22
-
23
- <div id="topmenu">
24
- <ul>
25
- <li><a href="#" title="/posts/list"><span>Blog</span></a></li>
26
- <li><a href="#" title="Gallery"><span>Get Merb</span></a></li>
27
- <li><a href="#" title="Links"><span>Tutorial</span></a></li>
28
- </ul>
29
- </div>
30
-
31
- <div id="introduction">
32
- <h3>Merb Mascot</h3>
33
- <ul>
34
- <li><img src="/images/louiecon.gif" /></li>
35
- </ul>
36
- <%= catch_content :sidebar %>
37
- </div>
38
-
39
- <%= catch_content :layout %>
40
-
41
- <div class="maintext3">
42
- <div class="splitleft">
43
- <p>This is a split left box in the split left class.</p>
44
- </div>
45
-
46
- <div class="splitright">
47
- <p>This is a split right box<br /> you can also set the backround color in the class.</p>
48
- </div>
49
- </div>
50
- </div>
51
- </div>
52
-
53
- <div id="footer">Merb: Mongrel + Erb</div>
54
-
55
- </div>
56
-
57
-
58
-
59
-
60
- </body>
61
- </html>