gumdrop 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. data/.gitignore +3 -0
  2. data/ChangeLog.md +13 -0
  3. data/Gemfile +6 -2
  4. data/Gemfile.lock +43 -3
  5. data/Rakefile +37 -21
  6. data/Readme.md +60 -158
  7. data/bin/gumdrop +2 -1
  8. data/gumdrop.gemspec +11 -4
  9. data/lib/gumdrop/builder.rb +164 -0
  10. data/lib/gumdrop/cli/external.rb +14 -9
  11. data/lib/gumdrop/cli/internal.rb +54 -22
  12. data/lib/gumdrop/cli.rb +21 -0
  13. data/lib/gumdrop/content.rb +195 -132
  14. data/lib/gumdrop/data.rb +185 -0
  15. data/lib/gumdrop/data_providers/csv.rb +18 -0
  16. data/lib/gumdrop/data_providers/pstore.rb +25 -0
  17. data/lib/gumdrop/data_providers/sqlite.rb +43 -0
  18. data/lib/gumdrop/data_providers/xml.rb +15 -0
  19. data/lib/gumdrop/data_providers/yaml_and_json.rb +18 -0
  20. data/lib/gumdrop/data_providers/yamldb.rb +18 -0
  21. data/lib/gumdrop/data_providers/yamldoc.rb +12 -0
  22. data/lib/gumdrop/generator.rb +118 -94
  23. data/lib/gumdrop/renderer.rb +272 -0
  24. data/lib/gumdrop/server.rb +36 -27
  25. data/lib/gumdrop/site.rb +283 -338
  26. data/lib/gumdrop/support/compressor.rb +52 -0
  27. data/lib/gumdrop/support/sprockets.rb +14 -23
  28. data/lib/gumdrop/support/stitch.rb +25 -14
  29. data/lib/gumdrop/support/yaml_doc_template.rb +29 -0
  30. data/lib/gumdrop/util/configurable.rb +44 -0
  31. data/lib/gumdrop/util/core_ex.rb +84 -0
  32. data/lib/gumdrop/util/eventable.rb +35 -0
  33. data/lib/gumdrop/util/hash_object.rb +70 -0
  34. data/lib/gumdrop/util/loggable.rb +44 -0
  35. data/lib/gumdrop/util/pager.rb +51 -0
  36. data/lib/gumdrop/{support → util}/proxy_handler.rb +7 -6
  37. data/lib/gumdrop/util/scanner.rb +47 -0
  38. data/lib/gumdrop/util/site_access.rb +16 -0
  39. data/lib/gumdrop/util/view_helpers.rb +50 -0
  40. data/lib/gumdrop/util/yaml_doc.rb +51 -0
  41. data/lib/gumdrop/version.rb +2 -2
  42. data/lib/gumdrop.rb +40 -77
  43. data/specs/content_spec.rb +83 -73
  44. data/specs/fixtures/expected/data-access/from-csv.html +4 -0
  45. data/specs/fixtures/expected/data-access/from-json.html +6 -0
  46. data/specs/fixtures/expected/data-access/from-sqlite.html +5 -0
  47. data/specs/fixtures/expected/data-access/from-xml.html +4 -0
  48. data/specs/fixtures/expected/data-access/from-yaml.html +5 -0
  49. data/specs/fixtures/expected/data-access/from-yamldb.html +5 -0
  50. data/specs/fixtures/expected/data-access/from-yamldoc.html +2 -0
  51. data/specs/fixtures/expected/gen-with-block/as-file.html +1 -0
  52. data/specs/fixtures/expected/gen-with-block/as-plain.html +1 -0
  53. data/specs/fixtures/expected/gen-with-block/layout-nested.html +1 -0
  54. data/specs/fixtures/expected/gen-with-block/layout-nil.html +1 -0
  55. data/specs/fixtures/expected/gen-with-block/layout-wrap.html +1 -0
  56. data/specs/fixtures/expected/gen-with-inline-render/0-as-file.html +4 -0
  57. data/specs/fixtures/expected/gen-with-inline-render/0-as-plain.html +4 -0
  58. data/specs/fixtures/expected/gen-with-inline-render/0-layout-nil.html +4 -0
  59. data/specs/fixtures/expected/gen-with-inline-render/0-layout-sub.html +4 -0
  60. data/specs/fixtures/expected/gen-with-inline-render/0-layout-wrap.html +4 -0
  61. data/specs/fixtures/expected/gen-with-inline-render/1-as-file.html +4 -0
  62. data/specs/fixtures/expected/gen-with-inline-render/1-as-plain.html +4 -0
  63. data/specs/fixtures/expected/gen-with-inline-render/1-layout-nil.html +4 -0
  64. data/specs/fixtures/expected/gen-with-inline-render/1-layout-sub.html +4 -0
  65. data/specs/fixtures/expected/gen-with-inline-render/1-layout-wrap.html +4 -0
  66. data/specs/fixtures/expected/goodbye.html +1 -0
  67. data/specs/fixtures/expected/hello.html +1 -0
  68. data/specs/fixtures/expected/image.png +0 -0
  69. data/specs/fixtures/expected/index.html +47 -0
  70. data/specs/fixtures/expected/js/sprockets-app.js +7 -0
  71. data/specs/fixtures/expected/js/stitch-app.js +65 -0
  72. data/specs/fixtures/expected/js/stitch-app.min.js +5 -0
  73. data/specs/fixtures/expected/js/stitch-app.min.src.js +65 -0
  74. data/specs/fixtures/expected/js/straight.js +8 -0
  75. data/specs/fixtures/expected/js/test-coffee.js +5 -0
  76. data/specs/fixtures/expected/pages/docs/force-abs.html +2 -0
  77. data/specs/fixtures/expected/pages/docs/index.html +2 -0
  78. data/specs/fixtures/expected/partials/hoisted-data.html +3 -0
  79. data/specs/fixtures/expected/partials/nested.html +7 -0
  80. data/specs/fixtures/expected/partials/params.html +1 -0
  81. data/specs/fixtures/expected/partials/with-layouts.html +1 -0
  82. data/specs/fixtures/expected/robots.txt +1 -0
  83. data/specs/fixtures/expected/test-multi-procs.html +4 -0
  84. data/specs/fixtures/expected/test-nested-layout.html +1 -0
  85. data/specs/fixtures/expected/test-no-layout.html +2 -0
  86. data/specs/fixtures/expected/test-yamldoc.html +1 -0
  87. data/specs/fixtures/expected/test.html +2 -0
  88. data/{templates/backbone → specs/fixtures/source}/Gemfile +8 -4
  89. data/specs/fixtures/source/Gemfile.lock +84 -0
  90. data/specs/fixtures/source/Gumdrop +60 -9
  91. data/specs/fixtures/source/data/csv_data.csv +2 -0
  92. data/specs/fixtures/source/data/json_data.json +13 -0
  93. data/specs/fixtures/source/data/sql_data.sqlite +0 -0
  94. data/specs/fixtures/source/data/xml_data.xml +4 -0
  95. data/specs/fixtures/source/data/yaml_db.yamldb +9 -0
  96. data/specs/fixtures/source/data/yaml_items.yaml +2 -0
  97. data/specs/fixtures/source/data/yamldoc.yamldoc +4 -0
  98. data/specs/fixtures/source/data-access/from-csv.html.erb +4 -0
  99. data/specs/fixtures/source/data-access/from-json.html.erb +6 -0
  100. data/specs/fixtures/source/data-access/from-sqlite.html.erb +5 -0
  101. data/specs/fixtures/source/data-access/from-xml.html.erb +5 -0
  102. data/specs/fixtures/source/data-access/from-yaml.html.erb +5 -0
  103. data/specs/fixtures/source/data-access/from-yamldb.html.erb +5 -0
  104. data/specs/fixtures/source/data-access/from-yamldoc.html.erb +2 -0
  105. data/specs/fixtures/source/gen-with-inline-render.generator +7 -0
  106. data/specs/fixtures/source/goodbye.html.erb +1 -0
  107. data/specs/fixtures/source/hello.html +1 -0
  108. data/specs/fixtures/source/image.png +0 -0
  109. data/specs/fixtures/source/index.html.erb +6 -0
  110. data/specs/fixtures/source/js/sprockets/app.js +2 -0
  111. data/specs/fixtures/source/js/sprockets/view.js.coffee +1 -0
  112. data/specs/fixtures/source/js/stitch/app.js +1 -0
  113. data/specs/fixtures/source/js/stitch/view.js.coffee +1 -0
  114. data/specs/fixtures/source/js/straight.js +8 -0
  115. data/specs/fixtures/source/js/test-coffee.js.coffee +1 -0
  116. data/specs/fixtures/source/layouts/site.layout.erb +1 -0
  117. data/specs/fixtures/source/layouts/sub.layout.erb +1 -0
  118. data/specs/fixtures/source/layouts/wrap.layout.erb +1 -0
  119. data/specs/fixtures/source/pages/_users-nested.html.erb +7 -0
  120. data/specs/fixtures/source/pages/docs/force-abs.html.erb +2 -0
  121. data/specs/fixtures/source/pages/docs/index.html.erb +2 -0
  122. data/specs/fixtures/source/partials/_post_entry.html.erb +4 -0
  123. data/specs/fixtures/source/partials/_provides_name.html.erb +1 -0
  124. data/specs/fixtures/source/partials/_user-params.html.erb +1 -0
  125. data/specs/fixtures/source/partials/_user.html.erb +1 -0
  126. data/specs/fixtures/source/partials/_user_sets_layout.html.erb +1 -0
  127. data/specs/fixtures/source/partials/hoisted-data.html.erb +6 -0
  128. data/specs/fixtures/source/partials/nested.html.erb +1 -0
  129. data/specs/fixtures/source/partials/params.html.erb +1 -0
  130. data/specs/fixtures/source/partials/with-layouts.html.erb +1 -0
  131. data/specs/fixtures/source/test-multi-procs.html.markdown.erb +3 -0
  132. data/specs/fixtures/source/test-nested-layout.html.erb +1 -0
  133. data/specs/fixtures/source/test-no-layout.html.erb +2 -0
  134. data/specs/fixtures/source/test-yamldoc.html.erb.yamldoc +4 -0
  135. data/specs/fixtures/source/test.html.erb +2 -0
  136. data/specs/hash_object_spec.rb +53 -8
  137. data/specs/render_spec.rb +10 -0
  138. data/specs/site_spec.rb +79 -0
  139. data/specs/spec_helper.rb +59 -0
  140. data/templates/blank/Gemfile +0 -4
  141. data/templates/blank/Gumdrop +180 -113
  142. data/templates/default/Gemfile +3 -8
  143. data/templates/default/Gumdrop +166 -95
  144. data/templates/default/ReadMe.md +14 -0
  145. data/templates/default/config.ru +1 -0
  146. data/templates/default/data/news/20120703.yamldoc +14 -0
  147. data/templates/default/data/news/20120704.yamldoc +8 -0
  148. data/templates/{backbone/source/feed.xml.builder.txt → default/source/feed.xml.builder} +4 -4
  149. data/templates/default/source/index.html.erb +10 -1
  150. data/templates/default/source/theme/layout/_sidebar.html +1 -0
  151. data/templates/{backbone/source/theme/templates/site.template.slim → default/source/theme/layout/site.layout.slim} +3 -3
  152. metadata +212 -63
  153. data/lib/gumdrop/context.rb +0 -135
  154. data/lib/gumdrop/data_manager.rb +0 -214
  155. data/lib/gumdrop/support/base_packager.rb +0 -60
  156. data/lib/gumdrop/support/callbacks.rb +0 -30
  157. data/lib/gumdrop/support/hash_object.rb +0 -22
  158. data/lib/gumdrop/view_helpers.rb +0 -25
  159. data/notes.md +0 -347
  160. data/specs/deferred_loader_spec.rb +0 -31
  161. data/specs/fixtures/expected/posts/post1.html +0 -1
  162. data/specs/fixtures/expected/posts/post1.js +0 -14
  163. data/specs/fixtures/expected/posts/post2.html +0 -5
  164. data/specs/fixtures/expected/sub/sub/sub/test.html +0 -5
  165. data/specs/fixtures/expected/sub/sub/sub/test2.html +0 -5
  166. data/specs/fixtures/expected/test.js +0 -14
  167. data/specs/fixtures/source/posts/post1.html.slim +0 -6
  168. data/specs/fixtures/source/posts/post1.js.coffee +0 -3
  169. data/specs/fixtures/source/posts/post2.html.erb +0 -5
  170. data/specs/fixtures/source/sub/sub/sub/test.html +0 -5
  171. data/specs/fixtures/source/sub/sub/sub/test2.html.erb +0 -5
  172. data/specs/fixtures/source/test.js.coffee +0 -4
  173. data/specs/fixtures/source/test.js.erb.coffee +0 -3
  174. data/templates/backbone/Gumdrop +0 -123
  175. data/templates/backbone/Rakefile +0 -38
  176. data/templates/backbone/app/app.js.coffee +0 -49
  177. data/templates/backbone/app/init.js.coffee +0 -10
  178. data/templates/backbone/app/models/.gitkeep +0 -0
  179. data/templates/backbone/app/utils/index.js.coffee +0 -27
  180. data/templates/backbone/app/views/home.js.coffee +0 -17
  181. data/templates/backbone/app/views/styles/home.scss +0 -8
  182. data/templates/backbone/app/views/templates/home.mustache +0 -2
  183. data/templates/backbone/config.ru +0 -20
  184. data/templates/backbone/lib/all.js.coffee +0 -18
  185. data/templates/backbone/lib/backbone.js +0 -1158
  186. data/templates/backbone/lib/hogan.js +0 -509
  187. data/templates/backbone/lib/jquery.js +0 -9266
  188. data/templates/backbone/lib/underscore.js +0 -981
  189. data/templates/backbone/powrc +0 -2
  190. data/templates/backbone/source/default.htaccess.erb +0 -27
  191. data/templates/backbone/source/favicon.ico +0 -0
  192. data/templates/backbone/source/index.html.erb +0 -2
  193. data/templates/backbone/source/theme/screen.css.sass +0 -9
  194. data/templates/backbone/source/theme/scripts/app.js.coffee +0 -4
  195. data/templates/backbone/source/theme/styles/_tools.scss +0 -434
  196. data/templates/backbone/source/theme/templates/app.template.slim +0 -14
  197. data/templates/default/Rakefile +0 -38
  198. data/templates/default/powrc +0 -2
  199. data/templates/default/source/default.htaccess.erb +0 -27
  200. data/templates/default/source/feed.xml.builder.txt +0 -23
  201. data/templates/default/source/theme/templates/site.template.slim +0 -33
@@ -0,0 +1,272 @@
1
+ module Gumdrop
2
+
3
+ class Renderer
4
+ include Util::SiteAccess
5
+
6
+ SPECIAL_OPTS= %w(layout force_partial)
7
+ MUNGABLE_RE= Regexp.new(%Q<(href|data|src)([\s]*)=([\s]*)('|"|&quot;|&#34;|&#39;)?\\/([\\/]?)>, 'i')
8
+
9
+ attr_reader :context
10
+
11
+ def initialize
12
+ site.active_renderer= self
13
+ @context, @content, @opts= nil, nil, nil
14
+ @stack= []
15
+ end
16
+
17
+ def draw(content, opts={})
18
+ event_block :render_item do |data|
19
+ data[:content]= content
20
+ log.debug " rendering: #{ content.source_filename } (#{ content.uri })"
21
+ if content.binary? or content.missing?
22
+ log.warn "Missing content body for: #{ content.uri }"
23
+ nil
24
+ else
25
+ _in_context(content, opts) do
26
+ data[:context]= @context
27
+ data[:output]= _render_content!
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def _render_content!
36
+ output= @content.body
37
+ _render_pipeline(@content.source_filename) do |template_class|
38
+ output= _render_text(output, template_class)
39
+ end
40
+ output= _render_layouts output
41
+ _relativize_uris output
42
+ end
43
+
44
+ def _render_text(text, template_class, sub_content="")
45
+ log.debug " #{ template_class.to_s }"
46
+ template= template_class.new(@content.source_path) { text }
47
+ template.render(@context, content:sub_content) { sub_content }
48
+ end
49
+
50
+ def _render_layouts(text)
51
+ _layout_pipeline do |layout_class|
52
+ text= _render_layout text, layout_class
53
+ end
54
+ text
55
+ end
56
+
57
+ def _render_layout(text, layout)
58
+ log.debug " layout: #{layout.source_filename}"
59
+ _render_pipeline(layout.source_filename) do |layout_class|
60
+ text = _render_text(layout.body, layout_class, text)
61
+ end
62
+ text
63
+ end
64
+
65
+ # NOTE: Currently, the render pipeline ends when Renderer.for
66
+ # returns nil for an ext. Should it continue on until all the
67
+ # possible file ext templates are looked up?
68
+ def _render_pipeline(path)
69
+ filename_parts= path.split('.')
70
+ begin
71
+ ext= filename_parts.pop
72
+ template_class= Renderer.for(ext)
73
+ yield template_class unless template_class.nil?
74
+ end while !template_class.nil? #and filename_parts.size
75
+ end
76
+
77
+ def _layout_pipeline
78
+ layout = _layout_for_content
79
+ unless layout.nil?
80
+ yield layout
81
+ # Nested Layouts!
82
+ sub_layout= _sub_layout_for(layout)
83
+ while !sub_layout.nil?
84
+ yield sub_layout
85
+ sub_layout= _sub_layout_for(sub_layout)
86
+ end
87
+ end
88
+ end
89
+
90
+ def _relativize_uris(text)
91
+ return text unless _relativize?
92
+ path_to_root= _path_to_root
93
+ text.force_encoding("UTF-8") if text.respond_to? :force_encoding
94
+ text.gsub MUNGABLE_RE do |match|
95
+ if $5 == '/'
96
+ "#{ $1 }#{ $2 }=#{ $3 }#{ $4 }/"
97
+ else
98
+ "#{ $1 }#{ $2 }=#{ $3 }#{ $4 }#{ path_to_root }"
99
+ end
100
+ end
101
+ end
102
+
103
+ def _relativize?
104
+ return false if !site.config.relative_paths
105
+ return false if @context.force_absolute
106
+ return true if site.config.relative_paths_exts == :all
107
+ site.config.relative_paths_exts.include?(@content.ext)
108
+ end
109
+
110
+ def _layout_for_content
111
+ case
112
+ when @opts[:inline_render] then nil
113
+ when (@content.params.has_key?(:layout) and !@content.params.layout) then nil
114
+ # when (@content.partial? and !@opts[:layout] and !@content.params.layout) then nil
115
+ else
116
+ layout= @opts[:layout] || @content.params.layout || @context.get(:layout)
117
+ site.layouts.first layout
118
+ end
119
+ end
120
+
121
+ def _sub_layout_for(layout)
122
+ sub_layout_name= @context.get :layout
123
+ return nil if sub_layout_name.nil?
124
+ sub_layout= site.layouts.first sub_layout_name
125
+ return nil if sub_layout.nil?
126
+ return nil if sub_layout.uri == layout.uri
127
+ sub_layout
128
+ end
129
+
130
+ def _default_layout
131
+ if site.config.layout_exts.include? @content.ext
132
+ site.config.default_layout
133
+ else
134
+ nil
135
+ end
136
+ end
137
+
138
+ def _path_to_root
139
+ '../' * @content.level
140
+ end
141
+
142
+ def _in_context(content, opts)
143
+ _new_context(content, opts)
144
+ output= yield
145
+ _revert_context
146
+ output
147
+ end
148
+
149
+ def _new_context(content, opts)
150
+ @stack.push({
151
+ content: @content,
152
+ context: @context,
153
+ opts: @opts
154
+ }.to_hash_object)
155
+ @context= RenderContext.new content, self, @context
156
+ safe_opts= opts.reject { |o| SPECIAL_OPTS.include? o.to_s }
157
+ @context.set safe_opts
158
+ @content= content
159
+ @opts= opts
160
+ if @stack.size == 1
161
+ @context.set :layout, _default_layout
162
+ end
163
+ end
164
+
165
+ def _revert_context
166
+ prev= @stack.pop
167
+ case @opts[:hoist]
168
+ when :all, true
169
+ _hoist_data(prev.context)
170
+ when Array
171
+ _hoist_data(prev.context, @opts[:hoist])
172
+ end
173
+ @context= prev.context
174
+ @content= prev.content
175
+ @opts= prev.opts
176
+ end
177
+
178
+ def _hoist_data(to_context, keys=nil)
179
+ keys ||= @context.state.keys
180
+ safe_keys= keys.reject {|k| SPECIAL_OPTS.include? k.to_s }
181
+ safe_keys.each do |key|
182
+ to_context.set key, @context.state[key]
183
+ end
184
+ end
185
+
186
+ def _previous
187
+ @stack.last
188
+ end
189
+
190
+ class << self
191
+
192
+ # Returns the `Tilt::Template` for the given `ext` or nil
193
+ def for(ext)
194
+ Tilt[ext]
195
+ rescue LoadError # stupid tilt and redcarpet, they don't play well together!
196
+ nil
197
+ end
198
+
199
+ end
200
+ end
201
+
202
+ class RenderContext
203
+ include Util::SiteAccess
204
+ include Util::ViewHelpers
205
+
206
+ attr_reader :content, :state
207
+
208
+ def initialize(content, renderer, parent=nil)
209
+ @content= content
210
+ @renderer= renderer
211
+ @parent= parent
212
+ @state= {}
213
+ end
214
+
215
+ def render(path=nil, opts={})
216
+ content= site.resolve path, opts
217
+ raise StandardError, "Content or Partial cannot be found at: #{path} (#{opts})" if content.nil?
218
+ opts[:force_partial]= true
219
+ @renderer.draw content, opts
220
+ end
221
+
222
+ def get(key)
223
+ _get_from_state key.to_sym
224
+ end
225
+
226
+ def set(key, value=nil)
227
+ if key.is_a? Hash
228
+ key.each do |k,v|
229
+ @state[k.to_s.to_sym]= v
230
+ end
231
+ else
232
+ @state[key.to_s.to_sym]= value
233
+ end
234
+ end
235
+
236
+ def method_missing(sym, *args, &block)
237
+ if sym.to_s.ends_with? '='
238
+ key= sym.to_s.chop
239
+ set key, args[0]
240
+ else
241
+ get(sym)
242
+ end
243
+ end
244
+
245
+ private
246
+
247
+ def _get_from_state(key)
248
+ if @state.has_key? key
249
+ @state[key]
250
+ else
251
+ _get_from_parent key
252
+ end
253
+ end
254
+
255
+ def _get_from_parent(key)
256
+ if @parent.nil? or !@parent.has_key?(key)
257
+ _get_from_content key
258
+ else
259
+ @parent.get key
260
+ end
261
+ end
262
+
263
+ def _get_from_content(key)
264
+ return nil if @content.nil?
265
+ return @content.send(key.to_sym) if @content.respond_to?(key.to_sym)
266
+ return @content.params[key] if @content.params.has_key?(key)
267
+ nil
268
+ end
269
+
270
+ end
271
+
272
+ end
@@ -1,67 +1,76 @@
1
- # Rework this to be nicer.. Extend Sintra::Base?
1
+
2
+ # Maybe use Gserver?
2
3
 
3
4
  require 'sinatra/base'
4
- require 'logger'
5
5
 
6
6
  module Gumdrop
7
7
 
8
8
  STATIC_ASSETS= %w(.jpg .jpe .jpeg .gif .ico .png .swf)
9
9
 
10
10
  class Server < Sinatra::Base
11
- site= Gumdrop.fetch_site
11
+ include Util::Loggable
12
+
13
+ site= Gumdrop.site
12
14
 
13
15
  unless site.nil?
14
- site.rescan()
16
+ site.scan true
15
17
 
16
18
  set :port, site.config.server_port if site.config.server_port
17
19
 
18
20
  if site.config.proxy_enabled
19
- require 'gumdrop/support/proxy_handler'
21
+ require 'gumdrop/server/proxy_handler'
20
22
  get '/-proxy/*' do handle_proxy(params, env) end
21
23
  post '/-proxy/*' do handle_proxy(params, env) end
22
24
  put '/-proxy/*' do handle_proxy(params, env) end
23
25
  delete '/-proxy/*' do handle_proxy(params, env) end
24
26
  patch '/-proxy/*' do handle_proxy(params, env) end
25
27
  options '/-proxy/*' do handle_proxy(params, env) end
26
- site.report 'Enabled proxy at /-proxy/*', :info
28
+ log.info 'Enabled proxy at /-proxy/*'
27
29
  end
28
30
 
29
31
  get '/*' do
30
- site.report "- - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
32
+ # log.info "- - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
31
33
 
32
34
  file_path= get_content_path params[:splat].join('/'), site
33
- site.report "[#{$$}] GET /#{params[:splat].join('/')} -> #{file_path}"
35
+ log.info "\n\n[#{$$}] GET /#{params[:splat].join('/')} -> #{file_path}"
34
36
 
35
37
  unless static_asset file_path
36
38
  since_last_build= Time.now.to_i - site.last_run.to_i
37
39
  # site.report "!>!>>>>> since_last_build: #{since_last_build}"
38
40
  if since_last_build > site.config.server_timeout
39
- site.report "[#{$$}] Rebuilding from Source (#{since_last_build} > #{site.config.server_timeout})"
40
- site.rescan()
41
+ log.info "[#{$$}] Rebuilding from Source (#{since_last_build} > #{site.config.server_timeout})"
42
+ site.scan true
41
43
  end
42
44
  end
43
45
 
44
- if site.content_hash.has_key? file_path
45
- content= site.content_hash[file_path]
46
- if content.useLayout?
47
- site.report "[#{$$}] *Dynamic: #{file_path} (#{content.ext})"
48
- content_type :css if content.ext == '.css' # Meh?
49
- content_type :js if content.ext == '.js' # Meh?
50
- content_type :xml if content.ext == '.xml' # Meh?
51
- output= content.render
52
- site.content_filters.each {|f| output= f.call(output, content) }
53
- output
46
+ if site.contents.has_key? file_path
47
+ renderer= Renderer.new
48
+ content= site.contents[file_path]
49
+ content_type :css if content.ext == '.css' # Meh?
50
+ content_type :js if content.ext == '.js' # Meh?
51
+ content_type :xml if content.ext == '.xml' # Meh?
52
+ unless content.binary?
53
+ log.info "[#{$$}] *Dynamic: #{file_path} (#{content.ext})"
54
+ begin
55
+ content= renderer.draw content
56
+ rescue => ex
57
+ log.error "ERROR!"
58
+ log.error ex
59
+ $stderr.puts "\n\n --------- \n Error! (#{content.uri}) #{ex}\n --------- \n\n"
60
+ raise ex
61
+ end
62
+ content
54
63
  else
55
- site.report "[#{$$}] *Static: #{file_path}"
56
- send_file File.join( site.src_path, file_path)
64
+ log.info "[#{$$}] *Static: #{file_path} (binary)"
65
+ send_file site.source_path / file_path
57
66
  end
58
67
 
59
- elsif File.exists? File.join(site.config.output_dir, file_path)
60
- site.report "[#{$$}] *Static (from OUTPUT): #{file_path}"
61
- send_file File.join(site.config.output_dir, file_path)
68
+ elsif File.exists? site.output_path / file_path
69
+ log.info "[#{$$}] *Static (from OUTPUT): #{file_path}"
70
+ send_file site.output_path / file_path
62
71
 
63
72
  else
64
- site.report "[#{$$}] *Missing: #{file_path}", :error
73
+ log.warn "[#{$$}] *Missing: #{file_path}"
65
74
  "#{file_path} Not Found"
66
75
  end
67
76
  end
@@ -75,7 +84,7 @@ module Gumdrop
75
84
  if file_path == ""
76
85
  "index.html"
77
86
  else
78
- keys.detect {|k| site.content_hash.has_key?(k) } or file_path
87
+ keys.detect {|k| site.contents.has_key?(k) } or file_path
79
88
  end
80
89
  end
81
90