fix post preview

This commit is contained in:
Sami Samhuri 2015-04-19 16:39:24 -07:00
parent e544fe90b2
commit a136608ede

View file

@ -308,14 +308,14 @@ get '/posts/:year/:month/:id' do |year, month, id|
end
if post
if request.accept?('application/json')
status 200
headers 'Content-Type' => 'application/json'
JSON.generate(post: post.fields)
elsif request.accept?('text/html')
if request.accept?('text/html')
status 302
headers 'Location'=> "#{$config[:preview_url]}/posts/#{year}/#{month}/#{id}"
nil
elsif request.accept?('application/json')
status 200
headers 'Content-Type' => 'application/json'
JSON.generate(post: post.fields)
else
status 400
"content not available in an acceptable format: #{request.accept.join(', ')}"