waves 0.8.2 → 0.9.0
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/bin/waves +4 -3
- data/doc/VERSION +1 -1
- data/lib/waves.rb +52 -40
- data/lib/{caches → waves/caches}/file.rb +3 -1
- data/lib/waves/caches/memcached.rb +56 -0
- data/lib/{caches → waves/caches}/simple.rb +6 -7
- data/lib/{caches → waves/caches}/synchronized.rb +15 -1
- data/lib/{commands → waves/commands}/console.rb +4 -4
- data/lib/{commands → waves/commands}/generate.rb +6 -5
- data/lib/{commands → waves/commands}/help.rb +0 -0
- data/lib/{commands → waves/commands}/server.rb +1 -1
- data/lib/{dispatchers → waves/dispatchers}/base.rb +17 -31
- data/lib/waves/dispatchers/default.rb +19 -0
- data/lib/{ext → waves/ext}/float.rb +0 -0
- data/lib/{ext → waves/ext}/hash.rb +0 -0
- data/lib/{ext → waves/ext}/integer.rb +16 -1
- data/lib/{ext → waves/ext}/kernel.rb +3 -7
- data/lib/{ext → waves/ext}/module.rb +3 -3
- data/lib/{ext → waves/ext}/object.rb +2 -0
- data/lib/waves/ext/string.rb +73 -0
- data/lib/{ext → waves/ext}/symbol.rb +0 -1
- data/lib/{ext → waves/ext}/tempfile.rb +0 -0
- data/lib/waves/ext/time.rb +5 -0
- data/lib/{foundations → waves/foundations}/classic.rb +9 -21
- data/lib/{foundations → waves/foundations}/compact.rb +15 -20
- data/lib/waves/foundations/rest.rb +311 -0
- data/lib/waves/helpers/basic.rb +13 -0
- data/lib/{helpers → waves/helpers}/doc_type.rb +3 -0
- data/lib/waves/helpers/form.rb +94 -0
- data/lib/waves/helpers/formatting.rb +14 -0
- data/lib/waves/layers/mvc.rb +65 -0
- data/lib/{layers → waves/layers}/mvc/controllers.rb +0 -0
- data/lib/{layers → waves/layers}/mvc/extensions.rb +23 -11
- data/lib/{layers → waves/layers}/orm/migration.rb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/active_record.rb +2 -5
- data/lib/{layers → waves/layers}/orm/providers/active_record/migrations/empty.rb.erb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/active_record/tasks/generate.rb +1 -1
- data/lib/{layers → waves/layers}/orm/providers/active_record/tasks/schema.rb +1 -1
- data/lib/{layers → waves/layers}/orm/providers/data_mapper.rb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/filebase.rb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/sequel.rb +28 -29
- data/lib/{layers → waves/layers}/orm/providers/sequel/migrations/empty.rb.erb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/sequel/tasks/generate.rb +1 -1
- data/lib/{layers → waves/layers}/orm/providers/sequel/tasks/schema.rb +2 -0
- data/lib/waves/layers/rack/rack_cache.rb +32 -0
- data/lib/waves/layers/renderers/erubis.rb +52 -0
- data/lib/waves/layers/renderers/haml.rb +67 -0
- data/lib/waves/layers/renderers/markaby.rb +41 -0
- data/lib/waves/layers/text/inflect/english.rb +42 -0
- data/lib/waves/matchers/accept.rb +47 -0
- data/lib/waves/matchers/ext.rb +27 -0
- data/lib/waves/matchers/path.rb +72 -0
- data/lib/waves/matchers/query.rb +43 -0
- data/lib/waves/matchers/request.rb +86 -0
- data/lib/waves/matchers/requested.rb +31 -0
- data/lib/{matchers → waves/matchers}/resource.rb +8 -1
- data/lib/waves/matchers/traits.rb +30 -0
- data/lib/waves/matchers/uri.rb +69 -0
- data/lib/waves/media/mime_types.rb +542 -0
- data/lib/waves/renderers/mixin.rb +9 -0
- data/lib/waves/request/accept.rb +92 -0
- data/lib/{runtime → waves/request}/request.rb +77 -61
- data/lib/waves/resources/file_mixin.rb +11 -0
- data/lib/{resources → waves/resources}/mixin.rb +42 -44
- data/lib/waves/resources/paths.rb +132 -0
- data/lib/waves/response/client_errors.rb +10 -0
- data/lib/waves/response/packaged.rb +19 -0
- data/lib/waves/response/redirects.rb +35 -0
- data/lib/{runtime → waves/response}/response.rb +29 -11
- data/lib/{runtime → waves/response}/response_mixin.rb +30 -17
- data/lib/waves/runtime/applications.rb +18 -0
- data/lib/{runtime → waves/runtime}/configuration.rb +31 -25
- data/lib/waves/runtime/console.rb +24 -0
- data/lib/{runtime → waves/runtime}/logger.rb +3 -3
- data/lib/{runtime → waves/runtime}/mocks.rb +2 -2
- data/lib/waves/runtime/rackup.rb +37 -0
- data/lib/waves/runtime/runtime.rb +48 -0
- data/lib/waves/runtime/server.rb +33 -0
- data/lib/{servers → waves/servers}/base.rb +0 -0
- data/lib/{servers → waves/servers}/mongrel.rb +0 -0
- data/lib/{servers → waves/servers}/webrick.rb +0 -0
- data/lib/{tasks → waves/tasks}/gem.rb +0 -0
- data/lib/{tasks → waves/tasks}/generate.rb +0 -0
- data/lib/waves/views/cassy.rb +173 -0
- data/lib/{views → waves/views}/errors.rb +8 -7
- data/lib/waves/views/mixin.rb +23 -0
- data/lib/waves/views/templated.rb +40 -0
- data/samples/basic/basic_startup.rb +70 -0
- data/samples/basic/config.ru +9 -0
- data/samples/blog/configurations/development.rb +17 -16
- data/samples/blog/configurations/production.rb +0 -11
- data/samples/blog/resources/entry.rb +3 -3
- data/samples/blog/resources/map.rb +10 -3
- data/samples/blog/startup.rb +4 -3
- data/templates/classic/Rakefile +28 -29
- data/templates/classic/configurations/default.rb.erb +8 -3
- data/templates/classic/configurations/development.rb.erb +1 -20
- data/templates/classic/configurations/production.rb.erb +2 -16
- data/templates/classic/public/images/favicon.ico +0 -0
- data/templates/classic/resources/server.rb.erb +9 -0
- data/templates/classic/startup.rb.erb +3 -3
- data/templates/classic/views/css.rb.erb +14 -0
- data/templates/classic/views/default.rb.erb +17 -0
- data/templates/classic/views/errors.rb.erb +10 -0
- data/templates/classic/views/pages.rb.erb +14 -0
- data/templates/compact/startup.rb.erb +8 -3
- data/test/ext/object.rb +55 -0
- data/test/ext/shortcuts.rb +73 -0
- data/test/helpers.rb +17 -0
- data/test/match/accept.rb +78 -0
- data/test/match/ext.rb +156 -0
- data/test/match/methods.rb +22 -0
- data/test/match/params.rb +33 -0
- data/test/match/path.rb +106 -0
- data/test/match/query.rb +60 -0
- data/test/match/request.rb +91 -0
- data/test/match/requested.rb +149 -0
- data/test/match/uri.rb +136 -0
- data/test/process/request.rb +75 -0
- data/test/process/resource.rb +53 -0
- data/test/resources/path.rb +166 -0
- data/test/runtime/configurations.rb +19 -0
- data/test/runtime/request.rb +63 -0
- data/test/runtime/response.rb +85 -0
- data/test/views/views.rb +40 -0
- metadata +243 -157
- data/lib/caches/memcached.rb +0 -40
- data/lib/dispatchers/default.rb +0 -25
- data/lib/ext/string.rb +0 -20
- data/lib/helpers/basic.rb +0 -11
- data/lib/helpers/extended.rb +0 -21
- data/lib/helpers/form.rb +0 -42
- data/lib/helpers/formatting.rb +0 -30
- data/lib/helpers/layouts.rb +0 -37
- data/lib/helpers/model.rb +0 -37
- data/lib/helpers/view.rb +0 -22
- data/lib/layers/inflect/english.rb +0 -67
- data/lib/layers/mvc.rb +0 -54
- data/lib/layers/renderers/erubis.rb +0 -60
- data/lib/layers/renderers/haml.rb +0 -47
- data/lib/layers/renderers/markaby.rb +0 -29
- data/lib/matchers/accept.rb +0 -21
- data/lib/matchers/base.rb +0 -30
- data/lib/matchers/content_type.rb +0 -17
- data/lib/matchers/path.rb +0 -67
- data/lib/matchers/query.rb +0 -21
- data/lib/matchers/request.rb +0 -27
- data/lib/matchers/traits.rb +0 -19
- data/lib/matchers/uri.rb +0 -20
- data/lib/renderers/mixin.rb +0 -36
- data/lib/resources/paths.rb +0 -34
- data/lib/runtime/console.rb +0 -23
- data/lib/runtime/mime_types.rb +0 -536
- data/lib/runtime/monitor.rb +0 -32
- data/lib/runtime/runtime.rb +0 -67
- data/lib/runtime/server.rb +0 -20
- data/lib/runtime/session.rb +0 -27
- data/lib/runtime/worker.rb +0 -86
- data/lib/views/mixin.rb +0 -62
- data/samples/blog/blog.db +0 -0
- data/samples/blog/log/waves.production +0 -3
- data/templates/classic/resources/map.rb.erb +0 -8
- data/templates/classic/templates/errors/not_found_404.mab +0 -7
- data/templates/classic/templates/errors/server_error_500.mab +0 -7
- data/templates/classic/templates/layouts/default.mab +0 -14
- data/templates/classic/tmp/sessions/.gitignore +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Waves
|
|
2
|
+
|
|
3
|
+
class Server < Hive::Worker
|
|
4
|
+
|
|
5
|
+
include Waves::Runtime
|
|
6
|
+
|
|
7
|
+
def initialize( options = {} )
|
|
8
|
+
require 'ruby-debug' if options[:debugger]
|
|
9
|
+
super( options )
|
|
10
|
+
load # load the runtime
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def start_tasks
|
|
14
|
+
@server = config.server.new( application, host, port )
|
|
15
|
+
@server.start
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def stop_tasks() ; @server.stop ; end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def application()
|
|
23
|
+
@app ||= begin
|
|
24
|
+
config.application.run( config.dispatcher.new )
|
|
25
|
+
config.application.to_app
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
def port() ; ( @port ||= options[:port] || config.port ) ; end
|
|
29
|
+
def host() ; ( @host ||= options[:host] || config.host ) ; end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Markaby-ish way to declare CSS
|
|
2
|
+
# This code is based on code written by automatthew:
|
|
3
|
+
# http://github.com/automatthew/cassandra/tree/master
|
|
4
|
+
class Cassy
|
|
5
|
+
|
|
6
|
+
HTML_TAGS = %w( a abbr acronym address area b base bdo big blockquote body br button caption cite code col colgroup dd del dfn div dl dt em fieldset form
|
|
7
|
+
h1 h2 h3 h4 h5 h6 head hr html i img input ins kbd label legend li link map meta noscript object ol optgroup option p param pre q samp script select
|
|
8
|
+
small span strong style sub sup table tbody td textarea tfoot th thead title tr tt ul var )
|
|
9
|
+
|
|
10
|
+
CSS_PROPERTIES = %w( azimuth background background_attachment background_color background_image background_position background_repeat border
|
|
11
|
+
border_left border_top border_right border_bottom border_collapse border_color border_spacing border_style border_top border_top_color border_top_style
|
|
12
|
+
border_top_width border_width bottom caption_side clear clip color content counter_increment counter_reset cue cue_after cue_before cursor
|
|
13
|
+
direction display elevation empty_cells float font font_family font_size font_size_adjust font_stretch font_style font_variant font_weight height
|
|
14
|
+
left letter_spacing line_height list_style list_style_image list_style_position list_style_type margin margin_left margin_top margin_right margin_bottom
|
|
15
|
+
marker_offset marks max_height max_width min_height min_width orphans outline outline_color outline_style outline_width overflow padding padding_left
|
|
16
|
+
padding_top padding_right padding_bottom page page_break_after page_break_before page_break_inside pause pause_after pause_before pitch pitch_range
|
|
17
|
+
play_during position quotes richness right size speak speak_header speak_numeral speak_punctuation speech_rate stress table_layout text_align
|
|
18
|
+
text_decoration text_indent text_shadow text_transform top unicode_bidi vertical_align visibility voice_family volume white_space widows width
|
|
19
|
+
word_spacing z_index )
|
|
20
|
+
|
|
21
|
+
METHODS = %w( class include extend instance_eval send __send__ __id__ respond_to? )
|
|
22
|
+
instance_methods.each { |m| undef_method( m ) unless METHODS.include? m }
|
|
23
|
+
|
|
24
|
+
methods = HTML_TAGS.each do |tag|
|
|
25
|
+
module_eval( "def #{tag}(&block); selector_eval(@selector.first, '#{tag}', &block);end\n" )
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
attr_reader :data
|
|
29
|
+
|
|
30
|
+
def initialize(sel=nil)
|
|
31
|
+
@data = []
|
|
32
|
+
@selectors = [ sel ]
|
|
33
|
+
@properties = []
|
|
34
|
+
|
|
35
|
+
# Primitive state machine
|
|
36
|
+
# possible states are :closed_block, :chain, :open_block
|
|
37
|
+
@state = :closed_block
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.process(*args,&block)
|
|
41
|
+
self.new.process(*args,&block)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def process(*args, &block)
|
|
45
|
+
if block
|
|
46
|
+
instance_eval(&block)
|
|
47
|
+
else
|
|
48
|
+
instance_eval(args.join("\n"))
|
|
49
|
+
end
|
|
50
|
+
self
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def to_s
|
|
54
|
+
@data.map do |sel|
|
|
55
|
+
properties = sel.last.join("\n ")
|
|
56
|
+
"#{sel.first} {\n #{properties}\n}\n"
|
|
57
|
+
end.join
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# Pushes an empty array on the properties stack and registers
|
|
63
|
+
# that array (against the current selector) in @data
|
|
64
|
+
def new_property_set
|
|
65
|
+
@properties.push []
|
|
66
|
+
@data << [@selectors[-1], @properties[-1] ]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# Declare a CSS selector using a block. May be chained and nested.
|
|
71
|
+
def selector(sel)
|
|
72
|
+
if block_given?
|
|
73
|
+
open_block(sel)
|
|
74
|
+
yield
|
|
75
|
+
closed_block
|
|
76
|
+
else
|
|
77
|
+
chain(sel)
|
|
78
|
+
end
|
|
79
|
+
self
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Catch unknown methods and treat them as CSS class or id selectors.
|
|
83
|
+
def method_missing(name, &block)
|
|
84
|
+
sel = selectify(name)
|
|
85
|
+
if block_given?
|
|
86
|
+
open_block(sel)
|
|
87
|
+
yield
|
|
88
|
+
closed_block
|
|
89
|
+
else
|
|
90
|
+
chain(sel)
|
|
91
|
+
end
|
|
92
|
+
self
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# bang methods represent CSS ids. Otherwise CSS classes.
|
|
96
|
+
def selectify(method_name)
|
|
97
|
+
matches = method_name.to_s.match( /([\w_]+)!$/)
|
|
98
|
+
matches ? "##{matches[1]}" : ".#{method_name}"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# define tag methods that delegate to selector
|
|
103
|
+
methods = HTML_TAGS.map do |tag|
|
|
104
|
+
<<-METHOD
|
|
105
|
+
def #{tag}(&block)
|
|
106
|
+
selector('#{tag}', &block)
|
|
107
|
+
end
|
|
108
|
+
METHOD
|
|
109
|
+
end.join; module_eval(methods)
|
|
110
|
+
|
|
111
|
+
# define methods for CSS properties.
|
|
112
|
+
CSS_PROPERTIES.each do |method_name|
|
|
113
|
+
define_method method_name do |*args|
|
|
114
|
+
css_attr = method_name.gsub('_', '-')
|
|
115
|
+
property(css_attr, args)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Add a property declaration string to the current selector's properties array.
|
|
120
|
+
def property(css_attr, *args)
|
|
121
|
+
@properties[-1] << "#{css_attr}: #{args.join(' ')};"
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
## State transitions
|
|
125
|
+
|
|
126
|
+
# Push the accumulated selector and a new property array onto the
|
|
127
|
+
# tops of their respected stacks
|
|
128
|
+
def open_block(new_selector)
|
|
129
|
+
case @state
|
|
130
|
+
when :closed_block, :open_block
|
|
131
|
+
combined_selector = [@selectors[-1], new_selector].compact.join(" ")
|
|
132
|
+
@selectors.push combined_selector
|
|
133
|
+
new_property_set
|
|
134
|
+
when :chain
|
|
135
|
+
@selectors[-1] = "#{@selectors[-1]}#{new_selector}"
|
|
136
|
+
new_property_set
|
|
137
|
+
else
|
|
138
|
+
raise "You can't get to :open_block from #{@state.inspect}"
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
@state = :open_block
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Pushes accumulated selector on the stack without generating a new properties array.
|
|
145
|
+
def chain(new_selector)
|
|
146
|
+
case @state
|
|
147
|
+
when :closed_block, :open_block
|
|
148
|
+
combined_selector = [@selectors[-1], new_selector].compact.join(" ")
|
|
149
|
+
@selectors.push( combined_selector)
|
|
150
|
+
when :chain
|
|
151
|
+
@selectors[-1] = "#{@selectors[-1]}#{new_selector}"
|
|
152
|
+
else
|
|
153
|
+
raise "You can't get to :chain from #{@state.inspect}"
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
@state = :chain
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Pop the selector string and property array for the closing block
|
|
160
|
+
# off of their respective stacks
|
|
161
|
+
def closed_block
|
|
162
|
+
case @state
|
|
163
|
+
when :open_block, :closed_block
|
|
164
|
+
@selectors.pop
|
|
165
|
+
@properties.pop
|
|
166
|
+
else
|
|
167
|
+
raise "You can't get to :closed_block from #{@state.inspect}"
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
@state = :closed_block
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
end
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
require 'helpers/doc_type'
|
|
1
|
+
require 'waves/helpers/doc_type'
|
|
2
|
+
|
|
2
3
|
module Waves
|
|
3
4
|
module Views
|
|
4
5
|
class Errors < Waves::Views::Base
|
|
5
|
-
|
|
6
|
+
|
|
6
7
|
include Waves::Helpers::DocType
|
|
7
|
-
|
|
8
|
+
|
|
8
9
|
def header( title )
|
|
9
10
|
<<-HTML
|
|
10
11
|
<head>
|
|
@@ -17,7 +18,7 @@ module Waves
|
|
|
17
18
|
</head>
|
|
18
19
|
HTML
|
|
19
20
|
end
|
|
20
|
-
|
|
21
|
+
|
|
21
22
|
def not_found_404
|
|
22
23
|
DOCTYPES[ :html4_transitional ]
|
|
23
24
|
<<-HTML
|
|
@@ -30,14 +31,14 @@ module Waves
|
|
|
30
31
|
</html>
|
|
31
32
|
HTML
|
|
32
33
|
end
|
|
33
|
-
|
|
34
|
+
|
|
34
35
|
def server_error_500
|
|
35
36
|
DOCTYPES[ :html4_transitional ]
|
|
36
37
|
<<-HTML
|
|
37
38
|
<html>
|
|
38
39
|
#{ header( '500: Server Error' ) }
|
|
39
40
|
<body>
|
|
40
|
-
<h1>
|
|
41
|
+
<h1>500</h1>
|
|
41
42
|
<p>Internal server error. Sorry, but your request could not be processed.</p>
|
|
42
43
|
</body>
|
|
43
44
|
</html>
|
|
@@ -46,4 +47,4 @@ module Waves
|
|
|
46
47
|
|
|
47
48
|
end
|
|
48
49
|
end
|
|
49
|
-
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Waves
|
|
2
|
+
|
|
3
|
+
module Views
|
|
4
|
+
|
|
5
|
+
module Mixin
|
|
6
|
+
|
|
7
|
+
attr_reader :request
|
|
8
|
+
|
|
9
|
+
include Waves::ResponseMixin
|
|
10
|
+
|
|
11
|
+
def initialize( request )
|
|
12
|
+
@request = request
|
|
13
|
+
super()
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Base ; include Mixin ; end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Waves
|
|
2
|
+
|
|
3
|
+
module Views
|
|
4
|
+
|
|
5
|
+
class NoTemplateError < StandardError
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.renderers ; @renderers ||= [] ; end
|
|
9
|
+
def self.extensions; @extensions ||= renderers.map { |r| r::Extension }; end
|
|
10
|
+
|
|
11
|
+
module Templated
|
|
12
|
+
|
|
13
|
+
def template_file(name)
|
|
14
|
+
template = "templates/#{self.class.basename.snake_case}/#{name}"
|
|
15
|
+
extensions = Views.extensions.join(',')
|
|
16
|
+
# globbing on a {x,y,z} group returns the found files in x,y,z order
|
|
17
|
+
raise NoTemplateError.new( path ) unless file = Dir["#{template}.{#{extensions}}"].first
|
|
18
|
+
file
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Render the template found in the directory named after this view (snake cased, of course)
|
|
22
|
+
# E.g. App::Views::Gnome.new.render( "stink" ) would look for templates/gnome/stink.<ext>
|
|
23
|
+
|
|
24
|
+
def render( name, assigns={})
|
|
25
|
+
file = template_file(name)
|
|
26
|
+
ext = File.extname(file).slice(1..-1)
|
|
27
|
+
Waves.log.debug "Rendering: #{file}"
|
|
28
|
+
self.send( ext, File.read(file), assigns.merge!( :request => request ))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Render the template with the name of the missing method.
|
|
32
|
+
# E.g. App::Views::Gnome.new.stink would look for templates/gnome/stink
|
|
33
|
+
def method_missing(name,*args) ; render( name, *args ) ; end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require "autocode"
|
|
2
|
+
|
|
3
|
+
here = File.dirname __FILE__
|
|
4
|
+
waves = ENV["WAVES"] || File.join(here, "waves", "lib")
|
|
5
|
+
|
|
6
|
+
# Primitive startup file while developing the path matcher.
|
|
7
|
+
#
|
|
8
|
+
module Basic
|
|
9
|
+
|
|
10
|
+
# Register.
|
|
11
|
+
#
|
|
12
|
+
Waves << self
|
|
13
|
+
|
|
14
|
+
# All of our resources live here.
|
|
15
|
+
#
|
|
16
|
+
module Resources
|
|
17
|
+
include AutoCode
|
|
18
|
+
|
|
19
|
+
auto_load true, :directories => "resources"
|
|
20
|
+
|
|
21
|
+
# First-tier resource mapper.
|
|
22
|
+
#
|
|
23
|
+
class Main
|
|
24
|
+
include Waves::Resources::Mixin
|
|
25
|
+
|
|
26
|
+
on(:get, "moomin") { "Hi!" }
|
|
27
|
+
on(:get, "moomin", "there") { "Hi there!" }
|
|
28
|
+
|
|
29
|
+
# E.g. /moomin/wherever
|
|
30
|
+
on(:get, "moomin", :elsewhere) { "Hi #{captured.elsewhere}!" }
|
|
31
|
+
|
|
32
|
+
# E.g. /moomin/hobbies/football/medals or
|
|
33
|
+
# /moomin/hobbies/football/regional/medals
|
|
34
|
+
on(:get, "moomin", "hobbies", 1..2, "medals") { "No medals :/" }
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Configuration settings.
|
|
41
|
+
#
|
|
42
|
+
module Configurations
|
|
43
|
+
|
|
44
|
+
# Sane default config. Can be run standalone or from rackup.
|
|
45
|
+
#
|
|
46
|
+
class Development < Waves::Configurations::Default
|
|
47
|
+
reloadable [Basic::Resources]
|
|
48
|
+
|
|
49
|
+
# When running standalone.
|
|
50
|
+
server Waves::Servers::Mongrel
|
|
51
|
+
host "127.0.0.1"
|
|
52
|
+
port 8080
|
|
53
|
+
|
|
54
|
+
resource Basic::Resources::Main
|
|
55
|
+
|
|
56
|
+
application {
|
|
57
|
+
use Rack::ShowExceptions
|
|
58
|
+
use Rack::Static, :urls => %w[ /favicon.ico ],
|
|
59
|
+
:root => "public"
|
|
60
|
+
run Waves::Dispatchers::Fast.new
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class Production < Development
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# require 'layers/rack/rack_cache'
|
|
1
2
|
module Blog
|
|
2
3
|
|
|
3
4
|
module Configurations
|
|
@@ -5,22 +6,22 @@ module Blog
|
|
|
5
6
|
class Development < Default
|
|
6
7
|
|
|
7
8
|
reloadable [ Blog ]
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
|
|
10
|
+
# in case we want to use http caching
|
|
11
|
+
# include Waves::Cache::RackCache
|
|
12
|
+
application.use Rack::Session::Cookie, :key => 'rack.session',
|
|
13
|
+
:path => '/',
|
|
14
|
+
:expire_after => 2592000,
|
|
15
|
+
:secret => 'Change it'
|
|
16
|
+
|
|
17
|
+
application.use ::Rack::Static, :urls => %w[ /css /javascript /favicon.ico ],
|
|
18
|
+
:root => 'public'
|
|
19
|
+
|
|
20
|
+
application.run Waves::Dispatchers::Default.new
|
|
21
|
+
|
|
22
|
+
server Waves::Servers::Mongrel
|
|
23
|
+
host "0.0.0.0"
|
|
24
|
+
port 8080
|
|
24
25
|
|
|
25
26
|
end
|
|
26
27
|
|