public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
Search Repo:
refitted samples/blog to work with all the changes in the world
automatthew (author)
Thu May 15 15:16:26 -0700 2008
commit  81f2bf518e27d432b2c4554ec7b4124a11b38328
tree    7d11c8230bd1278e1d770f307043d86b733a14fe
parent  583a0afeb21673041d378a2bfb985a7b00797b5a
...
10
11
12
13
14
 
 
...
10
11
12
 
13
14
15
0
@@ -10,4 +10,5 @@ Waves::Console.load(:mode => ENV['mode'])
0
 %w( cluster generate gem ).each { |task| require "tasks/#{task}.rb" }
0
 
0
 # load tasks from this app's lib/tasks
0
-Dir["lib/tasks/*.{rb,rake}"].each { |task| require task }
0
\ No newline at end of file
0
+Dir["lib/tasks/*.{rb,rake}"].each { |task| require task }
0
+
...
1
 
2
3
4
5
 
6
7
 
8
9
10
11
12
13
14
15
 
 
 
 
 
 
 
16
17
18
19
20
 
 
 
21
22
23
24
25
26
 
27
 
...
1
2
3
 
4
 
5
6
 
7
8
9
10
11
12
 
 
 
13
14
15
16
17
18
19
20
21
 
 
 
22
23
24
25
26
27
 
 
28
29
30
31
0
@@ -1,27 +1,31 @@
0
 module Blog
0
+
0
   module Configurations
0
- class Development < Default
0
 
0
- host '127.0.0.1'
0
+ class Development < Base
0
 
0
- port 3000
0
+ database :adapter => 'sqlite', :database => 'blog.db'
0
 
0
       reloadable [ Blog ]
0
 
0
       log :level => :debug
0
 
0
- handler ::Rack::Handler::Mongrel, :Host => host, :Port => port
0
- # handler ::Rack::Handler::WEBrick, :BindAddress => host, :Port => port
0
- # handler ::Rack::Handler::Thin, :Host => host, :Port => port
0
+ host '127.0.0.1'
0
+
0
+ port 3000
0
+
0
+ handler ::Rack::Handler::Mongrel, :Host => host, :Port => port
0
+ # handler ::Rack::Handler::WEBrick, :BindAddress => host, :Port => port
0
+ # handler ::Rack::Handler::Thin, :Host => host, :Port => port
0
 
0
       application do
0
- use Rack::ShowExceptions
0
- use Rack::Static, :urls => [ '/css', '/javascript' ], :root => 'public'
0
- run Waves::Dispatchers::Default.new
0
+ use ::Rack::ShowExceptions
0
+ use ::Rack::Static, :urls => [ '/css', '/javascript' ], :root => 'public'
0
+ run ::Waves::Dispatchers::Default.new
0
       end
0
 
0
     end
0
- end
0
-end
0
 
0
+ end
0
 
0
+end
...
1
 
2
 
3
4
5
6
7
8
 
 
 
9
10
11
12
13
 
14
 
15
...
1
2
3
4
5
6
 
7
 
 
8
9
10
11
 
12
13
14
15
16
17
18
0
@@ -1,15 +1,18 @@
0
 module Blog
0
+
0
   module Configurations
0
+
0
     module Mapping
0
       extend Waves::Mapping
0
-
0
       path %r{^/comments/?$}, :method => :post do
0
- use( :comment ); comment = controller { create }
0
- redirect( "/entry/#{comment.entry.name}" )
0
+ resource( :comment ) do
0
+ controller { comment = create; redirect( "/entry/#{comment.entry.name}" ) }
0
+ end
0
       end
0
-
0
       include Waves::Mapping::PrettyUrls::RestRules
0
       include Waves::Mapping::PrettyUrls::GetRules
0
     end
0
+
0
   end
0
+
0
 end
...
4
5
6
7
8
9
 
 
10
11
12
...
14
15
16
17
18
19
 
 
 
 
 
 
 
20
21
22
 
23
24
25
26
27
28
29
...
4
5
6
 
 
 
7
8
9
10
11
...
13
14
15
 
 
 
16
17
18
19
20
21
22
23
24
 
25
26
27
28
 
29
 
30
0
@@ -4,9 +4,8 @@ module Blog
0
 
0
     class Production < Default
0
 
0
- host '0.0.0.0'
0
-
0
- port 80
0
+ database :host => 'localhost', :adapter => 'mysql', :database => 'blog',
0
+ :user => 'root', :password => ''
0
 
0
       reloadable []
0
 
0
@@ -14,16 +13,18 @@ module Blog
0
         :output => ( :log / "waves.#{$$}" ),
0
         :rotation => :weekly
0
 
0
- handler ::Rack::Handler::Mongrel, :Host => host, :Port => port
0
- # handler ::Rack::Handler::WEBrick, :BindAddress => host, :Port => port
0
- # handler ::Rack::Handler::Thin, :Host => host, :Port => port
0
+ host '0.0.0.0'
0
+
0
+ port 80
0
+
0
+ handler ::Rack::Handler::Mongrel, :Host => host, :Port => port
0
+ # handler ::Rack::Handler::WEBrick, :BindAddress => host, :Port => port
0
+ # handler ::Rack::Handler::Thin, :Host => host, :Port => port
0
 
0
       application do
0
- run Waves::Dispatchers::Default.new
0
+ run ::Waves::Dispatchers::Default.new
0
       end
0
 
0
     end
0
-
0
   end
0
-
0
 end
...
1
2
3
4
5
6
...
1
2
 
 
3
 
0
@@ -1,6 +1,3 @@
0
 module Blog
0
   include Waves::Foundations::Default
0
- include Layers::REST
0
- include Layers::ORM::Sequel
0
 end
0
-Waves << Blog
...
2
3
4
5
6
7
8
9
 
 
10
11
12
...
2
3
4
 
 
 
 
 
5
6
7
8
9
0
@@ -2,11 +2,8 @@ module Blog
0
 
0
   module Models
0
 
0
- class Comment < Sequel::Model(:comments)
0
- before_save do
0
- set(:updated_on => Time.now) if columns.include? :updated_on
0
- end
0
- one_to_one :entry, :from => Blog::Models::Entry
0
+ class Comment < Base
0
+ many_to_one :entry, :from => Blog::Models::Entry
0
     end
0
 
0
   end
...
2
3
4
5
6
7
8
 
9
10
11
...
2
3
4
 
 
 
 
5
6
7
8
0
@@ -2,10 +2,7 @@ module Blog
0
 
0
   module Models
0
 
0
- class Entry < Sequel::Model(:entries)
0
- before_save do
0
- set(:updated_on => Time.now) if columns.include? :updated_on
0
- end
0
+ class Entry < Base
0
       one_to_many :comments, :from => Blog::Models::Comment, :key => :entry_id
0
     end
0
 
...
7
8
9
10
 
11
12
13
...
7
8
9
 
10
11
12
13
0
@@ -7,7 +7,7 @@ class AddComments < Sequel::Migration
0
       text :name
0
       text :email
0
       text :content
0
- timestamp :created_on
0
+ timestamp :updated_on
0
     end
0
   end
0
 
...
 
1
2
 
3
4
5
 
6
...
1
2
 
3
4
5
 
6
7
0
@@ -1,5 +1,6 @@
0
+WAVES = File.join(File.dirname(__FILE__), "..", "..")
0
 lambda {
0
- waves = ( ENV['WAVES'] || File.join(File.dirname(__FILE__), 'waves') )
0
+ waves = ( ( WAVES if defined? WAVES ) || ENV['WAVES'] || File.join(File.dirname(__FILE__), 'waves') )
0
   $:.unshift(File.join( waves, "lib" )) if File.exist? waves
0
 }.call
0
-require 'waves'
0
+require 'waves'
0
\ No newline at end of file
...
1
2
3
4
 
 
 
 
5
6
...
 
 
 
 
1
2
3
4
5
6
0
@@ -1,6 +1,6 @@
0
-@comments.map{ |c| c }.sort_by( &:created_on ).each do |comment|
0
- p 'Posted on ' << comment.created_on.strftime('%b %d, %Y') << ' by ' <<
0
- ( ( comment.name.nil? or comment.name.empty? ) ?
0
- 'anonymous coward' : comment.name )
0
+@comments.map{ |c| c }.sort_by( &:updated_on ).each do |comment|
0
+ p "Posted on #{comment.updated_on.strftime('%b %d, %Y') if comment.updated_on} by
0
+ #{( ( comment.name.nil? or comment.name.empty? ) ?
0
+ 'anonymous coward' : comment.name )}"
0
   textile comment.content
0
 end
...
15
16
17
18
...
15
16
17
 
0
@@ -15,4 +15,3 @@ html do
0
   end
0
 
0
 end
0
-

Comments

    No one has commented yet.