pancake 0.1.29 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +0 -4
- data/Rakefile +1 -32
- data/TODO.textile +19 -0
- data/bin/pancake-gen +1 -0
- data/lib/pancake.rb +26 -39
- data/lib/pancake/bootloaders.rb +2 -2
- data/lib/pancake/configuration.rb +1 -1
- data/lib/pancake/core_ext/class.rb +3 -3
- data/lib/pancake/errors.rb +6 -8
- data/lib/pancake/generators.rb +1 -0
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt +0 -3
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt +0 -3
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/staging.rb.tt +0 -3
- data/lib/pancake/hooks/inheritable_inner_classes.rb +9 -10
- data/lib/pancake/hooks/on_inherit.rb +7 -7
- data/lib/pancake/logger.rb +1 -14
- data/lib/pancake/master.rb +7 -45
- data/lib/pancake/middleware.rb +11 -64
- data/lib/pancake/mixins/publish.rb +20 -20
- data/lib/pancake/mixins/render.rb +59 -69
- data/lib/pancake/mixins/render/template.rb +1 -1
- data/lib/pancake/mixins/render/view_context.rb +143 -7
- data/lib/pancake/mixins/request_helper.rb +38 -1
- data/lib/pancake/mixins/stack_helper.rb +2 -2
- data/lib/pancake/paths.rb +1 -1
- data/lib/pancake/router.rb +10 -2
- data/lib/pancake/stack/bootloader.rb +12 -1
- data/lib/pancake/stack/router.rb +2 -1
- data/lib/pancake/stack/stack.rb +60 -2
- data/lib/pancake/stacks/short/controller.rb +58 -3
- data/lib/pancake/stacks/short/default/views/base.html.haml +1 -1
- data/lib/pancake/stacks/short/default/views/error.html.haml +12 -0
- data/lib/pancake/stacks/short/stack.rb +1 -0
- data/spec/pancake/fixtures/render_templates/alternate.foo_env.html.haml +1 -0
- data/spec/pancake/fixtures/render_templates/alternate.html.haml +1 -0
- data/spec/pancake/fixtures/render_templates/view_context/capture_erb.erb +1 -1
- data/spec/pancake/fixtures/render_templates/view_context/capture_haml.haml +1 -1
- data/spec/pancake/fixtures/render_templates/view_context/concat_erb.erb +1 -1
- data/spec/pancake/fixtures/render_templates/view_context/concat_haml.haml +2 -1
- data/spec/pancake/middleware_spec.rb +4 -26
- data/spec/pancake/mixins/render/view_context_spec.rb +15 -23
- data/spec/pancake/mixins/render_spec.rb +54 -0
- data/spec/pancake/pancake_spec.rb +0 -22
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +1 -0
- metadata +193 -108
- data/TODO +0 -7
- data/bin/jeweler +0 -19
- data/lib/pancake/mixins/render/render.rb +0 -197
data/TODO
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
TODO:
|
2
|
-
|
3
|
-
* Add default middleware to the short stack
|
4
|
-
* Add before/after filters to the short stack
|
5
|
-
* move the mount apps bootloader to after the before_build_stack bootloader which will allow us to mount application later and allow devs to add new things just before building the stack.
|
6
|
-
* optimise template lookup
|
7
|
-
|
data/bin/jeweler
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/opt/local/bin/ruby
|
2
|
-
#
|
3
|
-
# This file was generated by RubyGems.
|
4
|
-
#
|
5
|
-
# The application 'jeweler' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
|
11
|
-
version = ">= 0"
|
12
|
-
|
13
|
-
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
|
14
|
-
version = $1
|
15
|
-
ARGV.shift
|
16
|
-
end
|
17
|
-
|
18
|
-
gem 'jeweler', version
|
19
|
-
load Gem.bin_path('jeweler', 'jeweler', version)
|
@@ -1,197 +0,0 @@
|
|
1
|
-
module Pancake
|
2
|
-
module Mixins
|
3
|
-
module Render
|
4
|
-
class ViewContext
|
5
|
-
class << self
|
6
|
-
def _concat_methods
|
7
|
-
@_concat_methods ||= {}
|
8
|
-
end
|
9
|
-
|
10
|
-
def _capture_methods
|
11
|
-
@_capture_methods ||= {}
|
12
|
-
end
|
13
|
-
|
14
|
-
def capture_method_for(item)
|
15
|
-
key = case item
|
16
|
-
when Template
|
17
|
-
item.renderer.class
|
18
|
-
when Tilt::Template
|
19
|
-
item
|
20
|
-
end
|
21
|
-
_capture_methods[key]
|
22
|
-
end
|
23
|
-
|
24
|
-
def concat_method_for(item)
|
25
|
-
key = case item
|
26
|
-
when Template
|
27
|
-
item.renderer.class
|
28
|
-
when Tilt::Template
|
29
|
-
item
|
30
|
-
end
|
31
|
-
_concat_methods[key]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
_capture_methods[Tilt::HamlTemplate ] = :_haml_capture
|
36
|
-
_capture_methods[Tilt::ERBTemplate ] = :_erb_capture
|
37
|
-
_capture_methods[Tilt::ErubisTemplate ] = :_erb_capture
|
38
|
-
_concat_methods[ Tilt::HamlTemplate ] = :_haml_concat
|
39
|
-
_concat_methods[ Tilt::ERBTemplate ] = :_erb_concat
|
40
|
-
_concat_methods[ Tilt::ErubisTemplate ] = :_erb_concat
|
41
|
-
|
42
|
-
module Renderer
|
43
|
-
def render(template, opts = {}, &blk)
|
44
|
-
template = _view_context_for.template(template)
|
45
|
-
raise TemplateNotFound unless template
|
46
|
-
result = _with_renderer template do
|
47
|
-
_current_renderer.render(self, opts, &blk) # only include the block once
|
48
|
-
end
|
49
|
-
|
50
|
-
if @_inherit_helper.inherits_from
|
51
|
-
next_template = template.owner.template(@_inherit_helper.inherits_from)
|
52
|
-
@_inherit_helper.inherits_from = nil
|
53
|
-
result = _with_renderer next_template do
|
54
|
-
render(next_template, opts)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
result
|
58
|
-
end
|
59
|
-
|
60
|
-
def partial(*args)
|
61
|
-
_view_context_for.partial(*args)
|
62
|
-
end
|
63
|
-
|
64
|
-
def _with_renderer(renderer)
|
65
|
-
orig_renderer = @_current_renderer
|
66
|
-
@_current_renderer = renderer
|
67
|
-
result = yield
|
68
|
-
@_current_renderer = orig_renderer
|
69
|
-
result
|
70
|
-
end
|
71
|
-
|
72
|
-
def _current_renderer
|
73
|
-
@_current_renderer
|
74
|
-
end
|
75
|
-
|
76
|
-
def content_type
|
77
|
-
@_view_context_for.content_type
|
78
|
-
end
|
79
|
-
end # Renderer
|
80
|
-
|
81
|
-
module Capture
|
82
|
-
def capture(opts = {}, &block)
|
83
|
-
opts[:_capture_method] ||= ViewContext.capture_method_for(_current_renderer)
|
84
|
-
raise "CaptureMethod not specified" unless opts[:_capture_method]
|
85
|
-
send(opts[:_capture_method], block)
|
86
|
-
end
|
87
|
-
|
88
|
-
def concat(string, opts = {})
|
89
|
-
opts[:_concat_method] ||= ViewContext.concat_method_for(_current_renderer)
|
90
|
-
raise "ConcatMethod not specified" unless opts[:_concat_method]
|
91
|
-
send(opts[:_concat_method], string)
|
92
|
-
end
|
93
|
-
|
94
|
-
def _haml_capture(block)
|
95
|
-
with_haml_buffer Haml::Buffer.new(nil, :encoding => "UTF-8") do
|
96
|
-
capture_haml(&block)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def _erb_capture(block)
|
101
|
-
_out_buf, @_out_buf = @_out_buf, ""
|
102
|
-
block.call
|
103
|
-
ret = @_out_buf
|
104
|
-
@_out_buf = _out_buf
|
105
|
-
ret
|
106
|
-
end
|
107
|
-
|
108
|
-
def _haml_concat(string)
|
109
|
-
haml_concat string
|
110
|
-
end
|
111
|
-
|
112
|
-
def _erb_concat(string)
|
113
|
-
@_out_buf << string
|
114
|
-
end
|
115
|
-
end # Capture
|
116
|
-
|
117
|
-
module ContentInheritance
|
118
|
-
def initialize(*args)
|
119
|
-
super()
|
120
|
-
@_inherit_helper = Helper.new
|
121
|
-
end
|
122
|
-
|
123
|
-
def inherits_from(ntos, name_or_opts = nil, opts = {})
|
124
|
-
name_or_template = case ntos
|
125
|
-
when String, Symbol
|
126
|
-
if ntos == :default!
|
127
|
-
begin
|
128
|
-
Pancake.default_base_template(:format => content_type)
|
129
|
-
rescue
|
130
|
-
:base
|
131
|
-
end
|
132
|
-
else
|
133
|
-
ntos
|
134
|
-
end
|
135
|
-
else
|
136
|
-
if name_or_opts.kind_of?(Hash)
|
137
|
-
opts = name_or_opts
|
138
|
-
name_or_opts = nil
|
139
|
-
end
|
140
|
-
name_or_opts ||= ntos.base_template_name
|
141
|
-
ntos.template(name_or_opts, opts)
|
142
|
-
end
|
143
|
-
@_inherit_helper.inherits_from = name_or_template
|
144
|
-
end
|
145
|
-
|
146
|
-
def content_block(label = nil, &block)
|
147
|
-
return self if label.nil?
|
148
|
-
current_label = @_inherit_helper.current_label
|
149
|
-
@_inherit_helper.current_label = label
|
150
|
-
capture_method = ViewContext.capture_method_for(_current_renderer)
|
151
|
-
@_inherit_helper.blocks[label] << [block, capture_method]
|
152
|
-
if @_inherit_helper.inherits_from.nil?
|
153
|
-
result = _capture_content_block(label)
|
154
|
-
send(ViewContext.concat_method_for(_current_renderer), result)
|
155
|
-
end
|
156
|
-
@_inherit_helper.current_label = current_label
|
157
|
-
end
|
158
|
-
|
159
|
-
def super
|
160
|
-
@_inherit_helper.increment_super!
|
161
|
-
result = _capture_content_block(@_inherit_helper.current_label)
|
162
|
-
@_inherit_helper.decrement_super!
|
163
|
-
result
|
164
|
-
end
|
165
|
-
|
166
|
-
private
|
167
|
-
def _capture_content_block(label)
|
168
|
-
blk, meth = @_inherit_helper.block_for(label)
|
169
|
-
send(meth, blk)
|
170
|
-
end
|
171
|
-
|
172
|
-
class Helper
|
173
|
-
attr_accessor :inherits_from, :current_label
|
174
|
-
attr_reader :blocks, :super_index
|
175
|
-
|
176
|
-
def initialize
|
177
|
-
@blocks = Hash.new{|h,k| h[k] = []}
|
178
|
-
@super_index = 0
|
179
|
-
end
|
180
|
-
|
181
|
-
def block_for(label)
|
182
|
-
@blocks[label][@super_index]
|
183
|
-
end
|
184
|
-
|
185
|
-
def increment_super!
|
186
|
-
@super_index += 1
|
187
|
-
end
|
188
|
-
|
189
|
-
def decrement_super!
|
190
|
-
@super_index -= 1
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end # ViewContext
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|