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