bevacqua / woofmark

:dog2: Barking up the DOM tree. A modular, progressive, and beautiful Markdown and HTML editor
https://bevacqua.github.io/woofmark
MIT License
1.62k stars 74 forks source link

image upload response needs to be parsed into JSON? #30

Closed jywarren closed 7 years ago

jywarren commented 8 years ago

I'm responding (from Rails) to an image upload, and when I send a response back it's parsed as a string, not JSON, oddly. The headers seem right:

Cache-Control:max-age=0, private, must-revalidate
Connection:keep-alive
Content-Encoding:gzip
Content-Type:application/json; charset=utf-8
Date:Fri, 03 Jun 2016 18:14:26 GMT
ETag:W/"366c2e915957fbb3688349173c85b656"
Server:nginx/1.8.1 + Phusion Passenger 5.0.26
Set-Cookie:_session_id=546ca71df6549ce20171d258b9616027; path=/; HttpOnly
Status:200 OK
Transfer-Encoding:chunked
X-Powered-By:Phusion Passenger 5.0.26
X-Request-Id:39752ef745d8261da5eee350caa554a3
X-Runtime:5.814758
X-UA-Compatible:IE=Edge

And the response body is:

{"id":29,"url":"/system/images/photos/000/000/029/large/batman.gif","filename":"batman.gif","href":"/system/images/photos/000/000/029/large/batman.gif","title":"batman.gif"}

However, I had to add the following to line 180 of Woofmark's prompts/prompt.js to get body.href to return anything:

body = JSON.parse(body);

Do you think I'm doing something wrong in encoding my server response, and/or would adding an extra check and ability to parse into JSON be a useful extension to Woofmark's abilities?

Thanks!

jywarren commented 8 years ago

Alternatively, the ability to pass an onResponse() or after() method in the images options object, to enable custom response parsing?

bevacqua commented 7 years ago

This changed quite a bit actually

bevacqua commented 7 years ago

See bureaucracy

jywarren commented 7 years ago

Oh, cool -- do you mean potentially to use bureaucracy in woofmark code or just in my application code? Thanks!

bevacqua commented 7 years ago

Woofmark already uses bureaucracy now. That's what I meant

jywarren commented 7 years ago

Awesome, thanks!

On Jul 21, 2016 4:24 PM, "Nicolás Bevacqua" notifications@github.com wrote:

Woofmark already uses bureaucracy now. That's what I meant

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bevacqua/woofmark/issues/30#issuecomment-234372442, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ0fQTDeo3QzO5mTU1x84iXUwWyU9ks5qX9VKgaJpZM4Itx7l .

jywarren commented 7 years ago

Closing this now for an issue in bureaucracy: https://github.com/bevacqua/bureaucracy/issues/1

Thanks!