lib/gumdrop/server.rb in gumdrop-0.7.4 vs lib/gumdrop/server.rb in gumdrop-0.7.5

- old
+ new

@@ -29,21 +29,22 @@ get '/*' do site.report "- - - - - - - - - - - - - - - - - - - - - - - - - - - - -" file_path= get_content_path params[:splat].join('/'), site site.report "[#{$$}] GET /#{params[:splat].join('/')} -> #{file_path}" + unless static_asset file_path since_last_build= Time.now.to_i - site.last_run.to_i # site.report "!>!>>>>> since_last_build: #{since_last_build}" if since_last_build > site.config.server_timeout site.report "[#{$$}] Rebuilding from Source (#{since_last_build} > #{site.config.server_timeout})" site.rescan() end end - if site.node_tree.has_key? file_path - content= site.node_tree[file_path] + if site.content_hash.has_key? file_path + content= site.content_hash[file_path] if content.useLayout? site.report "[#{$$}] *Dynamic: #{file_path} (#{content.ext})" content_type :css if content.ext == '.css' # Meh? content_type :js if content.ext == '.js' # Meh? content_type :xml if content.ext == '.xml' # Meh? @@ -52,10 +53,15 @@ output else site.report "[#{$$}] *Static: #{file_path}" send_file File.join( site.src_path, file_path) end + + elsif File.exists? File.join(site.config.output_dir, file_path) + site.report "[#{$$}] *Static (from OUTPUT): #{file_path}" + send_file File.join(site.config.output_dir, file_path) + else site.report "[#{$$}] *Missing: #{file_path}", :error "#{file_path} Not Found" end end @@ -67,11 +73,11 @@ "#{file_path}/index.html" ] if file_path == "" "index.html" else - keys.detect {|k| site.node_tree.has_key?(k) } + keys.detect {|k| site.content_hash.has_key?(k) } or file_path end end def handle_proxy(params, env) proxy_to= params[:splat][0] @@ -82,9 +88,10 @@ opts={ :to=>host, :path_info=>path_info } Gumdrop.handle_proxy opts, proxy_to, env end def static_asset(file_path) + return false if file_path.nil? or File.extname(file_path).nil? STATIC_ASSETS.include? File.extname(file_path).to_s end run! else \ No newline at end of file