lib/slinky/server.rb in slinky-0.7.0 vs lib/slinky/server.rb in slinky-0.7.1

- old
+ new

@@ -36,17 +36,24 @@ end def self.process_path resp, path, pushstate = false file = manifest.find_by_path(path).first if file.is_a? ManifestDir - file = manifest.find_by_path(path+"/index.html").first + file = manifest.find_by_path(path + "/index.html").first + path += "/index.html" end resp.content_type MIME::Types.type_for(path).first if file - handle_file(resp, file) + if file.source.end_with?(path) + # They're requesting the source file and we should just + # return it + serve_file(resp, file.source) + else + handle_file(resp, file) + end elsif !pushstate && p = config.pushstate_for_path("/" + path) path = p[0] == "/" ? p[1..-1] : p self.process_path(resp, path, true) else not_found resp @@ -54,12 +61,16 @@ resp end # Takes a manifest file and produces a response for it def self.handle_file resp, mf - if path = mf.process - serve_file resp, path.to_s - else + begin + if path = mf.process + serve_file resp, path.to_s + else + raise StandardError.new + end + rescue resp.status = 500 resp.content = "Error compiling #{mf.source}\n" end resp end