lib/siteleaf/server.rb in siteleaf-0.9.10 vs lib/siteleaf/server.rb in siteleaf-0.9.11

- old
+ new

@@ -48,32 +48,33 @@ Rack::File.new(Dir.pwd).call(env) else template_data = nil is_asset = /^(?!(sitemap|feed)\.xml)(assets|.*\.)/.match(path) - if is_asset + if is_asset and !File.exist?("#{path}.liquid") output = site.resolve(url) if output.code == 200 require 'open-uri' asset = open(output['file']['url']) [output.code, {'Content-Type' => asset.content_type}, [asset.read]] else [output.code, {'Content-Type' => 'text/html'}, [output.to_s]] end else - if template_data = resolve_template(url) + if (File.exist?("#{path}.liquid") and template_data = File.read("#{path}.liquid")) or (template_data = resolve_template(url)) # compile liquid includes into a single page include_tags = /\{\%\s+include\s+['"]([A-Za-z0-9_\-\/]+)['"]\s+\%\}/ while include_tags.match(template_data) template_data = template_data.gsub(include_tags) { |i| File.read("_#{$1}.html") } end end output = site.preview(url, template_data) - if output.code == 200 - [output.code, {'Content-Type' => output.headers[:content_type]}, [output]] + if output.code == 200 && output.headers[:content_type] + puts output.class + [output.code, {'Content-Type' => output.headers[:content_type]}, [output.to_s]] else - [output.code, {'Content-Type' => 'text/html'}, [output]] + [output.code, {'Content-Type' => 'text/html'}, [output.to_s]] end end end end end \ No newline at end of file